Changeset 07b59ea


Ignore:
Timestamp:
Jun 3, 2010, 2:58:30 AM (11 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.7, release-1.8, release-1.9
Children:
e8128c5
Parents:
4dd115f
Message:
Maintain the cursor location with the context stack
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • context.c

    r2a17b63 r07b59ea  
    99  ctx->mode = OWL_CTX_STARTUP;
    1010  ctx->data = NULL;
     11  ctx->cursor = NULL;
    1112  return 0;
    1213}
  • functions.c

    r40597e7 r07b59ea  
    292292  owl_editwin_set_cbdata(e, data, cleanup);
    293293  owl_editwin_set_callback(e, callback);
    294   owl_global_push_context(&g, OWL_CTX_EDITMULTI, e, "editmulti");
     294  owl_global_push_context(&g, OWL_CTX_EDITMULTI, e, "editmulti", owl_global_get_curs_typwin(&g));
    295295}
    296296
     
    12601260
    12611261  owl_popwin_up(pw);
    1262   owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless");
     1262  owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless", NULL);
    12631263  owl_viewwin_init_text(v, owl_popwin_get_content(pw), text);
    12641264}
     
    12731273
    12741274  owl_popwin_up(pw);
    1275   owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless");
     1275  owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless", NULL);
    12761276  owl_viewwin_init_fmtext(v, owl_popwin_get_content(pw), fm);
    12771277}
     
    18951895  owl_editwin_insert_string(tw, line);
    18961896
    1897   owl_global_push_context(&g, OWL_CTX_EDITLINE, tw, "editline");
     1897  owl_global_push_context(&g, OWL_CTX_EDITLINE, tw, "editline", owl_global_get_curs_typwin(&g));
    18981898  owl_editwin_set_callback(tw, owl_callback_command);
    18991899}
     
    19071907  owl_editwin_set_locktext(tw, line);
    19081908
    1909   owl_global_push_context(&g, OWL_CTX_EDITRESPONSE, tw, "editresponse");
     1909  owl_global_push_context(&g, OWL_CTX_EDITRESPONSE, tw, "editresponse", owl_global_get_curs_typwin(&g));
    19101910  return tw;
    19111911}
     
    19211921  owl_editwin_set_locktext(tw, line);
    19221922
    1923   owl_global_push_context(&g, OWL_CTX_EDITRESPONSE, tw, "editresponse");
     1923  owl_global_push_context(&g, OWL_CTX_EDITRESPONSE, tw, "editresponse", owl_global_get_curs_typwin(&g));
    19241924  return tw;
    19251925}
  • global.c

    r4dd115f r07b59ea  
    3434
    3535  g->context_stack = NULL;
    36   owl_global_push_context(g, OWL_CTX_STARTUP, NULL, NULL);
     36  owl_global_push_context(g, OWL_CTX_STARTUP, NULL, NULL, NULL);
    3737
    3838  g->curmsg=0;
     
    177177}
    178178
    179 static void owl_global_lookup_keymap(owl_global *g) {
    180   owl_context *c = owl_global_get_context(g);
    181   if (!c || !c->keymap)
     179static void owl_global_activate_context(owl_global *g, owl_context *c) {
     180  if (!c)
    182181    return;
    183182
    184   if (!owl_keyhandler_activate(owl_global_get_keyhandler(g), c->keymap)) {
    185     owl_function_error("Unable to activate keymap '%s'", c->keymap);
    186   }
    187 }
    188 
    189 void owl_global_push_context(owl_global *g, int mode, void *data, const char *keymap) {
     183  if (c->keymap) {
     184    if (!owl_keyhandler_activate(owl_global_get_keyhandler(g), c->keymap)) {
     185      owl_function_error("Unable to activate keymap '%s'", c->keymap);
     186    }
     187  }
     188  owl_window_set_cursor(c->cursor);
     189}
     190
     191void owl_global_push_context(owl_global *g, int mode, void *data, const char *keymap, owl_window *cursor) {
    190192  owl_context *c;
    191193  if (!(mode & OWL_CTX_MODE_BITS))
     
    194196  c->mode = mode;
    195197  c->data = data;
     198  c->cursor = cursor ? g_object_ref(cursor) : NULL;
    196199  c->keymap = owl_strdup(keymap);
    197200  g->context_stack = g_list_prepend(g->context_stack, c);
    198   owl_global_lookup_keymap(g);
     201  owl_global_activate_context(g, owl_global_get_context(g));
    199202}
    200203
     
    206209  g->context_stack = g_list_delete_link(g->context_stack,
    207210                                        g->context_stack);
     211  if (c->cursor)
     212    g_object_unref(c->cursor);
    208213  owl_free(c->keymap);
    209214  owl_free(c);
    210   owl_global_lookup_keymap(g);
     215  owl_global_activate_context(g, owl_global_get_context(g));
    211216}
    212217
  • owl.c

    r4dd115f r07b59ea  
    464464  if (owl_global_is_needrefresh(&g)) {
    465465    /* Redraw the screen */
    466 
    467     /* HACK: move the cursor to unmanaged window if necessary; these should be
    468      * associated with the context or something. */
    469     if (!owl_popwin_is_active(owl_global_get_popwin(&g))
    470         && owl_global_get_typwin(&g)) {
    471       owl_window_set_cursor(owl_global_get_curs_typwin(&g));
    472     } else {
    473       owl_window_set_cursor(NULL);
    474     }
    475 
    476466    owl_window_redraw_scheduled();
    477467    doupdate();
     
    549539
    550540  owl_global_pop_context(&g);
    551   owl_global_push_context(&g, OWL_CTX_READCONFIG, NULL, NULL);
     541  owl_global_push_context(&g, OWL_CTX_READCONFIG, NULL, NULL, NULL);
    552542
    553543  perlerr=owl_perlconfig_initperl(opts.configfile, &argc, &argv, &env);
     
    616606
    617607  owl_global_pop_context(&g);
    618   owl_global_push_context(&g, OWL_CTX_READCONFIG|OWL_CTX_RECV, NULL, "recv");
     608  owl_global_push_context(&g, OWL_CTX_READCONFIG|OWL_CTX_RECV, NULL, "recv", NULL);
    619609
    620610  owl_select_add_pre_select_action(owl_refresh_pre_select_action, NULL, NULL);
  • owl.h

    rfa65671 r07b59ea  
    310310  void *data;           /* determined by mode */
    311311  char *keymap;
     312  owl_window *cursor;
    312313} owl_context;
    313314
  • popexec.c

    r68f63a2 r07b59ea  
    2727
    2828  owl_popwin_up(pw);
    29   owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless");
     29  owl_global_push_context(&g, OWL_CTX_POPLESS, v, "popless", NULL);
    3030  owl_viewwin_init_text(v, owl_popwin_get_content(pw), "");
    3131  owl_viewwin_set_onclose_hook(v, owl_popexec_viewwin_onclose, pe);
Note: See TracChangeset for help on using the changeset viewer.