[w3m-dev 03667] fold patch

* anchor.c (reAnchorPos): rewrite
	(reAnchorWord): delete reseq_anchor()
	(reAnchorAny): use l->size
			delete reseq_anchor()
* backend.c (internal_get): pass TRUE to saveBuffer
* buffer.c (newBuffer): delete n->linelen
	(reshapeBuffer): rewrite
* display.c (displayBuffer): FoldLine
	(redrawLine): l->bpos
	(cursorUp0): added
	(cursorUp): rewrite
	(cursorDown0): added
	(cursowDown): rewrite
	(cursorRight): check l->next
			l->bwidth
	(cursorLeft): l->prev && l->bpos
			l->bwidth
	(arrangeCursor): buf->currentLine->bwidth
		buf->cursorX
* etc.c (checkType): **oporp
			rewrite
	(calcPosition): realColumn allocated by New_reuse
* file.c (addnewline): add nlines arg
	(propBuffer): deleted
	(colorBuffer): deleted
	(readHeader): propBuffer
		FOLD_BUFFER_WIDTH
	(HTMLlineproc2body): rewrite
	(addnewline2): added
	(addnewline): rewrite
	(loadBuffer): propBuffer, colorBuffer
	(saveBuffer): cont arg
	(getNextPage): rewrite
* fm.h (LINELEN): 256
	(FNLEN): deleted
	(Line): add size, bpos, bwidth
	(Buffer): delete linelen
	(INIT_BUFFER_WIDTH): check showLineNum
	(FOLD_BUFFER_WIDTH): added
	(FoldLine): added
* funcname.tab (RESHAPE): added
* main.c (do_dump): pass FALSE to saveBuffer
	(nscroll): rewrite
	(clear_mark): l->size
	(shiftvisualpos): rewrite
	(pipeBuf): pass TRUE to saveBuffer
	(linebeg): check line->prev && line->bpos
	(linend): check line->next, line->next->bpos
	(editScr): pass TRUE to saveBuffer
	(svBuf): pass TRUE to saveBuffer
	(vmSrc): pass TRUE to saveBuffer
	(reshape): added
	(curlno): rewrite
* mimehead.c (LINELEN): deleted
* proto.h (reshape): added
	(saveBuffer): add cont arg
	(cursorUp0): added
	(cursorDown0): added
	(checkType): change type oprop, ocolor, delete check_color, len
* rc.c (CMT_FOLD_LINE): added
	(params1): add fold_line
	(sync_with_option): check PagerMax
* search.c (set_mark): l->size
	(forwardSearch): rewrite
	(backwardSearch): rewrite
