pike.git / lib / modules / Stdio.pmod / Readline.pike

version» Context lines:

pike.git/lib/modules/Stdio.pmod/Readline.pike:1: - // $Id: Readline.pike,v 1.19 1999/06/09 16:23:31 marcus Exp $ + // $Id: Readline.pike,v 1.20 1999/06/09 17:34:32 marcus Exp $      class OutputController   {    static private object outfd, term;    static private int xpos = 0, columns = 0;    static private mapping oldattrs = 0;       void disable()    {    catch{
pike.git/lib/modules/Stdio.pmod/Readline.pike:48:    return columns;    }       static string escapify(string s, void|int hide)    {   #if 1    s=replace(s,    ({    "\000","\001","\002","\003","\004","\005","\006","\007",    "\010","\011","\012","\013","\014","\015","\016","\017", +  "\020","\021","\022","\023","\024","\025","\026","\027", +  "\030","\031","\032","\033","\034","\035","\036","\037",    "\177",    "\200","\201","\202","\203","\204","\205","\206","\207",    "\210","\211","\212","\213","\214","\215","\216","\217",    "\220","\221","\222","\223","\224","\225","\226","\227",    "\230","\231","\232","\233","\234","\235","\236","\237",    }),    ({    "^@","^A","^B","^C","^D","^E","^F","^G",    "^H","^I","^J","^K","^L","^M","^N","^O", -  +  "^P","^Q","^R","^S","^T","^U","^V","^W", +  "^X","^Y","^Z","^[","^\\","^]","^^","^_",    "^?",    "~@","~A","~B","~C","~D","~E","~F","~G",    "~H","~I","~J","~K","~L","~M","~N","~O",    "~P","~Q","~R","~S","~T","~U","~V","~W",    "~X","~Y","~Z","~[","~\\","~]","~^","~_",    }));    return hide ? "*"*strlen(s) : s;   #else       for(int i=0; i<strlen(s); i++)
pike.git/lib/modules/Stdio.pmod/Readline.pike:88:    static int width(string s)    {    return strlen(s);    }       static int escapified_width(string s)    {    return width(escapify(s));    }    -  void low_write(string s, void|int opt, void|int word_break) +  void low_write(string s, void|int word_break)    {    int n = width(s);    if(!n)    return;      // werror("low_write(%O)\n",s);       if(word_break)    {    while(xpos+n>=columns)
pike.git/lib/modules/Stdio.pmod/Readline.pike:131:    int l = columns-xpos;    outfd->write(s[..l-1]);    s=s[l..];    n-=l;    xpos = 0;    if(!term->tgetflag("am"))    outfd->write((term->put("cr")||"")+(term->put("do")||"\n"));    }    }    string le; -  if(!opt && xpos==0 && term->tgetflag("am") && (le=term->put("le"))) -  outfd->write(" "+le); +     if(n>0) {    outfd->write(s);    xpos += n; -  +  } else if(xpos==0 && term->tgetflag("am") && (le=term->put("le"))) +  outfd->write(" "+le);    } -  } +     -  void write(string s,void|int opt, void|int word_break,void|int hide) +  void write(string s,void|int word_break,void|int hide)    { -  low_write(escapify(s,hide),opt,word_break); +  low_write(escapify(s,hide),word_break);    }       void low_move_downward(int n)    {    if(n<=0)    return;    outfd->write(term->put("DO", n) || (term->put("do")||"")*n);    }       void low_move_upward(int n)
pike.git/lib/modules/Stdio.pmod/Readline.pike:1041:    return mark;   }      void insert(string s, int p)   {    if (p<0)    p = 0;    if (p>strlen(text))    p = strlen(text);    setcursorpos(p); -  output_controller->write(s,0,0,hide); +  output_controller->write(s,0,hide);    cursorpos += strlen(s);    string rest = text[p..];    if (strlen(rest))    { -  output_controller->write(rest,0,0,hide); +  output_controller->write(rest,0,hide);    output_controller->move_backward(rest);    }    text = text[..p-1]+s+rest;       if (mark>p) mark+=strlen(s);   }      void delete(int p1, int p2)   {    if (p1<0)    p1 = 0;    if (p2>strlen(text))    p2 = strlen(text);    setcursorpos(p1);    if (p1>=p2)    return; -  output_controller->write(text[p2..],0,0,hide); +  output_controller->write(text[p2..],0,hide);    output_controller->erase(text[p1..p2-1]);    text = text[..p1-1]+text[p2..];       if (mark>p2) mark-=(p2-p1);    else if (mark>p1) mark=p1;       cursorpos = strlen(text);    setcursorpos(p1);   }   
pike.git/lib/modules/Stdio.pmod/Readline.pike:1144:    else if(!nobackup) {    setcursorpos(0);    output_controller->bol();    output_controller->clear(1);    }    output_controller->check_columns();      // This seems like a silly limitation   // if(newline_func == read_newline)    output_controller->write(prompt); -  output_controller->write(text,0,0,hide); +  output_controller->write(text,0,hide);    cursorpos = sizeof(text);    setcursorpos(p);   }      static private void initline()   {    text = "";    cursorpos = 0;    if (historyobj)    historyobj->initline();
pike.git/lib/modules/Stdio.pmod/Readline.pike:1201:      void write(string msg,void|int word_wrap)   {    int p = cursorpos;    setcursorpos(0);    output_controller->bol();    output_controller->clear(1);    array(string) tmp=msg/"\n";    foreach(tmp[..sizeof(tmp)-2],string l)    { -  output_controller->write(l,1,word_wrap); +  output_controller->write(l,word_wrap);    output_controller->newline();    } -  output_controller->write(tmp[-1],0,word_wrap); +  output_controller->write(tmp[-1],word_wrap);       cursorpos=strlen(text);    redisplay(0, 1);    setcursorpos(p);   }      void list_completions(array(string) c)   {    message(sprintf("%-*#s",output_controller->get_number_of_columns(),    c*"\n"));