home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 3 / CD ACTUAL 3.iso / linux / incoming / jstools-.6v3 / jstools- / jstools-tk3.6v3.0 / lib / jedit_bindings.tcl < prev    next >
Encoding:
Text File  |  1995-03-14  |  4.4 KB  |  130 lines

  1. # jedit_bindings.tcl - bindings for command accelerators for jedit
  2. # Copyright 1992-1994 by Jay Sekora.  All rights reserved, except 
  3. # that this file may be freely redistributed in whole or in part 
  4. # for non-profit, noncommercial use.
  5.  
  6. ######################################################################
  7. # jedit:mkbindings - set keyboard shortcuts and special map additions
  8. #   widgets and t are often the same, but needn't be - widgets could
  9. #   also include entry widgets
  10. ######################################################################
  11.  
  12. proc jedit:mkbindings {widgets t} {
  13.   global WORD_END
  14.   # the following can't be redefined in ~/.tk/textbindings.tcl;
  15.   # if you want to change them, do so in $HOME/.tk/jeditrc.tcl
  16.   #
  17.   foreach w $widgets {
  18.     bind $w <Meta-Tab>        {jedit:cmd:toggle_dabbrev %W}
  19.     bind $w <Meta-space>    {jedit:cmd:toggle_sabbrev %W}
  20.     bind $w <Meta-minus>    {jedit:cmd:hyphen %W}
  21.     bind $w <Meta-semicolon>    {jedit:cmd:dabbrev %W}
  22.     catch {
  23.       bind $w <Meta-quoteright>    {jedit:cmd:sabbrev %W}
  24.     }
  25.     catch {
  26.       bind $w <Meta-apostrophe>    {jedit:cmd:sabbrev %W}
  27.     }
  28.     bind $w <Meta-bar>        {jedit:cmd:run_pipe %W}
  29.     bind $w <Meta-exclam>    {jedit:cmd:run_command %W}
  30.     bind $w <Meta-bracketleft>    "jedit:text_regsub %W {(^|\n)\[> \] } {\\1}"
  31.     bind $w <Meta-bracketright>    "jedit:text_regsub %W {(^|\n)} {\\1  }"
  32.     bind $w <Meta-a>        {jedit:cmd:select_all %W}
  33.     bind $w <Meta-B>        {jedit:font:bold %W}
  34.     bind $w <Meta-c>        {jedit:cmd:copy %W}
  35.     bind $w <Meta-C>        {jedit:cmd:current_line %W}
  36.     bind $w <Meta-f>        {jedit:cmd:find %W}
  37.     bind $w <Meta-F>        "jedit:pipe $t {fmt}"
  38.     bind $w <Meta-g>        {jedit:cmd:find_again %W}
  39.     bind $w <Meta-G>        {j:global_pref_panel}
  40.     bind $w <Meta-h>        {jedit:cmd:help %W}
  41.     bind $w <Meta-i>        {jedit:cmd:insfile %W}
  42.     bind $w <Meta-I>        {jedit:font:italic %W}
  43.     bind $w <Meta-l>        {jedit:cmd:load %W}
  44.     bind $w <Meta-L>        {jedit:cmd:go_to_line %W}
  45.     bind $w <Meta-m>        {jedit:cmd:ask_mode  %W}
  46.     bind $w <Meta-Key-M>    {jedit:font:typewriter %W}
  47.     bind $w <Meta-n>        {jedit:cmd:new_window %W}
  48.     bind $w <Meta-N>        {jedit:cmd:note %W}
  49.     bind $w <Meta-p>        {jedit:cmd:print %W}
  50.     bind $w <Meta-P>        {jedit:cmd:edit_prefs %W}
  51.     bind $w <Meta-R>        {jedit:font:roman %W}
  52.     bind $w <Meta-s>        {jedit:cmd:save %W}
  53.     bind $w <Meta-S>        {jedit:cmd:saveas %W}
  54.     bind $w <Meta-T>        {j:prompt_tcl}
  55.     bind $w <Meta-U>        {j:prompt_unix}
  56.     bind $w <Meta-v>        {jedit:cmd:paste %W}
  57.     bind $w <Meta-V>        {jedit:cmd:xpaste %W}
  58.     bind $w <Meta-x>        {jedit:cmd:cut %W}
  59.     bind $w <Meta-X>        {jedit:font:bolditalic %W}
  60.     bind $w <Meta-q>        {jedit:cmd:quit %W}
  61.     bind $w <Meta-w>        {jedit:cmd:close %W}
  62.     bind $w <Meta-z>        {jedit:cmd:undo %W}
  63.     bind $w <Meta-Z>        {jedit:cmd:redo %W}
  64.  }
  65.   
  66.   # set up bindings for word-end punctuation (for abbrevs):
  67.   
  68.   foreach key $WORD_END {
  69.     foreach map {basic vi-insert emacs-normal edt-normal} {
  70.       j:tkb:mkmap $w $map $map [format {
  71.         {%s            jedit:self_insert_punct}
  72.       } $key]
  73.     }
  74.   }
  75.   
  76.   # set up bindings for a few other special characters:
  77.   
  78.   foreach map {basic vi-insert emacs-normal edt-normal} {
  79.     j:tkb:mkmap $w $map $map [format {
  80.       {Tab            jedit:tabkey}
  81.     } $key]
  82.     j:tkb:mkmap $w $map $map [format {
  83.       {space            jedit:spacebar}
  84.     } $key]
  85.     j:tkb:mkmap $w $map $map [format {
  86.       {Return            jedit:returnkey}
  87.     } $key]
  88.   }
  89.   
  90.   # additional application-specific Emacs-style keyboard bindings:
  91.   
  92.   j:tkb:mkmap $w emacs-normal emacs-normal {
  93.     {Control-s            jedit:cmd:find_forward}
  94.     {Control-r            jedit:cmd:find_backward}
  95.   }
  96.   j:tkb:mkmap $w emacs-escape emacs-normal {
  97.     {percent            jedit:cmd:find}
  98.   }
  99.   j:tkb:mkmap $w emacs-control-x emacs-normal {
  100.     {Control-s            jedit:cmd:save}
  101.     {Control-w            jedit:cmd:saveas}
  102.     {Control-f            jedit:cmd:load}
  103.     {Control-v            jedit:cmd:load}
  104.     {Control-c            jedit:cmd:quit}
  105.   }
  106.   
  107.   # additional application-specific vi-style keyboard bindings:
  108.   
  109.   j:tkb:mkmap $w vi-command vi-command {
  110.     {slash            jedit:cmd:find_forward}
  111.     {question            jedit:cmd:find_backward}
  112.     {n                jedit:cmd:find_again}
  113.   }
  114.   
  115.   # create a vi-Z map for the "ZZ" command:
  116.   
  117.   j:tkb:mkmap $w vi-command vi-command {
  118.     {Z                j:tkb:new_mode vi-Z}
  119.   }
  120.   
  121.   j:tkb:mkmap $w vi-Z vi-command {
  122.     {DEFAULT            j:tb:no_op}
  123.     {Shift-DEFAULT        j:tb:no_op}
  124.     {Control-DEFAULT        j:tb:no_op}
  125.     {Meta-DEFAULT        j:tb:no_op}
  126.     {Z                jedit:cmd:done}
  127.   }
  128. }
  129.