Changeset 2a17b63


Ignore:
Timestamp:
Jan 7, 2010, 6:54:15 PM (10 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.6, release-1.7, release-1.8, release-1.9
Children:
10557e6
Parents:
a999d9e
git-author:
Nelson Elhage <nelhage@mit.edu> (12/30/09 17:52:20)
git-committer:
Nelson Elhage <nelhage@mit.edu> (01/07/10 18:54:15)
Message:
Push and pop contexts whenever we change context.

This allows us to get rid of the awful hack in owl_process_input_char,
and opens the path to being able to invoke popup windows from the
editwin and vice versa (In fact, you can now do so without
segfaulting, although the display layer does not yet quite do the
right thing).
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    r6700c605 r2a17b63  
    26652665  owl_editwin_new_style(e, OWL_EDITWIN_STYLE_ONELINE, NULL);
    26662666
    2667   owl_function_activate_keymap("recv");
     2667  owl_global_pop_context(&g);
    26682668}
    26692669
     
    27232723  owl_history_reset(hist);
    27242724  owl_global_set_typwin_inactive(&g);
     2725  owl_global_pop_context(&g);
    27252726  cmd = owl_strdup(owl_editwin_get_text(e));
    27262727  owl_editwin_fullclear(e);
     
    27432744
    27442745  owl_global_set_typwin_inactive(&g);
     2746  owl_global_pop_context(&g);
    27452747  owl_editwin_fullclear(e);
    27462748  wnoutrefresh(owl_editwin_get_curswin(e));
     
    27602762  owl_editwin_fullclear(e);
    27612763  owl_global_set_typwin_inactive(&g);
     2764  owl_global_pop_context(&g);
    27622765  owl_global_set_needrefresh(&g);
    27632766  wnoutrefresh(owl_editwin_get_curswin(e));
     
    27812784{
    27822785  owl_popwin_close(owl_global_get_popwin(&g));
     2786  owl_global_pop_context(&g);
    27832787  owl_viewwin_free(vw);
    27842788  owl_global_set_needrefresh(&g);
  • context.c

    r3f8514b r2a17b63  
    5252  return(ctx->mode & OWL_CTX_INTERACTIVE)?1:0;
    5353}
    54 
    55 void owl_context_set_startup(owl_context *ctx)
    56 {
    57   SET_MODE(ctx, OWL_CTX_STARTUP);
    58 }
    59 
    60 void owl_context_set_readconfig(owl_context *ctx)
    61 {
    62   SET_MODE(ctx, OWL_CTX_READCONFIG);
    63 }
    64 
    65 void owl_context_set_interactive(owl_context *ctx)
    66 {
    67   SET_MODE(ctx, OWL_CTX_INTERACTIVE);
    68 }
    69 
    70 void owl_context_set_popless(owl_context *ctx, owl_viewwin *vw)
    71 {
    72   ctx->data = vw;
    73   SET_ACTIVE(ctx, OWL_CTX_POPLESS);
    74 }
    75 
    76 void owl_context_set_recv(owl_context *ctx)
    77 {
    78   SET_ACTIVE(ctx, OWL_CTX_RECV);
    79 }
    80 
    81 void owl_context_set_editmulti(owl_context *ctx, owl_editwin *ew)
    82 {
    83   ctx->data = ew;
    84   SET_ACTIVE(ctx, OWL_CTX_EDITMULTI);
    85 }
    86 
    87 void owl_context_set_editline(owl_context *ctx, owl_editwin *ew)
    88 {
    89   ctx->data = ew;
    90   SET_ACTIVE(ctx, OWL_CTX_EDITLINE);
    91 }
    92 
    93 void owl_context_set_editresponse(owl_context *ctx, owl_editwin *ew)
    94 {
    95   ctx->data = ew;
    96   SET_ACTIVE(ctx, OWL_CTX_EDITRESPONSE);
    97 }
    98 
  • functions.c

    r8a2815b r2a17b63  
    301301  owl_editwin_set_cbdata(owl_global_get_typwin(&g), data);
    302302  owl_global_set_buffercallback(&g, callback);
     303  owl_global_push_context(&g, OWL_CTX_EDITMULTI, e, "editmulti");
    303304}
    304305
     
    13011302
    13021303  owl_popwin_up(pw);
     1304  owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless");
    13031305  owl_viewwin_init_text(v, owl_popwin_get_curswin(pw),
    13041306                        owl_popwin_get_lines(pw), owl_popwin_get_cols(pw),
     
    13181320
    13191321  owl_popwin_up(pw);
     1322  owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless");
    13201323  owl_viewwin_init_fmtext(v, owl_popwin_get_curswin(pw),
    13211324                   owl_popwin_get_lines(pw), owl_popwin_get_cols(pw),
     
    19401943  owl_editwin_redisplay(tw, 0);
    19411944
    1942   owl_context_set_editline(owl_global_get_context(&g), tw);
    1943   owl_function_activate_keymap("editline");
     1945  owl_global_push_context(&g, OWL_CTX_EDITLINE, tw, "editline");
    19441946}
    19451947
     
    19571959  owl_editwin_redisplay(tw, 0);
    19581960
    1959   owl_context_set_editresponse(owl_global_get_context(&g), tw);
    1960   owl_function_activate_keymap("editresponse");
     1961  owl_global_push_context(&g, OWL_CTX_EDITRESPONSE, tw, "editline");
    19611962}
    19621963
     
    19751976  owl_editwin_redisplay(tw, 0);
    19761977
    1977   owl_context_set_editresponse(owl_global_get_context(&g), tw);
    1978   owl_function_activate_keymap("editresponse");
     1978  owl_global_push_context(&g, OWL_CTX_EDITRESPONSE, tw, "editresponse");
    19791979}
    19801980
     
    28302830  if (direction==0) {
    28312831    owl_list_append_element(fl, f);
    2832   }
    2833 }
    2834 
    2835 void owl_function_activate_keymap(const char *keymap)
    2836 {
    2837   if (!owl_keyhandler_activate(owl_global_get_keyhandler(&g), keymap)) {
    2838     owl_function_error("Unable to activate keymap '%s'", keymap);
    28392832  }
    28402833}
  • keys.c

    r6aa4611 r2a17b63  
    312312  BIND_CMD("C-c",  "",                "no effect in this mode");
    313313  BIND_CMD("C-g",  "",                "no effect in this mode");
    314 
    315 
    316   /**********************/
    317 
    318   owl_function_activate_keymap("recv");
    319 
    320314}
    321315
  • owl.c

    rb752f1e r2a17b63  
    538538  /* Initialize perl */
    539539  owl_function_debugmsg("startup: processing config file");
    540   owl_context_set_readconfig(owl_global_get_context(&g));
     540
     541  owl_global_pop_context(&g);
     542  owl_global_push_context(&g, OWL_CTX_READCONFIG, NULL, NULL);
     543
    541544  perlerr=owl_perlconfig_initperl(opts.configfile, &argc, &argv, &env);
    542545  if (perlerr) {
     
    612615
    613616  owl_function_debugmsg("startup: setting context interactive");
    614   owl_context_set_interactive(owl_global_get_context(&g));
     617
     618  owl_global_pop_context(&g);
     619  owl_global_push_context(&g, OWL_CTX_READCONFIG|OWL_CTX_RECV, NULL, "recv");
    615620
    616621  owl_select_add_timer(180, 180, owl_zephyr_buddycheck_timer, NULL, NULL);
  • popexec.c

    r18fdd5f9 r2a17b63  
    2727
    2828  owl_popwin_up(pw);
     29  owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless");
    2930  owl_viewwin_init_text(v, owl_popwin_get_curswin(pw),
    3031                        owl_popwin_get_lines(pw), owl_popwin_get_cols(pw),
  • select.c

    rb752f1e r2a17b63  
    261261{
    262262  int ret;
    263   owl_popwin *pw;
    264   owl_editwin *tw;
    265263
    266264  owl_global_set_lastinputtime(&g, time(NULL));
    267   pw=owl_global_get_popwin(&g);
    268   tw=owl_global_get_typwin(&g);
    269 
    270   owl_global_set_lastinputtime(&g, time(NULL));
    271   /* find and activate the current keymap.
    272    * TODO: this should really get fixed by activating
    273    * keymaps as we switch between windows...
    274    */
    275   if (pw && owl_popwin_is_active(pw) && owl_global_get_viewwin(&g)) {
    276     owl_context_set_popless(owl_global_get_context(&g),
    277                             owl_global_get_viewwin(&g));
    278     owl_function_activate_keymap("popless");
    279   } else if (owl_global_is_typwin_active(&g)
    280              && owl_editwin_get_style(tw)==OWL_EDITWIN_STYLE_ONELINE) {
    281     /*
    282       owl_context_set_editline(owl_global_get_context(&g), tw);
    283       owl_function_activate_keymap("editline");
    284     */
    285   } else if (owl_global_is_typwin_active(&g)
    286              && owl_editwin_get_style(tw)==OWL_EDITWIN_STYLE_MULTILINE) {
    287     owl_context_set_editmulti(owl_global_get_context(&g), tw);
    288     owl_function_activate_keymap("editmulti");
    289   } else {
    290     owl_context_set_recv(owl_global_get_context(&g));
    291     owl_function_activate_keymap("recv");
    292   }
    293   /* now actually handle the keypress */
    294265  ret = owl_keyhandler_process(owl_global_get_keyhandler(&g), j);
    295266  if (ret!=0 && ret!=1) {
Note: See TracChangeset for help on using the changeset viewer.