[w3m-dev 01170] Re: cursor position after RELOAD, EDIT

From: Hironori Sakamoto (hsaka@mth.biglobe.ne.jp)
Date: Thu Oct 12 2000 - 09:12:50 CDT

  • Next message: Okabe Katsuya: "[w3m-dev 01171] environment variable MAN_PN and buffer name"

    $B:dK\$G$9!#(B

    >> $B$G$b!"$J$s$+(B clear_buffer=1 $B$G(B RELOAD $B$d(B EDIT $B$H(B VIEW_SOURCE $B$r(B
    >> $BAH$_9g$o$;$F;H$&$H(B cache $B%U%!%$%k$,;D$k$3$H$,$"$kMM$G$9!#(B
    >> buf->clone $B$NLdBj$+$J$H$b;W$$$^$9$,!"$A$g$C$H9M$($F$_$^$9!#(B
    $B=$@5$7$^$7$?!#(B($B;W$C$?DL$j$G$7$?(B)

    $B$=$NB>(B
    $B!&%G%#%l%/%H%j%j%9%H$N(B URL $B$,(B /$LIB/dirlis.cgi$B!D(B $B$H3J9%0-$+$C$?$N$G!"(B
      $B85$N%G%#%l%/%H%j$=$N$b$N$K$J$k$h$&$K$7$^$7$?!#(B
      dirlist.in $B$rJQ99$7$F$$$^$9$N$G!"(Bconfigure $B$r:F<B9T$9$k$+!"(B
      cp dirlist.in dirlist.cgi $B$H$7$F(B @PERL@ $B$H(B @CYGWIN@ $B$r=q$-49$($F$/$@$5$$!#(B
    $B!&(Bkeymap $B$G0z?t$r5-=R$G$-$k3HD%$r0J2<$N4X?t$KE,MQ$7$^$7$?!#(B
      LOAD $B!D(B $B%U%!%$%kL>(B
      EXTERN, EXTERN_LINK $B!D(B $B30It%V%i%&%6L>(B
        (w3m-control: $B$+$i$O;H$($^$;$s(B)
      EXEC_SHELL, READ_SHELL, PIPE_SHELL $B!D(B shell$B%3%^%s%I(B
        (w3m-control: $B$+$i$O;H$($^$;$s(B)
      SAVE, SAVE_IMAGE, SAVE_LINK, SAVE_SCREEN $B!D(B $B%U%!%$%kL>(B(pipe $B%3%^%s%I(B)
        (w3m-control: $B$+$i$O;H$($^$;$s(B)

      $BM-MQ$=$&$JNc(B
        # $B%W%j%s%H(B
        keymap P SAVE_SCREEN "| a2ps | lpr"
        # $BJL(B Window $B$GI=<((B(2 ESC-M $B$NBeMQ(B)
        keymap C-w EXTERN_LINK "kterm -e w3m %s &"
        # local-CGI
        keymap x LOAD "file:/cgi-bin/w3mmine.cgi"

      $BG$0U$N%3%^%s%I<B9T$,2DG=$J$b$N$O(B w3m-control: $B$+$i$O;H$($J$$$h$&$K(B
      $B$7$F$"$j$^$9$,!"$I$&$7$^$7$g$&$+!#(B
      local CGI $B$N<B9T$r5v$90J>e!"5v$7$F$bLdBj$J$$MM$K$b;W$$$^$9$,!#(B
    ----------------------------------
    $B:dK\(B $B9@B'(B <hsaka@mth.biglobe.ne.jp>
     http://www2u.biglobe.ne.jp/~hsaka/

    diff -u buffer.c.orig buffer.c
    --- buffer.c.orig Sat Oct 7 18:04:05 2000
    +++ buffer.c Wed Oct 11 22:20:44 2000
    @@ -83,6 +83,8 @@
                 continue;
             b->linkBuffer[REV_LB[i]] = NULL;
         }
    + if (buf->savecache)
    + unlink(buf->savecache);
         if (--(*buf->clone))
             return;
         if (buf->pagerSource) {
    @@ -99,8 +101,6 @@
             deleteFrameSet(buf->frameset);
             buf->frameset = popFrameTree(&(buf->frameQ), NULL, NULL);
         }
    - if (buf->savecache)
    - unlink(buf->savecache);
     }
     
     /*
    diff -u main.c.orig main.c
    --- main.c.orig Wed Oct 11 22:20:28 2000
    +++ main.c Wed Oct 11 23:42:10 2000
    @@ -68,6 +68,7 @@
     
     #define PREC_NUM (prec_num ? prec_num : 1)
     #define PREC_LIMIT 10000
    +static int searchKeyNum(void);
     
     #include "gcmain.c"
     
    @@ -1144,10 +1145,14 @@
         Buffer *buf;
         char *cmd;
     
    - cmd = inputLineHist("(read shell[pipe])!", "", IN_COMMAND, ShellHist);
    + CurrentKeyData = NULL; /* not allowed in w3m-control: */
    + cmd = searchKeyData();
         if (cmd == NULL || *cmd == '\0') {
    - displayBuffer(Currentbuf, B_NORMAL);
    - return;
    + cmd = inputLineHist("(read shell[pipe])!", "", IN_COMMAND, ShellHist);
    + if (cmd == NULL || *cmd == '\0') {
    + displayBuffer(Currentbuf, B_NORMAL);
    + return;
    + }
         }
         buf = getpipe(cmd);
         if (buf == NULL) {
    @@ -1170,10 +1175,14 @@
         MySignalHandler(*prevtrap) ();
         char *cmd;
     
    - cmd = inputLineHist("(read shell)!", "", IN_COMMAND, ShellHist);
    + CurrentKeyData = NULL; /* not allowed in w3m-control: */
    + cmd = searchKeyData();
         if (cmd == NULL || *cmd == '\0') {
    - displayBuffer(Currentbuf, B_NORMAL);
    - return;
    + cmd = inputLineHist("(read shell)!", "", IN_COMMAND, ShellHist);
    + if (cmd == NULL || *cmd == '\0') {
    + displayBuffer(Currentbuf, B_NORMAL);
    + return;
    + }
         }
         prevtrap = signal(SIGINT, intTrap);
         crmode();
    @@ -1200,7 +1209,12 @@
         int use_m = use_mouse;
     #endif
         char *cmd;
    - cmd = inputLineHist("(exec shell)!", "", IN_COMMAND, ShellHist);
    +
    + CurrentKeyData = NULL; /* not allowed in w3m-control: */
    + cmd = searchKeyData();
    + if (cmd == NULL || *cmd == '\0') {
    + cmd = inputLineHist("(exec shell)!", "", IN_COMMAND, ShellHist);
    + }
         if (cmd != NULL && *cmd != '\0') {
             fmTerm();
             system(cmd);
    @@ -1226,10 +1240,13 @@
     {
         char *fn;
     
    - fn = inputFilenameHist("(Load)Filename? ", NULL, LoadHist);
    + fn = searchKeyData();
         if (fn == NULL || *fn == '\0') {
    - displayBuffer(Currentbuf, B_NORMAL);
    - return;
    + fn = inputFilenameHist("(Load)Filename? ", NULL, LoadHist);
    + if (fn == NULL || *fn == '\0') {
    + displayBuffer(Currentbuf, B_NORMAL);
    + return;
    + }
         }
         cmd_loadfile(fn);
     }
    @@ -2902,6 +2919,7 @@
     void
     svA(void)
     {
    + CurrentKeyData = NULL; /* not allowed in w3m-control: */
         do_download = TRUE;
         followA();
         do_download = FALSE;
    @@ -2911,6 +2929,7 @@
     void
     svI(void)
     {
    + CurrentKeyData = NULL; /* not allowed in w3m-control: */
         do_download = TRUE;
         followI();
         do_download = FALSE;
    @@ -2924,10 +2943,14 @@
         FILE *f;
         int is_pipe;
     
    - file = inputLineHist("Save buffer to: ", NULL, IN_COMMAND, SaveHist);
    + CurrentKeyData = NULL; /* not allowed in w3m-control: */
    + file = searchKeyData();
         if (file == NULL || *file == '\0') {
    - displayBuffer(Currentbuf, B_FORCE_REDRAW);
    - return;
    + file = inputLineHist("Save buffer to: ", NULL, IN_COMMAND, SaveHist);
    + if (file == NULL || *file == '\0') {
    + displayBuffer(Currentbuf, B_FORCE_REDRAW);
    + return;
    + }
         }
         if (*file == '|') {
             is_pipe = TRUE;
    @@ -2958,6 +2981,7 @@
     {
         if (Currentbuf->sourcefile == NULL)
             return;
    + CurrentKeyData = NULL; /* not allowed in w3m-control: */
         PermitSaveToPipe = TRUE;
         doFileCopy(Currentbuf->sourcefile,
                    guess_save_name(Currentbuf->currentURL.file));
    @@ -3275,22 +3299,26 @@
         char *browser = NULL;
         int bg = 0;
     
    - switch (prec_num) {
    - case 0:
    - case 1:
    - browser = ExtBrowser;
    - break;
    - case 2:
    - browser = ExtBrowser2;
    - break;
    - case 3:
    - browser = ExtBrowser3;
    - break;
    - }
    + CurrentKeyData = NULL; /* not allowed in w3m-control: */
    + browser = searchKeyData();
         if (browser == NULL || *browser == '\0') {
    - browser = inputStr("Browse command: ", NULL);
    - if (browser == NULL || *browser == '\0')
    - return;
    + switch (prec_num) {
    + case 0:
    + case 1:
    + browser = ExtBrowser;
    + break;
    + case 2:
    + browser = ExtBrowser2;
    + break;
    + case 3:
    + browser = ExtBrowser3;
    + break;
    + }
    + if (browser == NULL || *browser == '\0') {
    + browser = inputStr("Browse command: ", NULL);
    + if (browser == NULL || *browser == '\0')
    + return;
    + }
         }
         url = quoteShell(url)->ptr;
         if (strcasestr(browser, "%s")) {
    @@ -3650,16 +3678,28 @@
     #endif /* DICT */
     
     char *
    -searchKeyData()
    +searchKeyData(void)
     {
         KeyListItem *item;
     
    - if (CurrentKeyData != NULL && CurrentKeyData != '\0')
    - return CurrentKeyData;
    + if (CurrentKeyData != NULL && *CurrentKeyData != '\0')
    + return allocStr(CurrentKeyData, 0);
         if (CurrentKey < 0)
             return NULL;
         item = searchKeyList(&w3mKeyList, CurrentKey);
         if (item == NULL || item->data == NULL || *item->data == '\0')
             return NULL;
    - return item->data;
    + return allocStr(item->data, 0);
    +}
    +
    +static int
    +searchKeyNum(void)
    +{
    + char *d;
    + int n = 1;
    +
    + d = searchKeyData();
    + if (d != NULL)
    + n = atoi(d);
    + return n * PREC_NUM;
     }
    diff -u file.c.orig file.c
    --- file.c.orig Wed Oct 11 23:22:05 2000
    +++ file.c Wed Oct 11 23:16:12 2000
    @@ -877,7 +877,12 @@
                                            pu.file,
                                            "#current",
                                            NULL);
    - return loadGeneralFile(tmp->ptr, NULL, NO_REFERER, 0, NULL);
    + b = loadGeneralFile(tmp->ptr, NULL, NO_REFERER, 0, NULL);
    + if (b != NULL) {
    + copyParsedURL(&b->currentURL, &pu);
    + b->filename = b->currentURL.file;
    + }
    + return b;
                         }
                         else {
                             b = dirBuffer(pu.file);
    @@ -5609,12 +5614,16 @@
     doFileCopy(char *tmpf, char *defstr)
     {
         char filen[256], msg[LINELEN];
    - char *p;
    + char *p, *q;
     
         if (fmInitialized) {
    - p = inputLineHist("(Download)Save file to: ", defstr, IN_COMMAND, SaveHist);
    - if (p == NULL)
    - return;
    + p = searchKeyData();
    + if (p == NULL || *p == '\0') {
    + p = inputLineHist("(Download)Save file to: ",
    + defstr, IN_COMMAND, SaveHist);
    + if (p == NULL || *p == '\0')
    + return;
    + }
             if (*p != '|' || !PermitSaveToPipe) {
                 p = expandName(p);
                 if (checkOverWrite(p) < 0)
    @@ -5631,16 +5640,20 @@
             }
         }
         else {
    - printf("(Download)Save file to: ");
    - fflush(stdout);
    - p = fgets(filen, sizeof(filen), stdin);
    - if (p == NULL || *filen == '\0')
    - return;
    - for (p = filen + strlen(filen) - 1; IS_SPACE(*p); p--);
    + q = searchKeyData();
    + if (q == NULL || *q == '\0') {
    + printf("(Download)Save file to: ");
    + fflush(stdout);
    + p = fgets(filen, sizeof(filen), stdin);
    + if (p == NULL || filen[0] == '\0')
    + return;
    + q = filen;
    + }
    + for (p = q + strlen(q) - 1; IS_SPACE(*p); p--);
             *(p + 1) = '\0';
    - if (*filen == '\0')
    + if (*q == '\0')
                 return;
    - p = filen;
    + p = q;
             if (*p != '|' || !PermitSaveToPipe) {
                 p = expandName(p);
                 if (checkOverWrite(p) < 0)
    @@ -5667,11 +5680,15 @@
     doFileSave(URLFile uf, char *defstr)
     {
         char filen[256], msg[LINELEN];
    - char *p;
    + char *p, *q;
         if (fmInitialized) {
    - p = inputLineHist("(Download)Save file to: ", defstr, IN_FILENAME, SaveHist);
    - if (p == NULL || *p == '\0')
    - return;
    + p = searchKeyData();
    + if (p == NULL || *p == '\0') {
    + p = inputLineHist("(Download)Save file to: ",
    + defstr, IN_FILENAME, SaveHist);
    + if (p == NULL || *p == '\0')
    + return;
    + }
             if (checkOverWrite(p) < 0)
                 return;
             if (checkSaveFile(uf.stream.f, p) < 0) {
    @@ -5685,16 +5702,20 @@
             }
         }
         else {
    - printf("(Download)Save file to: ");
    - fflush(stdout);
    - p = fgets(filen, sizeof(filen), stdin);
    - if (p == NULL || *filen == '\0')
    - return;
    - for (p = filen + strlen(filen) - 1; IS_SPACE(*p); p--);
    + q = searchKeyData();
    + if (q == NULL || *q == '\0') {
    + printf("(Download)Save file to: ");
    + fflush(stdout);
    + p = fgets(filen, sizeof(filen), stdin);
    + if (p == NULL || filen[0] == '\0')
    + return;
    + q = filen;
    + }
    + for (p = q + strlen(q) - 1; IS_SPACE(*p); p--);
             *(p + 1) = '\0';
    - if (*filen == '\0')
    + if (*q == '\0')
                 return;
    - p = expandName(filen);
    + p = expandName(q);
             if (checkOverWrite(p) < 0)
                 return;
             if (checkSaveFile(uf.stream.f, p) < 0) {
    diff -u proto.h.orig proto.h
    --- proto.h.orig Wed Oct 11 22:20:29 2000
    +++ proto.h Wed Oct 11 22:20:43 2000
    @@ -458,7 +458,7 @@
     #define msToggle nulcmd
     #endif /* not MOUSE */
     
    -extern char *searchKeyData();
    +extern char *searchKeyData(void);
     
     extern void initKeymap(void);
     extern int countFuncList(FuncList * list);
    diff -u scripts/dirlist.in.orig scripts/dirlist.in
    --- scripts/dirlist.in.orig Wed Oct 11 22:21:30 2000
    +++ scripts/dirlist.in Wed Oct 11 22:21:33 2000
    @@ -8,11 +8,10 @@
     
     $RC_DIR =~ s@^~/@$ENV{'HOME'}/@;
     $CONFIG = "$RC_DIR/dirlist";
    -$BASE = "file:$0";
    -($CGI = $0) =~ s@.*/@@;
    -$CGI = &html_quote(&form_encode($CGI));
    +$CGI = $ENV{'SCRIPT_NAME'} || $0;
    +$CGI = &html_quote(&form_encode("file:$CGI"));
     
    -$AFMT = '<a href="%s">%s</a>';
    +$AFMT = '<a href="%s"><nobr>%s</nobr></a>';
     $NOW = time();
     
     @OPT = &init_option($CONFIG);
    @@ -94,7 +93,6 @@
     
     <html>
     <head>
    -<base url="$BASE">
     <title>Directory list of $qdir</title>
     </head>
     <body>
    @@ -123,7 +121,7 @@
       } else {
         $n = '';
       }
    - printf("$AFMT\n", "$CGI?dir=$e#current$n", "<b>$q</b>");
    + printf("$AFMT\n", "$q$n", "<b>$q</b>");
       $N = 0;
       $SKIPLINE = "";
     
    @@ -191,11 +189,11 @@
           } else {
             $n = '';
           }
    - printf("${pre}o-$AFMT\n", "$CGI?dir=$edir$e#current$n", "<b>$q</b>");
    + printf("${pre}o-$AFMT\n", "$qdir$q$n", "<b>$q</b>");
           &left_dir(@cdirs ? "$pre| " : "$pre ", $d, @sdirs);
           $ok = 1;
         } else {
    - printf("${pre}+-$AFMT\n", "$CGI?dir=$edir$e#current", $q);
    + printf("${pre}+-$AFMT\n", "$qdir$q", $q);
         }
       }
     }
    @@ -281,7 +279,7 @@
             print "<td>";
           }
           if (-d $f) {
    - printf($AFMT, "$CGI?dir=$edir$e#current", "$q/");
    + printf($AFMT, "$qdir$q", "$q/");
           } else {
             printf($AFMT, "$qdir$q", $q);
           }
    @@ -301,7 +299,7 @@
         $e = &html_quote(&form_encode($_));
         print $prints{$_};
         if (-d $f) {
    - printf($AFMT, "$CGI?dir=$edir$e#current", "$q/");
    + printf($AFMT, "$qdir$q", "$q/");
         } else {
           printf($AFMT, "$qdir$q", $q);
         }



    This archive was generated by hypermail 2b29 : Thu Oct 12 2000 - 09:22:44 CDT