シェルスクリプト言語xyzshのソースコード。
Révision | e6937031845487331f4725d07d3efa18e748b1ad (tree) |
---|---|
l'heure | 2013-02-04 18:12:09 |
Auteur | ab25cq <ab25cq@gmai...> |
Commiter | ab25cq |
1.3.4
@@ -1,4 +1,10 @@ | ||
1 | 1 | |
2 | +2013 3rd Feburary version 1.3.4 | |
3 | + | |
4 | + 1. Added "-source" option to "completion" inner command. | |
5 | + | |
6 | + 2. Added file name completion to "cd" inner command. | |
7 | + | |
2 | 8 | 2013 3rd Feburary version 1.3.3 |
3 | 9 | |
4 | 10 | 1. Modified configure.in and Makfile.in especially for related with docdir and sysconfdir |
@@ -209,3 +209,18 @@ completion rl::help ( | ||
209 | 209 | rl::self | egrep native\ function\$ | egrep -v 'run|show' | root::scan '(^.+?):' | each ( | chomp | quote | pomch ) |
210 | 210 | ) |
211 | 211 | |
212 | +completion cd ( | |
213 | + | file_completion | |
214 | + hash COMPLETION_OPTIONS -key cd | |
215 | +) | |
216 | + | |
217 | +completion __all__ ( | |
218 | + | file_completion | |
219 | +) | |
220 | + | |
221 | +root::compl::run( root::object sys ) | |
222 | + | |
223 | +completion sys::__all__ ( | |
224 | + | file_completion | |
225 | +) | |
226 | + |
@@ -967,8 +967,10 @@ completion (オブジェクト::)コマンド名 (ブロック) | ||
967 | 967 | root::complにオブジェクトとして登録される |
968 | 968 | ARGVにはコマンド名と入力中の文字列が入っている |
969 | 969 | コンテキストパイプには入力中の行が入っている |
970 | -コマンド名に*を使うとコマンド名が見つからなかった時は*が使われる | |
970 | +コマンド名に__all__を使うとコマンド名が見つからなかった時は__all__が使われる | |
971 | 971 | ブロックが無かった場合は定義された補完を実行して結果を返す。 |
972 | + | |
973 | +-source ソースを表示する | |
972 | 974 | - |
973 | 975 | help コマンド名 |
974 | 976 | - |
@@ -1865,8 +1867,10 @@ completion (object name::)(command name) (block) | ||
1865 | 1867 | If there is a block, define the user completion in root::compl. Output of block is candidates for completion. |
1866 | 1868 | ARGV has a command name and an inputing string. |
1867 | 1869 | Context pipe has all inputing line. |
1868 | -If you use * for command name, it is wild card. | |
1870 | +If you use __all__ for command name, it is wild card. | |
1869 | 1871 | If there is not a block, run the completion and return output. |
1872 | + | |
1873 | +-source output a source program of completion | |
1870 | 1874 | - |
1871 | 1875 | help (command name) |
1872 | 1876 | - |
@@ -1942,6 +1946,10 @@ write_history (file name) | ||
1942 | 1946 | read_history (file name) |
1943 | 1947 | - |
1944 | 1948 | ヒストリをファイルから読み出す |
1949 | +- | |
1950 | +file_name_completion_null_generator | |
1951 | +- | |
1952 | +readlineの補完で補完がない場合にデフォルトの補完を使わないようにする | |
1945 | 1953 | EOS | help::set_helps_ja |
1946 | 1954 | |
1947 | 1955 | print <<<'EOS' |
@@ -1980,6 +1988,10 @@ write readline cmdline history to a file | ||
1980 | 1988 | read_history (file name) |
1981 | 1989 | - |
1982 | 1990 | read readline cmdline history to the memory |
1991 | +- | |
1992 | +file_name_completion_null_generator | |
1993 | +- | |
1994 | +Don't use default readline completion of file name. | |
1983 | 1995 | EOS | help::set_helps |
1984 | 1996 | ) |
1985 | 1997 |
@@ -1,3 +1,5 @@ | ||
1 | +print migemo.dll.xyzsh | p > /dev/null | |
2 | + | |
1 | 3 | print "welcome to migemo.so dynamic library. You can read help type with \"migemo::help 'command name'\""\n |
2 | 4 | |
3 | 5 | compl::run( root::object migemo ) |
@@ -149,9 +149,18 @@ root::run( | ||
149 | 149 | ) |
150 | 150 | |
151 | 151 | def file_completion ( |
152 | + | chomp | split '(?<!\\) +' | length -line-num | var -local input_num | |
152 | 153 | | split '(?<!\\) +' | lines -1 | var -local inputing |
153 | 154 | |
154 | - if(inputing | index -quiet /) ( | |
155 | + if(input_num | = 1\n) ( | |
156 | + ls | each ( | |
157 | + | if (|chomp| -d) ( | |
158 | + | chomp | xyzsh_quote | add / | pomch | |
159 | + ) else ( | |
160 | + |chomp | xyzsh_quote| pomch | |
161 | + ) | |
162 | + ) | |
163 | + ) elif (inputing | index -quiet /) ( | |
155 | 164 | sys::dirname $(inputing|chomp| if (|rows -1 | = /) ( |add aaa ) else ( | print ) ) | var -local DIR |
156 | 165 | |
157 | 166 | ls $(DIR|xyzsh_dequote|chomp) | each ( |
@@ -721,26 +721,55 @@ BOOL cmd_completion(sObject* nextin, sObject* nextout, sRunInfo* runinfo) | ||
721 | 721 | } |
722 | 722 | /// output /// |
723 | 723 | else if(runinfo->mBlocksNum == 0) { |
724 | - int i; | |
725 | - for(i=1; i<runinfo->mArgsNumRuntime; i++) { | |
726 | - sObject* compl; | |
727 | - if(!get_object_from_str(&compl, runinfo->mArgsRuntime[i], runinfo->mCurrentObject, runinfo->mRunningObject, runinfo)) { | |
728 | - return FALSE; | |
729 | - } | |
724 | + if(sRunInfo_option(runinfo, "-source")) { | |
725 | + int i; | |
726 | + for(i=1; i<runinfo->mArgsNumRuntime; i++) { | |
727 | + sObject* compl; | |
728 | + if(!get_object_from_str(&compl, runinfo->mArgsRuntime[i], runinfo->mCurrentObject, runinfo->mRunningObject, runinfo)) { | |
729 | + return FALSE; | |
730 | + } | |
731 | + | |
732 | + if(compl && TYPE(compl) == T_COMPLETION) { | |
733 | + sObject* block = SCOMPLETION(compl).mBlock; | |
734 | + if(!fd_write(nextout, SBLOCK(block).mSource, strlen(SBLOCK(block).mSource))) | |
735 | + { | |
736 | + err_msg("signal interrupt", runinfo->mSName, runinfo->mSLine, runinfo->mArgs[0]); | |
737 | + runinfo->mRCode = RCODE_SIGNAL_INTERRUPT; | |
738 | + return FALSE; | |
739 | + } | |
740 | + | |
741 | + } | |
742 | + else { | |
743 | + err_msg("There is no object", runinfo->mSName, runinfo->mSLine, runinfo->mArgsRuntime[i]); | |
730 | 744 | |
731 | - if(compl && TYPE(compl) == T_COMPLETION) { | |
732 | - if(!run_object(compl, nextin, nextout, runinfo)) { | |
733 | 745 | return FALSE; |
734 | 746 | } |
735 | 747 | } |
736 | - else { | |
737 | - err_msg("There is no object", runinfo->mSName, runinfo->mSLine, runinfo->mArgsRuntime[i]); | |
738 | 748 | |
739 | - return FALSE; | |
740 | - } | |
749 | + runinfo->mRCode = 0; | |
741 | 750 | } |
751 | + else { | |
752 | + int i; | |
753 | + for(i=1; i<runinfo->mArgsNumRuntime; i++) { | |
754 | + sObject* compl; | |
755 | + if(!get_object_from_str(&compl, runinfo->mArgsRuntime[i], runinfo->mCurrentObject, runinfo->mRunningObject, runinfo)) { | |
756 | + return FALSE; | |
757 | + } | |
742 | 758 | |
743 | - runinfo->mRCode = 0; | |
759 | + if(compl && TYPE(compl) == T_COMPLETION) { | |
760 | + if(!run_object(compl, nextin, nextout, runinfo)) { | |
761 | + return FALSE; | |
762 | + } | |
763 | + } | |
764 | + else { | |
765 | + err_msg("There is no object", runinfo->mSName, runinfo->mSLine, runinfo->mArgsRuntime[i]); | |
766 | + | |
767 | + return FALSE; | |
768 | + } | |
769 | + } | |
770 | + | |
771 | + runinfo->mRCode = 0; | |
772 | + } | |
744 | 773 | } |
745 | 774 | } |
746 | 775 |
@@ -881,6 +910,8 @@ BOOL cmd_readline_file_name_completion_null_generator(sObject* nextin, sObject* | ||
881 | 910 | { |
882 | 911 | rl_completion_entry_function = readline_filename_completion_null_generator; |
883 | 912 | |
913 | + runinfo->mRCode = 0; | |
914 | + | |
884 | 915 | return TRUE; |
885 | 916 | } |
886 | 917 |