next up previous contents index
Next: Mouse variables Up: Mouse input Previous: Mouse input   Contents   Index


Bind

The bind allows defining or redefining a hotkey, i.e. a sequence of gnuplot commands which will be executed when a certain key or key sequence is pressed while the driver's window has the input focus. Note that bind is only available if gnuplot was compiled with mouse support and it is used by all mouse-capable terminals. Bindings overwrite the builtin bindings (like in every real editor), except 5#5space6#6 and 'q' which cannot be rebound (unless one exception, see below). Mouse buttons cannot be rebound.

You get the list of all hotkeys by typing bind or by hitting 'h' in the graph window.

Note that multikey-bindings with modifiers have to be quoted.

Normally hotkeys are only recognized when the currently active plot window has focus. bind allwindows 5#5key6#6 ... (short form: bind all 5#5key6#6 ...) causes the binding for 5#5key6#6 to apply to all gnuplot plot windows, active or not. In this case gnuplot variable MOUSE_KEY_WINDOW is set to the ID of the originating window, and may be used by the bound command.

By default, the 5#5space6#6 hotkey raises gnuplot's command window. On some terminals (e.g. x11, wx, pm), 'q' closes the graph window. These defaults can be changed to ctrl-space and ctrl-q by starting gnuplot as 'gnuplot -ctrlq', see x11 command-line-options (p. [*]), or by the X Resource 'gnuplot*ctrlq'. Note: if 5#5space6#6 (or ctrl-space) does not raise the gnuplot window under X11, see discussion in raise (p. [*]).

Syntax:

     bind {allwindows} [<key-sequence>] ["<gnuplot commands>"]
     bind!

Examples:

- set bindings:


   bind a "replot"
   bind "ctrl-a" "plot x*x"
   bind "ctrl-alt-a" 'print "great"'
   bind Home "set view 60,30; replot"
   bind all Home 'print "This is window ",MOUSE_KEY_WINDOW'

- show bindings:

   bind "ctrl-a"          # shows the binding for ctrl-a
   bind                   # shows all bindings

- remove bindings:

   bind "ctrl-alt-a" ""   # removes binding for ctrl-alt-a
                            (note that builtins cannot be removed)
   bind!                  # installs default (builtin) bindings

- bind a key to toggle something:

 v=0
 bind "ctrl-r" "v=v+1;if(v%2)set term x11 noraise; else set term x11 raise"

Modifiers (ctrl / alt) are case insensitive, keys not:

   ctrl-alt-a == CtRl-alT-a
   ctrl-alt-a != ctrl-alt-A

List of modifiers (alt == meta):

   ctrl, alt

List of supported special keys:


  "BackSpace", "Tab", "Linefeed", "Clear", "Return", "Pause", "Scroll_Lock",
  "Sys_Req", "Escape", "Delete", "Home", "Left", "Up", "Right", "Down",
  "PageUp", "PageDown", "End", "Begin",


  "KP_Space", "KP_Tab", "KP_Enter", "KP_F1", "KP_F2", "KP_F3", "KP_F4",
  "KP_Home", "KP_Left", "KP_Up", "KP_Right", "KP_Down", "KP_PageUp",
  "KP_PageDown", "KP_End", "KP_Begin", "KP_Insert", "KP_Delete", "KP_Equal",
  "KP_Multiply", "KP_Add", "KP_Separator", "KP_Subtract", "KP_Decimal",
  "KP_Divide",


  "KP_1" - "KP_9", "F1" - "F12"

See also help for mouse (p. [*]) and if (p. [*]).


next up previous contents index
Next: Mouse variables Up: Mouse input Previous: Mouse input   Contents   Index
Ethan Merritt 2007-03-03