Changeset d6bd3f1 for owl.c


Ignore:
Timestamp:
May 4, 2009, 9:55:17 PM (15 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
3a84694
Parents:
adee9cc
git-author:
Nelson Elhage <nelhage@mit.edu> (05/04/09 20:24:13)
git-committer:
Nelson Elhage <nelhage@mit.edu> (05/04/09 21:55:17)
Message:
Refactor owl_handle_input to allow injecting keystrokes.

This patch is preparation for handling SIGINT and injecting a fake
keystroke in response.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • owl.c

    radee9cc rd6bd3f1  
    571571void owl_process_input(owl_dispatch *d)
    572572{
    573   int ret;
    574573  owl_input j;
    575   owl_popwin *pw;
    576   owl_editwin *tw;
    577574  WINDOW *typwin;
    578575
    579576  typwin = owl_global_get_curs_typwin(&g);
     577
    580578  while (1) {
    581579    j.ch = wgetch(typwin);
    582580    if (j.ch == ERR) return;
    583    
    584     owl_global_set_lastinputtime(&g, time(NULL));
    585     pw=owl_global_get_popwin(&g);
    586     tw=owl_global_get_typwin(&g);
    587581
    588582    j.uch = '\0';
     
    630624      j.uch = j.ch;
    631625    }
    632    
    633     owl_global_set_lastinputtime(&g, time(NULL));
    634     /* find and activate the current keymap.
    635      * TODO: this should really get fixed by activating
    636      * keymaps as we switch between windows...
    637      */
    638     if (pw && owl_popwin_is_active(pw) && owl_global_get_viewwin(&g)) {
    639       owl_context_set_popless(owl_global_get_context(&g),
    640                               owl_global_get_viewwin(&g));
    641       owl_function_activate_keymap("popless");
    642     } else if (owl_global_is_typwin_active(&g)
    643                && owl_editwin_get_style(tw)==OWL_EDITWIN_STYLE_ONELINE) {
    644       /*
    645         owl_context_set_editline(owl_global_get_context(&g), tw);
    646         owl_function_activate_keymap("editline");
    647       */
    648     } else if (owl_global_is_typwin_active(&g)
    649                && owl_editwin_get_style(tw)==OWL_EDITWIN_STYLE_MULTILINE) {
    650       owl_context_set_editmulti(owl_global_get_context(&g), tw);
    651       owl_function_activate_keymap("editmulti");
    652     } else {
    653       owl_context_set_recv(owl_global_get_context(&g));
    654       owl_function_activate_keymap("recv");
    655     }
    656     /* now actually handle the keypress */
    657     ret = owl_keyhandler_process(owl_global_get_keyhandler(&g), j);
    658     if (ret!=0 && ret!=1) {
    659       owl_function_makemsg("Unable to handle keypress");
    660     }
     626
     627    owl_process_input_char(j);
     628  }
     629}
     630
     631void owl_process_input_char(owl_input j)
     632{
     633  int ret;
     634  owl_popwin *pw;
     635  owl_editwin *tw;
     636
     637  owl_global_set_lastinputtime(&g, time(NULL));
     638  pw=owl_global_get_popwin(&g);
     639  tw=owl_global_get_typwin(&g);
     640
     641  owl_global_set_lastinputtime(&g, time(NULL));
     642  /* find and activate the current keymap.
     643   * TODO: this should really get fixed by activating
     644   * keymaps as we switch between windows...
     645   */
     646  if (pw && owl_popwin_is_active(pw) && owl_global_get_viewwin(&g)) {
     647    owl_context_set_popless(owl_global_get_context(&g),
     648                            owl_global_get_viewwin(&g));
     649    owl_function_activate_keymap("popless");
     650  } else if (owl_global_is_typwin_active(&g)
     651             && owl_editwin_get_style(tw)==OWL_EDITWIN_STYLE_ONELINE) {
     652    /*
     653      owl_context_set_editline(owl_global_get_context(&g), tw);
     654      owl_function_activate_keymap("editline");
     655    */
     656  } else if (owl_global_is_typwin_active(&g)
     657             && owl_editwin_get_style(tw)==OWL_EDITWIN_STYLE_MULTILINE) {
     658    owl_context_set_editmulti(owl_global_get_context(&g), tw);
     659    owl_function_activate_keymap("editmulti");
     660  } else {
     661    owl_context_set_recv(owl_global_get_context(&g));
     662    owl_function_activate_keymap("recv");
     663  }
     664  /* now actually handle the keypress */
     665  ret = owl_keyhandler_process(owl_global_get_keyhandler(&g), j);
     666  if (ret!=0 && ret!=1) {
     667    owl_function_makemsg("Unable to handle keypress");
    661668  }
    662669}
Note: See TracChangeset for help on using the changeset viewer.