commit 25750316e3b3ea6e476f9fe5543e9d538f60cd49
parent d1b42585dbddca5eea848cb90aab1daa113a8e44
Author: ukai <ukai>
Date: Thu, 31 Jan 2002 03:55:35 +0000
[w3m-dev 02946] toggle migemo
* fm.h (migemo_active): added
* proto.h (inputLineHistSearch): add arg `prop' to incrfunc()
* linein.c (inputLineHistSearch): ditto
* main.c (isrch): ditto
* main.c (dispincsrch): ditto
C-\ toggle migemo
underline when migemo is active
* search.c (migemo_active): deleted
* search.c (migemo_running): added
* search.c (init_migemo): migemo_running
* search.c (migemostr): ditto
* search.c (forwardSearch): migemo_active > 0
* search.c (backwardSearch): ditto
From: Fumitoshi UKAI <ukai@debian.or.jp>
Diffstat:
6 files changed, 50 insertions(+), 15 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,20 @@
+2002-01-31 Fumitoshi UKAI <ukai@debian.or.jp>
+
+ * [w3m-dev 02946] toggle migemo
+ * fm.h (migemo_active): added
+ * proto.h (inputLineHistSearch): add arg `prop' to incrfunc()
+ * linein.c (inputLineHistSearch): ditto
+ * main.c (isrch): ditto
+ * main.c (dispincsrch): ditto
+ C-\ toggle migemo
+ underline when migemo is active
+ * search.c (migemo_active): deleted
+ * search.c (migemo_running): added
+ * search.c (init_migemo): migemo_running
+ * search.c (migemostr): ditto
+ * search.c (forwardSearch): migemo_active > 0
+ * search.c (backwardSearch): ditto
+
2002-01-31 Fumitoshi UKAI <ukai@debian.or.jp>
* [w3m-dev 02942] Digest qop=auth support
diff --git a/fm.h b/fm.h
@@ -782,6 +782,7 @@ global int DefaultURLString init(DEFAULT_URL_EMPTY);
#ifdef USE_MIGEMO
global int use_migemo init(FALSE);
+global int migemo_active init(0);
global char *migemo_command init(DEF_MIGEMO_COMMAND);
#endif /* USE_MIGEMO */
diff --git a/linein.c b/linein.c
@@ -82,7 +82,7 @@ static void ins_kanji(Str tmp);
char *
inputLineHistSearch(char *prompt, char *def_str, int flag, Hist *hist,
- int (*incrfunc) (int ch, Str str))
+ int (*incrfunc) (int ch, Str str, Lineprop *prop))
{
int opos, x, y, lpos, rpos, epos;
unsigned char c;
@@ -192,7 +192,7 @@ inputLineHistSearch(char *prompt, char *def_str, int flag, Hist *hist,
InnerCode);
ins_kanji(tmp);
if (incrfunc)
- incrfunc(-1, strBuf);
+ incrfunc(-1, strBuf, strProp);
}
else
#endif
@@ -229,10 +229,11 @@ inputLineHistSearch(char *prompt, char *def_str, int flag, Hist *hist,
cm_disp_next = -1;
}
else if (!i_quote && c < 0x20) { /* Control code */
- if (incrfunc == NULL || (c = incrfunc((int)c, strBuf)) < 0x20)
+ if (incrfunc == NULL
+ || (c = incrfunc((int)c, strBuf, strProp)) < 0x20)
(*InputKeymap[(int)c]) (c);
if (incrfunc)
- incrfunc(-1, strBuf);
+ incrfunc(-1, strBuf, strProp);
if (cm_clear)
cm_next = FALSE;
if (cm_disp_clear)
@@ -249,7 +250,7 @@ inputLineHistSearch(char *prompt, char *def_str, int flag, Hist *hist,
tmp = conv_str(tmp, DisplayCode, InnerCode);
ins_kanji(tmp);
if (incrfunc)
- incrfunc(-1, strBuf);
+ incrfunc(-1, strBuf, strProp);
}
else if ((c & 0x80) || in_kanji) { /* Kanji 1 */
i_quote = FALSE;
@@ -278,7 +279,7 @@ inputLineHistSearch(char *prompt, char *def_str, int flag, Hist *hist,
CPos++;
mode = PC_ASCII;
if (incrfunc)
- incrfunc(-1, strBuf);
+ incrfunc(-1, strBuf, strProp);
}
if (CLen && (flag & IN_CHAR))
break;
diff --git a/main.c b/main.c
@@ -1401,7 +1401,7 @@ disp_srchresult(int result, char *prompt, char *str)
}
static int
-dispincsrch(int ch, Str buf)
+dispincsrch(int ch, Str buf, Lineprop *prop)
{
static Buffer sbuf;
static Line *currentLine;
@@ -1426,6 +1426,11 @@ dispincsrch(int ch, Str buf)
searchRoutine = forwardSearch;
do_next_search = TRUE;
break;
+
+ case 034:
+ migemo_active = -migemo_active;
+ goto done;
+
default:
if (ch >= 0)
return ch; /* use InputKeymap */
@@ -1459,6 +1464,16 @@ dispincsrch(int ch, Str buf)
}
displayBuffer(Currentbuf, B_FORCE_REDRAW);
clear_mark(Currentbuf->currentLine);
+ done:
+ {
+ int i;
+ for (i = 0; str[i] != '\0'; i++) {
+ if (migemo_active > 0)
+ prop[i] |= PE_UNDER;
+ else
+ prop[i] &= ~PE_UNDER;
+ }
+ }
return -1;
}
@@ -1468,7 +1483,7 @@ isrch(int (*func) (Buffer *, char *), char *prompt)
char *str;
Buffer sbuf;
SAVE_BUFPOSITION(&sbuf);
- dispincsrch(0, NULL); /* initialize incremental search state */
+ dispincsrch(0, NULL, NULL); /* initialize incremental search state */
searchRoutine = func;
str = inputLineHistSearch(prompt, NULL, IN_STRING, TextHist, dispincsrch);
diff --git a/proto.h b/proto.h
@@ -268,7 +268,8 @@ extern void escmap(void);
extern void escbmap(void);
extern void escdmap(char c);
extern char *inputLineHistSearch(char *prompt, char *def_str, int flag,
- Hist *hist, int (*incfunc) (int ch, Str buf));
+ Hist *hist, int (*incfunc) (int ch, Str buf,
+ Lineprop *prop));
#ifdef USE_HISTORY
extern Buffer *historyBuffer(Hist *hist);
extern void loadHistory(Hist *hist);
diff --git a/search.c b/search.c
@@ -15,13 +15,13 @@ set_mark(Line *l, int pos, int epos)
#ifdef USE_MIGEMO
/* Migemo: romaji --> kana+kanji in regexp */
static FILE *migemor, *migemow;
-static int migemo_active;
+static int migemo_running;
static int migemo_pid;
void
init_migemo()
{
- migemo_active = use_migemo;
+ migemo_active = migemo_running = use_migemo;
if (migemor != NULL)
fclose(migemor);
if (migemow != NULL)
@@ -75,7 +75,7 @@ open_migemo(char *migemo_command)
close(fdr[0]);
close(fdr[1]);
err0:
- migemo_active = 0;
+ migemo_active = migemo_running = 0;
return 0;
}
@@ -104,7 +104,7 @@ migemostr(char *str)
err:
/* XXX: backend migemo is not working? */
init_migemo();
- migemo_active = 0;
+ migemo_active = migemo_running = 0;
return str;
}
#endif /* USE_MIGEMO */
@@ -118,7 +118,7 @@ forwardSearch(Buffer *buf, char *str)
int pos;
#ifdef USE_MIGEMO
- if (migemo_active) {
+ if (migemo_active > 0) {
if (((p = regexCompile(migemostr(str), IgnoreCase)) != NULL)
&& ((p = regexCompile(str, IgnoreCase)) != NULL)) {
message(p, 0, 0);
@@ -196,7 +196,7 @@ backwardSearch(Buffer *buf, char *str)
int pos;
#ifdef USE_MIGEMO
- if (migemo_active) {
+ if (migemo_active > 0) {
if (((p = regexCompile(migemostr(str), IgnoreCase)) != NULL)
&& ((p = regexCompile(str, IgnoreCase)) != NULL)) {
message(p, 0, 0);