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.2 1999/03/15 17:25:16 marcus Exp $ + // $Id: Readline.pike,v 1.3 1999/03/17 23:35:40 marcus Exp $      class OutputController   {    static private object outfd, term;    static private int xpos = 0, columns = 0;       void check_columns()    {    catch {    int c = outfd->tcgetattr()->columns;
pike.git/lib/modules/Stdio.pmod/Readline.pike:48:    int n = width(s);    if(!n)    return;    while(xpos+n>=columns) {    int l = columns-xpos;    outfd->write(s[..l-1]);    s = s[l..];    n -= l;    xpos = 0;    if(!term->tgetflag("am")) -  outfd->write("\r\n"); +  outfd->write((term->put("cr")||"\r")+(term->put("do")||"\n"));    }    if(xpos==0 && term->tgetflag("am")) -  outfd->write(" "+term->put("le")); +  outfd->write(" "+(term->put("le")||"\b"));    if(n>0) {    outfd->write(s);    xpos += n;    }    }       void write(string s)    {    low_write(escapify(s));    }
pike.git/lib/modules/Stdio.pmod/Readline.pike:82:    if(n<=0)    return;    outfd->write(term->put("UP", n) || (term->put("up")||"")*n);    }       void low_move_forward(int n)    {    if(n<=0)    return;    if(xpos+n<columns) { -  outfd->write(term->put("RI", n) || (term->put("ri")||"")*n); +  outfd->write(term->put("RI", n) || (term->put("ri")||" ")*n);    xpos += n;    } else {    int l = (xpos+n)/columns;    low_move_downward(l);    n -= l*columns;    if(n<0)    low_move_backward(-n);    else if(n>0)    low_move_forward(n);    }    }       void low_move_backward(int n)    {    if(n<=0)    return;    if(xpos-n>=0) { -  outfd->write(term->put("LE", n) || (term->put("le")||"")*n); +  outfd->write(term->put("LE", n) || (term->put("le")||"\b")*n);    xpos -= n;    } else {    int l = 1+(n-xpos-1)/columns;    low_move_upward(l);    n -= l*columns;    if(n<0)    low_move_forward(-n);    else if(n>0)    low_move_backward(n);    }
pike.git/lib/modules/Stdio.pmod/Readline.pike:142:    low_move_backward(escapified_width(s));    }       void erase(string s)    {    low_erase(escapified_width(s));    }       void newline()    { -  outfd->write("\r\n"); +  outfd->write((term->put("cr")||"\r")+(term->put("do")||"\n"));    xpos = 0;    }       void bol()    { -  outfd->write("\r"); +  outfd->write(term->put("cr")||"\r");    xpos = 0;    }       void clear(int|void partial)    {    string s;    if(!partial && (s = term->put("cl"))) {    outfd->write(s);    xpos = 0;    return;    }    if(!partial) {    outfd->write(term->put("ho")||term->put("cm", 0, 0)||"\f");    xpos = 0;    } -  outfd->write(term->put("cd")||""); +  outfd->write(term->put("cd")||(partial?"":"\f"));    }       void create(object|void _outfd, object|string|void _term)    {    outfd = _outfd || Stdio.File("stdout");    term = objectp(_term)? _term : .Terminfo.getTerm(_term);    check_columns();    }      }