Author Topic: Key bindings don't work with user-defined languages  (Read 1915 times)

bengle

  • Senior Community Member
  • Posts: 126
  • Hero Points: 4
Key bindings don't work with user-defined languages
« on: May 29, 2013, 02:11:12 pm »
Key bindings do not seem to work with user-defined languages.  To duplicate the problem, define a new language in the Language Manager.   Then in the Key Bindings options, double-click on the name of a command.  Press the Advanced button, check the “Bind to Mode” check box, and select the new language from the dropdown list.  Enter the key sequence and press the Bind button.

In the key binding list, the new key will display a mode of “ext” rather than the language you selected in the dropdown list.  The new key binding will not work when editing a file of the new language.     

Matthew

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 990
  • Hero Points: 44
Re: Key bindings don't work with user-defined languages
« Reply #1 on: May 30, 2013, 02:10:49 pm »
This appears to be working for me. What is the emulation you're working from, and what is the key sequence you're trying to bind? Also, when you load the file, make sure that the Document > Select Mode (lang) menu item does correctly show your new language in the (parens).
If your language is showing up as the correct and current document mode, execute the what-is command on the command line, press your sequence, and see what it reports.

bengle

  • Senior Community Member
  • Posts: 126
  • Hero Points: 4
Re: Key bindings don't work with user-defined languages
« Reply #2 on: May 30, 2013, 03:50:04 pm »
The problem is that when I define the new key binding, it sets the mode to "default" and not to the mode I specified in the dropdown list.  I am using the Visual Studio emulation if that makes any difference. 
Here is how to reproduce the problem...
1. Define a new language in the Language Manager, copying all of the settings from "Plain Text".  Mine is called "Dump".
2. Create a key binding for any command (e.g. gui_goto_line), press the Advanced button, and select "Dump" from the dropdown list.
3. Enter the key sequence (e.g. Ctrl+Shift+Q).
3. Press the Bind button.

The new key binding shows up in the key binding list with a mode of "default" and not the mode "Dump" which I selected in the dropdown list.

Any help would be greatly appreciated.  Is there anything I can do to collect documentation on the issue? 
 

Matthew

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 990
  • Hero Points: 44
Re: Key bindings don't work with user-defined languages
« Reply #3 on: May 30, 2013, 04:20:03 pm »
Part of the confusion here is that key binding modes are not a one-to-one map with language modes.
When you created the language, if you clicked the "Inherit Keybindings and Callbacks" checkbox, then the base key mode for that language will always be used. Even if you pick that new language explicitly, it's still mapping back to the base keybindings, which in the case of Plain Text is "default". If you had created your language with C++ (or its variants) as the base language and checked the "Inherit Keybindings", you'd see that commands were being mapped to the "c" key mode.

If you do not click that checkbox, then you will be able to bind a key sequence to just that language mode (shown as "ext"). You'll still get key events and commands for everything in "default" (Ctrl+C will still copy) but now you can define your own bindings for just that language mode, which won't be pushed back into the default bindings.

bengle

  • Senior Community Member
  • Posts: 126
  • Hero Points: 4
Re: Key bindings don't work with user-defined languages
« Reply #4 on: May 30, 2013, 05:10:34 pm »
That did the trick, and I thank you very much, Matthew.    I think the confusion would be eliminated if the dropdown list in the key binding dialog only included the base languages, and not languages that were remapped to something else.   :)       

bengle

  • Senior Community Member
  • Posts: 126
  • Hero Points: 4
Re: Key bindings don't work with user-defined languages
« Reply #5 on: May 30, 2013, 06:27:22 pm »
Question: When I export the key bindings, the exported XML file simply says:
<Mode Name="ext">
If I were to import these to my other machine, for example, how would it know which language the bindings are for since it says Name="ext" and not Name="dump"? 

bengle

  • Senior Community Member
  • Posts: 126
  • Hero Points: 4
Re: Key bindings don't work with user-defined languages
« Reply #6 on: May 30, 2013, 07:04:21 pm »
Another problem...  When I open some files (I believe that it may be related to size), it opens them in Plain Text mode, and the key bindings don't work.  When I try to change the mode using Document -> Select Mode, I get a message that says "Plain Text mode chosen for better performance".

Is there any way around this?  I have the language defined such that it already looks like plain text.  Color Coding is disabled (lexer: None), auto-complete is disabled, adaptive formatting is disabled, etc.   As such, it doesn't seem that there would be any performance advantage in changing the mode to plain text.  The sole purpose in defining this language is to get the separate key bindings.  I am not utilizing any language-specific features that would impact performance.
     

Matthew

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 990
  • Hero Points: 44
Re: Key bindings don't work with user-defined languages
« Reply #7 on: May 30, 2013, 07:09:51 pm »
There are some settings in the Options dialog under Editing > General > Large File Editing. You can set the limits at which Plain Text mode is activated and when undo/redo is turned off.

bengle

  • Senior Community Member
  • Posts: 126
  • Hero Points: 4
Re: Key bindings don't work with user-defined languages
« Reply #8 on: May 30, 2013, 08:03:47 pm »
Thank you once again.  Changing the Edit size limits corrected the problem.   :D