diff options
author | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-03-19 16:06:52 +0000 |
---|---|---|
committer | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-03-19 16:06:52 +0000 |
commit | f475e89f9f08db4fbb0d461b4ecaae6c1a11ca4c (patch) | |
tree | 3d9d729379650d9fe797bb0f019f1fd514feec33 | |
parent | [w3m-dev 03135] commit of [w3m-dev 03006] is incomplete. (diff) | |
download | w3m-f475e89f9f08db4fbb0d461b4ecaae6c1a11ca4c.tar.gz w3m-f475e89f9f08db4fbb0d461b4ecaae6c1a11ca4c.zip |
[w3m-dev 03136] Add COMMAND to execute multiple commands
* fm.h (CurrentMenuData): deleted
(CurrentCmdData): added
* func.c (getKey): check next char of ^
(getWord): get word until ';'
(getQWord): rewrite using Str
* funcname.tab (COMMAND): added
* main.c (MAIN): delete CurrentMenuData
initialize CurrentCmdData
(searchKeyData): use CurrentCmdData
(execCmd): added
(SigAlarm): delete CurrentMenuData, use CurrentCmdData
* menu.c (action_menu): delete CurrentMenuData, use CurrentCmdData
* proto.h (execCmd): added
* doc/README.func (ALARM): capitalize
(COMMAND): added
* doc-jp/README.func (COMMAND): added
From: Hironori Sakamoto <hsaka@mth.biglobe.ne.jp>
-rw-r--r-- | ChangeLog | 22 | ||||
-rw-r--r-- | doc-jp/README.func | 1 | ||||
-rw-r--r-- | doc/README.func | 3 | ||||
-rw-r--r-- | fm.h | 6 | ||||
-rw-r--r-- | func.c | 49 | ||||
-rw-r--r-- | funcname.tab | 3 | ||||
-rw-r--r-- | main.c | 83 | ||||
-rw-r--r-- | menu.c | 6 | ||||
-rw-r--r-- | proto.h | 3 |
9 files changed, 114 insertions, 62 deletions
@@ -1,5 +1,25 @@ 2002-03-20 Hironori Sakamoto <hsaka@mth.biglobe.ne.jp> + * [w3m-dev 03136] Add COMMAND to execute multiple commands + * fm.h (CurrentMenuData): deleted + (CurrentCmdData): added + * func.c (getKey): check next char of ^ + (getWord): get word until ';' + (getQWord): rewrite using Str + * funcname.tab (COMMAND): added + * main.c (MAIN): delete CurrentMenuData + initialize CurrentCmdData + (searchKeyData): use CurrentCmdData + (execCmd): added + (SigAlarm): delete CurrentMenuData, use CurrentCmdData + * menu.c (action_menu): delete CurrentMenuData, use CurrentCmdData + * proto.h (execCmd): added + * doc/README.func (ALARM): capitalize + (COMMAND): added + * doc-jp/README.func (COMMAND): added + +2002-03-20 Hironori Sakamoto <hsaka@mth.biglobe.ne.jp> + * [w3m-dev 03135] commit of [w3m-dev 03006] is incomplete. * file.c (HTMLlineproc2body): check form_int fid attr update forms[] @@ -3242,4 +3262,4 @@ * release-0-2-1 * import w3m-0.2.1 -$Id: ChangeLog,v 1.356 2002/03/19 15:54:47 ukai Exp $ +$Id: ChangeLog,v 1.357 2002/03/19 16:06:52 ukai Exp $ diff --git a/doc-jp/README.func b/doc-jp/README.func index ad5d72e..6503283 100644 --- a/doc-jp/README.func +++ b/doc-jp/README.func @@ -6,6 +6,7 @@ BEGIN 文書のいちばん上の行に移動します BOOKMARK ブックマークを読み込みます CENTER_H カーソルのある位置を行の中央に移動します CENTER_V カーソルのある行を画面の中央に移動します +COMMAND w3mのコマンドを実行します COOKIE クッキー一覧を表示します DELETE_PREVBUF 前のバッファを消去します(主に local-CGI 用) DICT_WORD 入力した単語を辞書コマンドで調べます diff --git a/doc/README.func b/doc/README.func index 024cfc1..2c9645e 100644 --- a/doc/README.func +++ b/doc/README.func @@ -1,11 +1,12 @@ ABORT Quit w3m without confirmation ADD_BOOKMARK Add current page to bookmark -ALARM set alarm +ALARM Set alarm BACK Back to previous buffer BEGIN Go to the first line BOOKMARK Read bookmark CENTER_H Move to the center line CENTER_V Move to the center column +COMMAND Execute w3m command(s) COOKIE View cookie list DELETE_PREVBUF Delete previous buffer (mainly for local-CGI) DICT_WORD Execute dictionary command (see README.dict) @@ -1,4 +1,4 @@ -/* $Id: fm.h,v 1.56 2002/03/15 18:33:32 ukai Exp $ */ +/* $Id: fm.h,v 1.57 2002/03/19 16:06:52 ukai Exp $ */ /* * w3m: WWW wo Miru utility * @@ -765,9 +765,7 @@ global Buffer *Currentbuf; global Buffer *Firstbuf; global int CurrentKey; global char *CurrentKeyData; -#ifdef USE_MENU -global char *CurrentMenuData; -#endif +global char *CurrentCmdData; extern char *ullevel[]; extern char *w3m_version; @@ -1,4 +1,4 @@ -/* $Id: func.c,v 1.7 2001/12/10 17:02:44 ukai Exp $ */ +/* $Id: func.c,v 1.8 2002/03/19 16:06:52 ukai Exp $ */ /* * w3m func.c */ @@ -139,7 +139,7 @@ getKey(char *s) s += 2; ctrl = 1; } - else if (*s == '^') { /* ^, ^[^ */ + else if (*s == '^' && *(s + 1)) { /* ^, ^[^ */ s++; ctrl = 1; } @@ -157,7 +157,7 @@ getKey(char *s) s += 2; ctrl = 1; } - else if (*s == '^') { /* ^[^, ^[[^ */ + else if (*s == '^' && *(s + 1)) { /* ^[^, ^[[^ */ s++; ctrl = 1; } @@ -229,46 +229,36 @@ getWord(char **str) p = *str; SKIP_BLANKS(p); - s = p; - while (*p != '\0') { - if (IS_SPACE(*p)) { - *p = '\0'; - p++; - break; - } - p++; - } + for (s = p; *p && ! IS_SPACE(*p) && *p != ';'; p++) ; *str = p; - return s; + return Strnew_charp_n(s, p - s)->ptr; } char * getQWord(char **str) { - char *p, *s, *e; + Str tmp = Strnew(); + char *p; int in_q = 0, in_dq = 0, esc = 0; p = *str; - while (*p && IS_SPACE(*p)) - p++; - s = p; - e = p; - while (*p != '\0') { + SKIP_BLANKS(p); + for (; *p; p++) { if (esc) { if (in_q) { if (*p != '\\' && *p != '\'') /* '..\\..', '..\'..' */ - *e++ = '\\'; + Strcat_char(tmp, '\\'); } else if (in_dq) { if (*p != '\\' && *p != '"') /* "..\\..", "..\".." */ - *e++ = '\\'; + Strcat_char(tmp, '\\'); } else { if (*p != '\\' && *p != '\'' && /* ..\\.., ..\'.. */ *p != '"' && !IS_SPACE(*p)) /* ..\".., ..\.. */ - *e++ = '\\'; + Strcat_char(tmp, '\\'); } - *e++ = *p; + Strcat_char(tmp, *p); esc = 0; } else if (*p == '\\') { @@ -278,13 +268,13 @@ getQWord(char **str) if (*p == '\'') in_q = 0; else - *e++ = *p; + Strcat_char(tmp, *p); } else if (in_dq) { if (*p == '"') in_dq = 0; else - *e++ = *p; + Strcat_char(tmp, *p); } else if (*p == '\'') { in_q = 1; @@ -292,16 +282,13 @@ getQWord(char **str) else if (*p == '"') { in_dq = 1; } - else if (IS_SPACE(*p)) { - p++; + else if (IS_SPACE(*p) || *p == ';') { break; } else { - *e++ = *p; + Strcat_char(tmp, *p); } - p++; } - *e = '\0'; *str = p; - return s; + return tmp->ptr; } diff --git a/funcname.tab b/funcname.tab index 3057e80..d29dd21 100644 --- a/funcname.tab +++ b/funcname.tab @@ -1,4 +1,4 @@ -# $Id: funcname.tab,v 1.7 2002/01/31 17:54:51 ukai Exp $ +# $Id: funcname.tab,v 1.8 2002/03/19 16:06:52 ukai Exp $ # macro name function name #---------------------------- @@@ nulcmd @@ -10,6 +10,7 @@ BEGIN goLineF BOOKMARK ldBmark CENTER_H ctrCsrH CENTER_V ctrCsrV +COMMAND execCmd COOKIE cooLst DELETE_PREVBUF deletePrevBuf DICT_WORD dictword @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.90 2002/03/15 19:02:40 ukai Exp $ */ +/* $Id: main.c,v 1.91 2002/03/19 16:06:52 ukai Exp $ */ #define MAINPROGRAM #include "fm.h" #include <signal.h> @@ -729,7 +729,6 @@ MAIN(int argc, char **argv, char **envp) initKeymap(); #ifdef USE_MENU initMenu(); - CurrentMenuData = NULL; #endif /* MENU */ fmInit(); #ifdef SIGWINCH @@ -953,9 +952,7 @@ MAIN(int argc, char **argv, char **envp) for (i = 0; i < n_event_queue; i++) { CurrentKey = -1; CurrentKeyData = eventQueue[i].user_data; -#ifdef USE_MENU - CurrentMenuData = NULL; -#endif + CurrentCmdData = NULL; w3mFuncList[eventQueue[i].cmd].func(); } n_event_queue = 0; @@ -4929,17 +4926,14 @@ set_buffer_environ(Buffer *buf) char * searchKeyData(void) { - char *data; + char *data = NULL; if (CurrentKeyData != NULL && *CurrentKeyData != '\0') - return allocStr(CurrentKeyData, -1); -#ifdef USE_MENU - if (CurrentMenuData != NULL && *CurrentMenuData != '\0') - return allocStr(CurrentMenuData, -1); -#endif - if (CurrentKey < 0) - return NULL; - data = getKeyData(CurrentKey); + data = CurrentKeyData; + else if (CurrentCmdData != NULL && *CurrentCmdData != '\0') + data = CurrentCmdData; + else if (CurrentKey >= 0) + data = getKeyData(CurrentKey); if (data == NULL || *data == '\0') return NULL; return allocStr(data, -1); @@ -4984,26 +4978,72 @@ w3m_exit(int i) exit(i); } +void +execCmd(void) +{ + char *data, *p; + int cmd; + + CurrentKeyData = NULL; /* not allowed in w3m-control: */ + data = searchKeyData(); + if (data == NULL || *data == '\0') { + data = inputStrHist("command [; ...]: ", "", TextHist); + if (data == NULL) { + displayBuffer(Currentbuf, B_NORMAL); + return; + } + } + /* data: FUNC [DATA] [; FUNC [DATA] ...] */ + while (*data) { + SKIP_BLANKS(data); + if (*data == ';') { + data++; + continue; + } + p = getWord(&data); + cmd = getFuncList(p); + if (cmd < 0) + break; + p = getQWord(&data); + CurrentKey = -1; + CurrentKeyData = NULL; + CurrentCmdData = *p ? p : NULL; +#ifdef USE_MOUSE + if (use_mouse) + mouse_inactive(); +#endif + w3mFuncList[cmd].func(); +#ifdef USE_MOUSE + if (use_mouse) + mouse_active(); +#endif + CurrentCmdData = NULL; + } + displayBuffer(Currentbuf, B_NORMAL); +} + #ifdef USE_ALARM static MySignalHandler SigAlarm(SIGNAL_ARG) { if (alarm_sec > 0) { CurrentKey = -1; - CurrentKeyData = (char *)alarm_event.user_data; -#ifdef USE_MENU - CurrentMenuData = NULL; -#endif + CurrentKeyData = NULL; + CurrentCmdData = (char *)alarm_event.user_data; #ifdef USE_MOUSE if (use_mouse) mouse_inactive(); #endif w3mFuncList[alarm_event.cmd].func(); - onA(); #ifdef USE_MOUSE if (use_mouse) mouse_active(); #endif + CurrentCmdData = NULL; + onA(); + disp_message_nsec(Sprintf("%s %s", w3mFuncList[alarm_event.cmd].id, + CurrentCmdData ? CurrentCmdData : "")->ptr, + FALSE, alarm_sec - 1, FALSE, TRUE); if (alarm_status == AL_IMPLICIT) { alarm_buffer = Currentbuf; alarm_status = AL_IMPLICIT_DONE; @@ -5041,7 +5081,10 @@ setAlarm(void) cmd = getFuncList(getWord(&data)); } if (cmd >= 0) { - setAlarmEvent(sec, AL_EXPLICIT, cmd, getQWord(&data)); + data = getQWord(&data); + setAlarmEvent(sec, AL_EXPLICIT, cmd, data); + disp_message_nsec(Sprintf("%s %s", w3mFuncList[cmd].id, data)->ptr, + FALSE, sec - 1, FALSE, TRUE); } else { setAlarmEvent(0, AL_UNSET, FUNCNAME_nulcmd, NULL); @@ -1,4 +1,4 @@ -/* $Id: menu.c,v 1.14 2002/01/31 17:54:52 ukai Exp $ */ +/* $Id: menu.c,v 1.15 2002/03/19 16:06:52 ukai Exp $ */ /* * w3m menu.c */ @@ -641,9 +641,9 @@ action_menu(Menu *menu) if (item.type & MENU_FUNC) { CurrentKey = -1; CurrentKeyData = NULL; - CurrentMenuData = item.data; + CurrentCmdData = item.data; (*item.func) (); - CurrentMenuData = NULL; + CurrentCmdData = NULL; } } else if (mselect == MENU_CLOSE) { @@ -1,4 +1,4 @@ -/* $Id: proto.h,v 1.39 2002/03/15 18:33:32 ukai Exp $ */ +/* $Id: proto.h,v 1.40 2002/03/19 16:06:52 ukai Exp $ */ /* * This file was automatically generated by version 1.7 of cextract. * Manual editing not recommended. @@ -102,6 +102,7 @@ extern void rFrame(void); extern void extbrz(void); extern void linkbrz(void); extern void curlno(void); +extern void execCmd(void); #ifdef USE_IMAGE extern void dispI(void); extern void stopI(void); |