commit a05e1d3eb74354c57036aa80c7f23c7e614eda74
parent 0e8349ba72b86a4641b07e497d40f217ddb6c966
Author: ukai <ukai>
Date: Fri, 8 Nov 2002 15:54:46 +0000
[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>
Diffstat:
M | ChangeLog | | | 31 | +++++++++++++++++++++++++++++++ |
M | buffer.c | | | 15 | +++++++++------ |
M | display.c | | | 41 | +++++++++++++++++++++-------------------- |
M | etc.c | | | 7 | +++---- |
M | fm.h | | | 1 | + |
M | main.c | | | 40 | ++++++++++++++++------------------------ |
6 files changed, 81 insertions(+), 54 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,5 +1,36 @@
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>
+
* [w3m-dev 03386] Re: Interrupt in no_proxy_check()
* file.c (getAuthCookie): term_cbreak()
(loadGeneralFile): term_cbreak()
diff --git a/buffer.c b/buffer.c
@@ -32,6 +32,7 @@ newBuffer(int width)
bzero((void *)n, sizeof(Buffer));
n->width = width;
n->COLS = COLS;
+ n->LINES = LASTLINE;
n->currentURL.scheme = SCM_UNKNOWN;
n->baseURL = NULL;
n->baseTarget = NULL;
@@ -252,15 +253,16 @@ gotoLine(Buffer *buf, int n)
sprintf(msg, "Last line is #%ld", buf->lastLine->linenumber);
set_delayed_message(msg);
buf->currentLine = l;
- buf->topLine = lineSkip(buf, buf->currentLine, -(LASTLINE - 1), FALSE);
+ buf->topLine = lineSkip(buf, buf->currentLine, -(buf->LINES - 1),
+ FALSE);
return;
}
for (; l != NULL; l = l->next) {
if (l->linenumber >= n) {
buf->currentLine = l;
if (n < buf->topLine->linenumber ||
- buf->topLine->linenumber + LASTLINE <= n)
- buf->topLine = lineSkip(buf, l, -(LASTLINE + 1) / 2, FALSE);
+ buf->topLine->linenumber + buf->LINES <= n)
+ buf->topLine = lineSkip(buf, l, -(buf->LINES + 1) / 2, FALSE);
break;
}
}
@@ -294,15 +296,16 @@ gotoRealLine(Buffer *buf, int n)
sprintf(msg, "Last line is #%ld", buf->lastLine->real_linenumber);
set_delayed_message(msg);
buf->currentLine = l;
- buf->topLine = lineSkip(buf, buf->currentLine, -(LASTLINE - 1), FALSE);
+ buf->topLine = lineSkip(buf, buf->currentLine, -(buf->LINES - 1),
+ FALSE);
return;
}
for (; l != NULL; l = l->next) {
if (l->real_linenumber >= n) {
buf->currentLine = l;
if (n < buf->topLine->real_linenumber ||
- buf->topLine->real_linenumber + LASTLINE <= n)
- buf->topLine = lineSkip(buf, l, -(LASTLINE + 1) / 2, FALSE);
+ buf->topLine->real_linenumber + buf->LINES <= n)
+ buf->topLine = lineSkip(buf, l, -(buf->LINES + 1) / 2, FALSE);
break;
}
}
diff --git a/display.c b/display.c
@@ -254,16 +254,18 @@ displayBuffer(Buffer *buf, int mode)
else
buf->rootX = 0;
buf->COLS = COLS - buf->rootX;
- if (nTab > 1)
+ if (nTab > 1) {
ny = (nTab - 1) / N_TAB + 2;
- if (buf->rootY != ny) {
+ if (ny > LASTLINE)
+ ny = LASTLINE;
+ }
+ if (buf->rootY != ny || buf->LINES != LASTLINE - ny) {
buf->rootY = ny;
+ buf->LINES = LASTLINE - ny;
arrangeCursor(buf);
+ mode = B_REDRAW_IMAGE;
}
- if (mode == B_FORCE_REDRAW || mode == B_SCROLL ||
-#ifdef USE_IMAGE
- mode == B_REDRAW_IMAGE ||
-#endif
+ if (mode == B_FORCE_REDRAW || mode == B_SCROLL || mode == B_REDRAW_IMAGE ||
cline != buf->topLine || ccolumn != buf->currentColumn) {
if (
#ifdef USE_IMAGE
@@ -271,15 +273,15 @@ displayBuffer(Buffer *buf, int mode)
#endif
mode == B_SCROLL && cline && buf->currentColumn == ccolumn) {
int n = buf->topLine->linenumber - cline->linenumber;
- if (n > 0 && n < LASTLINE) {
+ if (n > 0 && n < buf->LINES) {
move(LASTLINE, 0);
clrtoeolx();
refresh();
scroll(n);
}
- else if (n < 0 && n > -LASTLINE) {
+ else if (n < 0 && n > -buf->LINES) {
#if defined(__CYGWIN__) && LANG == JA
- move(LASTLINE + n + 1, 0);
+ move(buf->LINES + n + 1, 0);
clrtoeolx();
refresh();
#endif /* defined(__CYGWIN__) && LANG == JA */
@@ -468,9 +470,9 @@ redrawNLine(Buffer *buf, int n)
for (i = 0; i < COLS; i++)
addch('~');
}
- for (i = buf->rootY, l = buf->topLine; i < LASTLINE; i++) {
- if (i >= LASTLINE - n || (i - buf->rootY) < -n)
- l0 = redrawLine(buf, l, i);
+ for (i = 0, l = buf->topLine; i < buf->LINES; i++) {
+ if (i >= buf->LINES - n || i < -n)
+ l0 = redrawLine(buf, l, i + buf->rootY);
else {
l0 = (l) ? l->next : NULL;
}
@@ -485,9 +487,9 @@ redrawNLine(Buffer *buf, int n)
if (!(activeImage && displayImage && buf->img))
return;
move(buf->cursorY + buf->rootY, buf->cursorX + buf->rootX);
- for (i = 0, l = buf->topLine; i < LASTLINE; i++) {
- if (i >= LASTLINE - n || i < -n)
- l0 = redrawLineImage(buf, l, i);
+ for (i = 0, l = buf->topLine; i < buf->LINES; i++) {
+ if (i >= buf->LINES - n || i < -n)
+ l0 = redrawLineImage(buf, l, i + buf->rootY);
else {
l0 = (l) ? l->next : NULL;
}
@@ -519,7 +521,7 @@ redrawLine(Buffer *buf, Line *l, int i)
if (l == NULL) {
if (buf->pagerSource) {
- l = getNextPage(buf, LASTLINE - i);
+ l = getNextPage(buf, buf->LINES - i);
if (l == NULL)
return NULL;
}
@@ -706,7 +708,7 @@ redrawLineImage(Buffer *buf, Line *l, int i)
buf->need_reshape = TRUE;
}
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);
sy = (int)((l->linenumber - image->y) * pixel_per_line);
if (sx == 0 && x + image->xoffset >= 0)
@@ -1105,7 +1107,7 @@ cursorDown(Buffer *buf, int n)
{
if (buf->firstLine == NULL)
return;
- if (buf->cursorY + buf->rootY < LASTLINE - 1)
+ if (buf->cursorY < buf->LINES - 1)
cursorUpDown(buf, 1);
else {
buf->topLine = lineSkip(buf, buf->topLine, n, FALSE);
@@ -1220,8 +1222,7 @@ arrangeCursor(Buffer *buf)
if (buf == NULL || buf->currentLine == NULL)
return;
/* Arrange line */
- if (buf->currentLine->linenumber - buf->topLine->linenumber >= LASTLINE -
- buf->rootY
+ if (buf->currentLine->linenumber - buf->topLine->linenumber >= buf->LINES
|| buf->currentLine->linenumber < buf->topLine->linenumber) {
/*
* buf->topLine = buf->currentLine;
diff --git a/etc.c b/etc.c
@@ -42,7 +42,7 @@ columnSkip(Buffer *buf, int offset)
{
int i, maxColumn;
int column = buf->currentColumn + offset;
- int nlines = LASTLINE + 1 - buf->rootY;
+ int nlines = buf->LINES + 1;
Line *l;
maxColumn = 0;
@@ -91,8 +91,7 @@ lineSkip(Buffer *buf, Line *line, int offset, int last)
#ifdef NEXTPAGE_TOPLINE
if (!nextpage_topline)
#endif
- for (i = (LASTLINE - 1 - buf->rootY) - (buf->lastLine->linenumber
- - l->linenumber);
+ for (i = buf->LINES - 1 - (buf->lastLine->linenumber - l->linenumber);
i > 0 && l->prev != NULL; i--, l = l->prev) ;
return l;
}
@@ -104,7 +103,7 @@ currentLineSkip(Buffer *buf, Line *line, int offset, int last)
Line *l = line;
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)
getNextPage(buf, n - buf->lastLine->linenumber);
while ((last || (buf->lastLine->linenumber < n)) &&
diff --git a/fm.h b/fm.h
@@ -406,6 +406,7 @@ typedef struct _Buffer {
short rootX;
short rootY;
short COLS;
+ short LINES;
InputStream pagerSource;
AnchorList *href;
AnchorList *name;
diff --git a/main.c b/main.c
@@ -1307,8 +1307,7 @@ nscroll(int n, int mode)
}
else {
tlnum = Currentbuf->topLine->linenumber;
- llnum = Currentbuf->topLine->linenumber + LASTLINE - Currentbuf->rootY
- - 1;
+ llnum = Currentbuf->topLine->linenumber + Currentbuf->LINES - 1;
#ifdef NEXTPAGE_TOPLINE
if (nextpage_topline)
diff_n = 0;
@@ -1331,12 +1330,11 @@ pgFore(void)
{
#ifdef VI_PREC_NUM
if (vi_prec_num)
- nscroll(searchKeyNum() * (LASTLINE - Currentbuf->rootY - 1), B_NORMAL);
+ nscroll(searchKeyNum() * (Currentbuf->LINES - 1), B_NORMAL);
else
#endif
nscroll(prec_num ? searchKeyNum() : searchKeyNum()
- * (LASTLINE - Currentbuf->rootY - 1),
- prec_num ? B_SCROLL : B_NORMAL);
+ * (Currentbuf->LINES - 1), prec_num ? B_SCROLL : B_NORMAL);
}
/* Move page backward */
@@ -1345,13 +1343,11 @@ pgBack(void)
{
#ifdef VI_PREC_NUM
if (vi_prec_num)
- nscroll(-searchKeyNum() * (LASTLINE - Currentbuf->rootY - 1),
- B_NORMAL);
+ nscroll(-searchKeyNum() * (Currentbuf->LINES - 1), B_NORMAL);
else
#endif
nscroll(-(prec_num ? searchKeyNum() : searchKeyNum()
- * (LASTLINE - Currentbuf->rootY - 1)),
- prec_num ? B_SCROLL : B_NORMAL);
+ * (Currentbuf->LINES - 1)), prec_num ? B_SCROLL : B_NORMAL);
}
/* 1 line up */
@@ -1375,7 +1371,7 @@ ctrCsrV(void)
int offsety;
if (Currentbuf->firstLine == NULL)
return;
- offsety = (LASTLINE - Currentbuf->rootY) / 2 - Currentbuf->cursorY;
+ offsety = Currentbuf->LINES / 2 - Currentbuf->cursorY;
if (offsety != 0) {
#if 0
Currentbuf->currentLine = lineSkip(Currentbuf,
@@ -1969,7 +1965,7 @@ _movD(int n)
void
movD(void)
{
- _movD((LASTLINE - Currentbuf->rootY + 1) / 2);
+ _movD((Currentbuf->LINES + 1) / 2);
}
void
@@ -1993,7 +1989,7 @@ _movU(int n)
void
movU(void)
{
- _movU((LASTLINE - Currentbuf->rootY + 1) / 2);
+ _movU((Currentbuf->LINES + 1) / 2);
}
void
@@ -2284,7 +2280,7 @@ _goLine(char *l)
else if (*l == '$') {
Currentbuf->topLine =
lineSkip(Currentbuf, Currentbuf->lastLine,
- -(LASTLINE - Currentbuf->rootY + 1) / 2, TRUE);
+ -(Currentbuf->LINES + 1) / 2, TRUE);
Currentbuf->currentLine = Currentbuf->lastLine;
}
else
@@ -3285,7 +3281,7 @@ drawAnchorCursor(Buffer *buf)
else
hseq = -1;
tline = buf->topLine->linenumber;
- eline = tline + LASTLINE - buf->rootY;
+ eline = tline + buf->LINES;
prevhseq = buf->hmarklist->prevhseq;
drawAnchorCursor0(buf, hseq, prevhseq, tline, eline, 1);
@@ -3918,11 +3914,7 @@ setOpt(void)
}
if (set_param_option(opt))
sync_with_option();
-#ifdef USE_IMAGE
- if (activeImage)
- displayBuffer(Currentbuf, B_REDRAW_IMAGE);
-#endif
- displayBuffer(Currentbuf, B_FORCE_REDRAW);
+ displayBuffer(Currentbuf, B_REDRAW_IMAGE);
}
/* error message list */
@@ -5418,7 +5410,7 @@ void
newT(void)
{
_newT();
- displayBuffer(Currentbuf, B_FORCE_REDRAW);
+ displayBuffer(Currentbuf, B_REDRAW_IMAGE);
}
TabBuffer *
@@ -5482,7 +5474,7 @@ closeT(void)
tab = CurrentTab;
if (tab)
deleteTab(tab);
- displayBuffer(Currentbuf, B_FORCE_REDRAW);
+ displayBuffer(Currentbuf, B_REDRAW_IMAGE);
}
void
@@ -5498,7 +5490,7 @@ nextT(void)
else
CurrentTab = FirstTab;
}
- displayBuffer(Currentbuf, B_FORCE_REDRAW);
+ displayBuffer(Currentbuf, B_REDRAW_IMAGE);
}
void
@@ -5514,7 +5506,7 @@ prevT(void)
else
CurrentTab = LastTab;
}
- displayBuffer(Currentbuf, B_FORCE_REDRAW);
+ displayBuffer(Currentbuf, B_REDRAW_IMAGE);
}
void
@@ -5656,7 +5648,7 @@ moveTab(TabBuffer * t, TabBuffer * t2, int right)
FirstTab = t;
t2->prevTab = t;
}
- displayBuffer(Currentbuf, B_FORCE_REDRAW);
+ displayBuffer(Currentbuf, B_NORMAL);
}
void