1

I'm trying to change the comment/uncomment hotkey, but it's not working. I'm on a Mac, but I want to actually use the Ctrl key modifier instead of the Cmd key. Since the hotkey that I want to use is already assigned to something else, I'm trying to assign that hotkey too, to avoid conflict.

I've typed the following in the user settings and saved the file, but it's not working. The default hotkeys are still in effect.

--[[--
  Use this file to specify **User** preferences.
  Review [examples](+/Volumes/ZeroBraneStudio/ZeroBraneStudio.app/Contents/ZeroBraneStudio/cfg/user-sample.lua) or check [online documentation](http://studio.zerobrane.com/documentation.html) for details.
--]]--

  keymap[ID.REPPLACEINFILES] = "Ctrl-Alt-R"
  keymap[ID.REPLACE]         = "Ctrl-Shift-R"
  keymap[ID.COMMENT]         = "Ctrl-R"

What am I doing wrong or missing?

Bernoulli Lizard
  • 537
  • 1
  • 12
  • 23

1 Answers1

0

Since the hotkey that I want to use is already assigned to something else, I'm trying to assign that hotkey too, to avoid conflict.

This is the correct idea.

I see two reasons: you have a typo in ID.REPPLACEINFILES (double P) and Ctrl is always mapped to Cmd on macOS. You need to use RawCtrl instead (as it's mapped to Ctrl on all platforms, including macOS). See this section for details: https://github.com/pkulchenko/ZeroBraneStudio/blob/master/src/editor/keymap.lua#L27-L29

Paul Kulchenko
  • 25,884
  • 3
  • 38
  • 56
  • This works the first time it is used, but never twice in a row. For example, I've assigned the hotkey RawCtrl+s to 'save.' If the file has changes, this works. If the file has already been save, pressing the hotkey 'types' a box with (in this case) the text "DC3." This happens for pretty much every hot key I've assigned. Why does this happen? – Bernoulli Lizard Apr 26 '20 at 04:43
  • I don't think it's related to hotkey handling. It's likely that pressing Ctrl+S in the editor produces some sort of control character that is being displayed. When the file is saved, the "Save" menu items becomes disabled, so pressing Ctrl+S again doesn't trigger saving, but gets handled by the editor tab producing the control character. I may suggest a workaround to handle this, but need to do a bit of testing first. – Paul Kulchenko Apr 26 '20 at 05:56
  • Ok, thanks; I thought it might be that. If you know of a way to either disable the feature in the editor that prints the control character, or to disable/re-enable hotkeys based on their menu item state, that would be great. – Bernoulli Lizard Apr 26 '20 at 14:43
  • You can try adding the following line to the ide config (`user.lua`): `package { onEditorCharAdded = function(self, editor, event) if event:GetKey() < 32 then return false end end }` – Paul Kulchenko Apr 26 '20 at 17:11
  • Thanks, but for me adding that line didn't change anything. The line starts at the word package, right? So I'm not copying and including the name of the file `(user.lua ):`? Also, is the only way to have changes to the user.lua file take effect to completely restart my IDE? I can't just reload the config? – Bernoulli Lizard Apr 26 '20 at 17:59
  • Yes, just include the line starting from "package" to one of the configuration files listed here: https://studio.zerobrane.com/doc-configuration – Paul Kulchenko Apr 26 '20 at 18:23
  • Since this doesn't work, is there any other solution? The entire IDE is unusable because of this problem. – Bernoulli Lizard Apr 27 '20 at 05:44
  • 1
    You can try the following in the config: `package { onEditorCharAdded = function(self, editor, event) local key = event:GetKey() if key < 32 and key ~= 10 then editor:Undo() return false end end }` – Paul Kulchenko Apr 27 '20 at 18:46