[w3m-dev 03387] Re: tab browser

* buffer.c (newBuffer): buf->LINES initialize
	(gotoLine): use buf->LINES
	(gotoRealLine): use buf->LINES
* display.c (displayBuffer): check by buf->LINES
	(redrawNLine): buf->LINES
	(redrawLine): buf->LINES
	(redrawLineImage): no need buf->rootY
	(cursorDown): buf->LINES
	(arrangeCursor): buf->LINES
* etc.c (columnSkip): buf->LINES
	(lineSkip): buf->LINES
	(currentLineSkip): buf->LINES
* fm.h (Buffer): add LINES
* main.c (nscroll): Currentbuf->LINES
	(pgFore): Currentbuf->LINES
	(pgBack): Currentbuf->LINES
	(ctrCsrV): Currentbuf->LINES
	(movD): Currentbuf->LINES
	(movU): Currentbuf->LINES
	(_goLine): Currentbuf->LINES
	(drawAnchorCursor): Currentbuf->LINES
	(setOpt): B_REDRAW_IMAGE
	(newT): B_REDRAW_IMAGE
	(closeT): B_REDRAW_IMAGE
	(nextT): B_REDRAW_IMAGE
	(prevT): B_REDRAW_IMAGE
	(moveTab): B_NORMAL
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
This commit is contained in:
Fumitoshi UKAI
2002-11-08 15:54:46 +00:00
parent 9f17edac44
commit 885e5cad27
6 changed files with 89 additions and 62 deletions
+32 -1
View File
@@ -1,3 +1,34 @@
2002-11-09 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
* [w3m-dev 03387] Re: tab browser
* buffer.c (newBuffer): buf->LINES initialize
(gotoLine): use buf->LINES
(gotoRealLine): use buf->LINES
* display.c (displayBuffer): check by buf->LINES
(redrawNLine): buf->LINES
(redrawLine): buf->LINES
(redrawLineImage): no need buf->rootY
(cursorDown): buf->LINES
(arrangeCursor): buf->LINES
* etc.c (columnSkip): buf->LINES
(lineSkip): buf->LINES
(currentLineSkip): buf->LINES
* fm.h (Buffer): add LINES
* main.c (nscroll): Currentbuf->LINES
(pgFore): Currentbuf->LINES
(pgBack): Currentbuf->LINES
(ctrCsrV): Currentbuf->LINES
(movD): Currentbuf->LINES
(movU): Currentbuf->LINES
(_goLine): Currentbuf->LINES
(drawAnchorCursor): Currentbuf->LINES
(setOpt): B_REDRAW_IMAGE
(newT): B_REDRAW_IMAGE
(closeT): B_REDRAW_IMAGE
(nextT): B_REDRAW_IMAGE
(prevT): B_REDRAW_IMAGE
(moveTab): B_NORMAL
2002-11-09 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> 2002-11-09 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
* [w3m-dev 03386] Re: Interrupt in no_proxy_check() * [w3m-dev 03386] Re: Interrupt in no_proxy_check()
@@ -4387,4 +4418,4 @@ a * [w3m-dev 03276] compile error on EWS4800
* release-0-2-1 * release-0-2-1
* import w3m-0.2.1 * import w3m-0.2.1
$Id: ChangeLog,v 1.485 2002/11/08 15:46:05 ukai Exp $ $Id: ChangeLog,v 1.486 2002/11/08 15:54:46 ukai Exp $
+10 -7
View File
@@ -1,4 +1,4 @@
/* $Id: buffer.c,v 1.13 2002/03/15 19:02:40 ukai Exp $ */ /* $Id: buffer.c,v 1.14 2002/11/08 15:54:46 ukai Exp $ */
#include "fm.h" #include "fm.h"
#ifdef USE_MOUSE #ifdef USE_MOUSE
@@ -32,6 +32,7 @@ newBuffer(int width)
bzero((void *)n, sizeof(Buffer)); bzero((void *)n, sizeof(Buffer));
n->width = width; n->width = width;
n->COLS = COLS; n->COLS = COLS;
n->LINES = LASTLINE;
n->currentURL.scheme = SCM_UNKNOWN; n->currentURL.scheme = SCM_UNKNOWN;
n->baseURL = NULL; n->baseURL = NULL;
n->baseTarget = NULL; n->baseTarget = NULL;
@@ -252,15 +253,16 @@ gotoLine(Buffer *buf, int n)
sprintf(msg, "Last line is #%ld", buf->lastLine->linenumber); sprintf(msg, "Last line is #%ld", buf->lastLine->linenumber);
set_delayed_message(msg); set_delayed_message(msg);
buf->currentLine = l; buf->currentLine = l;
buf->topLine = lineSkip(buf, buf->currentLine, -(LASTLINE - 1), FALSE); buf->topLine = lineSkip(buf, buf->currentLine, -(buf->LINES - 1),
FALSE);
return; return;
} }
for (; l != NULL; l = l->next) { for (; l != NULL; l = l->next) {
if (l->linenumber >= n) { if (l->linenumber >= n) {
buf->currentLine = l; buf->currentLine = l;
if (n < buf->topLine->linenumber || if (n < buf->topLine->linenumber ||
buf->topLine->linenumber + LASTLINE <= n) buf->topLine->linenumber + buf->LINES <= n)
buf->topLine = lineSkip(buf, l, -(LASTLINE + 1) / 2, FALSE); buf->topLine = lineSkip(buf, l, -(buf->LINES + 1) / 2, FALSE);
break; break;
} }
} }
@@ -294,15 +296,16 @@ gotoRealLine(Buffer *buf, int n)
sprintf(msg, "Last line is #%ld", buf->lastLine->real_linenumber); sprintf(msg, "Last line is #%ld", buf->lastLine->real_linenumber);
set_delayed_message(msg); set_delayed_message(msg);
buf->currentLine = l; buf->currentLine = l;
buf->topLine = lineSkip(buf, buf->currentLine, -(LASTLINE - 1), FALSE); buf->topLine = lineSkip(buf, buf->currentLine, -(buf->LINES - 1),
FALSE);
return; return;
} }
for (; l != NULL; l = l->next) { for (; l != NULL; l = l->next) {
if (l->real_linenumber >= n) { if (l->real_linenumber >= n) {
buf->currentLine = l; buf->currentLine = l;
if (n < buf->topLine->real_linenumber || if (n < buf->topLine->real_linenumber ||
buf->topLine->real_linenumber + LASTLINE <= n) buf->topLine->real_linenumber + buf->LINES <= n)
buf->topLine = lineSkip(buf, l, -(LASTLINE + 1) / 2, FALSE); buf->topLine = lineSkip(buf, l, -(buf->LINES + 1) / 2, FALSE);
break; break;
} }
} }
+24 -23
View File
@@ -1,4 +1,4 @@
/* $Id: display.c,v 1.28 2002/11/06 03:19:30 ukai Exp $ */ /* $Id: display.c,v 1.29 2002/11/08 15:54:47 ukai Exp $ */
#include <signal.h> #include <signal.h>
#include "fm.h" #include "fm.h"
@@ -254,16 +254,18 @@ displayBuffer(Buffer *buf, int mode)
else else
buf->rootX = 0; buf->rootX = 0;
buf->COLS = COLS - buf->rootX; buf->COLS = COLS - buf->rootX;
if (nTab > 1) if (nTab > 1) {
ny = (nTab - 1) / N_TAB + 2; ny = (nTab - 1) / N_TAB + 2;
if (buf->rootY != ny) { if (ny > LASTLINE)
buf->rootY = ny; ny = LASTLINE;
arrangeCursor(buf);
} }
if (mode == B_FORCE_REDRAW || mode == B_SCROLL || if (buf->rootY != ny || buf->LINES != LASTLINE - ny) {
#ifdef USE_IMAGE buf->rootY = ny;
mode == B_REDRAW_IMAGE || buf->LINES = LASTLINE - ny;
#endif arrangeCursor(buf);
mode = B_REDRAW_IMAGE;
}
if (mode == B_FORCE_REDRAW || mode == B_SCROLL || mode == B_REDRAW_IMAGE ||
cline != buf->topLine || ccolumn != buf->currentColumn) { cline != buf->topLine || ccolumn != buf->currentColumn) {
if ( if (
#ifdef USE_IMAGE #ifdef USE_IMAGE
@@ -271,15 +273,15 @@ displayBuffer(Buffer *buf, int mode)
#endif #endif
mode == B_SCROLL && cline && buf->currentColumn == ccolumn) { mode == B_SCROLL && cline && buf->currentColumn == ccolumn) {
int n = buf->topLine->linenumber - cline->linenumber; int n = buf->topLine->linenumber - cline->linenumber;
if (n > 0 && n < LASTLINE) { if (n > 0 && n < buf->LINES) {
move(LASTLINE, 0); move(LASTLINE, 0);
clrtoeolx(); clrtoeolx();
refresh(); refresh();
scroll(n); scroll(n);
} }
else if (n < 0 && n > -LASTLINE) { else if (n < 0 && n > -buf->LINES) {
#if defined(__CYGWIN__) && LANG == JA #if defined(__CYGWIN__) && LANG == JA
move(LASTLINE + n + 1, 0); move(buf->LINES + n + 1, 0);
clrtoeolx(); clrtoeolx();
refresh(); refresh();
#endif /* defined(__CYGWIN__) && LANG == JA */ #endif /* defined(__CYGWIN__) && LANG == JA */
@@ -468,9 +470,9 @@ redrawNLine(Buffer *buf, int n)
for (i = 0; i < COLS; i++) for (i = 0; i < COLS; i++)
addch('~'); addch('~');
} }
for (i = buf->rootY, l = buf->topLine; i < LASTLINE; i++) { for (i = 0, l = buf->topLine; i < buf->LINES; i++) {
if (i >= LASTLINE - n || (i - buf->rootY) < -n) if (i >= buf->LINES - n || i < -n)
l0 = redrawLine(buf, l, i); l0 = redrawLine(buf, l, i + buf->rootY);
else { else {
l0 = (l) ? l->next : NULL; l0 = (l) ? l->next : NULL;
} }
@@ -485,9 +487,9 @@ redrawNLine(Buffer *buf, int n)
if (!(activeImage && displayImage && buf->img)) if (!(activeImage && displayImage && buf->img))
return; return;
move(buf->cursorY + buf->rootY, buf->cursorX + buf->rootX); move(buf->cursorY + buf->rootY, buf->cursorX + buf->rootX);
for (i = 0, l = buf->topLine; i < LASTLINE; i++) { for (i = 0, l = buf->topLine; i < buf->LINES; i++) {
if (i >= LASTLINE - n || i < -n) if (i >= buf->LINES - n || i < -n)
l0 = redrawLineImage(buf, l, i); l0 = redrawLineImage(buf, l, i + buf->rootY);
else { else {
l0 = (l) ? l->next : NULL; l0 = (l) ? l->next : NULL;
} }
@@ -519,7 +521,7 @@ redrawLine(Buffer *buf, Line *l, int i)
if (l == NULL) { if (l == NULL) {
if (buf->pagerSource) { if (buf->pagerSource) {
l = getNextPage(buf, LASTLINE - i); l = getNextPage(buf, buf->LINES - i);
if (l == NULL) if (l == NULL)
return NULL; return NULL;
} }
@@ -706,7 +708,7 @@ redrawLineImage(Buffer *buf, Line *l, int i)
buf->need_reshape = TRUE; buf->need_reshape = TRUE;
} }
x = (int)((rcol - column + buf->rootX) * pixel_per_char); x = (int)((rcol - column + buf->rootX) * pixel_per_char);
y = (int)((i + buf->rootY) * pixel_per_line); y = (int)(i * pixel_per_line);
sx = (int)((rcol - COLPOS(l, a->start.pos)) * pixel_per_char); sx = (int)((rcol - COLPOS(l, a->start.pos)) * pixel_per_char);
sy = (int)((l->linenumber - image->y) * pixel_per_line); sy = (int)((l->linenumber - image->y) * pixel_per_line);
if (sx == 0 && x + image->xoffset >= 0) if (sx == 0 && x + image->xoffset >= 0)
@@ -1105,7 +1107,7 @@ cursorDown(Buffer *buf, int n)
{ {
if (buf->firstLine == NULL) if (buf->firstLine == NULL)
return; return;
if (buf->cursorY + buf->rootY < LASTLINE - 1) if (buf->cursorY < buf->LINES - 1)
cursorUpDown(buf, 1); cursorUpDown(buf, 1);
else { else {
buf->topLine = lineSkip(buf, buf->topLine, n, FALSE); buf->topLine = lineSkip(buf, buf->topLine, n, FALSE);
@@ -1220,8 +1222,7 @@ arrangeCursor(Buffer *buf)
if (buf == NULL || buf->currentLine == NULL) if (buf == NULL || buf->currentLine == NULL)
return; return;
/* Arrange line */ /* Arrange line */
if (buf->currentLine->linenumber - buf->topLine->linenumber >= LASTLINE - if (buf->currentLine->linenumber - buf->topLine->linenumber >= buf->LINES
buf->rootY
|| buf->currentLine->linenumber < buf->topLine->linenumber) { || buf->currentLine->linenumber < buf->topLine->linenumber) {
/* /*
* buf->topLine = buf->currentLine; * buf->topLine = buf->currentLine;
+4 -5
View File
@@ -1,4 +1,4 @@
/* $Id: etc.c,v 1.36 2002/11/06 15:05:34 ukai Exp $ */ /* $Id: etc.c,v 1.37 2002/11/08 15:54:47 ukai Exp $ */
#include "fm.h" #include "fm.h"
#include <pwd.h> #include <pwd.h>
#include "myctype.h" #include "myctype.h"
@@ -42,7 +42,7 @@ columnSkip(Buffer *buf, int offset)
{ {
int i, maxColumn; int i, maxColumn;
int column = buf->currentColumn + offset; int column = buf->currentColumn + offset;
int nlines = LASTLINE + 1 - buf->rootY; int nlines = buf->LINES + 1;
Line *l; Line *l;
maxColumn = 0; maxColumn = 0;
@@ -91,8 +91,7 @@ lineSkip(Buffer *buf, Line *line, int offset, int last)
#ifdef NEXTPAGE_TOPLINE #ifdef NEXTPAGE_TOPLINE
if (!nextpage_topline) if (!nextpage_topline)
#endif #endif
for (i = (LASTLINE - 1 - buf->rootY) - (buf->lastLine->linenumber for (i = buf->LINES - 1 - (buf->lastLine->linenumber - l->linenumber);
- l->linenumber);
i > 0 && l->prev != NULL; i--, l = l->prev) ; i > 0 && l->prev != NULL; i--, l = l->prev) ;
return l; return l;
} }
@@ -104,7 +103,7 @@ currentLineSkip(Buffer *buf, Line *line, int offset, int last)
Line *l = line; Line *l = line;
if (buf->pagerSource && !(buf->bufferprop & BP_CLOSE)) { if (buf->pagerSource && !(buf->bufferprop & BP_CLOSE)) {
n = line->linenumber + offset + LASTLINE - buf->rootY; n = line->linenumber + offset + buf->LINES;
if (buf->lastLine->linenumber < n) if (buf->lastLine->linenumber < n)
getNextPage(buf, n - buf->lastLine->linenumber); getNextPage(buf, n - buf->lastLine->linenumber);
while ((last || (buf->lastLine->linenumber < n)) && while ((last || (buf->lastLine->linenumber < n)) &&
+2 -1
View File
@@ -1,4 +1,4 @@
/* $Id: fm.h,v 1.71 2002/11/06 15:07:40 ukai Exp $ */ /* $Id: fm.h,v 1.72 2002/11/08 15:54:47 ukai Exp $ */
/* /*
* w3m: WWW wo Miru utility * w3m: WWW wo Miru utility
* *
@@ -406,6 +406,7 @@ typedef struct _Buffer {
short rootX; short rootX;
short rootY; short rootY;
short COLS; short COLS;
short LINES;
InputStream pagerSource; InputStream pagerSource;
AnchorList *href; AnchorList *href;
AnchorList *name; AnchorList *name;
+17 -25
View File
@@ -1,4 +1,4 @@
/* $Id: main.c,v 1.120 2002/11/06 03:27:04 ukai Exp $ */ /* $Id: main.c,v 1.121 2002/11/08 15:54:47 ukai Exp $ */
#define MAINPROGRAM #define MAINPROGRAM
#include "fm.h" #include "fm.h"
#include <signal.h> #include <signal.h>
@@ -1307,8 +1307,7 @@ nscroll(int n, int mode)
} }
else { else {
tlnum = Currentbuf->topLine->linenumber; tlnum = Currentbuf->topLine->linenumber;
llnum = Currentbuf->topLine->linenumber + LASTLINE - Currentbuf->rootY llnum = Currentbuf->topLine->linenumber + Currentbuf->LINES - 1;
- 1;
#ifdef NEXTPAGE_TOPLINE #ifdef NEXTPAGE_TOPLINE
if (nextpage_topline) if (nextpage_topline)
diff_n = 0; diff_n = 0;
@@ -1331,12 +1330,11 @@ pgFore(void)
{ {
#ifdef VI_PREC_NUM #ifdef VI_PREC_NUM
if (vi_prec_num) if (vi_prec_num)
nscroll(searchKeyNum() * (LASTLINE - Currentbuf->rootY - 1), B_NORMAL); nscroll(searchKeyNum() * (Currentbuf->LINES - 1), B_NORMAL);
else else
#endif #endif
nscroll(prec_num ? searchKeyNum() : searchKeyNum() nscroll(prec_num ? searchKeyNum() : searchKeyNum()
* (LASTLINE - Currentbuf->rootY - 1), * (Currentbuf->LINES - 1), prec_num ? B_SCROLL : B_NORMAL);
prec_num ? B_SCROLL : B_NORMAL);
} }
/* Move page backward */ /* Move page backward */
@@ -1345,13 +1343,11 @@ pgBack(void)
{ {
#ifdef VI_PREC_NUM #ifdef VI_PREC_NUM
if (vi_prec_num) if (vi_prec_num)
nscroll(-searchKeyNum() * (LASTLINE - Currentbuf->rootY - 1), nscroll(-searchKeyNum() * (Currentbuf->LINES - 1), B_NORMAL);
B_NORMAL);
else else
#endif #endif
nscroll(-(prec_num ? searchKeyNum() : searchKeyNum() nscroll(-(prec_num ? searchKeyNum() : searchKeyNum()
* (LASTLINE - Currentbuf->rootY - 1)), * (Currentbuf->LINES - 1)), prec_num ? B_SCROLL : B_NORMAL);
prec_num ? B_SCROLL : B_NORMAL);
} }
/* 1 line up */ /* 1 line up */
@@ -1375,7 +1371,7 @@ ctrCsrV(void)
int offsety; int offsety;
if (Currentbuf->firstLine == NULL) if (Currentbuf->firstLine == NULL)
return; return;
offsety = (LASTLINE - Currentbuf->rootY) / 2 - Currentbuf->cursorY; offsety = Currentbuf->LINES / 2 - Currentbuf->cursorY;
if (offsety != 0) { if (offsety != 0) {
#if 0 #if 0
Currentbuf->currentLine = lineSkip(Currentbuf, Currentbuf->currentLine = lineSkip(Currentbuf,
@@ -1969,7 +1965,7 @@ _movD(int n)
void void
movD(void) movD(void)
{ {
_movD((LASTLINE - Currentbuf->rootY + 1) / 2); _movD((Currentbuf->LINES + 1) / 2);
} }
void void
@@ -1993,7 +1989,7 @@ _movU(int n)
void void
movU(void) movU(void)
{ {
_movU((LASTLINE - Currentbuf->rootY + 1) / 2); _movU((Currentbuf->LINES + 1) / 2);
} }
void void
@@ -2284,7 +2280,7 @@ _goLine(char *l)
else if (*l == '$') { else if (*l == '$') {
Currentbuf->topLine = Currentbuf->topLine =
lineSkip(Currentbuf, Currentbuf->lastLine, lineSkip(Currentbuf, Currentbuf->lastLine,
-(LASTLINE - Currentbuf->rootY + 1) / 2, TRUE); -(Currentbuf->LINES + 1) / 2, TRUE);
Currentbuf->currentLine = Currentbuf->lastLine; Currentbuf->currentLine = Currentbuf->lastLine;
} }
else else
@@ -3285,7 +3281,7 @@ drawAnchorCursor(Buffer *buf)
else else
hseq = -1; hseq = -1;
tline = buf->topLine->linenumber; tline = buf->topLine->linenumber;
eline = tline + LASTLINE - buf->rootY; eline = tline + buf->LINES;
prevhseq = buf->hmarklist->prevhseq; prevhseq = buf->hmarklist->prevhseq;
drawAnchorCursor0(buf, hseq, prevhseq, tline, eline, 1); drawAnchorCursor0(buf, hseq, prevhseq, tline, eline, 1);
@@ -3918,11 +3914,7 @@ setOpt(void)
} }
if (set_param_option(opt)) if (set_param_option(opt))
sync_with_option(); sync_with_option();
#ifdef USE_IMAGE displayBuffer(Currentbuf, B_REDRAW_IMAGE);
if (activeImage)
displayBuffer(Currentbuf, B_REDRAW_IMAGE);
#endif
displayBuffer(Currentbuf, B_FORCE_REDRAW);
} }
/* error message list */ /* error message list */
@@ -5418,7 +5410,7 @@ void
newT(void) newT(void)
{ {
_newT(); _newT();
displayBuffer(Currentbuf, B_FORCE_REDRAW); displayBuffer(Currentbuf, B_REDRAW_IMAGE);
} }
TabBuffer * TabBuffer *
@@ -5482,7 +5474,7 @@ closeT(void)
tab = CurrentTab; tab = CurrentTab;
if (tab) if (tab)
deleteTab(tab); deleteTab(tab);
displayBuffer(Currentbuf, B_FORCE_REDRAW); displayBuffer(Currentbuf, B_REDRAW_IMAGE);
} }
void void
@@ -5498,7 +5490,7 @@ nextT(void)
else else
CurrentTab = FirstTab; CurrentTab = FirstTab;
} }
displayBuffer(Currentbuf, B_FORCE_REDRAW); displayBuffer(Currentbuf, B_REDRAW_IMAGE);
} }
void void
@@ -5514,7 +5506,7 @@ prevT(void)
else else
CurrentTab = LastTab; CurrentTab = LastTab;
} }
displayBuffer(Currentbuf, B_FORCE_REDRAW); displayBuffer(Currentbuf, B_REDRAW_IMAGE);
} }
void void
@@ -5656,7 +5648,7 @@ moveTab(TabBuffer * t, TabBuffer * t2, int right)
FirstTab = t; FirstTab = t;
t2->prevTab = t; t2->prevTab = t;
} }
displayBuffer(Currentbuf, B_FORCE_REDRAW); displayBuffer(Currentbuf, B_NORMAL);
} }
void void