• Login
Community
  • Login

Two Questions About Shortcut Mapper

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
8 Posts 4 Posters 658 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B
    Bob Smith 0
    last edited by Apr 3, 2024, 6:28 PM

    1. Using the excellent shortcut mapper, I defined Num+ and Num- to SCI_LINESCROLLUP/DOWN. Works fine, except those keystrokes at the same time also insert + and - symbols into the text. How can I stop the text insertion?

    2. (Perhaps related to Q#1) How do I define (say) Alt-a to insert a Unicode character into the text (say ⍺ a.k.a. U+237A, lowercase Greek alpha)? I have a bunch of these I would like to define.

    Great program! Thanks for any help you can provide.

    P 1 Reply Last reply Apr 3, 2024, 7:12 PM Reply Quote 1
    • P
      PeterJones @Bob Smith 0
      last edited by Apr 3, 2024, 7:12 PM

      @Bob-Smith-0 ,

      except those keystrokes at the same time also insert + and - symbols into the text.

      The intention for typable keys (any of the alphanumeric or punctuation) available in the shortcut mapper is that you will only assign shortcuts to those keys if there’s a non-typable modifier. So Alt+Num+ and Alt+Num- would work, without typing. I doubt that the developer would implement the ability to circumvent the typing of a character from the keyboard (imagine assigning a command to the shortcut b, and never being able to type the name Bob again!)

      How do I define (say) Alt-a to insert a Unicode character into the text

      My recommendation would be to record a macro of you typing it in using the Windows Alt+NumericKeypad hex-numpad syntax (*). So

      1. Macro > Start Recording
      2. Hold Alt, then type Num+ then 237 on the keypad then A, then finally release Alt ⇒ the ⍺ will be typed
      3. Macro > Stop Recording
      4. Macro > Save Current Recorded Macro ⇒ Give it a name (like type ⍺) and a shortcut
        5e1394e8-b4f3-47a1-8e55-7d15929207e7-image.png

      Once you’ve got one, you could theoretically edit the %AppData\Notepad++\shortcuts.xml to copy/paste the main sequence, and just change the name and keystroke and sParam="⍺" for each. For example, here are ⍺ U+237A and ß U+00DF as Alt+A and Alt+B:

              <Macro name="type ⍺" Ctrl="no" Alt="yes" Shift="no" Key="65">
                  <Action type="1" message="2170" wParam="0" lParam="0" sParam="⍺" />
              </Macro>
              <Macro name="type ß" Ctrl="no" Alt="yes" Shift="no" Key="66">
                  <Action type="1" message="2170" wParam="0" lParam="0" sParam="ß" />
              </Macro>
      

      _* Note: You can enable the extended Unicode syntax by creating/setting the registry key HKEY_Current_User/Control Panel/Input Method to have a REG_SZ entry EnableHexNumpad set to 1. Now any Unicode up to U+FFFD can be entered with that by using the Alt, Num+, and entering the hex Unicode codepoint; and any from U+10000 and above can be entered by using their two four-hex-digit surrogate codes as two Alt+Num+ codes.

      say ⍺ a.k.a. U+237A, lowercase Greek alpha

      Not related to your question, but I thought I’d clarify: ⍺ U+237A looks like a lowercase Greek alpha, but is actually “APL FUNCTIONAL SYMBOL ALPHA”, and is not considered a “letter character” in Unicode, whereas α U+03B1 is the official “GREEK SMALL LETTER ALPHA”, and is considered a “letter character” in Unicode. They have different uses/meanings in Unicode, as described in the wikipedia: Digital encoding of APL symbols .

      (For the irony, I used U+00DF LATIN SMALL LETTER SHARP S instead of a beta for the Alt+B example, above.)

      If you’re going to be doing lots of different Unicode characters, I would look into an alternate method of entry, rather than dozens or hundreds of shortcuts… I personally have a script for the PythonScript plugin called pyscReplaceBackslashSequence.py which I have mapped to Alt+\ , and if I type \u+XXXX then hit Alt+\, it will replace it with the appropriate Unicode character; this can be installed per the instructions in our PythonScript FAQ.

      A 1 Reply Last reply Apr 3, 2024, 7:18 PM Reply Quote 2
      • A
        Alan Kilborn @PeterJones
        last edited by Alan Kilborn Apr 3, 2024, 7:19 PM Apr 3, 2024, 7:18 PM

        @PeterJones said in Two Questions About Shortcut Mapper:

        The intention for typable keys (any of the alphanumeric or punctuation) available in the shortcut mapper is that you will only assign shortcuts to those keys if there’s a non-typable modifier.

        It seems that situations like the Num+ example should be trapped-out if a modifier isn’t added to the combination. Or, the “Num-x” commands should be an exception to the no-modifiers rule naturally, because there is always a way to get the character they represent, without the numeric keypad being involved.

        FWIW, I tried assigning the “Open containing folder in Explorer” command to the barebones Num+, and it worked to run Explorer without also putting a + in the document.

        P 1 Reply Last reply Apr 3, 2024, 7:25 PM Reply Quote 2
        • P
          PeterJones @Alan Kilborn
          last edited by PeterJones Apr 3, 2024, 7:33 PM Apr 3, 2024, 7:25 PM

          @Alan-Kilborn said in Two Questions About Shortcut Mapper:

          FWIW, I tried assigning the “Open containing folder in Explorer” command to the barebones Num+, and it worked to run Explorer without also putting a + in the document.

          So it’s exhibiting different behavior for Scintilla commands vs builting commands. This is then a bug, IMO.

          @Bob-Smith-0 , for #1, I recommend you read our FAQ: Feature Request or Bug Report and put in an official Bug Report, where you explain that mapping Num+ or Num- to a Notepad++ command (like File > Open Containing Folder > Explorer) will map the action and correctly not type the + or -, but mapping Num+ to a Scintilla command (like SCI_LINESCROLLUP/DOWN) will cause it to do the Scintilla action and incorrectly also type the + or -.

          @Alan-Kilborn,

          It seems that situations like the Num+ example should be trapped-out if a modifier isn’t added to the combination. Or, the “Num-x” commands should be an exception to the no-modifiers rule naturally, because there is always a way to get the character they represent, without the numeric keypad being involved.

          Apparently, while my internal recommendation has always been “typeable”, the actual rule seems to not allow lonely alphanumeric, but the special keys and punctuation keys are mappable, even without modifier. So yes, Num-x commands are exceptions to the no-modifiers rule, but as Scintilla hotkeys they do “too much”

          C 1 Reply Last reply Apr 4, 2024, 12:23 AM Reply Quote 1
          • C
            Coises @PeterJones
            last edited by Coises Apr 4, 2024, 12:29 AM Apr 4, 2024, 12:23 AM

            @PeterJones said in Two Questions About Shortcut Mapper:

            So it’s exhibiting different behavior for Scintilla commands vs builting commands. This is then a bug, IMO.

            I traced this much. For Scintilla commands, Notepad++ calls SCI_ASSIGNCMDKEY to set the association and lets Scintilla handle it from there.

            However, Scintilla doesn’t contain the message loop — Notepad++ does. And since keys assigned to Scintilla commands aren’t Notepad++ commands, they go through the normal call to TranslateMessage . Part of what TranslateMessage does is to add a WM_CHAR message following a WM_KEYDOWN for a printable character. TranslateMessage consults the keyboard layout and state to determine what character to send; for the plus key on the numeric keypad with no modifier keys down it creates a WM_CHAR message containing a “+” character.

            The WM_CHAR message goes to Scintilla, which handles it here . Since “+” is not a control character, the code in the if block executes, and the character is added to the document.

            Addressing this in Notepad++ would require either bypassing TranslateMessage without using either of the standard alternatives (IsDialogMessage or TranslateAccelerator) instead, or intercepting the DispatchMessage call for the WM_CHAR message. I don’t know what pitfalls those things might create, but either would be an “unusual” thing to do. It could get messy.

            I don’t know if Scintilla could address it, because I don’t know the reasoning behind all the logic there. (It looks like it might be designed to skip ASCII control characters, but not printable or non-ASCII characters, when a command action was just triggered. I don’t know the reason for that choice, if that is what they intended.)

            1 Reply Last reply Reply Quote 2
            • A
              Alan Kilborn
              last edited by Apr 4, 2024, 12:54 AM

              Github issue was created: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/14936

              1 Reply Last reply Reply Quote 1
              • B
                Bob Smith 0
                last edited by Apr 4, 2024, 8:16 PM

                I tried the suggestions from @PeterJones (Thank You Very Much) to insert lines into my shortcuts.xml file to enable typing APL characters, which worked perfectly for all 94 macros.

                There are 11 keys for which I had to scramble to find the corresponding virtual keycode. For others who may follow this path here they are

                KeyCap                   KeyCode    KeyName
                Semicolon/Colon            186      VK_OEM_1
                Equal/Plus                 187      VK_OEM_PLUS
                Comma/Leftcaret            188      VK_OEM_COMMA
                Hyphen/Underbar            189      VK_OEM_MINUS
                Period/Rightcaret          190      VK_OEM_PERIOD
                Slash/Query                191      VK_OEM_2
                Backtick/Tilde             192      VK_OEM_3
                Leftbracket/Leftbrace      219      VK_OEM_4
                Backslash/Stile            220      VK_OEM_5
                Rightbracket/Rightbrace    221      VK_OEM_6
                Singlequote/Doublequote    222      VK_OEM_7
                

                The above correspondences between KeyCaps and KeyNames were copied from a wensite I can’t mention here. There may be other sources, but this one worked for me.


                Also, I tried replying to the previous message to thank the folks who helped me, but was told I needed a higher reputation. I tried upvoting to improve my rep, but that, too, needed a higher rep.

                Instead, I’d like to thank you all for all of your help.

                P 1 Reply Last reply Apr 4, 2024, 8:30 PM Reply Quote 3
                • P
                  PeterJones @Bob Smith 0
                  last edited by PeterJones Apr 4, 2024, 8:31 PM Apr 4, 2024, 8:30 PM

                  @Bob-Smith-0 ,

                  There are 11 keys for which I had to scramble to find the corresponding virtual keycode.

                  Those keystrokes are mentioned in the FAQ: List of Notepad++ key combinations, available for shortcuts – for example, VK_OEM_1 is in the “third part” in that FAQ. (Search that page for third part or VK_OEM_1 to find it)

                  ----

                  and Forum related stuff:

                  copied from a wensite I can’t mention here

                  No one had upvoted you yet, so you could not post links to external sites. (Otherwise, the forum just becomes an open invitation to spam bots; the amount of spam we have to deal with has dropped significantly since the link-reputation rule was put in.)

                  I tried replying to the previous message to thank the folks who helped me, but was told I needed a higher reputation.

                  You needed a higher reputation to post an external link; if it weren’t for that link, you would have been able to reply. I have used moderator powers to merge this back into the original discussion.

                  I tried upvoting to improve my rep

                  You cannot improve your own reputation yourself (otherwise, spammers would just upvote themselves or each other to get around this limitation).

                  I normally try to upvote well-asked questions, but forgot in your case. I have upvoted your posts, so things should be easier for you going forward.

                  1 Reply Last reply Reply Quote 0
                  2 out of 8
                  • First post
                    2/8
                    Last post
                  The Community of users of the Notepad++ text editor.
                  Powered by NodeBB | Contributors