jed-users mailing list

[2002 Date Index] [2002 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: get_modifier()


Andy Sy <andy@xxxxxxxxxxx> wrote:
>Guenter Milde said on 2002-02-19: 
>
>> My favourite would be a jed startup script, that loads 
>> the "jed-enhanced" keybindings just before opening jed 
>> and unloads them on exit. (I just wonder what will happen 
>> to apps in another console.)

You can probably do some of this via the init/reset_display hooks, e.g.,

   static define init_console_keymap ()
   {
      () = run_shell_cmd ("loadkeys_for_jed");
   }

   static define reset_console_keymap ()
   {
      () = run_shell_cmd ("unloadkeys_for_jed");
   }

   add_to_hook ("_jed_reset_display_hooks", &init_console_keymap);
   add_to_hook ("_jed_init_display_hooks", &reset_console_keymap);

where load/unload_keys_for_jed are (setuid?) scripts that load and
unload the approriate console keymap. 

>Dang you're right. Is there a way to have your cake
>and eat it too? i.e. ensure that Shift-PgUp/PgDn give
>the CUA behaviour under jed in one VC and yet maintain 
>its normal Linux behaviour in the others?

The above would work, except when switching to another console from
within jed.  The trick there is to let jed do the switching for you
via the appropriate console escape sequence, e.g.,

    define switch_to_console (n)
    {
        tt_send (sprintf ("\e[12;%d]", n));
    }

may be used to switch to another virtual console.  Unfortunately, that
will not do the keymap swapping.  So, before calling
switch_to_console, call the reset_console_keymap function and then add
a post-key hook that calls init_console_keymap, e.g.,

   static define before_key_hook ();
   static define before_key_hook (fun)
   {
      remove_from_hook ("_jed_before_key_hooks", &before_key_hook);
      init_console_keymap ();
   }
   define switch_to_console_2 ()
   {
      reset_console_keymap ();
      add_to_hook ("_jed_before_key_hooks", &before_key_hook);
      switch_to_console (2);
   }
   setkey ("switch_to_console_2", "WHATEVER");

The idea is that some key, e.g., Alt-F2 is bound to
switch_to_console_2.  Then pressing Alt-F2 causes the jed console
keymap to be unloaded.  In addition, the before_key_hook function will
be added to the before_key_hooks, before the console is changed to the
seond one.  Then after the console running jed is brought into the
foreground, pressing a key causes the before_key_hook to run, which
simply unloads itself and reinitializes the keymap.  The main caveat
is that jed may not see the first key that gets pressed when returning
to the console, since at that moment, the jed-specific keymap will not
have been loaded.

I have not tested any of the above code, but I hope that the basic
idea is clear.

Thanks,
--John

--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2002 date index] [2002 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]