w3m

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/w3m.git/
Log | Files | Refs | README

commit 414449af90a6a66b1dfa32e864d43ede95bc27f1
parent 689852ddefb4a2da67ac1da70017111069ef70da
Author: ukai <ukai>
Date:   Fri, 10 Jan 2003 16:08:19 +0000

[w3m-dev 03620] -m option and header
* buffer.c (reshapeBuffer): fix reading from stdin
			fix -m option
* display.c (redrawNLine): rewrite
	(redrawLine): return l instead of l->next
	(redrawLineImage): ditto
* file.c (loadFile): read header even if skip header
	(loadGeneralFile): read header even if skip header
* fm.h (SkipHeader): added
* main.c (main): check whether reading from stdin
		SkipHeader
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>

Diffstat:
MChangeLog | 14++++++++++++++
Mbuffer.c | 10+++++-----
Mdisplay.c | 32++++++++++----------------------
Mfile.c | 10+++++++++-
Mfm.h | 1+
Mmain.c | 9++++++++-
6 files changed, 47 insertions(+), 29 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,17 @@ +2003-01-11 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> + + * [w3m-dev 03620] -m option and header + * buffer.c (reshapeBuffer): fix reading from stdin + fix -m option + * display.c (redrawNLine): rewrite + (redrawLine): return l instead of l->next + (redrawLineImage): ditto + * file.c (loadFile): read header even if skip header + (loadGeneralFile): read header even if skip header + * fm.h (SkipHeader): added + * main.c (main): check whether reading from stdin + SkipHeader + 2003-01-10 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> * [w3m-dev 03619] Re: Error occured while reset diff --git a/buffer.c b/buffer.c @@ -530,9 +530,9 @@ reshapeBuffer(Buffer *buf) UseContentCharset = FALSE; UseAutoDetect = FALSE; #endif - if (buf->search_header && buf->currentURL.scheme == SCM_LOCAL) { - if (buf->header_source && (buf->mailcap_source || - !strcmp(buf->currentURL.file, "-"))) { + if (buf->header_source) { + if (buf->currentURL.scheme != SCM_LOCAL || + buf->mailcap_source || !strcmp(buf->currentURL.file, "-")) { URLFile h; init_stream(&h, SCM_LOCAL, NULL); examineFile(buf->header_source, &h); @@ -540,8 +540,8 @@ reshapeBuffer(Buffer *buf) readHeader(&h, buf, TRUE, NULL); UFclose(&h); } - } - else + } + else if (buf->search_header) /* -m option */ readHeader(&f, buf, TRUE, NULL); } diff --git a/display.c b/display.c @@ -561,7 +561,7 @@ drawAnchorCursor(Buffer *buf) static void redrawNLine(Buffer *buf, int n) { - Line *l, *l0; + Line *l; int i; #ifdef USE_COLOR @@ -616,19 +616,13 @@ redrawNLine(Buffer *buf, int n) for (i = 0; i < COLS; i++) addch('~'); } - for (i = 0, l = buf->topLine; i < buf->LINES; i++) { + for (i = 0, l = buf->topLine; i < buf->LINES; i++, l = l->next) { if (i >= buf->LINES - n || i < -n) - l0 = redrawLine(buf, l, i + buf->rootY); - else { - l0 = (l) ? l->next : NULL; - } - if (l0 == NULL && l == NULL) + l = redrawLine(buf, l, i + buf->rootY); + if (l == NULL) break; - l = l0; } if (n > 0) { - if (i == 0 && buf->topLine != NULL) - i++; move(i + buf->rootY, 0); clrtobotx(); } @@ -637,15 +631,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 < buf->LINES; i++) { + for (i = 0, l = buf->topLine; i < buf->LINES && l; i++, l = l->next) { if (i >= buf->LINES - n || i < -n) - l0 = redrawLineImage(buf, l, i + buf->rootY); - else { - l0 = (l) ? l->next : NULL; - } - if (l0 == NULL && l == NULL) - break; - l = l0; + redrawLineImage(buf, l, i + buf->rootY); } getAllImage(buf); #endif @@ -702,7 +690,7 @@ redrawLine(Buffer *buf, Line *l, int i) l->width = COLPOS(l, l->len); if (l->len == 0 || l->width - 1 < column) { clrtoeolx(); - return l->next; + return l; } /* need_clrtoeol(); */ pos = columnPos(l, column); @@ -818,7 +806,7 @@ redrawLine(Buffer *buf, Line *l, int i) #endif if (rcol - column < buf->COLS) clrtoeolx(); - return l->next; + return l; } #ifdef USE_IMAGE @@ -835,7 +823,7 @@ redrawLineImage(Buffer *buf, Line *l, int i) if (l->width < 0) l->width = COLPOS(l, l->len); if (l->len == 0 || l->width - 1 < column) - return l->next; + return l; pos = columnPos(l, column); rcol = COLPOS(l, pos); for (j = 0; rcol - column < buf->COLS && pos + j < l->len; j++) { @@ -888,7 +876,7 @@ redrawLineImage(Buffer *buf, Line *l, int i) } rcol = COLPOS(l, pos + j + 1); } - return l->next; + return l; } #endif diff --git a/file.c b/file.c @@ -472,16 +472,20 @@ convertLine(URLFile *uf, Str line, char *code, int mode) Buffer * loadFile(char *path) { + Buffer *buf; URLFile uf; init_stream(&uf, SCM_LOCAL, NULL); examineFile(path, &uf); if (uf.stream == NULL) return NULL; + buf = newBuffer(INIT_BUFFER_WIDTH); + if (SkipHeader) + readHeader(&uf, buf, TRUE, NULL); current_content_length = 0; #ifdef JP_CHARSET content_charset = '\0'; #endif - return loadSomething(&uf, path, loadBuffer, NULL); + return loadSomething(&uf, path, loadBuffer, buf); } int @@ -1907,6 +1911,10 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, if (f.guess_type) t = f.guess_type; } + if (SkipHeader) { + t_buf = newBuffer(INIT_BUFFER_WIDTH); + readHeader(&f, t_buf, TRUE, NULL); + } if (real_type == NULL) real_type = t; proc = loadBuffer; diff --git a/fm.h b/fm.h @@ -765,6 +765,7 @@ global char InnerCode init(CODE_INNER_EUC); /* use EUC-JP internally; do not cha #endif /* JP_CHARSET */ global char SearchHeader init(FALSE); +global char SkipHeader init(FALSE); global char *DefaultType init(NULL); global char RenderFrame init(FALSE); global char TargetSelf init(FALSE); diff --git a/main.c b/main.c @@ -886,7 +886,8 @@ main(int argc, char **argv, char **envp) } else if (newbuf == NO_BUFFER) continue; - newbuf->search_header = search_header; + if (newbuf->pagerSource || strcmp(newbuf->currentURL.file, "-")) + newbuf->search_header = search_header; if (CurrentTab == NULL) { FirstTab = LastTab = CurrentTab = newTab(); nTab = 1; @@ -4409,12 +4410,15 @@ vwSrc(void) char old_code = DocumentCode; DocumentCode = Currentbuf->document_code; #endif + SkipHeader = Currentbuf->search_header; buf = loadFile(fn); #ifdef JP_CHARSET DocumentCode = old_code; #endif + SkipHeader = FALSE; if (buf == NULL) return; + buf->search_header = Currentbuf->search_header; buf->type = "text/plain"; if (Currentbuf->real_type && !strcasecmp(Currentbuf->real_type, "text/html")) @@ -4427,11 +4431,14 @@ vwSrc(void) Currentbuf->linkBuffer[LB_SOURCE] = buf; } else if (!strcasecmp(Currentbuf->type, "text/plain")) { + SkipHeader = Currentbuf->search_header; DefaultType = "text/html"; buf = loadGeneralFile(file_to_url(fn), NULL, NO_REFERER, 0, NULL); + SkipHeader = FALSE; DefaultType = NULL; if (buf == NULL || buf == NO_BUFFER) return; + buf->search_header = Currentbuf->search_header; if (Currentbuf->real_type && !strcasecmp(Currentbuf->real_type, "text/plain")) buf->real_type = "text/html";