diff options
author | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-09-05 15:43:21 +0000 |
---|---|---|
committer | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-09-05 15:43:21 +0000 |
commit | 970ac43a935eda207af179e6d64c3d5f08197ffc (patch) | |
tree | 9547228a6dc3d6908c16261adfdcdb282729f0bb /anchor.c | |
parent | * [w3m-dev 03291] parsetagx.c:toNumber() (diff) | |
download | w3m-970ac43a935eda207af179e6d64c3d5f08197ffc.tar.gz w3m-970ac43a935eda207af179e6d64c3d5f08197ffc.zip |
[w3m-dev 03292] Re: load file at cursor
* anchor.c (reAnchorPos): added
(reAnchorWord): added
(reAnchorAny): rewrite to use reAnchorPos()
* funcname.tab (MARK_WORD): added
* keybind.c (;) MARK_WORD
* main.c (getCurWord): added
(chkWORD): added
(is_wordchar): added
(getCurWord): added
(GetWord): rewrite to use getCurWord()
* proto.h (chkWORD): added
(reAnchorWord): added
* doc/README.func: add MARK_WORD
* doc/keymap.default: add MARK_WORD
* doc-jp/README.func: add MARK_WORD
* doc-jp/keymap.default: add MARK_WORD
* NEWS: add MARK_WORD
From: Fumitoshi UKAI <ukai@debian.or.jp>
Diffstat (limited to '')
-rw-r--r-- | anchor.c | 50 |
1 files changed, 32 insertions, 18 deletions
@@ -1,4 +1,4 @@ -/* $Id: anchor.c,v 1.10 2002/03/29 16:39:37 ukai Exp $ */ +/* $Id: anchor.c,v 1.11 2002/09/05 15:43:21 ukai Exp $ */ #include "fm.h" #include "myctype.h" #include "regex.h" @@ -277,6 +277,36 @@ reseq_anchor(Buffer *buf) reseq_anchor0(buf->formitem, seqmap); } +static char * +reAnchorPos(Buffer *buf, Line *l, char *p1, char *p2, + Anchor *(*anchorproc) (Buffer *, char *, char *, int, int)) +{ + Anchor *a; + int spos, epos; + int i; + + spos = p1 - l->lineBuf; + epos = p2 - l->lineBuf; + for (i = spos; i < epos; i++) { + if (l->propBuf[i] & (PE_ANCHOR | PE_FORM)) + return p2; + } + a = anchorproc(buf, p1, p2, l->linenumber, p1 - l->lineBuf); + a->end.line = l->linenumber; + a->end.pos = epos; + a->hseq = -2; + for (i = a->start.pos; i < a->end.pos; i++) + l->propBuf[i] |= PE_ANCHOR; + return p2; +} + +void +reAnchorWord(Buffer *buf, Line *l, int spos, int epos) +{ + reAnchorPos(buf, l, &l->lineBuf[spos], &l->lineBuf[epos], _put_anchor_all); + reseq_anchor(buf); +} + /* search regexp and register them as anchors */ /* returns error message if any */ static char * @@ -285,9 +315,6 @@ reAnchorAny(Buffer *buf, char *re, { Line *l; char *p, *p1, *p2; - Anchor *a; - int i; - int spos, epos; if (re == NULL || *re == '\0') { return NULL; @@ -302,20 +329,7 @@ reAnchorAny(Buffer *buf, char *re, for (;;) { if (regexMatch(p, &l->lineBuf[l->len] - p, p == l->lineBuf) == 1) { matchedPosition(&p1, &p2); - spos = p1 - l->lineBuf; - epos = p2 - l->lineBuf; - for (i = spos; i < epos; i++) { - if (l->propBuf[i] & (PE_ANCHOR | PE_FORM)) - goto _next; - } - a = anchorproc(buf, p1, p2, l->linenumber, p1 - l->lineBuf); - a->end.line = l->linenumber; - a->end.pos = epos; - a->hseq = -2; - for (i = a->start.pos; i < a->end.pos; i++) - l->propBuf[i] |= PE_ANCHOR; - _next: - p = p2; + p = reAnchorPos(buf, l, p1, p2, anchorproc); } else break; |