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

version» Context lines:

pike.git/lib/modules/Stdio.pmod/Readline.pmod:1: - // $Id: Readline.pmod,v 1.1 1999/03/13 01:12:37 marcus Exp $ + // $Id: Readline.pmod,v 1.2 1999/03/14 01:33:20 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.pmod:638:    {    _readline = readline;    set_default_bindings();    }      }      class History   {    static private array(string) historylist; +  static private mapping(int:string) historykeep;    static private int minhistory, maxhistory, historynum;       int get_history_num()    {    return historynum;    }       string history(int n, string text)    {    if (n<minhistory)    n = minhistory;    else if (n-minhistory>=sizeof(historylist))    n = sizeof(historylist)+minhistory-1; -  +  if(text != historylist[historynum-minhistory]) { +  if(!historykeep[historynum]) +  historykeep[historynum] = historylist[historynum-minhistory];    historylist[historynum-minhistory]=text; -  +  }    return historylist[(historynum=n)-minhistory];    }       void initline()    {    if (sizeof(historylist)==0 || historylist[-1]!="") {    historylist += ({ "" });    if (maxhistory && sizeof(historylist)>maxhistory)    {    int n = sizeof(historylist)-maxhistory;    historylist = historylist[n..];    minhistory += n;    }    }    historynum = sizeof(historylist)-1+minhistory; -  +  historykeep = ([]);    }       void finishline(string text)    { -  historylist[historynum-minhistory]=text; +  foreach(indices(historykeep), int n) +  historylist[n-minhistory]=historykeep[n]; +  historykeep = 0; +  historylist[-1] = text; +  if(sizeof(historylist)>1 && historylist[-2]==historylist[-1]) +  historylist = historylist[..sizeof(historylist)-2];    }       void set_max_history(int maxhist)    {    maxhistory = maxhist;    }       void create(int maxhist)    {    historylist = ({ "" });