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.12 1999/04/25 08:29:28 neotron Exp $ + // $Id: Readline.pike,v 1.13 1999/04/25 15:48:41 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:611:    void transpose_chars()    {    int p = _readline->getcursorpos();    if (p<0 || p>=strlen(_readline->gettext()))    return;    string c = _readline->gettext()[p-1..p];    _readline->delete(p-1, p+1);    _readline->insert(reverse(c), p-1);    }    -  array find_word_to_manipulate() +  static array find_word_to_manipulate()    {    int p = _readline->getcursorpos();    int ep;    string line = _readline->gettext();    while(word_break_chars[ line[p..p] ] && p < strlen(line))    p++;    if(p >= strlen(line)) {    _readline->setcursorpos(p);    return ({ 0, 0 });    }
pike.git/lib/modules/Stdio.pmod/Readline.pike:634:    return ({ line[p..ep-1], p });    }       void capitalize_word()    {    [string word, string pos]= find_word_to_manipulate();    if(word)    _readline->insert(String.capitalize(lower_case(word)), pos);    }    -  void upper_case_word() +  void upcase_word()    {    [string word, string pos]= find_word_to_manipulate();    if(word)    _readline->insert(upper_case(word), pos);    }    -  void lower_case_word() +  void downcase_word()    {    [string word, string pos]= find_word_to_manipulate();    if(word)    _readline->insert(lower_case(word), pos);    }    -  int forward_find_word() +  static int forward_find_word()    {    int p, n;    string line = _readline->gettext();    for(p = _readline->getcursorpos(); p < sizeof(line); p++) {    if(word_break_chars[ line[p..p] ]) {    if(n) break;    } else n = 1;    }    return p;    }    -  int backward_find_word() +  static int backward_find_word()    {    int p = _readline->getcursorpos()-1;    string line = _readline->gettext();    if(p >= strlen(line)) p = strlen(line) - 1;    while(word_break_chars[ line[p..p] ] && p >= 0)    // find first "non break char"    p--;    for(;p >= 0; p--)    if(word_break_chars[ line[p..p] ]) {    p++; // We want to be one char before the break char.
pike.git/lib/modules/Stdio.pmod/Readline.pike:686:    void forward_word()    {    _readline->setcursorpos(forward_find_word());    }       void backward_word()    {    _readline->setcursorpos(backward_find_word());    }    -  void forward_delete_word() +  void delete_word()    {    _readline->delete(_readline->getcursorpos(), forward_find_word());    }       void backward_delete_word()    {    int sp = backward_find_word();    int ep = _readline->getcursorpos();    if((ep - sp) == 0)    sp--;
pike.git/lib/modules/Stdio.pmod/Readline.pike:725:    void clear_screen()    {    _readline->redisplay(1);    }       static array(array(string|function)) default_bindings = ({    ({ "^[[A", up_history }),    ({ "^[[B", down_history }),    ({ "^[[C", forward_char }),    ({ "^[[D", backward_char }), +  ({ "^[C", capitalize_word }), +  ({ "^[c", capitalize_word }), +  ({ "^[U", upcase_word }), +  ({ "^[u", upcase_word }), +  ({ "^[L", downcase_word }), +  ({ "^[l", downcase_word }), +  ({ "^[D", delete_word }), +  ({ "^[^H", backward_delete_word }), +  ({ "^[^?", backward_delete_word }), +  ({ "^[d", delete_word }), +  ({ "^[F", forward_word }), +  ({ "^[B", backward_word }), +  ({ "^[f", forward_word }), +  ({ "^[b", backward_word }),    ({ "^A", beginning_of_line }),    ({ "^B", backward_char }),    ({ "^D", delete_char_or_eof }),    ({ "^E", end_of_line }),    ({ "^F", forward_char }),    ({ "^H", backward_delete_char }),    ({ "^J", newline }),    ({ "^K", kill_line }),    ({ "^L", clear_screen }),    ({ "^M", newline }),
pike.git/lib/modules/Stdio.pmod/Readline.pike:746:    ({ "^P", up_history }),    ({ "^R", redisplay }),    ({ "^T", transpose_chars }),    ({ "^U", kill_whole_line }),    ({ "^V", quoted_insert }),    ({ "^?", backward_delete_char }),    ({ "\\!ku", up_history }),    ({ "\\!kd", down_history }),    ({ "\\!kr", forward_char }),    ({ "\\!kl", backward_char }), -  ({ "^[C", capitalize_word }), -  ({ "^[c", capitalize_word }), -  ({ "^[U", upper_case_word }), -  ({ "^[u", upper_case_word }), -  ({ "^[L", lower_case_word }), -  ({ "^[l", lower_case_word }), -  ({ "^[D", forward_delete_word }), -  ({ "^[^H", backward_delete_word }), -  ({ "^[^?", backward_delete_word }), -  ({ "^[d", forward_delete_word }), -  ({ "^[F", forward_word }), -  ({ "^[B", backward_word }), -  ({ "^[f", forward_word }), -  ({ "^[b", backward_word }), +     });       static void set_default_bindings()    {    object ic = _readline->get_input_controller();    ic->nullbindings();    for(int i=' '; i<'\177'; i++)    ic->bindstr(sprintf("%c", i), self_insert_command);    for(int i='\240'; i<='\377'; i++)    ic->bindstr(sprintf("%c", i), self_insert_command);