diff options
Diffstat (limited to '')
-rw-r--r-- | ChangeLog | 34 | ||||
-rw-r--r-- | display.c | 32 | ||||
-rw-r--r-- | fm.h | 9 | ||||
-rw-r--r-- | linein.c | 21 | ||||
-rw-r--r-- | main.c | 56 | ||||
-rw-r--r-- | proto.h | 6 | ||||
-rw-r--r-- | rc.c | 6 | ||||
-rw-r--r-- | search.c | 13 |
8 files changed, 123 insertions, 54 deletions
@@ -1,3 +1,35 @@ +2002-01-17 Hironori Sakamoto <hsaka@mth.biglobe.ne.jp> + + * [w3m-dev 02854] highlight for incremental search + * display.c (EFFECT_MARK_START): added + * display.c (EFFECT_MARK_END): added + * display.c (EFFECT_MARK_START_C): added + * display.c (EFFECT_MARK_END_C): added + * display.c (EFFECT_MARK_START_M): added + * display.c (EFFECT_MARK_END_M): added + * display.c: define_effect for MARK_{START,END} + * display.c (mark_mode): added + * display.c (redrawLine): if mark_mode + * display.c (do_effects): do_effect2(PE_MARK, ...) + * display.c (do_effects): do_effect1(PE_MARK, ...) + * fm.h (P_EFFECT): changed to 0x01ff + * fm.h (PE_MARK): moved + * fm.h (mark_color): added + * linein.c (inputLineHistSearch): incrfunc(int ch, Str str) + * main.c (clear_mark): added + * main.c (dispincsrch): remove arg `x', `y' + * main.c (dispincsrch): move SAVE_BUFPOSITION() + * main.c (srch): if (result & SR_FOUND) clear_mark() + * main.c (cmd_mark): PE_MARK + * main.c (nextMk): s/PM_MARK/PE_MARK/ + * main.c (prevMk): s/PM_MARK/PE_MARK/ + * proto.h (inputLineHistSearch): change prototype incfunc() + * rc.c (CMT_MARK_COLOR): added + * rc.c (params2): add "mark_color" + * search.c (set_mark): added + * search.c (forwardSearch): use set_mark() + * search.c (backwardSearch): use set_mark() + 2002-01-16 Tsutomu Okada <okada@furuno.co.jp> * [w3m-dev 02851] @@ -2003,4 +2035,4 @@ * release-0-2-1 * import w3m-0.2.1 -$Id: ChangeLog,v 1.228 2002/01/16 04:38:06 ukai Exp $ +$Id: ChangeLog,v 1.229 2002/01/16 15:37:06 ukai Exp $ @@ -1,4 +1,4 @@ -/* $Id: display.c,v 1.13 2001/12/26 18:17:57 ukai Exp $ */ +/* $Id: display.c,v 1.14 2002/01/16 15:37:06 ukai Exp $ */ #include <signal.h> #include "fm.h" @@ -17,6 +17,8 @@ #define EFFECT_ACTIVE_END effect_active_end() #define EFFECT_VISITED_START effect_visited_start() #define EFFECT_VISITED_END effect_visited_end() +#define EFFECT_MARK_START effect_mark_start() +#define EFFECT_MARK_END effect_mark_end() /* color: * 0 black * 1 red * 2 green * 3 yellow * * 4 blue * 5 magenta * 6 cyan * 7 white */ @@ -26,12 +28,22 @@ #define EFFECT_FORM_START_C setfcolor(form_color) #define EFFECT_ACTIVE_START_C (setfcolor(active_color), underline()) #define EFFECT_VISITED_START_C setfcolor(visited_color) +#ifdef USE_BG_COLOR +#define EFFECT_MARK_START_C setbcolor(mark_color) +#else +#define EFFECT_MARK_START_C standout() +#endif #define EFFECT_IMAGE_END_C setfcolor(basic_color) #define EFFECT_ANCHOR_END_C setfcolor(basic_color) #define EFFECT_FORM_END_C setfcolor(basic_color) #define EFFECT_ACTIVE_END_C (setfcolor(basic_color), underlineend()) #define EFFECT_VISITED_END_C setfcolor(basic_color) +#ifdef USE_BG_COLOR +#define EFFECT_MARK_END_C setbcolor(bg_color) +#else +#define EFFECT_MARK_END_C standend() +#endif #define EFFECT_ANCHOR_START_M underline() #define EFFECT_ANCHOR_END_M underlineend() @@ -45,6 +57,8 @@ #define EFFECT_ACTIVE_END_M boldend() #define EFFECT_VISITED_START_M /**/ #define EFFECT_VISITED_END_M /**/ +#define EFFECT_MARK_START_M standout() +#define EFFECT_MARK_END_M standend() #define define_effect(name_start,name_end,color_start,color_end,mono_start,mono_end) \ static void name_start { if (useColor) { color_start; } else { mono_start; }}\ static void name_end { if (useColor) { color_end; } else { mono_end; }} @@ -54,6 +68,8 @@ define_effect(EFFECT_IMAGE_START, EFFECT_IMAGE_END, EFFECT_IMAGE_START_C, EFFECT_IMAGE_END_C, EFFECT_IMAGE_START_M, EFFECT_IMAGE_END_M) define_effect(EFFECT_FORM_START, EFFECT_FORM_END, EFFECT_FORM_START_C, EFFECT_FORM_END_C, EFFECT_FORM_START_M, EFFECT_FORM_END_M) +define_effect(EFFECT_MARK_START, EFFECT_MARK_END, EFFECT_MARK_START_C, + EFFECT_MARK_END_C, EFFECT_MARK_START_M, EFFECT_MARK_END_M) /*****************/ /* *INDENT-OFF* */ @@ -128,6 +144,8 @@ EFFECT_VISITED_END #define EFFECT_ACTIVE_END boldend() #define EFFECT_VISITED_START /**/ #define EFFECT_VISITED_END /**/ +#define EFFECT_MARK_START standout() +#define EFFECT_MARK_END standend() #endif /* not USE_COLOR */ #ifndef KANJI_SYMBOLS static char g_rule[] = "ntwluxkavmqajaaa"; @@ -176,7 +194,7 @@ static int ccolumn = -1; static int ulmode = 0, somode = 0, bomode = 0; static int anch_mode = 0, emph_mode = 0, imag_mode = 0, form_mode = 0, - active_mode = 0, visited_mode = 0; + active_mode = 0, visited_mode = 0, mark_mode = 0; #ifndef KANJI_SYMBOLS static int graph_mode = 0; #endif /* not KANJI_SYMBOLS */ @@ -512,6 +530,10 @@ redrawLine(Buffer *buf, Line *l, int i) active_mode = FALSE; EFFECT_ACTIVE_END; } + if (mark_mode) { + mark_mode = FALSE; + EFFECT_MARK_END; + } #ifndef KANJI_SYMBOLS if (graph_mode) { graph_mode = FALSE; @@ -649,6 +671,10 @@ redrawLineRegion(Buffer *buf, Line *l, int i, int bpos, int epos) active_mode = FALSE; EFFECT_ACTIVE_END; } + if (mark_mode) { + mark_mode = FALSE; + EFFECT_MARK_END; + } #ifndef KANJI_SYMBOLS if (graph_mode) { graph_mode = FALSE; @@ -690,6 +716,7 @@ do_effects(Lineprop m) do_effect2(PE_VISITED, visited_mode, EFFECT_VISITED_START, EFFECT_VISITED_END); do_effect2(PE_ACTIVE, active_mode, EFFECT_ACTIVE_START, EFFECT_ACTIVE_END); + do_effect2(PE_MARK, mark_mode, EFFECT_MARK_START, EFFECT_MARK_END); #ifndef KANJI_SYMBOLS if (graph_mode) { graphend(); @@ -708,6 +735,7 @@ do_effects(Lineprop m) do_effect1(PE_VISITED, visited_mode, EFFECT_VISITED_START, EFFECT_VISITED_END); do_effect1(PE_ACTIVE, active_mode, EFFECT_ACTIVE_START, EFFECT_ACTIVE_END); + do_effect1(PE_MARK, mark_mode, EFFECT_MARK_START, EFFECT_MARK_END); #ifndef KANJI_SYMBOLS if (m & PC_RULE) { if (!graph_mode && graph_ok()) { @@ -1,4 +1,4 @@ -/* $Id: fm.h,v 1.38 2002/01/15 17:23:29 ukai Exp $ */ +/* $Id: fm.h,v 1.39 2002/01/16 15:37:06 ukai Exp $ */ /* * w3m: WWW wo Miru utility * @@ -126,8 +126,9 @@ void bzero(void *, int); #endif /* not KANJI_SYMBOLS */ /* Effect ( standout/underline ) */ -#define P_EFFECT 0x01fe +#define P_EFFECT 0x01ff #define PE_NORMAL 0x00 +#define PE_MARK 0x01 #define PE_UNDER 0x02 #define PE_STAND 0x04 #define PE_BOLD 0x08 @@ -138,9 +139,6 @@ void bzero(void *, int); #define PE_ACTIVE 0x80 #define PE_VISITED 0x0100 -/* Mark */ -#define PM_MARK 0x01 - #define CharType(c) ((c)&P_CHARTYPE) #ifdef KANJI_SYMBOLS #define CharEffect(c) ((c)&P_EFFECT) @@ -722,6 +720,7 @@ global int image_color init(2); /* green */ global int form_color init(1); /* red */ #ifdef USE_BG_COLOR global int bg_color init(8); /* don't change */ +global int mark_color init(6); /* cyan */ #endif /* USE_BG_COLOR */ global int useActiveColor init(FALSE); global int active_color init(6); /* cyan */ @@ -1,4 +1,4 @@ -/* $Id: linein.c,v 1.18 2001/12/25 13:43:51 ukai Exp $ */ +/* $Id: linein.c,v 1.19 2002/01/16 15:37:06 ukai Exp $ */ #include "fm.h" #include "local.h" #include "myctype.h" @@ -82,14 +82,12 @@ static void ins_kanji(Str tmp); char * inputLineHistSearch(char *prompt, char *def_str, int flag, Hist *hist, - int (*incrfunc) (int ch, Str str, short *x, short *y)) + int (*incrfunc) (int ch, Str str)) { int opos, x, y, lpos, rpos, epos; unsigned char c; char *p; Lineprop mode; - short cursorX = -1; - short cursorY = -1; #ifdef JP_CHARSET Str tmp = Strnew(); #endif /* JP_CHARSET */ @@ -170,10 +168,7 @@ inputLineHistSearch(char *prompt, char *def_str, int flag, Hist *hist, else addStr(strBuf->ptr, strProp, CLen, offset, COLS - opos); clrtoeolx(); - if (cursorX >= 0 && cursorY >= 0) - move(cursorY, cursorX); - else - move(LASTLINE, opos + x - offset); + move(LASTLINE, opos + x - offset); refresh(); next_char: @@ -197,7 +192,7 @@ inputLineHistSearch(char *prompt, char *def_str, int flag, Hist *hist, InnerCode); ins_kanji(tmp); if (incrfunc) - incrfunc(-1, strBuf, &cursorX, &cursorY); + incrfunc(-1, strBuf); } else #endif @@ -235,10 +230,10 @@ inputLineHistSearch(char *prompt, char *def_str, int flag, Hist *hist, } else if (!i_quote && c < 0x20) { /* Control code */ if (incrfunc == NULL - || (c = incrfunc((int)c, strBuf, &cursorX, &cursorY)) < 0x20) + || (c = incrfunc((int)c, strBuf)) < 0x20) (*InputKeymap[(int)c]) (c); if (incrfunc) - incrfunc(-1, strBuf, &cursorX, &cursorY); + incrfunc(-1, strBuf); if (cm_clear) cm_next = FALSE; if (cm_disp_clear) @@ -255,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, &cursorX, &cursorY); + incrfunc(-1, strBuf); } else if ((c & 0x80) || in_kanji) { /* Kanji 1 */ i_quote = FALSE; @@ -284,7 +279,7 @@ inputLineHistSearch(char *prompt, char *def_str, int flag, Hist *hist, CPos++; mode = PC_ASCII; if (incrfunc) - incrfunc(-1, strBuf, &cursorX, &cursorY); + incrfunc(-1, strBuf); } if (CLen && (flag & IN_CHAR)) break; @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.59 2002/01/15 17:23:29 ukai Exp $ */ +/* $Id: main.c,v 1.60 2002/01/16 15:37:06 ukai Exp $ */ #define MAINPROGRAM #include "fm.h" #include <signal.h> @@ -1351,6 +1351,16 @@ migemostr(char *str) } #endif /* USE_MIGEMO */ +static void +clear_mark(Line *l) +{ + short pos; + if (!l) + return; + for (pos = 0; pos < l->len; pos++) + l->propBuf[pos] &= ~PE_MARK; +} + /* search by regular expression */ static int srchcore(char *str, int (*func) (Buffer *, char *)) @@ -1391,7 +1401,7 @@ disp_srchresult(int result, char *prompt, char *str) } static int -dispincsrch(int ch, Str buf, short *x, short *y) +dispincsrch(int ch, Str buf) { static Buffer sbuf; static Line *currentLine; @@ -1422,8 +1432,8 @@ dispincsrch(int ch, Str buf, short *x, short *y) } if (do_next_search) { + SAVE_BUFPOSITION(&sbuf); if (*str) { - SAVE_BUFPOSITION(&sbuf); srchcore(str, searchRoutine); arrangeCursor(Currentbuf); if (Currentbuf->currentLine == currentLine @@ -1432,28 +1442,20 @@ dispincsrch(int ch, Str buf, short *x, short *y) srchcore(str, searchRoutine); arrangeCursor(Currentbuf); } - *x = Currentbuf->cursorX; - *y = Currentbuf->cursorY; - displayBuffer(Currentbuf, B_NORMAL); - return -1; - } - else { - return 020; /* _prev completion? */ } } - else if (*str) { + else { RESTORE_BUFPOSITION(&sbuf); arrangeCursor(Currentbuf); - srchcore(str, searchRoutine); - arrangeCursor(Currentbuf); - *x = Currentbuf->cursorX; - *y = Currentbuf->cursorY; + if (*str) { + srchcore(str, searchRoutine); + arrangeCursor(Currentbuf); + } currentLine = Currentbuf->currentLine; pos = Currentbuf->pos; - displayBuffer(Currentbuf, B_NORMAL); } - else - displayBuffer(Currentbuf, B_NORMAL); + displayBuffer(Currentbuf, B_FORCE_REDRAW); + clear_mark(Currentbuf->currentLine); return -1; } @@ -1463,14 +1465,14 @@ isrch(int (*func) (Buffer *, char *), char *prompt) char *str; Buffer sbuf; SAVE_BUFPOSITION(&sbuf); - dispincsrch(0, NULL, NULL, NULL); /* initialize incremental search state */ + dispincsrch(0, NULL); /* initialize incremental search state */ searchRoutine = func; str = inputLineHistSearch(prompt, NULL, IN_STRING, TextHist, dispincsrch); if (str == NULL) { RESTORE_BUFPOSITION(&sbuf); } - displayBuffer(Currentbuf, B_NORMAL); + displayBuffer(Currentbuf, B_FORCE_REDRAW); onA(); } @@ -1486,6 +1488,8 @@ srch(int (*func) (Buffer *, char *), char *prompt) if (str == NULL) return; result = srchcore(str, func); + if (result & SR_FOUND) + clear_mark(Currentbuf->currentLine); displayBuffer(Currentbuf, B_NORMAL); onA(); disp_srchresult(result, prompt, str); @@ -1539,6 +1543,8 @@ srch_nxtprv(int reverse) if (searchRoutine == backwardSearch) reverse ^= 1; result = srchcore(SearchString, routine[reverse]); + if (result & SR_FOUND) + clear_mark(Currentbuf->currentLine); displayBuffer(Currentbuf, B_NORMAL); onA(); disp_srchresult(result, (reverse ? "Backward: " : "Forward: "), @@ -2355,11 +2361,7 @@ cmd_mark(Lineprop *p) { if (!use_mark) return; - if ((*p & PM_MARK) && (*p & PE_STAND)) - *p &= ~PE_STAND; - else if (!(*p & PM_MARK) && !(*p & PE_STAND)) - *p |= PE_STAND; - *p ^= PM_MARK; + *p |= PE_MARK; } /* Go to next mark */ @@ -2381,7 +2383,7 @@ nextMk(void) } while (l != NULL) { for (; i < l->len; i++) { - if (l->propBuf[i] & PM_MARK) { + if (l->propBuf[i] & PE_MARK) { Currentbuf->currentLine = l; Currentbuf->pos = i; arrangeCursor(Currentbuf); @@ -2415,7 +2417,7 @@ prevMk(void) } while (l != NULL) { for (; i >= 0; i--) { - if (l->propBuf[i] & PM_MARK) { + if (l->propBuf[i] & PE_MARK) { Currentbuf->currentLine = l; Currentbuf->pos = i; arrangeCursor(Currentbuf); @@ -1,4 +1,4 @@ -/* $Id: proto.h,v 1.24 2002/01/14 15:59:17 ukai Exp $ */ +/* $Id: proto.h,v 1.25 2002/01/16 15:37:07 ukai Exp $ */ /* * This file was automatically generated by version 1.7 of cextract. * Manual editing not recommended. @@ -262,9 +262,7 @@ 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, short *x, - short *y)); + Hist *hist, int (*incfunc) (int ch, Str buf)); #ifdef USE_HISTORY extern Buffer *historyBuffer(Hist *hist); extern void loadHistory(Hist *hist); @@ -1,4 +1,4 @@ -/* $Id: rc.c,v 1.29 2002/01/15 17:23:29 ukai Exp $ */ +/* $Id: rc.c,v 1.30 2002/01/16 15:37:07 ukai Exp $ */ /* * Initialization file etc. */ @@ -74,6 +74,7 @@ static char *config_file = NULL; #define CMT_I_COLOR "画像リンクの色" #define CMT_F_COLOR "フォームの色" #define CMT_BG_COLOR "背景の色" +#define CMT_MARK_COLOR "マークの色" #define CMT_ACTIVE_STYLE "現在選択されているリンクの色を指定する" #define CMT_C_COLOR "現在選択されているリンクの色" #define CMT_VISITED_ANCHOR "訪れたことがあるリンクは色を変える" @@ -200,6 +201,7 @@ static char *config_file = NULL; #define CMT_VISITED_ANCHOR "Use visited link color" #define CMT_V_COLOR "Color of visited link" #define CMT_BG_COLOR "Color of background" +#define CMT_MARK_COLOR "Color of mark" #define CMT_HTTP_PROXY "URL of HTTP proxy host" #ifdef USE_GOPHER #define CMT_GOPHER_PROXY "URL of GOPHER proxy host" @@ -435,6 +437,8 @@ struct param_ptr params2[] = { {"form_color", P_COLOR, PI_SEL_C, (void *)&form_color, CMT_F_COLOR, colorstr}, #ifdef USE_BG_COLOR + {"mark_color", P_COLOR, PI_SEL_C, (void *)&mark_color, CMT_MARK_COLOR, + colorstr}, {"bg_color", P_COLOR, PI_SEL_C, (void *)&bg_color, CMT_BG_COLOR, colorstr}, #endif /* USE_BG_COLOR */ {"active_style", P_INT, PI_ONOFF, (void *)&useActiveColor, @@ -1,7 +1,14 @@ -/* $Id: search.c,v 1.7 2002/01/11 03:00:16 ukai Exp $ */ +/* $Id: search.c,v 1.8 2002/01/16 15:37:07 ukai Exp $ */ #include "fm.h" #include "regex.h" +static void +set_mark(Line *l, int pos, int epos) +{ + for (; pos < epos && pos < l->len; pos++) + l->propBuf[pos] |= PE_MARK; +} + int forwardSearch(Buffer *buf, char *str) { @@ -27,6 +34,7 @@ forwardSearch(Buffer *buf, char *str) matchedPosition(&first, &last); buf->pos = first - l->lineBuf; arrangeCursor(buf); + set_mark(l, buf->pos, last - l->lineBuf); return SR_FOUND; } for (l = l->next;; l = l->next) { @@ -60,6 +68,7 @@ forwardSearch(Buffer *buf, char *str) buf->currentLine = l; gotoLine(buf, l->linenumber); arrangeCursor(buf); + set_mark(l, buf->pos, last - l->lineBuf); return SR_FOUND | (wrapped ? SR_WRAPPED : 0); } if (wrapped && l == begin) /* no match */ @@ -109,6 +118,7 @@ backwardSearch(Buffer *buf, char *str) if (found) { buf->pos = found - l->lineBuf; arrangeCursor(buf); + set_mark(l, buf->pos, last - l->lineBuf); return SR_FOUND; } } @@ -143,6 +153,7 @@ backwardSearch(Buffer *buf, char *str) buf->currentLine = l; gotoLine(buf, l->linenumber); arrangeCursor(buf); + set_mark(l, buf->pos, last - l->lineBuf); return SR_FOUND | (wrapped ? SR_WRAPPED : 0); } if (wrapped && l == begin) /* no match */ |