binding.html

来自「nedit 是一款linux下的开发源码的功能强大的编辑器」· HTML 代码 · 共 99 行

HTML
99
字号
<HTML><HEAD><TITLE> Customizing </TITLE></HEAD><BODY><A NAME="Key_Binding"></A><H2> Key Binding </H2><P>There are several ways to change key bindings in NEdit.  The easiest way toadd a new key binding in NEdit is to define a macro in Preferences -&#62; DefaultSettings -&#62; Customize Menus -&#62; Macro Menu.  However, if you want to changeexisting bindings or add a significant number of new key bindings you willneed to do so via X resources.</P><P>Before reading this section, you must understand how to set X resources (seethe help section "<A HREF="resources.html#X_Resources">X Resources</A>").  Since setting X resources is tricky, it isalso helpful when working on key-binding, to set some easier-to-verifyresource at the same time, as a simple check that the NEdit program isactually seeing your changes.  The appres program is also very helpful inchecking that the resource settings that you make, actually reach the programfor which they are intended in the correct form.</P><P><H3>Key Binding in General</H3></P><P>Keyboard commands are associated with editor action routines through twoseparate mechanisms in NEdit.  Commands which appear in pull-down menus haveindividual resources designating a keyboard equivalent to the menu command,called an accelerator key.  Commands which do not have an associated menuitem are bound to keys via the X toolkit translation mechanism.  The methodsfor changing these two kinds of bindings are quite different.</P><P><H3>Key Binding Via Translations</H3></P><P>The most general way to bind actions to keys in NEdit is to use thetranslation table associated with the text widget.  To add a binding to Alt+Yto insert the string "Hi!", for example, add lines similar to the followingto your X resource file:</P><P><PRE>    NEdit*text.Translations: #override \n\      Alt&#60;Key&#62;y: insert_string("Hi!") \n</PRE></P><P>The Help topic "<A HREF="actions.html#Action_Routines">Action Routines</A>" lists the actions available to be bound.</P><P>Translation tables map key and mouse presses, window operations, and otherkinds of events, to actions. The syntax for translation tables issimplified here, so you may need to refer to a book on the X window systemfor more detailed information.</P><P>Note that accelerator resources (discussed below) override translations, andthat most Ctrl+letter and Alt+letter combinations are already bound to anaccelerator key.  To use one of these combinations from a translation table,therefore, you must first un-bind the original menu accelerator.</P><P>A resource for changing a translation table consists of a keyword; #override,#augment, or #replace; followed by lines (separated by newline characters)pairing events with actions.  Events begin with modifiers, like Ctrl, Shift,or Alt, followed by the event type in &#60;&#62;.  BtnDown, Btn1Down, Btn2Down,Btn1Up, Key, KeyUp are valid event types.  For key presses, the event type isfollowed by the name of the key.  You can specify a combination of events,such as a sequence of key presses, by separating them with commas.  The otherhalf of the event/action pair is a set of actions.  These are separated fromthe event specification by a colon and from each other by spaces.  Actionsare names followed by parentheses, optionally containing one or moreparameters separated by comas.</P><P><H3>Changing Menu Accelerator Keys</H3></P><P>The menu shortcut keys shown at the right of NEdit menu items can also bechanged via X resources.  Each menu item has two resources associated withit, accelerator, the event to trigger the menu item; and acceleratorText, thestring shown in the menu.  The form of the accelerator resource is the sameas events for translation table entries discussed above, though multiple keysand other subtleties are not allowed.  The resource name for a menu is thetitle in lower case, followed by "Menu", the resource name of menu item isthe name in lower case, run together, with words separated by caps, and allpunctuation removed.  For example, to change Cut to Ctrl+X, you would add thefollowing to your .Xdefaults file:</P><P><PRE>      nedit*editMenu.cut.accelerator: Ctrl&#60;Key&#62;x      nedit*editMenu.cut.acceleratorText: Ctrl+X</PRE></P><P>Accelerator keys with optional shift key modifiers, like Find..., have anadditional accelerator resource with Shift appended to the name.  Forexample:</P><P><PRE>      nedit*searchMenu.find.acceleratorText: [Shift]Alt+F      nedit*searchMenu.find.accelerator: Alt&#60;Key&#62;f      nedit*searchMenu.findShift.accelerator: Shift Alt&#60;Key&#62;f</PRE></P><P></P></BODY></HTML>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?