シェルスクリプト言語xyzshのソースコード。
Revisão | ab78e2bcd178d9b394d41f63a4146ff966a562d9 (tree) |
---|---|
Hora | 2013-02-01 13:50:51 |
Autor | ab25q <ab25cq@gmai...> |
Commiter | ab25q |
1.3.3
@@ -23,6 +23,18 @@ | ||
23 | 23 | |
24 | 24 | 9. Modified completion working especially tilde completion.. |
25 | 25 | |
26 | + 10. Fixed below bug. | |
27 | + | |
28 | + > adfasfa | less | |
29 | + no an error occures | |
30 | + | |
31 | + | | |
32 | + | | |
33 | + v | |
34 | + | |
35 | + > adfastfa | less | |
36 | + adfastfa is not found | |
37 | + | |
26 | 38 | 2013 20th January version 1.3.2 |
27 | 39 | |
28 | 40 | 1. Added "strip" and "objinfo" inner command |
@@ -1931,6 +1931,10 @@ insert_text (text) | ||
1931 | 1931 | - |
1932 | 1932 | コンプレッション時のテキスト挿入。 |
1933 | 1933 | - |
1934 | +forced_update_display | |
1935 | +- | |
1936 | +テキスト削除やテキスト挿入をした後に呼び出すと画面が更新される。 | |
1937 | +- | |
1934 | 1938 | write_history (file name) |
1935 | 1939 | - |
1936 | 1940 | ヒストリをファイルに書き込む |
@@ -1965,6 +1969,10 @@ insert_text (text) | ||
1965 | 1969 | - |
1966 | 1970 | add string to editing line on completion. |
1967 | 1971 | - |
1972 | +forced_update_display | |
1973 | +- | |
1974 | +call this after "insert_text" or "delete_text" to update command line. | |
1975 | +- | |
1968 | 1976 | write_history (file name) |
1969 | 1977 | - |
1970 | 1978 | write readline cmdline history to a file |
@@ -56,7 +56,7 @@ root::run( | ||
56 | 56 | ) |
57 | 57 | ) |
58 | 58 | |
59 | - def is_all_ascii ( | |
59 | + def ascii_only ( | |
60 | 60 | | length -byte | var -local LEN |
61 | 61 | |
62 | 62 | LEN | -eq $(| length -utf8) |
@@ -66,47 +66,59 @@ root::run( | ||
66 | 66 | print $ARGV[0] | var -local inputing |
67 | 67 | print $ARGV[1] | var -local editing_line |
68 | 68 | |
69 | + print 1 | var -local ALL_ASCII_ONLY | |
69 | 70 | | each ( |
70 | - if (inputing | =~ '.*\/[a-zA-Z]+$') ( | |
71 | - | if(|=~ '.*\/[a-zA-Z]+[^a-zA-z/]+$') ( | |
72 | - (inputing; |print) | common_head | var -local same_head | |
73 | - | |
74 | - same_head | var -local no_migemo_string | |
75 | - inputing | sub -no-regex $same_head '' | var -local migemo_string | |
76 | - ) else ( | |
77 | - inputing | sub '(.*\/)[a-zA-Z]+$' '\1' | var -local no_migemo_string | |
78 | - inputing | sub '.*\/([a-zA-Z]+)$' '\1' | var -local migemo_string | |
71 | + if(|ascii_only) ( | |
72 | + | if(| index $inputing | = 0\n) ( | |
73 | ||
79 | 74 | ) |
80 | - ) elif (inputing | =~ '.*\/[^a-zA-Z]+[a-zA-Z]+$') ( | |
81 | - inputing | sub '(.*\/[^a-zA-Z]+)[a-zA-Z]+$' '\1' | var -local no_migemo_string | |
82 | - inputing | sub '.*\/[^a-zA-Z]+([a-zA-Z]+)$' '\1' | var -local migemo_string | |
83 | - ) elif (inputing | =~ '[a-zA-Z]+$') ( | |
84 | - | if(|=~ '[a-zA-Z]+[^a-zA-z/]+$') ( | |
85 | - (inputing; |print) | common_head | var -local same_head | |
86 | - | |
87 | - same_head | var -local no_migemo_string | |
88 | - inputing | sub -no-regex $same_head '' | var -local migemo_string | |
75 | + ) else ( | |
76 | + print 0 | var -local ALL_ASCII_ONLY | |
77 | + | |
78 | + if (inputing | =~ '.*\/[a-zA-Z]+$') ( | |
79 | + | if(|=~ '.*\/[a-zA-Z]+[^a-zA-z/]+$') ( | |
80 | + (inputing; |print) | common_head | var -local same_head | |
81 | + | |
82 | + same_head | var -local no_migemo_string | |
83 | + inputing | sub -no-regex $same_head '' | var -local migemo_string | |
84 | + ) else ( | |
85 | + inputing | sub '(.*\/)[a-zA-Z]+$' '\1' | var -local no_migemo_string | |
86 | + inputing | sub '.*\/([a-zA-Z]+)$' '\1' | var -local migemo_string | |
87 | + ) | |
88 | + ) elif (inputing | =~ '.*\/[^a-zA-Z]+[a-zA-Z]+$') ( | |
89 | + inputing | sub '(.*\/[^a-zA-Z]+)[a-zA-Z]+$' '\1' | var -local no_migemo_string | |
90 | + inputing | sub '.*\/[^a-zA-Z]+([a-zA-Z]+)$' '\1' | var -local migemo_string | |
91 | + ) elif (inputing | =~ '[a-zA-Z]+$') ( | |
92 | + | if(|=~ '[a-zA-Z]+[^a-zA-z/]+$') ( | |
93 | + (inputing; |print) | common_head | var -local same_head | |
94 | + | |
95 | + same_head | var -local no_migemo_string | |
96 | + inputing | sub -no-regex $same_head '' | var -local migemo_string | |
97 | + ) else ( | |
98 | + print "" | var -local no_migemo_string | |
99 | + inputing | var -local migemo_string | |
100 | + ) | |
101 | + ) elif (inputing | =~ '[^a-zA-Z]+[a-zA-Z]+$') ( | |
102 | + inputing | sub '([^a-zA-Z]+)[a-zA-Z]+$' '\1' | var -local no_migemo_string | |
103 | + inputing | sub '[^a-zA-Z]+([a-zA-Z]+)$' '\1' | var -local migemo_string | |
89 | 104 | ) else ( |
90 | 105 | print "" | var -local no_migemo_string |
91 | - inputing | var -local migemo_string | |
106 | + print "" | var -local migemo_string | |
92 | 107 | ) |
93 | - ) elif (inputing | =~ '[^a-zA-Z]+[a-zA-Z]+$') ( | |
94 | - inputing | sub '([^a-zA-Z]+)[a-zA-Z]+$' '\1' | var -local no_migemo_string | |
95 | - inputing | sub '[^a-zA-Z]+([a-zA-Z]+)$' '\1' | var -local migemo_string | |
96 | - ) else ( | |
97 | - print "" | var -local no_migemo_string | |
98 | - print "" | var -local migemo_string | |
99 | - ) | |
100 | 108 | |
101 | - | if(| sub -no-regex $no_migemo_string '' | chomp | migemo::match $migemo_string | lines 0 | = 0\n) ( | |
102 | ||
109 | + | if(| sub -no-regex $no_migemo_string '' | chomp | migemo::match $migemo_string | lines 0 | = 0\n) ( | |
110 | ||
111 | + ) | |
103 | 112 | ) |
104 | 113 | ) | (| common_head | var -local COMMON_HEAD; | length -line-num | var -local NUM) |
105 | 114 | |
106 | - if(COMMON_HEAD | chomp | -n && COMMON_HEAD | length | -gt $(inputing | length)) ( | |
115 | + if(ALL_ASCII_ONLY | = 0\n && COMMON_HEAD | chomp | -n && COMMON_HEAD | length | -gt $(inputing | length)) ( | |
107 | 116 | rl::delete_text $(editing_line | rindex $inputing) $(rl::point) |
108 | - rl::insert_text $COMMON_HEAD | |
109 | - if(NUM | chomp | -eq 1 && COMMON_HEAD| chomp | rows -1 | != /) ( rl::insert_text " " ) | |
117 | + if(NUM | chomp | -eq 1 && COMMON_HEAD| chomp | rows -1 | != /) ( | |
118 | + rl::insert_text $COMMON_HEAD" " | |
119 | + ) else ( | |
120 | + rl::insert_text $COMMON_HEAD | |
121 | + ) | |
110 | 122 | ) |
111 | 123 | ) |
112 | 124 |
@@ -145,7 +157,8 @@ root::run( | ||
145 | 157 | ) |
146 | 158 | ) |
147 | 159 | |
148 | - if(MIGEMO_COMPLETION_AUTO_LOAD | = 1\n || readline "Do you want to use migemo completion which is Japanese ROMAJI completion?(y/n)" | chomp |=~ -ignore-case ^y) ( | |
160 | + if((defined MIGEMO_COMPLETION_AUTO_LOAD && MIGEMO_COMPLETION_AUTO_LOAD | = 1\n) || readline "Do you want to use migemo completion which is Japanese ROMAJI completion?(y/n)" | chomp |=~ -ignore-case ^y) ( | |
149 | 161 | MigemoCompletion |
162 | + print "loaded migemo completion.\n" | |
150 | 163 | ) |
151 | 164 | ) |
@@ -792,12 +792,19 @@ BOOL cmd_readline_point_move(sObject* nextin, sObject* nextout, sRunInfo* runinf | ||
792 | 792 | return TRUE; |
793 | 793 | } |
794 | 794 | |
795 | +BOOL cmd_readline_forced_update_display(sObject* nextin, sObject* nextout, sRunInfo* runinfo) | |
796 | +{ | |
797 | + puts(""); | |
798 | + rl_forced_update_display(); | |
799 | + runinfo->mRCode = 0; | |
800 | + | |
801 | + return TRUE; | |
802 | +} | |
803 | + | |
795 | 804 | BOOL cmd_readline_insert_text(sObject* nextin, sObject* nextout, sRunInfo* runinfo) |
796 | 805 | { |
797 | 806 | if(runinfo->mArgsNumRuntime == 2) { |
798 | 807 | (void)rl_insert_text(runinfo->mArgsRuntime[1]); |
799 | - puts(""); | |
800 | - rl_forced_update_display(); | |
801 | 808 | |
802 | 809 | runinfo->mRCode = 0; |
803 | 810 | } |
@@ -818,8 +825,6 @@ BOOL cmd_readline_delete_text(sObject* nextin, sObject* nextout, sRunInfo* runin | ||
818 | 825 | if(rl_point < 0) { |
819 | 826 | rl_point = 0; |
820 | 827 | } |
821 | - puts(""); | |
822 | - rl_forced_update_display(); | |
823 | 828 | |
824 | 829 | runinfo->mRCode = 0; |
825 | 830 | } |
@@ -331,6 +331,24 @@ static BOOL wait_child_program(pid_t pid, pid_t nextin_reader_pid, int nextout2, | ||
331 | 331 | |
332 | 332 | return FALSE; |
333 | 333 | } |
334 | + /// exited normally /// | |
335 | + else if(WIFEXITED(status)) { | |
336 | + /// command not found /// | |
337 | + if(WEXITSTATUS(status) == 127) { | |
338 | + if(gAppType == kATConsoleApp) // && nextout2 == 1) | |
339 | + { | |
340 | + if(tcsetpgrp(0, getpgid(0)) < 0) { | |
341 | + perror("tcsetpgrp(xyzsh)"); | |
342 | + exit(1); | |
343 | + } | |
344 | + } | |
345 | + | |
346 | + char buf[BUFSIZ]; | |
347 | + snprintf(buf, BUFSIZ, "command not found"); | |
348 | + err_msg(buf, runinfo->mSName, runinfo->mSLine, program); | |
349 | + return FALSE; | |
350 | + } | |
351 | + } | |
334 | 352 | else if(WIFSIGNALED(status)) { // a xyzsh external program which is not a last command can't be stopped by CTRL-Z |
335 | 353 | err_msg("signal interrupt8", runinfo->mSName, runinfo->mSLine, program); |
336 | 354 |
@@ -116,6 +116,7 @@ void uobject_root_init(sObject* self) | ||
116 | 116 | uobject_put(self, "rl", readline); |
117 | 117 | |
118 | 118 | uobject_put(readline, "file_name_completion_null_generator", NFUN_NEW_GC(cmd_readline_file_name_completion_null_generator, NULL, TRUE)); |
119 | + uobject_put(readline, "forced_update_display", NFUN_NEW_GC(cmd_readline_forced_update_display, NULL, TRUE)); | |
119 | 120 | uobject_put(readline, "insert_text", NFUN_NEW_GC(cmd_readline_insert_text, NULL, TRUE)); |
120 | 121 | uobject_put(readline, "delete_text", NFUN_NEW_GC(cmd_readline_delete_text, NULL, TRUE)); |
121 | 122 | uobject_put(readline, "clear_screen", NFUN_NEW_GC(cmd_readline_clear_screen, NULL, TRUE)); |
@@ -567,6 +567,7 @@ BOOL cmd_objinfo(sObject* nextin, sObject* nextout, sRunInfo* runinfo); | ||
567 | 567 | BOOL cmd_kanjicode(sObject* nextin, sObject* nextout, sRunInfo* runinfo); |
568 | 568 | BOOL cmd_defined(sObject* nextin, sObject* nextout, sRunInfo* runinfo); |
569 | 569 | BOOL cmd_funinfo(sObject* nextin, sObject* nextout, sRunInfo* runinfo); |
570 | +BOOL cmd_readline_forced_update_display(sObject* nextin, sObject* nextout, sRunInfo* runinfo); | |
570 | 571 | BOOL cmd_readline_file_name_completion_null_generator(sObject* nextin, sObject* nextout, sRunInfo* runinfo); |
571 | 572 | BOOL cmd_readline_replace_line(sObject* nextin, sObject* nextout, sRunInfo* runinfo); |
572 | 573 | BOOL cmd_readline_point(sObject* nextin, sObject* nextout, sRunInfo* runinfo); |