w3m

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/w3m.git/
Log | Files | Refs | README

commit dd3be768f185fb748b2981932860e61a8973a37a
parent 129fa90f14e85910e96727a2ed22d351fc0286c6
Author: ukai <ukai>
Date:   Tue, 19 Mar 2002 16:06:52 +0000

[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>

Diffstat:
MChangeLog | 20++++++++++++++++++++
Mdoc-jp/README.func | 1+
Mdoc/README.func | 3++-
Mfm.h | 4+---
Mfunc.c | 47+++++++++++++++++------------------------------
Mfuncname.tab | 1+
Mmain.c | 81++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------
Mmenu.c | 4++--
Mproto.h | 1+
9 files changed, 107 insertions(+), 55 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -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[] diff --git 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 @@ -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) diff --git a/fm.h b/fm.h @@ -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; diff --git a/func.c b/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 @@ -10,6 +10,7 @@ BEGIN goLineF BOOKMARK ldBmark CENTER_H ctrCsrH CENTER_V ctrCsrV +COMMAND execCmd COOKIE cooLst DELETE_PREVBUF deletePrevBuf DICT_WORD dictword diff --git a/main.c b/main.c @@ -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); diff --git a/menu.c b/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) { diff --git a/proto.h b/proto.h @@ -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);