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.26 1999/09/10 16:17:59 noring Exp $ + // $Id: Readline.pike,v 1.27 1999/10/04 00:16:42 js Exp $      class OutputController   {    static private object outfd, term;    static private int xpos = 0, columns = 0;    static private mapping oldattrs = 0;      #define BLINK 1   #define BOLD 2   #define DIM 4
pike.git/lib/modules/Stdio.pmod/Readline.pike:1006:    }      }      class History   {    static private array(string) historylist;    static private mapping(int:string) historykeep=([]);    static private int minhistory, maxhistory, historynum;    +  array(string) encode() +  { +  return historylist; +  } +     int get_history_num()    {    return historynum;    }       string history(int n, string text)    {    if (n<minhistory)    n = minhistory;    else if (n-minhistory>=sizeof(historylist))
pike.git/lib/modules/Stdio.pmod/Readline.pike:1055:    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) +  void create(int maxhist, void|array(string) hist)    { -  historylist = ({ "" }); +  historylist = hist || ({ "" });    minhistory = historynum = 0;    maxhistory = maxhist;    }      }         static private object(OutputController) output_controller;   static private object(InputController) input_controller;   static private string prompt="";   static private string text="", readtext;   static private function(string:void) newline_func;   static private int cursorpos = 0;   static private int mark = 0; - static private object(History) historyobj = 0; + /*static private */ object(History) historyobj = 0;   static private int hide = 0;      static private array(string) kill_ring=({});   static private int kill_ring_size=30;      object(OutputController) get_output_controller()   {    return output_controller;   }   
pike.git/lib/modules/Stdio.pmod/Readline.pike:1401:    }       function oldnl = newline_func;    output_controller->write(local_prompt||prompt);    initline();    newline_func = read_newline;    readtext = "";    output_controller->enable();    insert(data, 0);    int res = input_controller->run_blocking(); +  +     set_nonblocking(oldnl);       if(local_prompt)    set_prompt(old_prompt);       return (res>=0 || sizeof(readtext)) && readtext;   }      string read(string|void prompt)   {    return edit("", prompt);   }    - void enable_history(object(History)|int hist) + void enable_history(array(string)|object(History)|int hist)   {    if (objectp(hist))    historyobj = hist; -  +  else if(arrayp(hist)) +  historyobj = History(512,hist);    else if(!hist)    historyobj = 0;    else if(historyobj)    historyobj->set_max_history(hist);    else    historyobj = History(hist);   }    -  + History get_history() + { +  return historyobj; + } +    void destroy()   {    if(input_controller)    destruct(input_controller);    if(output_controller)    destruct(output_controller);   }      void create(object|void infd, object|string|void interm,    object|void outfd, object|string|void outterm)   {    atexit(destroy);    output_controller = OutputController(outfd || infd, outterm || interm);    input_controller = InputController(infd, interm);    DefaultEditKeys(this_object());   }