aboutsummaryrefslogtreecommitdiffstats
path: root/main.c
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 /main.c
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--main.c58
1 files changed, 48 insertions, 10 deletions
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