* doc/README.func (RESHAPE): added
* doc-jp/README.func (RESHAPE): added
* scripts/w3mhelp.cgi.in (Buffer operation): add reshape
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
This commit is contained in:
Fumitoshi UKAI
2003-01-23 18:37:18 +00:00
parent e718702d12
commit 61c2c2de18
17 changed files with 541 additions and 233 deletions
+73 -1
View File
@@ -1,3 +1,75 @@
2003-01-24 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
* [w3m-dev 03667] fold patch
* anchor.c (reAnchorPos): rewrite
(reAnchorWord): delete reseq_anchor()
(reAnchorAny): use l->size
delete reseq_anchor()
* backend.c (internal_get): pass TRUE to saveBuffer
* buffer.c (newBuffer): delete n->linelen
(reshapeBuffer): rewrite
* display.c (displayBuffer): FoldLine
(redrawLine): l->bpos
(cursorUp0): added
(cursorUp): rewrite
(cursorDown0): added
(cursowDown): rewrite
(cursorRight): check l->next
l->bwidth
(cursorLeft): l->prev && l->bpos
l->bwidth
(arrangeCursor): buf->currentLine->bwidth
buf->cursorX
* etc.c (checkType): **oporp
rewrite
(calcPosition): realColumn allocated by New_reuse
* file.c (addnewline): add nlines arg
(propBuffer): deleted
(colorBuffer): deleted
(readHeader): propBuffer
FOLD_BUFFER_WIDTH
(HTMLlineproc2body): rewrite
(addnewline2): added
(addnewline): rewrite
(loadBuffer): propBuffer, colorBuffer
(saveBuffer): cont arg
(getNextPage): rewrite
* fm.h (LINELEN): 256
(FNLEN): deleted
(Line): add size, bpos, bwidth
(Buffer): delete linelen
(INIT_BUFFER_WIDTH): check showLineNum
(FOLD_BUFFER_WIDTH): added
(FoldLine): added
* funcname.tab (RESHAPE): added
* main.c (do_dump): pass FALSE to saveBuffer
(nscroll): rewrite
(clear_mark): l->size
(shiftvisualpos): rewrite
(pipeBuf): pass TRUE to saveBuffer
(linebeg): check line->prev && line->bpos
(linend): check line->next, line->next->bpos
(editScr): pass TRUE to saveBuffer
(svBuf): pass TRUE to saveBuffer
(vmSrc): pass TRUE to saveBuffer
(reshape): added
(curlno): rewrite
* mimehead.c (LINELEN): deleted
* proto.h (reshape): added
(saveBuffer): add cont arg
(cursorUp0): added
(cursorDown0): added
(checkType): change type oprop, ocolor, delete check_color, len
* rc.c (CMT_FOLD_LINE): added
(params1): add fold_line
(sync_with_option): check PagerMax
* search.c (set_mark): l->size
(forwardSearch): rewrite
(backwardSearch): rewrite
* doc/README.func (RESHAPE): added
* doc-jp/README.func (RESHAPE): added
* scripts/w3mhelp.cgi.in (Buffer operation): add reshape
2003-01-24 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
* etc.c (next_status): after = is R_ST_VALUE
@@ -6743,4 +6815,4 @@ a * [w3m-dev 03276] compile error on EWS4800
* release-0-2-1
* import w3m-0.2.1
$Id: ChangeLog,v 1.708 2003/01/23 18:01:01 ukai Exp $
$Id: ChangeLog,v 1.709 2003/01/23 18:37:18 ukai Exp $
+23 -10
View File
@@ -1,4 +1,4 @@
/* $Id: anchor.c,v 1.20 2003/01/15 16:11:43 ukai Exp $ */
/* $Id: anchor.c,v 1.21 2003/01/23 18:37:20 ukai Exp $ */
#include "fm.h"
#include "myctype.h"
#include "regex.h"
@@ -294,7 +294,7 @@ reAnchorPos(Buffer *buf, Line *l, char *p1, char *p2,
{
Anchor *a;
int spos, epos;
int i;
int i, hseq = -2;
spos = p1 - l->lineBuf;
epos = p2 - l->lineBuf;
@@ -302,12 +302,27 @@ reAnchorPos(Buffer *buf, Line *l, char *p1, char *p2,
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++)
for (i = spos; i < epos; i++)
l->propBuf[i] |= PE_ANCHOR;
while (1) {
a = anchorproc(buf, p1, p2, l->linenumber, spos);
a->hseq = hseq;
if (hseq == -2) {
reseq_anchor(buf);
hseq = a->hseq;
}
a->end.line = l->linenumber;
if (epos > l->len) {
a->end.pos = l->len;
spos = 0;
epos -= l->len;
l = l->next;
}
else {
a->end.pos = epos;
break;
}
}
return p2;
}
@@ -315,7 +330,6 @@ 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 */
@@ -338,7 +352,7 @@ reAnchorAny(Buffer *buf, char *re,
l = l->next) {
p = l->lineBuf;
for (;;) {
if (regexMatch(p, &l->lineBuf[l->len] - p, p == l->lineBuf) == 1) {
if (regexMatch(p, &l->lineBuf[l->size] - p, p == l->lineBuf) == 1) {
matchedPosition(&p1, &p2);
p = reAnchorPos(buf, l, p1, p2, anchorproc);
}
@@ -346,7 +360,6 @@ reAnchorAny(Buffer *buf, char *re,
break;
}
}
reseq_anchor(buf);
return NULL;
}
+2 -2
View File
@@ -1,4 +1,4 @@
/* $Id: backend.c,v 1.10 2002/12/24 17:20:46 ukai Exp $ */
/* $Id: backend.c,v 1.11 2003/01/23 18:37:20 ukai Exp $ */
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
@@ -148,7 +148,7 @@ internal_get(char *url, int flag, FormList *request)
}
print_headers(buf, len);
printf("\n");
saveBuffer(buf, stdout);
saveBuffer(buf, stdout, TRUE);
}
else {
print_headers(buf, 0);
+14 -4
View File
@@ -1,4 +1,4 @@
/* $Id: buffer.c,v 1.19 2003/01/22 16:16:19 ukai Exp $ */
/* $Id: buffer.c,v 1.20 2003/01/23 18:37:20 ukai Exp $ */
#include "fm.h"
#ifdef USE_MOUSE
@@ -40,7 +40,6 @@ newBuffer(int width)
n->bufferprop = BP_NORMAL;
n->clone = New(int);
*n->clone = 1;
n->linelen = 0;
n->trbyte = 0;
#ifdef USE_SSL
n->ssl_certificate = NULL;
@@ -558,8 +557,19 @@ reshapeBuffer(Buffer *buf)
#endif
buf->height = LASTLINE + 1;
if (buf->firstLine)
restorePosition(buf, &sbuf);
if (buf->firstLine && sbuf.firstLine) {
int n;
gotoRealLine(buf, sbuf.currentLine->real_linenumber);
n = (buf->currentLine->linenumber - buf->topLine->linenumber)
- (sbuf.currentLine->linenumber - sbuf.topLine->linenumber);
if (n) {
buf->topLine = lineSkip(buf, buf->topLine, n, FALSE);
gotoRealLine(buf, sbuf.currentLine->real_linenumber);
}
buf->pos = sbuf.pos;
buf->currentColumn = sbuf.currentColumn;
arrangeCursor(buf);
}
if (buf->check_url & CHK_URL)
chkURLBuffer(buf);
#ifdef USE_NNTP
+70 -20
View File
@@ -1,4 +1,4 @@
/* $Id: display.c,v 1.52 2003/01/20 15:32:02 ukai Exp $ */
/* $Id: display.c,v 1.53 2003/01/23 18:37:20 ukai Exp $ */
#include <signal.h>
#include "fm.h"
@@ -363,8 +363,8 @@ displayBuffer(Buffer *buf, int mode)
buf->width = COLS;
if (buf->height == 0)
buf->height = LASTLINE + 1;
if ((buf->width != INIT_BUFFER_WIDTH && buf->type &&
!strcmp(buf->type, "text/html")) || buf->need_reshape) {
if ((buf->width != INIT_BUFFER_WIDTH && (buf->type &&
!strcmp(buf->type, "text/html") || FoldLine)) || buf->need_reshape) {
buf->need_reshape = TRUE;
reshapeBuffer(buf);
}
@@ -679,7 +679,7 @@ redrawLine(Buffer *buf, Line *l, int i)
buf->rootX = COLS;
buf->COLS = COLS - buf->rootX;
}
if (l->real_linenumber)
if (l->real_linenumber && !l->bpos)
sprintf(tmp, "%*ld:", buf->rootX - 1, l->real_linenumber);
else
sprintf(tmp, "%*s ", buf->rootX - 1, "");
@@ -1233,10 +1233,8 @@ set_delayed_message(char *s)
}
void
cursorUp(Buffer *buf, int n)
cursorUp0(Buffer *buf, int n)
{
if (buf->firstLine == NULL)
return;
if (buf->cursorY > 0)
cursorUpDown(buf, -1);
else {
@@ -1248,10 +1246,28 @@ cursorUp(Buffer *buf, int n)
}
void
cursorDown(Buffer *buf, int n)
cursorUp(Buffer *buf, int n)
{
Line *l = buf->currentLine;
if (buf->firstLine == NULL)
return;
while (buf->currentLine->prev && buf->currentLine->bpos)
cursorUp0(buf, n);
if (buf->currentLine == buf->firstLine) {
gotoLine(buf, l->linenumber);
arrangeLine(buf);
return;
}
cursorUp0(buf, n);
while (buf->currentLine->prev && buf->currentLine->bpos &&
buf->currentLine->bwidth >=
buf->currentColumn + buf->visualpos)
cursorUp0(buf, n);
}
void
cursorDown0(Buffer *buf, int n)
{
if (buf->cursorY < buf->LINES - 1)
cursorUpDown(buf, 1);
else {
@@ -1262,6 +1278,26 @@ cursorDown(Buffer *buf, int n)
}
}
void
cursorDown(Buffer *buf, int n)
{
Line *l = buf->currentLine;
if (buf->firstLine == NULL)
return;
while (buf->currentLine->next && buf->currentLine->next->bpos)
cursorDown0(buf, n);
if (buf->currentLine == buf->lastLine) {
gotoLine(buf, l->linenumber);
arrangeLine(buf);
return;
}
cursorDown0(buf, n);
while (buf->currentLine->next && buf->currentLine->next->bpos &&
buf->currentLine->bwidth + buf->currentLine->width <
buf->currentColumn + buf->visualpos)
cursorDown0(buf, n);
}
void
cursorUpDown(Buffer *buf, int n)
{
@@ -1283,7 +1319,7 @@ cursorRight(Buffer *buf, int n)
if (buf->firstLine == NULL)
return;
if (buf->pos == l->len)
if (buf->pos == l->len && !(l->next && l->next->bpos))
return;
i = buf->pos;
p = l->propBuf;
@@ -1297,6 +1333,12 @@ cursorRight(Buffer *buf, int n)
else if (l->len == 0) {
buf->pos = 0;
}
else if (l->next && l->next->bpos) {
cursorDown0(buf, 1);
buf->pos = 0;
arrangeCursor(buf);
return;
}
else {
buf->pos = l->len - 1;
#ifdef JP_CHARSET
@@ -1305,7 +1347,7 @@ cursorRight(Buffer *buf, int n)
#endif /* JP_CHARSET */
}
cpos = COLPOS(l, buf->pos);
buf->visualpos = cpos - buf->currentColumn;
buf->visualpos = l->bwidth + cpos - buf->currentColumn;
delta = 1;
#ifdef JP_CHARSET
if (CharType(p[buf->pos]) == PC_KANJI1)
@@ -1314,9 +1356,9 @@ cursorRight(Buffer *buf, int n)
vpos2 = COLPOS(l, buf->pos + delta) - buf->currentColumn - 1;
if (vpos2 >= buf->COLS && n) {
columnSkip(buf, n + (vpos2 - buf->COLS) - (vpos2 - buf->COLS) % n);
buf->visualpos = cpos - buf->currentColumn;
buf->visualpos = l->bwidth + cpos - buf->currentColumn;
}
buf->cursorX = buf->visualpos;
buf->cursorX = buf->visualpos - l->bwidth;
}
void
@@ -1334,17 +1376,23 @@ cursorLeft(Buffer *buf, int n)
if (i >= 2 && CharType(p[i - 1]) == PC_KANJI2)
delta = 2;
#endif /* JP_CHARSET */
if (i > delta)
if (i >= delta)
buf->pos = i - delta;
else if (l->prev && l->bpos) {
cursorUp0(buf, -1);
buf->pos = buf->currentLine->len - 1;
arrangeCursor(buf);
return;
}
else
buf->pos = 0;
cpos = COLPOS(l, buf->pos);
buf->visualpos = cpos - buf->currentColumn;
if (buf->visualpos < 0 && n) {
columnSkip(buf, -n + buf->visualpos - buf->visualpos % n);
buf->visualpos = cpos - buf->currentColumn;
buf->visualpos = l->bwidth + cpos - buf->currentColumn;
if (buf->visualpos - l->bwidth < 0 && n) {
columnSkip(buf, -n + buf->visualpos - l->bwidth - (buf->visualpos - l->bwidth) % n);
buf->visualpos = l->bwidth + cpos - buf->currentColumn;
}
buf->cursorX = buf->visualpos;
buf->cursorX = buf->visualpos - l->bwidth;
}
void
@@ -1396,8 +1444,9 @@ arrangeCursor(Buffer *buf)
}
/* Arrange cursor */
buf->cursorY = buf->currentLine->linenumber - buf->topLine->linenumber;
buf->visualpos = buf->cursorX =
buf->visualpos = buf->currentLine->bwidth +
COLPOS(buf->currentLine, buf->pos) - buf->currentColumn;
buf->cursorX = buf->visualpos - buf->currentLine->bwidth;
#ifdef DISPLAY_DEBUG
fprintf(stderr,
"arrangeCursor: column=%d, cursorX=%d, visualpos=%d, pos=%d, len=%d\n",
@@ -1414,7 +1463,8 @@ arrangeLine(Buffer *buf)
if (buf->firstLine == NULL)
return;
buf->cursorY = buf->currentLine->linenumber - buf->topLine->linenumber;
i = columnPos(buf->currentLine, buf->currentColumn + buf->visualpos);
i = columnPos(buf->currentLine, buf->currentColumn + buf->visualpos
- buf->currentLine->bwidth);
cpos = COLPOS(buf->currentLine, i) - buf->currentColumn;
if (cpos >= 0) {
buf->cursorX = cpos;
+1
View File
@@ -102,6 +102,7 @@ REDRAW
REG_MARK 正規表現で指定された文字列を全てマークします
REINIT 設定ファイルを再読込します。
RELOAD バッファを再度読み込みます
RESHAPE 再レンダリングする
RIGHT 画面全体を1文字右にずらします
SAVE 文書のソースをファイルに保存します
SAVE_IMAGE リンクが指す画像をファイルに保存します
+1
View File
@@ -102,6 +102,7 @@ REDRAW Redraw screen
REG_MARK Set mark using regexp
REINIT Reload configuration files
RELOAD Reload buffer
RESHAPE Re-render buffer
RIGHT Shift screen one column right
SAVE Save document source to file
SAVE_IMAGE Save image to file
+39 -17
View File
@@ -1,4 +1,4 @@
/* $Id: etc.c,v 1.57 2003/01/23 18:01:05 ukai Exp $ */
/* $Id: etc.c,v 1.58 2003/01/23 18:37:20 ukai Exp $ */
#include "fm.h"
#include <pwd.h>
#include "myctype.h"
@@ -236,50 +236,62 @@ parse_ansi_color(char **str, Lineprop *effect, Linecolor *color)
*/
Str
checkType(Str s, Lineprop *oprop,
checkType(Str s, Lineprop **oprop
#ifdef USE_ANSI_COLOR
Linecolor *ocolor, int *check_color,
, Linecolor **ocolor
#endif
int len)
)
{
Lineprop mode;
Lineprop effect = PE_NORMAL;
Lineprop *prop = oprop;
Lineprop *prop;
static Lineprop *prop_buffer = NULL;
static int prop_size = 0;
char *str = s->ptr, *endp = &s->ptr[s->length], *bs = NULL;
#ifdef USE_ANSI_COLOR
Lineprop ceffect = PE_NORMAL;
Linecolor cmode = 0;
int check_color = FALSE;
Linecolor *color = NULL;
static Linecolor *color_buffer = NULL;
static int color_size = 0;
char *es = NULL;
#endif
int do_copy = FALSE;
int size = (len < s->length) ? len : s->length;
#ifdef USE_ANSI_COLOR
if (check_color)
*check_color = FALSE;
#endif
if (prop_size < s->length) {
prop_size = (s->length > LINELEN) ? s->length : LINELEN;
prop_buffer = New_Reuse(Lineprop, prop_buffer, prop_size);
}
prop = prop_buffer;
if (ShowEffect) {
bs = memchr(str, '\b', s->length);
#ifdef USE_ANSI_COLOR
if (ocolor) {
es = memchr(str, ESC_CODE, s->length);
if (es)
color = ocolor;
if (es) {
if (color_size < s->length) {
color_size = (s->length > LINELEN) ? s->length : LINELEN;
color_buffer = New_Reuse(Linecolor, color_buffer,
color_size);
}
color = color_buffer;
}
}
#endif
if (s->length > size || (bs != NULL)
if ((bs != NULL)
#ifdef USE_ANSI_COLOR
|| (es != NULL)
#endif
) {
s = Strnew_size(size);
s = Strnew_size(s->length);
do_copy = TRUE;
}
}
while (str < endp) {
if (prop - oprop >= len)
if (prop - prop_buffer >= prop_size)
break;
if (bs != NULL) {
if (str == bs - 2 && !strncmp(str, "__\b\b", 4)) {
@@ -410,7 +422,7 @@ checkType(Str s, Lineprop *oprop,
es = memchr(str, ESC_CODE, endp - str);
if (ok) {
if (cmode)
*check_color = TRUE;
check_color = TRUE;
continue;
}
}
@@ -458,13 +470,19 @@ checkType(Str s, Lineprop *oprop,
}
effect = PE_NORMAL;
}
*oprop = prop_buffer;
#ifdef USE_ANSI_COLOR
if (ocolor)
*ocolor = check_color ? color_buffer : NULL;
#endif
return s;
}
int
calcPosition(char *l, Lineprop *pr, int len, int pos, int bpos, int mode)
{
static short realColumn[LINELEN + 1];
static short *realColumn = NULL;
static int size = 0;
static char *prevl = NULL;
int i, j;
@@ -474,6 +492,10 @@ calcPosition(char *l, Lineprop *pr, int len, int pos, int bpos, int mode)
if (pos <= len)
return realColumn[pos];
}
if (size < len + 1) {
size = (len + 1 > LINELEN) ? (len + 1) : LINELEN;
realColumn = New_Reuse(short, realColumn, size);
}
prevl = l;
j = bpos;
for (i = 0;; i++) {
+164 -110
View File
@@ -1,4 +1,4 @@
/* $Id: file.c,v 1.202 2003/01/23 16:05:56 ukai Exp $ */
/* $Id: file.c,v 1.203 2003/01/23 18:37:20 ukai Exp $ */
#include "fm.h"
#include <sys/types.h>
#include "myctype.h"
@@ -39,14 +39,9 @@ static void addnewline(Buffer *buf, char *line, Lineprop *prop,
#ifdef USE_ANSI_COLOR
Linecolor *color,
#endif
int pos, int nlines);
int pos, int width, int nlines);
static void addLink(Buffer *buf, struct parsed_tag *tag);
static Lineprop propBuffer[LINELEN];
#ifdef USE_ANSI_COLOR
static Linecolor colorBuffer[LINELEN];
#endif
static JMP_BUF AbortLoading;
static struct table *tables[MAX_TABLE];
@@ -594,6 +589,7 @@ readHeader(URLFile *uf, Buffer *newBuf, int thru, ParsedURL *pu)
char code;
char *tmpf;
FILE *src = NULL;
Lineprop *propBuffer;
headerlist = newBuf->document_header = newTextList();
if (uf->scheme == SCM_HTTP
@@ -658,18 +654,18 @@ readHeader(URLFile *uf, Buffer *newBuf, int thru, ParsedURL *pu)
tmp = Strnew_size(lineBuf2->length);
for (p = lineBuf2->ptr; *p; p = q) {
for (q = p; *q && *q != '\r' && *q != '\n'; q++) ;
lineBuf2 = checkType(Strnew_charp_n(p, q - p), propBuffer,
lineBuf2 = checkType(Strnew_charp_n(p, q - p), &propBuffer
#ifdef USE_ANSI_COLOR
NULL, NULL,
, NULL
#endif
min(LINELEN, q - p));
);
Strcat(tmp, lineBuf2);
if (thru)
addnewline(newBuf, lineBuf2->ptr, propBuffer,
#ifdef USE_ANSI_COLOR
NULL,
#endif
lineBuf2->length, -1);
lineBuf2->length, FOLD_BUFFER_WIDTH, -1);
for (; *q && (*q == '\r' || *q == '\n'); q++) ;
}
#ifdef USE_IMAGE
@@ -908,7 +904,7 @@ readHeader(URLFile *uf, Buffer *newBuf, int thru, ParsedURL *pu)
#ifdef USE_ANSI_COLOR
NULL,
#endif
0, -1);
0, -1, -1);
if (src)
fclose(src);
}
@@ -4981,10 +4977,12 @@ textlist_feed()
static void
HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)
{
static char *outc = NULL;
static Lineprop *outp = NULL;
static int out_size = 0;
Anchor *a_href = NULL, *a_img = NULL, *a_form = NULL;
char outc[LINELEN];
char *p, *q, *r, *s, *t, *str;
Lineprop outp[LINELEN], mode, effect;
Lineprop mode, effect;
int pos;
int nlines;
FILE *debug = NULL;
@@ -5004,6 +5002,12 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)
Anchor **a_select = NULL;
#endif
if (out_size == 0) {
out_size = LINELEN;
outc = New_N(char, out_size);
outp = New_N(Lineprop, out_size);
}
n_textarea = -1;
if (!max_textarea) { /* halfload */
max_textarea = MAX_TEXTAREA;
@@ -5042,7 +5046,12 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)
#endif
str = line->ptr;
endp = str + line->length;
while (str < endp && pos < LINELEN) {
while (str < endp) {
if (out_size <= pos) {
out_size = pos * 3 / 2;
outc = New_N(char, out_size);
outp = New_N(Lineprop, out_size);
}
mode = get_mctype(str);
#ifndef KANJI_SYMBOLS
if (effect & PC_RULE && *str != '<') {
@@ -5539,7 +5548,7 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)
#ifdef USE_ANSI_COLOR
NULL,
#endif
pos, nlines);
pos, -1, nlines);
if (internal == HTML_N_INTERNAL)
internal = 0;
if (str != endp) {
@@ -6048,7 +6057,7 @@ extern char *NullLine;
extern Lineprop NullProp[];
static void
addnewline(Buffer *buf, char *line, Lineprop *prop,
addnewline2(Buffer *buf, char *line, Lineprop *prop,
#ifdef USE_ANSI_COLOR
Linecolor *color,
#endif
@@ -6057,26 +6066,16 @@ addnewline(Buffer *buf, char *line, Lineprop *prop,
Line *l;
l = New(Line);
l->next = NULL;
if (pos > 0) {
l->lineBuf = allocStr(line, pos);
l->propBuf = NewAtom_N(Lineprop, pos);
bcopy((void *)prop, (void *)l->propBuf, pos * sizeof(Lineprop));
}
else {
l->lineBuf = NullLine;
l->propBuf = NullProp;
}
l->lineBuf = line;
l->propBuf = prop;
#ifdef USE_ANSI_COLOR
if (pos > 0 && color) {
l->colorBuf = NewAtom_N(Linecolor, pos);
bcopy((void *)color, (void *)l->colorBuf, pos * sizeof(Linecolor));
}
else {
l->colorBuf = NULL;
}
l->colorBuf = color;
#endif
l->len = pos;
l->width = -1;
l->size = pos;
l->bpos = 0;
l->bwidth = 0;
l->prev = buf->currentLine;
if (buf->currentLine) {
l->next = buf->currentLine->next;
@@ -6100,6 +6099,86 @@ addnewline(Buffer *buf, char *line, Lineprop *prop,
l = NULL;
}
static void
addnewline(Buffer *buf, char *line, Lineprop *prop,
#ifdef USE_ANSI_COLOR
Linecolor *color,
#endif
int pos, int width, int nlines)
{
char *s;
Lineprop *p;
#ifdef USE_ANSI_COLOR
Linecolor *c;
#endif
Line *l;
int i, bpos, bwidth;
if (pos > 0) {
s = allocStr(line, pos);
p = NewAtom_N(Lineprop, pos);
bcopy((void *)prop, (void *)p, pos * sizeof(Lineprop));
}
else {
s = NullLine;
p = NullProp;
}
#ifdef USE_ANSI_COLOR
if (pos > 0 && color) {
c = NewAtom_N(Linecolor, pos);
bcopy((void *)color, (void *)c, pos * sizeof(Linecolor));
}
else {
c = NULL;
}
#endif
addnewline2(buf, s, p,
#ifdef USE_ANSI_COLOR
c,
#endif
pos, nlines);
if (pos <= 0 || width <= 0)
return;
bpos = 0;
bwidth = 0;
while (1) {
l = buf->currentLine;
l->width = COLPOS(l, l->len);
l->bpos = bpos;
l->bwidth = bwidth;
if (l->width <= width)
return;
i = columnPos(l, width);
#ifdef JP_CHARSET
if (CharType(p[i]) == PC_KANJI2)
i--;
#endif
if (i > 0 && COLPOS(l, i) > width) {
i--;
#ifdef JP_CHARSET
if (CharType(p[i]) == PC_KANJI2)
i--;
#endif
}
l->len = i;
l->width = COLPOS(l, l->len);
bpos += l->len;
bwidth += l->width;
s += i;
p += i;
#ifdef USE_ANSI_COLOR
if (c)
c += i;
#endif
pos -= i;
addnewline2(buf, s, p,
#ifdef USE_ANSI_COLOR
c,
#endif
pos, nlines);
}
}
/*
* loadHTMLBuffer: read file and make new buffer
*/
@@ -6734,8 +6813,9 @@ loadBuffer(URLFile *uf, Buffer *volatile newBuf)
int nlines;
Str tmpf;
clen_t linelen = 0, trbyte = 0;
Lineprop *propBuffer = NULL;
#ifdef USE_ANSI_COLOR
int check_color;
Linecolor *colorBuffer = NULL;
#endif
MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL;
@@ -6801,16 +6881,16 @@ loadBuffer(URLFile *uf, Buffer *volatile newBuf)
}
++nlines;
Strchop(lineBuf2);
lineBuf2 = checkType(lineBuf2, propBuffer,
lineBuf2 = checkType(lineBuf2, &propBuffer
#ifdef USE_ANSI_COLOR
colorBuffer, &check_color,
, &colorBuffer
#endif
LINELEN);
);
addnewline(newBuf, lineBuf2->ptr, propBuffer,
#ifdef USE_ANSI_COLOR
check_color ? colorBuffer : NULL,
colorBuffer,
#endif
lineBuf2->length, nlines);
lineBuf2->length, FOLD_BUFFER_WIDTH, nlines);
}
_end:
if (fmInitialized)
@@ -6927,7 +7007,7 @@ conv_rule(Line *l)
* saveBuffer: write buffer to file
*/
void
saveBuffer(Buffer *buf, FILE * f)
saveBuffer(Buffer *buf, FILE * f, int cont)
{
Line *l = buf->firstLine;
Str tmp;
@@ -6949,7 +7029,7 @@ saveBuffer(Buffer *buf, FILE * f)
tmp = Strnew_charp_n(l->lineBuf, l->len);
tmp = conv_str(tmp, InnerCode, DisplayCode);
Strfputs(tmp, f);
if (Strlastchar(tmp) != '\n')
if (Strlastchar(tmp) != '\n' && !(cont && l->next && l->next->bpos))
putc('\n', f);
}
if (buf->pagerSource && !(buf->bufferprop & BP_CLOSE)) {
@@ -7112,17 +7192,17 @@ openGeneralPagerBuffer(InputStream stream)
Line *
getNextPage(Buffer *buf, int plen)
{
Line *l, *fl, *pl = buf->lastLine;
Line *rl = NULL;
int len, i, nlines = 0;
clen_t linelen = buf->linelen, trbyte = buf->trbyte;
Line *top = buf->topLine, *last = buf->lastLine, *cur = buf->currentLine;
int i, nlines = 0;
clen_t linelen = 0, trbyte = buf->trbyte;
Str lineBuf2;
char pre_lbuf = '\0';
URLFile uf;
char code;
int squeeze_flag = 0;
int squeeze_flag = FALSE;
Lineprop *propBuffer = NULL;
#ifdef USE_ANSI_COLOR
int check_color;
Linecolor *colorBuffer = NULL;
#endif
if (buf->pagerSource == NULL)
@@ -7130,11 +7210,12 @@ getNextPage(Buffer *buf, int plen)
if (fmInitialized)
crmode();
if (pl != NULL) {
nlines = pl->real_linenumber;
pre_lbuf = *(pl->lineBuf);
if (last != NULL) {
nlines = last->real_linenumber;
pre_lbuf = *(last->lineBuf);
if (pre_lbuf == '\0')
pre_lbuf = '\n';
buf->currentLine = last;
}
#ifdef JP_CHARSET
@@ -7156,93 +7237,66 @@ getNextPage(Buffer *buf, int plen)
else if (getenv("MAN_PN") == NULL)
buf->buffername = CPIPEBUFFERNAME;
buf->bufferprop |= BP_CLOSE;
trbyte += linelen;
linelen = 0;
break;
}
linelen += lineBuf2->length;
showProgress(&linelen, &trbyte);
lineBuf2 = convertLine(&uf, lineBuf2, &code, PAGER_MODE);
if (squeezeBlankLine) {
squeeze_flag = 0;
squeeze_flag = FALSE;
if (lineBuf2->ptr[0] == '\n' && pre_lbuf == '\n') {
++nlines;
--i;
squeeze_flag = 1;
squeeze_flag = TRUE;
continue;
}
pre_lbuf = lineBuf2->ptr[0];
}
++nlines;
Strchop(lineBuf2);
lineBuf2 = checkType(lineBuf2, propBuffer,
lineBuf2 = checkType(lineBuf2, &propBuffer
#ifdef USE_ANSI_COLOR
colorBuffer, &check_color,
, &colorBuffer
#endif
LINELEN);
len = lineBuf2->length;
l = New(Line);
l->lineBuf = lineBuf2->ptr;
l->propBuf = NewAtom_N(Lineprop, len);
bcopy((void *)propBuffer, (void *)l->propBuf, len * sizeof(Lineprop));
);
addnewline(buf, lineBuf2->ptr, propBuffer,
#ifdef USE_ANSI_COLOR
if (check_color) {
l->colorBuf = NewAtom_N(Linecolor, len);
bcopy((void *)colorBuffer, (void *)l->colorBuf,
len * sizeof(Linecolor));
}
else {
l->colorBuf = NULL;
}
colorBuffer,
#endif
l->len = len;
l->width = -1;
l->prev = pl;
#if 0
if (squeezeBlankLine) {
#endif
l->real_linenumber = nlines;
l->linenumber = (pl == NULL ? nlines : pl->linenumber + 1);
#if 0
lineBuf2->length, FOLD_BUFFER_WIDTH, nlines);
if (!top) {
top = buf->firstLine;
cur = buf->currentLine;
}
else {
l->real_linenumber = l->linenumber = nlines;
if (buf->lastLine->real_linenumber - buf->firstLine->real_linenumber
>= PagerMax) {
Line *l = buf->firstLine;
do {
if (top == l)
top = l->next;
if (cur == l)
cur = l->next;
if (last == l)
last = NULL;
l = l->next;
} while (l && l->bpos);
buf->firstLine = l;
buf->firstLine->prev = NULL;
}
#endif
if (pl == NULL) {
pl = l;
buf->firstLine = buf->topLine = buf->currentLine = l;
}
else {
pl->next = l;
pl = l;
}
if (rl == NULL)
rl = l;
if (nlines > PagerMax) {
fl = buf->firstLine;
buf->firstLine = fl->next;
fl->next->prev = NULL;
if (buf->topLine == fl)
buf->topLine = fl->next;
if (buf->currentLine == fl)
buf->currentLine = fl->next;
}
}
if (pl != NULL)
pl->next = NULL;
buf->lastLine = pl;
if (rl == NULL && squeeze_flag) {
rl = pl;
}
if (fmInitialized)
term_raw();
buf->linelen = linelen;
buf->trbyte = trbyte;
buf->trbyte = trbyte + linelen;
#ifdef JP_CHARSET
buf->document_code = code;
#endif
return rl;
buf->topLine = top;
buf->currentLine = cur;
if (!last)
last = buf->firstLine;
else if (last && (last->next || !squeeze_flag))
last = last->next;
return last;
}
int
+8 -5
View File
@@ -1,4 +1,4 @@
/* $Id: fm.h,v 1.106 2003/01/23 18:01:06 ukai Exp $ */
/* $Id: fm.h,v 1.107 2003/01/23 18:37:20 ukai Exp $ */
/*
* w3m: WWW wo Miru utility
*
@@ -71,9 +71,8 @@ void bzero(void *, int);
/*
* Constants.
*/
#define LINELEN 4096 /* Maximum line length */
#define LINELEN 256 /* Initial line length */
#define PAGER_MAX_LINE 10000 /* Maximum line kept as pager */
#define FNLEN 80
#ifdef USE_IMAGE
#define MAX_IMAGE 1000
@@ -316,6 +315,9 @@ typedef struct _Line {
long linenumber; /* on buffer */
long real_linenumber; /* on file */
unsigned short usrflags;
short size;
short bpos;
short bwidth;
} Line;
typedef struct {
@@ -438,7 +440,6 @@ typedef struct _Buffer {
struct frameset *frameset;
struct frameset_queue *frameQ;
int *clone;
size_t linelen;
size_t trbyte;
char check_url;
#ifdef JP_CHARSET
@@ -521,7 +522,8 @@ typedef struct _DownloadList {
#define FONTSTAT_SIZE 4
#define INIT_BUFFER_WIDTH (COLS - 1)
#define INIT_BUFFER_WIDTH (COLS - (showLineNum ? 6 : 1))
#define FOLD_BUFFER_WIDTH (FoldLine ? (INIT_BUFFER_WIDTH + 1) : -1)
typedef struct {
int pos;
@@ -955,6 +957,7 @@ global char *DictCommand init("file:///$LIB/w3mdict" CGI_EXTENSION);
global int ignore_null_img_alt init(TRUE);
global int displayInsDel init(TRUE);
global int FoldTextarea init(FALSE);
global int FoldLine init(FALSE);
#define DEFAULT_URL_EMPTY 0
#define DEFAULT_URL_CURRENT 1
#define DEFAULT_URL_LINK 2
+2 -1
View File
@@ -1,4 +1,4 @@
# $Id: funcname.tab,v 1.19 2002/12/10 15:51:14 ukai Exp $
# $Id: funcname.tab,v 1.20 2003/01/23 18:37:21 ukai Exp $
# macro name function name
#----------------------------
@@@ nulcmd
@@ -110,6 +110,7 @@ REDRAW rdrwSc
REG_MARK reMark
REINIT reinit
RELOAD reload
RESHAPE reshape
RIGHT col1R
SAVE svSrc
SAVE_IMAGE svI
+70 -33
View File
@@ -1,4 +1,4 @@
/* $Id: main.c,v 1.197 2003/01/22 16:16:20 ukai Exp $ */
/* $Id: main.c,v 1.198 2003/01/23 18:37:21 ukai Exp $ */
#define MAINPROGRAM
#include "fm.h"
#include <signal.h>
@@ -1175,7 +1175,7 @@ do_dump(Buffer *buf)
if (w3m_dump & DUMP_SOURCE)
dump_source(buf);
if (w3m_dump == DUMP_BUFFER)
saveBuffer(buf, stdout);
saveBuffer(buf, stdout, FALSE);
signal(SIGINT, prevtrap);
}
@@ -1402,37 +1402,60 @@ SigPipe(SIGNAL_ARG)
static void
nscroll(int n, int mode)
{
Line *curtop = Currentbuf->topLine;
Buffer *buf = Currentbuf;
Line *top = buf->topLine, *cur = buf->currentLine;
int lnum, tlnum, llnum, diff_n;
if (Currentbuf->firstLine == NULL)
if (buf->firstLine == NULL)
return;
lnum = Currentbuf->currentLine->linenumber;
Currentbuf->topLine = lineSkip(Currentbuf, curtop, n, FALSE);
if (Currentbuf->topLine == curtop) {
lnum = cur->linenumber;
buf->topLine = lineSkip(buf, top, n, FALSE);
if (buf->topLine == top) {
lnum += n;
if (lnum < Currentbuf->topLine->linenumber)
lnum = Currentbuf->topLine->linenumber;
else if (lnum > Currentbuf->lastLine->linenumber)
lnum = Currentbuf->lastLine->linenumber;
if (lnum < buf->topLine->linenumber)
lnum = buf->topLine->linenumber;
else if (lnum > buf->lastLine->linenumber)
lnum = buf->lastLine->linenumber;
}
else {
tlnum = Currentbuf->topLine->linenumber;
llnum = Currentbuf->topLine->linenumber + Currentbuf->LINES - 1;
tlnum = buf->topLine->linenumber;
llnum = buf->topLine->linenumber + buf->LINES - 1;
#ifdef NEXTPAGE_TOPLINE
if (nextpage_topline)
diff_n = 0;
else
#endif
diff_n = n - (tlnum - curtop->linenumber);
diff_n = n - (tlnum - top->linenumber);
if (lnum < tlnum)
lnum = tlnum + diff_n;
if (lnum > llnum)
lnum = llnum + diff_n;
}
gotoLine(Currentbuf, lnum);
arrangeLine(Currentbuf);
displayBuffer(Currentbuf, mode);
gotoLine(buf, lnum);
arrangeLine(buf);
if (n > 0) {
if (buf->currentLine->bpos &&
buf->currentLine->bwidth >= buf->currentColumn + buf->visualpos)
cursorDown(buf, 1);
else {
while (buf->currentLine->next && buf->currentLine->next->bpos &&
buf->currentLine->bwidth + buf->currentLine->width <
buf->currentColumn + buf->visualpos)
cursorDown0(buf, 1);
}
}
else {
if (buf->currentLine->bwidth + buf->currentLine->width <
buf->currentColumn + buf->visualpos)
cursorUp(buf, 1);
else {
while (buf->currentLine->prev && buf->currentLine->bpos &&
buf->currentLine->bwidth >=
buf->currentColumn + buf->visualpos)
cursorUp0(buf, 1);
}
}
displayBuffer(buf, mode);
}
/* Move page forward */
@@ -1525,7 +1548,7 @@ clear_mark(Line *l)
short pos;
if (!l)
return;
for (pos = 0; pos < l->len; pos++)
for (pos = 0; pos < l->size; pos++)
l->propBuf[pos] &= ~PE_MARK;
}
@@ -1756,14 +1779,15 @@ srchprv(void)
static void
shiftvisualpos(Buffer *buf, int shift)
{
Line *l = buf->currentLine;
buf->visualpos -= shift;
if (buf->visualpos >= buf->COLS)
buf->visualpos = buf->COLS - 1;
else if (buf->visualpos < 0)
buf->visualpos = 0;
if (buf->visualpos - l->bwidth >= buf->COLS)
buf->visualpos = l->bwidth + buf->COLS - 1;
else if (buf->visualpos - l->bwidth < 0)
buf->visualpos = l->bwidth;
arrangeLine(buf);
if (buf->visualpos == -shift && buf->cursorX == 0)
buf->visualpos = 0;
if (buf->visualpos - l->bwidth == -shift && buf->cursorX == 0)
buf->visualpos = l->bwidth;
}
/* Shift screen left */
@@ -1878,7 +1902,7 @@ pipeBuf(void)
disp_message(Sprintf("Can't save buffer to %s", cmd)->ptr, TRUE);
return;
}
saveBuffer(Currentbuf, f);
saveBuffer(Currentbuf, f, TRUE);
fclose(f);
buf = getpipe(myExtCommand(cmd, tmpf, TRUE)->ptr);
if (buf == NULL) {
@@ -2450,6 +2474,8 @@ linbeg(void)
{
if (Currentbuf->firstLine == NULL)
return;
while (Currentbuf->currentLine->prev && Currentbuf->currentLine->bpos)
cursorUp0(Currentbuf, 1);
Currentbuf->pos = 0;
arrangeCursor(Currentbuf);
displayBuffer(Currentbuf, B_NORMAL);
@@ -2461,6 +2487,8 @@ linend(void)
{
if (Currentbuf->firstLine == NULL)
return;
while (Currentbuf->currentLine->next && Currentbuf->currentLine->next->bpos)
cursorDown0(Currentbuf, 1);
Currentbuf->pos = Currentbuf->currentLine->len - 1;
arrangeCursor(Currentbuf);
displayBuffer(Currentbuf, B_NORMAL);
@@ -2506,7 +2534,7 @@ editScr(void)
disp_err_message(Sprintf("Can't open %s", tmpf)->ptr, TRUE);
return;
}
saveBuffer(Currentbuf, f);
saveBuffer(Currentbuf, f, TRUE);
fclose(f);
fmTerm();
system(myEditor(Editor, tmpf, CUR_LINENUMBER(Currentbuf))->ptr);
@@ -4225,7 +4253,7 @@ svBuf(void)
disp_err_message(emsg, TRUE);
return;
}
saveBuffer(Currentbuf, f);
saveBuffer(Currentbuf, f, TRUE);
if (is_pipe)
pclose(f);
else
@@ -4370,7 +4398,7 @@ vwSrc(void)
f = fopen(tmpf->ptr, "w");
if (f == NULL)
return;
saveBuffer(Currentbuf, f);
saveBuffer(Currentbuf, f, TRUE);
fclose(f);
Currentbuf->sourcefile = tmpf->ptr;
}
@@ -4543,6 +4571,15 @@ reload(void)
displayBuffer(Currentbuf, B_FORCE_REDRAW);
}
/* reshape */
void
reshape(void)
{
Currentbuf->need_reshape = TRUE;
reshapeBuffer(Currentbuf);
displayBuffer(Currentbuf, B_FORCE_REDRAW);
}
/* mark URL-like patterns as anchors */
void
chkURLBuffer(Buffer *buf)
@@ -4739,22 +4776,22 @@ linkbrz()
void
curlno()
{
Line *l = Currentbuf->currentLine;
Str tmp;
int cur = 0, all, col, len = 0;
if (Currentbuf->currentLine != NULL) {
Line *l = Currentbuf->currentLine;
if (l != NULL) {
cur = l->real_linenumber;
if (l->width < 0)
l->width = COLPOS(l, l->len);
len = l->width;
len = l->bwidth + l->width;
}
col = Currentbuf->currentColumn + Currentbuf->cursorX + 1;
col = l->bwidth + Currentbuf->currentColumn + Currentbuf->cursorX + 1;
all =
(Currentbuf->lastLine ? Currentbuf->lastLine->
real_linenumber : Currentbuf->allLine);
if (all == 0 && Currentbuf->lastLine != NULL)
all = Currentbuf->currentLine->real_linenumber;
all = l->real_linenumber;
if (all == 0)
all = 1;
if (Currentbuf->pagerSource && !(Currentbuf->bufferprop & BP_CLOSE))
+1 -3
View File
@@ -1,4 +1,4 @@
/* $Id: mimehead.c,v 1.7 2002/12/24 17:20:47 ukai Exp $ */
/* $Id: mimehead.c,v 1.8 2003/01/23 18:37:21 ukai Exp $ */
/*
* MIME header support by Akinori ITO
*/
@@ -7,8 +7,6 @@
#include "myctype.h"
#include "Str.h"
#define LINELEN 4096
#define MIME_ENCODED_LINE_LIMIT 80
#define MIME_ENCODED_WORD_LENGTH_OFFSET 18
#define MIME_ENCODED_WORD_LENGTH_ESTIMATION(x) \
+8 -5
View File
@@ -1,4 +1,4 @@
/* $Id: proto.h,v 1.83 2003/01/22 16:10:28 ukai Exp $ */
/* $Id: proto.h,v 1.84 2003/01/23 18:37:21 ukai Exp $ */
/*
* This file was automatically generated by version 1.7 of cextract.
* Manual editing not recommended.
@@ -92,6 +92,7 @@ extern void peekIMG(void);
extern void curURL(void);
extern void vwSrc(void);
extern void reload(void);
extern void reshape(void);
extern void chkURL(void);
extern void chkURLBuffer(Buffer *buf);
extern void chkWORD(void);
@@ -224,7 +225,7 @@ extern Buffer *loadBuffer(URLFile *uf, Buffer *newBuf);
#ifdef USE_IMAGE
extern Buffer *loadImageBuffer(URLFile *uf, Buffer *newBuf);
#endif
extern void saveBuffer(Buffer *buf, FILE * f);
extern void saveBuffer(Buffer *buf, FILE * f, int cont);
extern Buffer *getshell(char *cmd);
extern Buffer *getpipe(char *cmd);
extern Buffer *openPagerBuffer(InputStream stream, Buffer *buf);
@@ -286,7 +287,9 @@ extern void disp_message_nomouse(char *s, int redraw_current);
#define disp_message_nomouse disp_message
#endif
extern void set_delayed_message(char *s);
extern void cursorUp0(Buffer *buf, int n);
extern void cursorUp(Buffer *buf, int n);
extern void cursorDown0(Buffer *buf, int n);
extern void cursorDown(Buffer *buf, int n);
extern void cursorUpDown(Buffer *buf, int n);
extern void cursorRight(Buffer *buf, int n);
@@ -301,11 +304,11 @@ extern int columnPos(Line *line, int column);
extern Line *lineSkip(Buffer *buf, Line *line, int offset, int last);
extern Line *currentLineSkip(Buffer *buf, Line *line, int offset, int last);
extern int gethtmlcmd(char **s);
extern Str checkType(Str s, Lineprop *oprop,
extern Str checkType(Str s, Lineprop **oprop
#ifdef USE_ANSI_COLOR
Linecolor *ocolor, int *check_color,
, Linecolor **ocolor
#endif
int len);
);
extern int calcPosition(char *l, Lineprop *pr, int len, int pos, int bpos,
int mode);
extern char *lastFileName(char *path);
+6 -1
View File
@@ -1,4 +1,4 @@
/* $Id: rc.c,v 1.79 2003/01/20 15:24:20 ukai Exp $ */
/* $Id: rc.c,v 1.80 2003/01/23 18:37:21 ukai Exp $ */
/*
* Initialization file etc.
*/
@@ -130,6 +130,7 @@ static int RC_table_size;
#ifdef NEXTPAGE_TOPLINE
#define CMT_NEXTPAGE_TOPLINE "次のページに移動する時にカーソルがトップになるようにする"
#endif
#define CMT_FOLD_LINE "plain text ファイルの行を折り返す"
#define CMT_SHOW_NUM "行番号を表示する"
#define CMT_SHOW_SRCH_STR "検索文字列を表示する"
#define CMT_MIMETYPES "利用するmime.types"
@@ -293,6 +294,7 @@ static int RC_table_size;
#ifdef NEXTPAGE_TOPLINE
#define CMT_NEXTPAGE_TOPLINE "Move cursor to top line when moving to next page"
#endif
#define CMT_FOLD_LINE "Fold lines of plain text file"
#define CMT_SHOW_NUM "Show line numbers"
#define CMT_SHOW_SRCH_STR "Show search string"
#define CMT_MIMETYPES "List of mime.types files"
@@ -566,6 +568,7 @@ struct param_ptr params1[] = {
{"image_map_list", P_INT, PI_ONOFF, (void *)&image_map_list,
CMT_IMAGE_MAP_LIST, NULL},
#endif
{"fold_line", P_INT, PI_ONOFF, (void *)&FoldLine, CMT_FOLD_LINE, NULL},
{"show_lnum", P_INT, PI_ONOFF, (void *)&showLineNum, CMT_SHOW_NUM, NULL},
{"show_srch_str", P_INT, PI_ONOFF, (void *)&show_srch_str,
CMT_SHOW_SRCH_STR, NULL},
@@ -1319,6 +1322,8 @@ do_mkdir(const char *dir, long mode)
void
sync_with_option(void)
{
if (PagerMax < LINES)
PagerMax = LINES;
WrapSearch = WrapDefault;
parse_proxy();
#ifdef USE_COOKIE
+2 -2
View File
@@ -1,5 +1,5 @@
#!@PERL@
# $Id: w3mhelp.cgi.in,v 1.23 2003/01/15 17:13:22 ukai Exp $
# $Id: w3mhelp.cgi.in,v 1.24 2003/01/23 18:37:22 ukai Exp $
if ( $^O =~ /^(ms)?(dos|win(32|nt)?)/i ) {
$CYGPATH = 1;
@@ -135,7 +135,7 @@ for $otherlang (@docdirs) {
&show_keymap("Buffer operation",
split(" ", "backBf nextBf prevBf selMn selBuf vwSrc svSrc svBuf
editBf editScr reload rdrwSc dispI stopI"));
editBf editScr reload reshape rdrwSc dispI stopI"));
&show_keymap("Tab operation",
split(" ", "newT closeT nextT prevT tabMn tabR tabL"));
+57 -19
View File
@@ -1,4 +1,4 @@
/* $Id: search.c,v 1.25 2003/01/22 16:10:29 ukai Exp $ */
/* $Id: search.c,v 1.26 2003/01/23 18:37:21 ukai Exp $ */
#include "fm.h"
#include "regex.h"
#include <signal.h>
@@ -8,7 +8,7 @@
static void
set_mark(Line *l, int pos, int epos)
{
for (; pos < epos && pos < l->len; pos++)
for (; pos < epos && pos < l->size; pos++)
l->propBuf[pos] |= PE_MARK;
}
@@ -103,20 +103,33 @@ forwardSearch(Buffer *buf, char *str)
message(p, 0, 0);
return SR_NOTFOUND;
}
l = begin = buf->currentLine;
l = buf->currentLine;
if (l == NULL) {
return SR_NOTFOUND;
}
pos = buf->pos + 1;
if (l->bpos) {
pos += l->bpos;
while (l->bpos && l->prev)
l = l->prev;
}
begin = l;
#ifdef JP_CHARSET
if (l->propBuf[pos] & PC_KANJI2)
pos++;
#endif
if (pos < l->len && regexMatch(&l->lineBuf[pos], l->len - pos, 0) == 1) {
if (pos < l->size && regexMatch(&l->lineBuf[pos], l->size - pos, 0) == 1) {
matchedPosition(&first, &last);
buf->pos = first - l->lineBuf;
pos = first - l->lineBuf;
while (pos >= l->len) {
pos -= l->len;
l = l->next;
}
buf->pos = pos;
if (l != buf->currentLine)
gotoLine(buf, l->linenumber);
arrangeCursor(buf);
set_mark(l, buf->pos, last - l->lineBuf);
set_mark(l, pos, pos + last - first);
return SR_FOUND;
}
for (l = l->next;; l = l->next) {
@@ -141,16 +154,23 @@ forwardSearch(Buffer *buf, char *str)
break;
}
}
if (regexMatch(l->lineBuf, l->len, 1) == 1) {
if (l->bpos)
continue;
if (regexMatch(l->lineBuf, l->size, 1) == 1) {
matchedPosition(&first, &last);
if (wrapped && l == begin && buf->pos == first - l->lineBuf)
/* exactly same match */
break;
buf->pos = first - l->lineBuf;
pos = first - l->lineBuf;
while (pos >= l->len) {
pos -= l->len;
l = l->next;
}
buf->pos = pos;
buf->currentLine = l;
gotoLine(buf, l->linenumber);
arrangeCursor(buf);
set_mark(l, buf->pos, last - l->lineBuf);
set_mark(l, pos, pos + last - first);
return SR_FOUND | (wrapped ? SR_WRAPPED : 0);
}
if (wrapped && l == begin) /* no match */
@@ -181,12 +201,19 @@ backwardSearch(Buffer *buf, char *str)
message(p, 0, 0);
return SR_NOTFOUND;
}
l = begin = buf->currentLine;
l = buf->currentLine;
if (l == NULL) {
return SR_NOTFOUND;
}
if (buf->pos > 0) {
pos = buf->pos - 1;
pos = buf->pos;
if (l->bpos) {
pos += l->bpos;
while (l->bpos && l->prev)
l = l->prev;
}
begin = l;
if (pos > 0) {
pos--;
#ifdef JP_CHARSET
if (l->propBuf[pos] & PC_KANJI2)
pos--;
@@ -195,7 +222,7 @@ backwardSearch(Buffer *buf, char *str)
found = NULL;
found_last = NULL;
q = l->lineBuf;
while (regexMatch(q, &l->lineBuf[l->len] - q, q == l->lineBuf) == 1) {
while (regexMatch(q, &l->lineBuf[l->size] - q, q == l->lineBuf) == 1) {
matchedPosition(&first, &last);
if (first <= p) {
found = first;
@@ -211,9 +238,16 @@ backwardSearch(Buffer *buf, char *str)
break;
}
if (found) {
buf->pos = found - l->lineBuf;
pos = found - l->lineBuf;
while (pos >= l->len) {
pos -= l->len;
l = l->next;
}
buf->pos = pos;
if (l != buf->currentLine)
gotoLine(buf, l->linenumber);
arrangeCursor(buf);
set_mark(l, buf->pos, found_last - l->lineBuf);
set_mark(l, pos, pos + found_last - found);
return SR_FOUND;
}
}
@@ -230,7 +264,7 @@ backwardSearch(Buffer *buf, char *str)
found = NULL;
found_last = NULL;
q = l->lineBuf;
while (regexMatch(q, &l->lineBuf[l->len] - q, q == l->lineBuf) == 1) {
while (regexMatch(q, &l->lineBuf[l->size] - q, q == l->lineBuf) == 1) {
matchedPosition(&first, &last);
if (wrapped && l == begin && buf->pos == first - l->lineBuf)
/* exactly same match */
@@ -247,11 +281,15 @@ backwardSearch(Buffer *buf, char *str)
q++;
}
if (found) {
buf->pos = found - l->lineBuf;
buf->currentLine = l;
pos = found - l->lineBuf;
while (pos >= l->len) {
pos -= l->len;
l = l->next;
}
buf->pos = pos;
gotoLine(buf, l->linenumber);
arrangeCursor(buf);
set_mark(l, buf->pos, found_last - l->lineBuf);
set_mark(l, pos, pos + found_last - found);
return SR_FOUND | (wrapped ? SR_WRAPPED : 0);
}
if (wrapped && l == begin) /* no match */