From 3f25d8f04868a17875fecef8d918cda4f9c3fbbe Mon Sep 17 00:00:00 2001 From: Fumitoshi UKAI Date: Wed, 22 Jan 2003 16:16:18 +0000 Subject: [w3m-dev 03677] view source, edit source * buffer.c (discardBuffer): unlink header source * file.c (loadFile): delete skip header * fm.h (BP_SOURCE): deleted (SkipHeader): deleted * main (editBf): cleanup (vmSrc): cleanup From: Hironori SAKAMOTO --- ChangeLog | 12 +++++++- buffer.c | 4 ++- file.c | 9 +----- fm.h | 4 +-- main.c | 101 +++++++++++--------------------------------------------------- 5 files changed, 34 insertions(+), 96 deletions(-) diff --git a/ChangeLog b/ChangeLog index 77d2151..d695cb0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2003-01-23 Hironori SAKAMOTO + + * [w3m-dev 03677] view source, edit source + * buffer.c (discardBuffer): unlink header source + * file.c (loadFile): delete skip header + * fm.h (BP_SOURCE): deleted + (SkipHeader): deleted + * main (editBf): cleanup + (vmSrc): cleanup + 2003-01-23 Hironori SAKAMOTO * [w3m-dev 03676] cleanup for pipe @@ -6700,4 +6710,4 @@ a * [w3m-dev 03276] compile error on EWS4800 * release-0-2-1 * import w3m-0.2.1 -$Id: ChangeLog,v 1.703 2003/01/22 16:10:27 ukai Exp $ +$Id: ChangeLog,v 1.704 2003/01/22 16:16:18 ukai Exp $ diff --git a/buffer.c b/buffer.c index e64f923..4fbb4fe 100644 --- a/buffer.c +++ b/buffer.c @@ -1,4 +1,4 @@ -/* $Id: buffer.c,v 1.18 2003/01/10 16:11:01 ukai Exp $ */ +/* $Id: buffer.c,v 1.19 2003/01/22 16:16:19 ukai Exp $ */ #include "fm.h" #ifdef USE_MOUSE @@ -102,6 +102,8 @@ discardBuffer(Buffer *buf) if (buf->real_scheme != SCM_LOCAL || buf->bufferprop & BP_FRAME) unlink(buf->sourcefile); } + if (buf->header_source) + unlink(buf->header_source); if (buf->mailcap_source) unlink(buf->mailcap_source); while (buf->frameset) { diff --git a/file.c b/file.c index 99fb8ed..67df9fd 100644 --- a/file.c +++ b/file.c @@ -1,4 +1,4 @@ -/* $Id: file.c,v 1.199 2003/01/22 16:11:03 ukai Exp $ */ +/* $Id: file.c,v 1.200 2003/01/22 16:16:20 ukai Exp $ */ #include "fm.h" #include #include "myctype.h" @@ -497,8 +497,6 @@ loadFile(char *path) 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'; @@ -1955,11 +1953,6 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, if (real_type == NULL) real_type = t; - if (SkipHeader) { - if (t_buf == NULL) - t_buf = newBuffer(INIT_BUFFER_WIDTH); - readHeader(&f, t_buf, TRUE, NULL); - } proc = loadBuffer; #ifdef USE_IMAGE cur_baseURL = New(ParsedURL); diff --git a/fm.h b/fm.h index 222be7f..91c7897 100644 --- a/fm.h +++ b/fm.h @@ -1,4 +1,4 @@ -/* $Id: fm.h,v 1.104 2003/01/20 15:24:19 ukai Exp $ */ +/* $Id: fm.h,v 1.105 2003/01/22 16:16:20 ukai Exp $ */ /* * w3m: WWW wo Miru utility * @@ -172,7 +172,6 @@ void bzero(void *, int); #define BP_NORMAL 0x0 #define BP_PIPE 0x1 #define BP_FRAME 0x2 -#define BP_SOURCE 0x4 #define BP_INTERNAL 0x8 #define BP_NO_URL 0x10 #define BP_REDIRECTED 0x20 @@ -766,7 +765,6 @@ 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 index 094cb0c..c0981bd 100644 --- a/main.c +++ b/main.c @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.196 2003/01/22 15:56:50 ukai Exp $ */ +/* $Id: main.c,v 1.197 2003/01/22 16:16:20 ukai Exp $ */ #define MAINPROGRAM #include "fm.h" #include @@ -2471,10 +2471,6 @@ void editBf(void) { char *fn = Currentbuf->filename; - Buffer *buf, *fbuf = NULL, sbuf; -#ifdef JP_CHARSET - char old_code; -#endif Str cmd; if (fn == NULL || Currentbuf->pagerSource != NULL || /* Behaving as a pager */ @@ -2484,9 +2480,6 @@ editBf(void) disp_err_message("Can't edit other than local file", TRUE); return; } - if (Currentbuf->frameset != NULL) - fbuf = Currentbuf->linkBuffer[LB_FRAME]; - copyBuffer(&sbuf, Currentbuf); if (Currentbuf->edit) cmd = unquote_mailcap(Currentbuf->edit, Currentbuf->real_type, fn, checkHeader(Currentbuf, "Content-Type:"), NULL); @@ -2496,42 +2489,8 @@ editBf(void) system(cmd->ptr); fmInit(); -#ifdef JP_CHARSET - old_code = DocumentCode; - DocumentCode = Currentbuf->document_code; -#endif - SearchHeader = Currentbuf->search_header; - DefaultType = Currentbuf->real_type; - buf = loadGeneralFile(file_to_url(fn), NULL, NO_REFERER, 0, NULL); -#ifdef JP_CHARSET - DocumentCode = old_code; -#endif - SearchHeader = FALSE; - DefaultType = NULL; - - if (buf == NULL) { - disp_err_message("Re-loading failed", FALSE); - buf = nullBuffer(); - } - else if (buf == NO_BUFFER) { - buf = nullBuffer(); - } - if (fbuf != NULL) - Firstbuf = deleteBuffer(Firstbuf, fbuf); - repBuffer(Currentbuf, buf); - if ((buf->type != NULL) && (sbuf.type != NULL) && - ((!strcasecmp(buf->type, "text/plain") && - !strcasecmp(sbuf.type, "text/html")) || - (!strcasecmp(buf->type, "text/html") && - !strcasecmp(sbuf.type, "text/plain")))) { - vwSrc(); - if (Currentbuf != buf) - Firstbuf = deleteBuffer(Firstbuf, buf); - } - Currentbuf->search_header = sbuf.search_header; - if (Currentbuf->firstLine) - restorePosition(Currentbuf, &sbuf); displayBuffer(Currentbuf, B_FORCE_REDRAW); + reload(); } /* Run editor on the current screen */ @@ -4393,7 +4352,6 @@ curURL(void) void vwSrc(void) { - char *fn; Buffer *buf; if (Currentbuf->type == NULL || Currentbuf->bufferprop & BP_FRAME) @@ -4414,78 +4372,55 @@ vwSrc(void) return; saveBuffer(Currentbuf, f); fclose(f); - fn = tmpf->ptr; - Currentbuf->sourcefile = fn; + Currentbuf->sourcefile = tmpf->ptr; } else { return; } } - else if (Currentbuf->real_scheme == SCM_LOCAL && - !(Currentbuf->real_type && - !strcasecmp(Currentbuf->real_type, "local:directory"))) { - fn = Currentbuf->filename; - } - else { - fn = Currentbuf->sourcefile; - } + + buf = newBuffer(INIT_BUFFER_WIDTH); + if (!strcasecmp(Currentbuf->type, "text/html")) { -#ifdef JP_CHARSET - 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")) buf->real_type = "text/plain"; else buf->real_type = Currentbuf->real_type; - buf->bufferprop |= BP_SOURCE; buf->buffername = Sprintf("source of %s", Currentbuf->buffername)->ptr; buf->linkBuffer[LB_N_SOURCE] = Currentbuf; 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; + buf->type = "text/html"; if (Currentbuf->real_type && !strcasecmp(Currentbuf->real_type, "text/plain")) buf->real_type = "text/html"; else buf->real_type = Currentbuf->real_type; - if (!strcmp(buf->buffername, conv_from_system(lastFileName(fn)))) - buf->buffername = - Sprintf("HTML view of %s", Currentbuf->buffername)->ptr; + buf->buffername = Sprintf("HTML view of %s", + Currentbuf->buffername)->ptr; buf->linkBuffer[LB_SOURCE] = Currentbuf; Currentbuf->linkBuffer[LB_N_SOURCE] = buf; -#ifdef USE_IMAGE - if (buf->img) - buf->need_reshape = TRUE; -#endif } else { return; } buf->currentURL = Currentbuf->currentURL; buf->real_scheme = Currentbuf->real_scheme; + buf->filename = Currentbuf->filename; buf->sourcefile = Currentbuf->sourcefile; + buf->header_source = Currentbuf->header_source; + buf->search_header = Currentbuf->search_header; +#ifdef JP_CHARSET + buf->document_code = Currentbuf->document_code; +#endif buf->clone = Currentbuf->clone; (*buf->clone)++; + + buf->need_reshape = TRUE; + reshapeBuffer(buf); pushBuffer(buf); displayBuffer(Currentbuf, B_NORMAL); } -- cgit v1.2.3