aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFumitoshi UKAI <ukai@debian.or.jp>2002-09-05 15:43:21 +0000
committerFumitoshi UKAI <ukai@debian.or.jp>2002-09-05 15:43:21 +0000
commit970ac43a935eda207af179e6d64c3d5f08197ffc (patch)
tree9547228a6dc3d6908c16261adfdcdb282729f0bb
parent* [w3m-dev 03291] parsetagx.c:toNumber() (diff)
downloadw3m-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--ChangeLog23
-rw-r--r--NEWS1
-rw-r--r--anchor.c50
-rw-r--r--doc-jp/README.func1
-rw-r--r--doc-jp/keymap.default1
-rw-r--r--doc/README.func1
-rw-r--r--doc/keymap.default1
-rw-r--r--funcname.tab3
-rw-r--r--keybind.c4
-rw-r--r--main.c58
-rw-r--r--proto.h4
11 files changed, 114 insertions, 33 deletions
diff --git a/ChangeLog b/ChangeLog
index 4b072a1..1fbd966 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2002-09-06 Fumitoshi UKAI <ukai@debian.or.jp>
+
+ * [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
+
2002-08-28 Kiyokazu SUTO <suto@ks-and-ks.ne.jp>
* [w3m-dev 03291] parsetagx.c:toNumber()
@@ -3721,4 +3742,4 @@
* release-0-2-1
* import w3m-0.2.1
-$Id: ChangeLog,v 1.418 2002/08/27 16:39:40 ukai Exp $
+$Id: ChangeLog,v 1.419 2002/09/05 15:43:21 ukai Exp $
diff --git a/NEWS b/NEWS
index d7761d7..718bc7b 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,6 @@
w3m 0.4?
+* func: MARK_WORD
* rc: imgsize: obsoleted
* w3m-img for framebuffer merged
diff --git a/anchor.c b/anchor.c
index d62f2ef..74a5c21 100644
--- a/anchor.c
+++ b/anchor.c
@@ -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;
diff --git a/doc-jp/README.func b/doc-jp/README.func
index ae6de37..515409b 100644
--- a/doc-jp/README.func
+++ b/doc-jp/README.func
@@ -45,6 +45,7 @@ MAIN_MENU メニューを立ち上げます
MARK マークを設定/解除します
MARK_MID Message-ID風の文字列を,news:のリンクにします
MARK_URL URL風の文字列をリンクにします
+MARK_WORD カーソルのある語をリンクにします
MENU メニューを立ち上げます
MOUSE_TOGGLE マウスの有効/無効をトグルする
MOVE_DOWN カーソルを下に移動します(改ページ時には半ページスクロール)
diff --git a/doc-jp/keymap.default b/doc-jp/keymap.default
index 2e6c54a..7acbb47 100644
--- a/doc-jp/keymap.default
+++ b/doc-jp/keymap.default
@@ -40,6 +40,7 @@ keymap , LEFT
keymap . RIGHT
keymap / SEARCH
keymap : MARK_URL
+keymap ; MARK_WORD
keymap < SHIFT_LEFT
keymap = INFO
keymap > SHIFT_RIGHT
diff --git a/doc/README.func b/doc/README.func
index ac8949e..7647f9d 100644
--- a/doc/README.func
+++ b/doc/README.func
@@ -45,6 +45,7 @@ MAIN_MENU Popup menu
MARK Set/unset mark
MARK_MID Mark Message-ID-like strings as anchors
MARK_URL Mark URL-like strings as anchors
+MARK_WORD Mark current word as anchor
MENU Popup menu
MOUSE_TOGGLE Toggle activity of mouse
MOVE_DOWN Move cursor down (a half screen scroll at the end of screen)
diff --git a/doc/keymap.default b/doc/keymap.default
index 2e6c54a..17ce41a 100644
--- a/doc/keymap.default
+++ b/doc/keymap.default
@@ -40,6 +40,7 @@ keymap , LEFT
keymap . RIGHT
keymap / SEARCH
keymap : MARK_URL
+keymap ; MARK_WORD
keymap < SHIFT_LEFT
keymap = INFO
keymap > SHIFT_RIGHT
diff --git a/funcname.tab b/funcname.tab
index e0f21b8..1bc1b2c 100644
--- a/funcname.tab
+++ b/funcname.tab
@@ -1,4 +1,4 @@
-# $Id: funcname.tab,v 1.10 2002/06/01 17:09:05 ukai Exp $
+# $Id: funcname.tab,v 1.11 2002/09/05 15:43:21 ukai Exp $
# macro name function name
#----------------------------
@@@ nulcmd
@@ -50,6 +50,7 @@ MAIN_MENU mainMn
MARK _mark
MARK_MID chkNMID
MARK_URL chkURL
+MARK_WORD chkWORD
MENU mainMn
MOUSE mouse
MOUSE_TOGGLE msToggle
diff --git a/keybind.c b/keybind.c
index 4d8a5bf..651ae09 100644
--- a/keybind.c
+++ b/keybind.c
@@ -1,4 +1,4 @@
-/* $Id: keybind.c,v 1.6 2002/01/23 17:19:47 ukai Exp $ */
+/* $Id: keybind.c,v 1.7 2002/09/05 15:43:21 ukai Exp $ */
#include "funcname2.h"
char GlobalKeymap[128] = {
@@ -21,7 +21,7 @@ char GlobalKeymap[128] = {
/* 0 1 2 3 4 5 6 7 */
nulcmd, nulcmd, nulcmd, nulcmd, nulcmd, nulcmd, nulcmd, nulcmd,
/* 8 9 : ; < = > ? */
- nulcmd, nulcmd, chkURL, nulcmd, shiftl, pginfo, shiftr, srchbak,
+ nulcmd, nulcmd, chkURL, chkWORD, shiftl, pginfo, shiftr, srchbak,
/* @ A B C D E F G */
readsh, nulcmd, backBf, nulcmd, nulcmd, editBf, rFrame, goLineL,
/* H I J K L M N O */
diff --git a/main.c b/main.c
index 8e0dd8e..9476238 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.110 2002/07/17 16:07:37 ukai Exp $ */
+/* $Id: main.c,v 1.111 2002/09/05 15:43:21 ukai Exp $ */
#define MAINPROGRAM
#include "fm.h"
#include <signal.h>
@@ -75,6 +75,8 @@ static void keyPressEventProc(int c);
int show_params_p = 0;
void show_params(FILE * fp);
+static char *getCurWord(Buffer *buf, int *spos, int *epos, const char *badchars);
+
static int display_ok = FALSE;
static void dump_source(Buffer *);
static void dump_head(Buffer *);
@@ -4381,6 +4383,18 @@ chkURL(void)
displayBuffer(Currentbuf, B_FORCE_REDRAW);
}
+void
+chkWORD(void)
+{
+ char *p;
+ int spos, epos;
+ p = getCurWord(Currentbuf, &spos, &epos, ":\"\'`<>");
+ if (p == NULL)
+ return;
+ reAnchorWord(Currentbuf, Currentbuf->currentLine, spos, epos);
+ displayBuffer(Currentbuf, B_FORCE_REDRAW);
+}
+
#ifdef USE_NNTP
/* mark Message-ID-like patterns as NEWS anchors */
void
@@ -4802,28 +4816,52 @@ wrapToggle(void)
}
}
+static int
+is_wordchar(int c, const char *badchars)
+{
+ if (badchars)
+ return !(IS_SPACE(c) || strchr(badchars, c));
+ else
+ return IS_ALPHA(c);
+}
+
static char *
-GetWord(Buffer *buf)
+getCurWord(Buffer *buf, int *spos, int *epos, const char *badchars)
{
+ char *p;
Line *l = buf->currentLine;
- char *lb;
int b, e;
+ *spos = 0;
+ *epos = 0;
if (l == NULL)
return NULL;
- lb = l->lineBuf;
-
+ p = l->lineBuf;
e = buf->pos;
- while (e > 0 && !IS_ALPHA(lb[e]))
+ while (e > 0 && !is_wordchar(p[e], badchars))
e--;
- if (!IS_ALPHA(lb[e]))
+ if (!is_wordchar(p[e], badchars))
return NULL;
b = e;
- while (b > 0 && IS_ALPHA(lb[b - 1]))
+ while (b > 0 && is_wordchar(p[b-1], badchars))
b--;
- while (e < l->len && IS_ALPHA(lb[e]))
+ while (e < l->len && is_wordchar(p[e], badchars))
e++;
- return Strnew_charp_n(&lb[b], e - b)->ptr;
+ *spos = b;
+ *epos = e;
+ return &p[b];
+}
+
+static char *
+GetWord(Buffer *buf)
+{
+ int b, e;
+ char *p;
+
+ if ((p = getCurWord(buf, &b, &e, 0)) != NULL) {
+ return Strnew_charp_n(p, e - b)->ptr;
+ }
+ return NULL;
}
#ifdef USE_DICT
diff --git a/proto.h b/proto.h
index 5ff9aa5..6e78cbc 100644
--- a/proto.h
+++ b/proto.h
@@ -1,4 +1,4 @@
-/* $Id: proto.h,v 1.45 2002/08/20 17:49:39 ukai Exp $ */
+/* $Id: proto.h,v 1.46 2002/09/05 15:43:22 ukai Exp $ */
/*
* This file was automatically generated by version 1.7 of cextract.
* Manual editing not recommended.
@@ -92,6 +92,7 @@ extern void vwSrc(void);
extern void reload(void);
extern void chkURL(void);
extern void chkURLBuffer(Buffer *buf);
+extern void chkWORD(void);
#ifdef USE_NNTP
extern void chkNMID(void);
extern void chkNMIDBuffer(Buffer *buf);
@@ -486,6 +487,7 @@ extern Anchor *retrieveCurrentImg(Buffer *buf);
extern Anchor *retrieveCurrentForm(Buffer *buf);
extern Anchor *searchAnchor(AnchorList *al, char *str);
extern Anchor *searchURLLabel(Buffer *buf, char *url);
+extern void reAnchorWord(Buffer *buf, Line *l, int spos, int epos);
extern char *reAnchor(Buffer *buf, char *re);
#ifdef USE_NNTP
extern char *reAnchorNews(Buffer *buf, char *re);