aboutsummaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorFumitoshi UKAI <ukai@debian.or.jp>2003-01-23 18:37:18 +0000
committerFumitoshi UKAI <ukai@debian.or.jp>2003-01-23 18:37:18 +0000
commit61c2c2de18d3ef19c321bac335043424c862aba7 (patch)
tree52b5d72b1c3298f7e12b72daabfff2b37eb37680 /main.c
parent* etc.c (next_status): after = is R_ST_VALUE (diff)
downloadw3m-61c2c2de18d3ef19c321bac335043424c862aba7.tar.gz
w3m-61c2c2de18d3ef19c321bac335043424c862aba7.zip
[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>
Diffstat (limited to 'main.c')
-rw-r--r--main.c103
1 files changed, 70 insertions, 33 deletions
diff --git a/main.c b/main.c
index c0981bd..6ae432f 100644
--- a/main.c
+++ b/main.c
@@ -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))