[w3m-dev 01211] Re: a small change to linein.c

From: Hironori Sakamoto (h-saka@lsi.nec.co.jp)
Date: Wed Oct 18 2000 - 00:01:12 CDT

  • Next message: $B2,ED: "[w3m-dev 01212] Re: a small change to linein.c"

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

    >> $B2,ED$G$9!#(B
    >> history $B$NMzNr$rC)$k$H$-$K!"0lEYD9$$(B URL $B$,I=<($5$l$k$H!"(BC-n $B$d(B C-p $B$@(B
    >> $B$1$G$O$=$N8e$NC;$$(B URL $B$,A4ItI=<($5$l$J$$$N$G!"0J2<$N%Q%C%A$N$h$&$KJQ(B
    >> $B99$7$F$_$^$7$?!#$$$+$,$G$7$g$&$+!)(B

    $B<+J,$G$=$&$7$F$*$-$J$,$i!";d$b5$$K$J$C$F$$$^$7$?!#(B($B$8$c$"D>$;!d<+J,(B)
    $B$?$@!"(B

    >> - if (CPos - offset < 10)
    >> - offset = (CPos > 10) ? (CPos - 10) : 0;
    >> + if (CPos - offset < COLS)
    >> + offset = (CPos > COLS) ? (CPos - COLS) : 0;

    $B$@$HD9$$J8;zNs$NJT=8$G$A$g$C$H8+$:$i$$$N$G!"0J2<$NMM$J$N$G$I$&$G$7$g$&$+!#(B
    # $B$$$^$$$A1x$$!D(B
    -----------------------------------
    $B:dK\(B $B9@B'(B <hsaka@mth.biglobe.ne.jp>
     http://www2u.biglobe.ne.jp/~hsaka/

    --- linein.c.orig Wed Oct 18 13:38:45 2000
    +++ linein.c Wed Oct 18 13:47:12 2000
    @@ -19,6 +19,7 @@
     #endif
     
     #define STR_LEN 1024
    +#define CLEN (COLS - 2)
     
     static Str strBuf;
     static Lineprop strProp[STR_LEN];
    @@ -58,7 +59,7 @@
     
     static void setStrType(Str str, Lineprop * prop);
     
    -static int CPos, CLen;
    +static int CPos, CLen, offset;
     static int i_cont, i_broken, i_quote;
     static int cm_mode, cm_next, cm_clear;
     
    @@ -69,7 +70,7 @@
     char *
     inputLineHist(char *prompt, char *def_str, int flag, Hist * hist)
     {
    - int i, opos, offset, x;
    + int i, opos, x, cpos;
         char c, *p;
         int redrawOK;
         Lineprop mode;
    @@ -96,6 +97,9 @@
         else
             cm_mode = CPL_OFF;
         opos = strlen(prompt);
    + cpos = (CLEN - opos) / 2;
    + if (cpos < 0)
    + cpos = 0;
         move(LASTLINE, 0);
         addstr(prompt);
         strBuf = Strnew();
    @@ -219,19 +223,19 @@
                 mode = PC_ASCII;
             }
             if (redrawOK) {
    - if (CPos - offset < 10)
    - offset = (CPos > 10) ? (CPos - 10) : 0;
    + if (CPos - offset < cpos)
    + offset = (CPos > cpos) ? (CPos - cpos) : 0;
                 if (flag & IN_PASSWORD) {
                     x = opos + (offset > 0) + CPos - offset;
    - if (x > COLS - 2) {
    - offset = opos + 1 + CPos - COLS + 2;
    - x = COLS - 2;
    + if (x > CLEN) {
    + offset = opos + 1 + CPos - CLEN;
    + x = CLEN;
                     }
                 }
                 else {
                     x = calcPosition(&strBuf->ptr[offset], CPos - offset, opos + (offset > 0), CP_FORCE);
    - while (x > COLS - 2) {
    - offset += x - COLS + 2;
    + while (x > CLEN) {
    + offset += x - CLEN;
                         if (offset >= CPos)
                             offset = CPos - 1;
                         x = calcPosition(&strBuf->ptr[offset], CPos - offset, opos + 1, CP_FORCE);
    @@ -623,6 +627,8 @@
         strBuf = Strnew_charp(hist->line[hist->position]);
         setStrType(strBuf, strProp);
         CLen = CPos = strBuf->length;
    + if (CPos - offset < CLEN)
    + offset = (CPos > CLEN) ? (CPos - CLEN) : 0;
     }
     
     static void
    @@ -643,6 +649,8 @@
         strBuf = Strnew_charp(hist->line[hist->position]);
         setStrType(strBuf, strProp);
         CLen = CPos = strBuf->length;
    + if (CPos - offset < CLEN)
    + offset = (CPos > CLEN) ? (CPos - CLEN) : 0;
     }
     
     static void



    This archive was generated by hypermail 2b29 : Wed Oct 18 2000 - 00:14:39 CDT