Community
    • Login

    strange behavior with macro

    Scheduled Pinned Locked Moved General Discussion
    28 Posts 4 Posters 2.2k 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.
    • PeterJonesP
      PeterJones @Paul Wormer
      last edited by PeterJones

      @Paul-Wormer said in strange behavior with macro:

      @Alan-Kilborn said in strange behavior with macro:

      <Action type=“2” message=“0” wParam=“43061” lParam=“0” sParam=“” />

      Alan, I tried to find the Scintilla function corresponding to IDM_SEARCH_MARKEDTOCLIP. I could not find it.

      The IDM-prefixed messages are Notepad++ menu command messages, not Scintilla messages.

      Could you please explain to me (and other interested readers) how to go from wParam="43061" via menuCmdID.h to a Scintilla function?

      Assuming you said "please explain how to go from a Notepad++ menu command to the number found in menuCmdID.h to get to wParam="43061":

      1. menuCmdID.h shows
      #define    IDM_SEARCH_MARKEDTOCLIP         (IDM_SEARCH + 61)
      
      1. Look for the first occurrence of IDM_SEARCH, which shows
      #define    IDM_SEARCH    (IDM + 3000)
      
      1. The #define for IDM near the top
      #define    IDM    40000
      
      1. So IDM_SEARCH = 40000 + 3000 = 43000, and thus IDM_SEARCH_MARKEDTOCLIP = 43000 + 61 = 43061.

      The macros section of the user manual explains how to take that 43061 number and create the type2 (Notepad++) action by putting it into the wParam.

      And reading a macro is just going in the reverse: look what type it is:

      • if it’s type2, you will use the wParam to get a number, then you will have to decompose that number into groups – most groups are the ten-thousands-place at the top level, the thousands-place for which subgroup, and the hundreds-tens-ones for which command from that group. So if you’ve got 43061, you see that it’s 40000 = IDM, so look for that definition; then you look for the 3000 that uses that IDM prefix to find IDM_SEARCH, then look for the 61 that gets added to IDM_SEARCH to find the individual command.
      • If it’s a type0 or type1, it will be a scintilla command, so use Scintilla.iface as the ID-to-Number document (noting that Scintilla.iface doesn’t show the SCI_ prefix, so if you wanted to look up 2001, you would see it as AddText=2001, which corresponds to SCI_ADDTEXT message; similarly, SCI_GETTEXT would search (case-insensitive) for GETTEXT to find [GetText=2182] in the .iface document.
      • if it’s a type3, you need the searching actions as macros section to understand what’s going on.

      —
      edit: fixed 43016 to the correct 43061 – can I blame old-age-onset dyslexia? Thanks @Lycan-Thrope for pointing this out.

      Paul WormerP 1 Reply Last reply Reply Quote 3
      • Paul WormerP
        Paul Wormer @PeterJones
        last edited by

        @PeterJones Thank you for your detailed explanation. I’m indeed confused about the borders between Scintilla and Notepad++, I often don’t know where the one starts and the other ends.

        But what I was really looking for, is a short description of the wParam named IDM_SEARCH_MARKEDTOCLIP (43061). I was hoping for a description of the type one finds in Plugins > PythonScript > Context-Help. I tried – perhaps clumsily – to generalize my question by phrasing it as a search for a description of a wParam defined in menuCmdID.h.

        I’ve searched in vain the context-help documents and the Npp user manual for a description of the wParam = 43061 search method. As it seemed to me that there must be a well-defined algorithm to find it, I asked the question earlier in this thread. Even after reading your illuminating explanation, I did not succeed in finding a description of the search method that copies a marked string to the clipboard.

        Alan KilbornA 1 Reply Last reply Reply Quote 0
        • Alan KilbornA
          Alan Kilborn @Paul Wormer
          last edited by Alan Kilborn

          @Paul-Wormer said in strange behavior with macro:

          what I was really looking for, is a short description of the wParam named IDM_SEARCH_MARKEDTOCLIP

          I’ve searched in vain the context-help documents and the Npp user manual for a description of the wParam = 43061

          I did not succeed in finding a description of the search method that copies a marked string to the clipboard.

          This is because what you are seeking to find does not exist.

          (Thus your search was actually successful?) – :-)

          IDM_SEARCH_MARKEDTOCLIP / 43061 are merely source code constructs. There is no further documentation about them.

          If you want to learn more about them, perhaps start with THIS SEARCH and go from there.

          Paul WormerP PeterJonesP 2 Replies Last reply Reply Quote 1
          • Paul WormerP
            Paul Wormer @Alan Kilborn
            last edited by

            @Alan-Kilborn So then the question arises: how in the world did you know that the topic starter missed wParam = “43061” in her/his macro?

            Alan KilbornA 1 Reply Last reply Reply Quote 0
            • Alan KilbornA
              Alan Kilborn @Paul Wormer
              last edited by Alan Kilborn

              @Paul-Wormer said in strange behavior with macro:

              how in the world did you know that the topic starter missed wParam = “43061” in her/his macro?

              Well, when the OP said:

              i think the issue is when paste copy marked text into new file.

              …that was a big clue. :-)
              So I went looking for specifically something related to that in a really short macro – it wasn’t hard to pinpoint the difficulty.

              And… the Copy Marked Text button is kind of an oddball in the Mark window, when you think about how the searching macros are encoded – it isn’t related to searching, but is rather something you do after searching.

              It is on my TODO list to file a bug report about this, since it has confused at least one user so far. There’s a workaround (as I pointed out), but it is still confusing.

              1 Reply Last reply Reply Quote 1
              • PeterJonesP
                PeterJones @Alan Kilborn
                last edited by PeterJones

                @Paul-Wormer said,

                I’ve searched in vain the context-help documents and the Npp user manual for a description of the wParam = 43061
                I did not succeed in finding a description of the search method that copies a marked string to the clipboard.

                And @Alan-Kilborn replied,

                This is because what you are seeking to find does not exist.

                It takes a little reading of the manual, and some intuition; there isn’t a nice simple name-to-description map, but the information is available. The user manual Macros section describes, in general, what the wParam is used for, and where to find details on the individual message:

                Firstly, looking in menuCmdId.h , the name of the file gives a really big hint that each of the IDM constants corresponds to a Notepad++ menu entry … but it does take some intuition.

                Secondly, it also directs you to localization\English.xml, where it says to look for those numbers. If you were to find a number like 43061 in that file, you would find one entry just labeled “Find Mark Style” in the “all menu item” <Commands> section (which would be confusing, because there are a series of entries near each other which all have that same name), but then the second instance of 43061 in the <ShortcutMapper><MainCommandNames> is the more clear “Copy Styled Text of Find Mark style”.

                However, I will add a “TODO” to try to make it more clear that the Type-2 macro entries all correspond to an entry in Notepad++'s menu system.

                Paul WormerP 1 Reply Last reply Reply Quote 0
                • Paul WormerP
                  Paul Wormer @PeterJones
                  last edited by Paul Wormer

                  @PeterJones I don’t have localization\English.xml, but I do have C:\Users[..]\AppData\Roaming\Notepad++\nativeLang.xml in which I found:

                  <Item id="43061" name="Find Mark Style"/>
                  

                  It takes lots of intuition and years of experience to associate this name with SEARCH_MARKEDTOCLIP.

                  In any case, thank you for pointing me to this file.

                  Alan KilbornA PeterJonesP 2 Replies Last reply Reply Quote 0
                  • Alan KilbornA
                    Alan Kilborn @Paul Wormer
                    last edited by

                    @Paul-Wormer said in strange behavior with macro:

                    I don’t have localization\English.xml, but I do have C:\Users[…]\AppData\Roaming\Notepad++\nativeLang.xml

                    Just a guess, but I’d suppose when using an installed version of Notepad++ (which I do not do), that english.xml would be under a localization folder under the folder in which the notepad++.exe file lives?

                    Paul WormerP 1 Reply Last reply Reply Quote 2
                    • PeterJonesP
                      PeterJones @Paul Wormer
                      last edited by PeterJones

                      @Paul-Wormer said in strange behavior with macro:

                      @PeterJones I don’t have localization\English.xml,

                      Yes you do. c:\program files\notepad++\localization\english.xml, or wherever else your Notepad++ is installed – unless you didn’t install the English language localization when you did your installation (in which case, look in whichever language you do use). See Config Files Location in the manual. That’s where nativeLang,xml comes from (when you select your localization). But yes, nativeLang.xml contains the same information, so if you cannot seem to find english.xml, then use that instead.

                      but I do have C:\Users[..]\AppData\Roaming\Notepad++\nativeLang.xml in which I found:

                      <Item id="43061" name="Find Mark Style"/>
                      

                      Umm. Did you not notice I said specifically,

                      you would find one entry just labeled “Find Mark Style” in the “all menu item” <Commands> section (which would be confusing, because there are a series of entries near each other which all have that same name), but then the second instance of 43061 in the <ShortcutMapper><MainCommandNames> is the more clear “Copy Styled Text of Find Mark style”.

                      I rather thought I covered that confusion with that sentence.

                      It takes lots of intuition and years of experience to associate this name with SEARCH_MARKEDTOCLIP.

                      That’s why I told you to keep searching for the second instance, which is a more helpful name.

                      And you seem to have not understood my explanation. If you know the ID already (ie, reading an existing macro), you can easily figure out which menu entry it maps to by searching for that number in the english.xml (or equivalent). On the other hand, if you want to figure out the number for a given menu entry, look at the name of the menu entry, then look for that text in the english.xml (or equivalent), and see the id it is associated with. Once you have that number, then you can figure out the number from menuCmdId.h if you really want to (but you don’t need to – because you already know which command ID which goes to the menu entry you are interested in).

                      Paul WormerP 1 Reply Last reply Reply Quote 1
                      • Paul WormerP
                        Paul Wormer @Alan Kilborn
                        last edited by

                        @Alan-Kilborn Yes indeed, I have English.xml under C:\Program Files\Notepad++\localization. So, which of the two files takes precedence? Isn’t having two files a bit superfluous and therefore error prone?

                        PeterJonesP Alan KilbornA 2 Replies Last reply Reply Quote 0
                        • PeterJonesP
                          PeterJones @Paul Wormer
                          last edited by

                          @Paul-Wormer ,

                          So, which of the two files takes precedence? Isn’t having two files a bit superfluous and therefore error prone?

                          6f1ddf8c-3062-4f46-940a-f671486e49e4-image.png

                          1 Reply Last reply Reply Quote 2
                          • Alan KilbornA
                            Alan Kilborn @Paul Wormer
                            last edited by

                            @Paul-Wormer said in strange behavior with macro:

                            So, which of the two files takes precedence?

                            Typically, the stuff in “appdata” is what Notepad++ is using specifically for YOU. And when a localization file is put there by the program, it calls it nativeLang.xml.

                            If you’re using English, all of the others (French, Spanish, etc.) are choices you could make in the future, so until you do, the “sources” for these are left with the main program files, with their original names.

                            1 Reply Last reply Reply Quote 2
                            • Paul WormerP
                              Paul Wormer @PeterJones
                              last edited by

                              @PeterJones Yes, I take that back. I understood perfectly well your explanation that 43061 is the key in going from Find Mark Style to IDM_SEARCH_MARKEDTOCLIP. But it takes intuition to realize that both names mean nothing more than: copy marked text to the clipboard. As Alan pointed out there is no Find involved. The Npp search popup adds to the confusion by speaking about Styled Text. I had no idea that styled text is the same as marked text, because I never looked into the text styling possibilities of N++.

                              Alan KilbornA 1 Reply Last reply Reply Quote 0
                              • Alan KilbornA
                                Alan Kilborn @Paul Wormer
                                last edited by Alan Kilborn

                                @Paul-Wormer said in strange behavior with macro:

                                the key in going from “Find Mark Style” to IDM_SEARCH_MARKEDTOCLIP

                                This may be the key part of Peter’s earlier reply for you:

                                but then the second instance of 43061 in the <ShortcutMapper><MainCommandNames> is the more clear “Copy Styled Text of Find Mark style”.

                                “Find Mark Style” is the bottom-level submenu text for the command. It may not convey full meaning until you combine it with the upper part, which is what “MainCommandNames” tries to do:

                                baa740da-7b2f-4ef4-ac8a-fe84b998b90b-image.png

                                But it takes intuition to realize that both names mean nothing more than: copy marked text to the clipboard

                                I think my current answer explains it?

                                Paul WormerP 1 Reply Last reply Reply Quote 0
                                • Paul WormerP
                                  Paul Wormer @Alan Kilborn
                                  last edited by

                                  @Alan-Kilborn said in strange behavior with macro:

                                  “Copy Styled Text of Find Mark style”

                                  You really feel that “Copy Styled Text of Find Mark style” is clear? Talking about intuition …

                                  Alan KilbornA PeterJonesP 2 Replies Last reply Reply Quote 0
                                  • Alan KilbornA
                                    Alan Kilborn @Paul Wormer
                                    last edited by Alan Kilborn

                                    @Paul-Wormer said in strange behavior with macro:

                                    You really feel that “Copy Styled Text of Find Mark style” is clear?

                                    Actually, I don’t find it poor. :-)
                                    YMMV.

                                    It actually sounds exactly like something the Notepad++ author (a non-native English speaker) would come up with. :-)

                                    1 Reply Last reply Reply Quote 1
                                    • PeterJonesP
                                      PeterJones @Paul Wormer
                                      last edited by PeterJones

                                      @Paul-Wormer ,

                                      The author of the program is not a native english speaker, and some of the legacy phrasings are not always the natural english phraseology. And sometimes it is hard to convey the full meaning in a brief piece of text that’s really just meant as an indicator in the Shortcut Mapper.

                                      Honestly, I would have preferred if the localization XML files had been organized in a <TopMenu menuId="search"><SubMenu menuId="Copy Styled Text"><Item id="43061" name="Find Mark Style"></SubMenu></TopMenu> format, because that would have made it easier for translators and users to find specific menu entries to translate. But at this late stage, after many years of using the existing format for the XML file, I highly doubt the developer would choose to completely redesign that config file, since it would also require changing the XML processing, and cause compatibility errors that would dwarf the confusion caused by the v7.9.1-conversion of the FunctionList definitions.

                                      Macros for normal users are meant to be something that they record and run, that they never have to think about the implementation details or the syntax. And they “just work”, most of the time.

                                      But if for those who want to dig into the nitty-gritty, the manual provides some guidance, but at some point, digging into the details is meant for Power Users, and Power Users are expected to have developed some intuition about the way the program works, and how to navigate through the various config files and menu systems and establish those mental mappings. And nothing but repeated readings of the manuals and tutorials that exist, navigating through the config files, and experimenting to figure things out will help you build that intuition. If you are not yet at that Power User level, that’s fine… but then you cannot expect to understand Power User details until you invest the effort. You can feel free to ask questions, and we will do our best to answer; but no answer we give nor phrasing of the user manual will ever turn you into an immediate Power User.

                                      ----
                                      Addendum: I do grant that one can be a Power User in one area of the application, and not in another, and some are easier to gain Power User status in than others. Macros may be one of the more complicated. You have often given great advice to other users, which I have appreciated and upvoted. However, in this instance, you may have to invest more time into exploring Macro syntax, and experimenting with going through the various steps I showed above, in order to gain Power User status on the Macros feature.

                                      Paul WormerP 1 Reply Last reply Reply Quote 3
                                      • Paul WormerP
                                        Paul Wormer @PeterJones
                                        last edited by Paul Wormer

                                        @PeterJones Well, this discussion makes it perfectly clear that I am not a “Power User” . It is a status I do not necessarily strive for. But this doesn’t mean that I don’t want to understand some of the topics that are discussed on this forum. As you rightly point out, this isn’t easy, the navigation through the Scintilla and Npp docs, reading your extensive user manual, all the possible settings etc., a non-Power-User experiences it as a jungle. Just like a real jungle all this has grown over the years, and not always in a clean, logical direction, I understand that.

                                        1 Reply Last reply Reply Quote 3
                                        • Alan KilbornA
                                          Alan Kilborn
                                          last edited by

                                          I opened an official issue about the original topic of this thread: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/13405

                                          Alan KilbornA 1 Reply Last reply Reply Quote 3
                                          • Alan KilbornA
                                            Alan Kilborn @Alan Kilborn
                                            last edited by

                                            @Alan-Kilborn said in strange behavior with macro:

                                            I opened an official issue about the original topic of this thread: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/13405

                                            This issue has been fixed and will appear in the next version of Notepad++, presumably that will be 8.5.2.

                                            1 Reply Last reply Reply Quote 3
                                            • First post
                                              Last post
                                            The Community of users of the Notepad++ text editor.
                                            Powered by NodeBB | Contributors