Community
    • Login

    Compose for Notepad++ (another experimental plugin)

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    13 Posts 3 Posters 261 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.
    • CoisesC
      Coises
      last edited by

      I’ve uploaded the first version of another experimental plugin, Compose for Notepad++.

      Compose for Notepad++ implements a compose key for entering characters that are not available on the keyboard using easy-to-remember sequences, such as 'a for á or --- for an em-dash.

      As a precaution, when Compose for Notepad++ is first installed it is not enabled. You can toggle that using the first item on the plugin’s menu.

      When you press the key or key combination chosen as the Compose key Compose watches the characters you type next. When it recognizes a meaningful sequence it substitutes the characters defined for that sequence — usually entering a special character that isn’t available on your keyboard. Examples:

      • Compose AE types Æ.
      • Compose -L types £.
      • Compose .-a types ǡ.

      Pressing the Compose key twice does whatever that key or key combination did originally.

      When enabled, Compose for Notepad++ takes effect anywhere you press the Compose key in Notepad++. You can use compose key sequences in dialogs such as Find and Replace, or even in plugin dialogs, as well as when editing text.

      You can select almost any key or key combination as the Compose key using the Compose key… item on the menu. The default Compose key is the Insert key (without Alt, Ctrl or Shift). Another good choice would be the Caps Lock key, if you don’t use that key often. You can also choose a typical “shortcut-style” key combination, such as Ctrl+Alt+P.

      You can add your own sequences in a user definition file. You could use this feature to define sequences for special characters you want that are not in the pre-defined set; but since the inserted text is not limited to a single character, you could also create shorthand sequences for any text you want to insert with just a few keystrokes.

      The pre-defined sequences include all the HTML named character entities; for example, you can type Compose © to type the copyright symbol. You can also enter Compose &#...; and Compose &#x....; sequences, or just type the Compose key, the hexadecimal value of a Unicode code point, and the Enter key. (If the hexadecimal value begins with two letters, type a zero first to be sure you don’t trigger a different, pre-defined sequence.)

      Around thirty combining marks (accents) are defined. You can enter sequences using multiple marks, such as Compose .-a to type ǡ (lower case a with a dot above and a macron). Compose for Notepad++ will insert a precomposed Unicode character when one exists; otherwise it will insert the appropriate combining characters.

      A detailed help file is available.

      1 Reply Last reply Reply Quote 6
      • astewart77A
        astewart77
        last edited by

        I like it! I can move my combo memory over from my Android keyboard compose key. What is the compose-default.json5 file used for? The compose-default.jsonc file is mentioned in the help and they are similar…

        CoisesC 1 Reply Last reply Reply Quote 1
        • CoisesC
          Coises @astewart77
          last edited by Coises

          @astewart77 said in Compose for Notepad++ (another experimental plugin):

          What is the compose-default.json5 file used for?

          That file is used to prove that I still don’t understand Microsoft Visual Studio build processes.

          It’s a leftover from when I started working on the project, before I realized .jsonc was the correct extension. It shouldn’t exist.

          1 Reply Last reply Reply Quote 2
          • PeterJonesP
            PeterJones
            last edited by

            @Coises ,

            Great idea for a plugin. It’s like my pyscReplaceBackslashSequence script in PythonScript plugin (born out of this discussion), on steroids.

            My script only handled &-entities, and \U+#### and \u#### notation, so yours is a lot more powerful in what it can handle. And then being able to work in N++ dialogs as well as in the editor is just superpowered.

            I’m going to have to start playing with it – though with all the sequences, it’s going to take me a while to learn the sequences for the symbols I use most often. But since I was never able to really memorize the &-entities for the characters I use, and thus don’t actually use my script all that often, maybe if it’s a more memerable sequence, I’ll be able to actually incorporate this one into my workflow.

            1 Reply Last reply Reply Quote 1
            • PeterJonesP
              PeterJones
              last edited by PeterJones

              @Coises ,

              As I experiment with it, I am going to pester you with questions and eventually suggestions.

              My first question: when I use Plugins > Compose > User definitions file… to pick an existing file, where does the plugin store the path to that file? I cannot see it creating a file in %AppData%\Notepad++\Plugins\Config\ hierarchy to store that, nor do I see anything in the plugin folder… so I am unsure where that information is stored.

              (I will eventually have a suggestion regarding that action… but first, I need to understand what it’s currently doing.)

              CoisesC 1 Reply Last reply Reply Quote 1
              • CoisesC
                Coises @PeterJones
                last edited by

                @PeterJones said in Compose for Notepad++ (another experimental plugin):

                My first question: when I use Plugins > Compose > User definitions file… to pick an existing file, where does the plugin store the path to that file? I cannot see it creating a file in %AppData%\Notepad++\Plugins\Config\ hierarchy to store that, nor do I see anything in the plugin folder… so I am unsure where that information is stored.

                %AppData%\Notepad++\Plugins\Config\Compose.json

                PeterJonesP 1 Reply Last reply Reply Quote 0
                • PeterJonesP
                  PeterJones @Coises
                  last edited by

                  @Coises said in Compose for Notepad++ (another experimental plugin):

                  %AppData%\Notepad++\Plugins\Config\Compose.json

                  Okay, I see it this time. I don’t know why I wasn’t seeing it earlier today.

                  1 Reply Last reply Reply Quote 0
                  • PeterJonesP
                    PeterJones
                    last edited by PeterJones

                    @Coises ,

                    Two main suggestions so far:

                    1. For the user config file: it’s “nice” that you’re allowing the user to pick the file anywhere, but …
                      • even after reading the https://coises.github.io/Compose-for-NotepadPlusPlus/help.htm#userdef last night, by this morning,
                        • it wasn’t obvious to me that
                          1. that I’d be creating it from scratch, and
                          2. that I’d need to have created it and decided on my own location for it before choosing the menu command
                        • For example, on EnhanceAnyLexer plugin, it will create the config file for you if it doesn’t exist already, and the comments in the created file give you hints as to how to populate it
                      • Maybe have two menu options instead of one: “Create user definitions file” vs “Choose user definitions file”
                        • Create ⇒ have it default to being in the NPPM_GETPLUGINSCONFIGDIR alongside the Compose.json (maybe compose_userdef.jsonc),
                          • with maybe one dummy definition populated, or use your “simple example” from the help file
                          • open the file when you create it, so that you can immediately edit it
                        • Choose ⇒ use the existing “User definitions file…” action
                    2. restructure the zipfile to match Plugins Admin expectations
                      • only have DLL and compose-default.jsonc in main folder
                      • definitely put the help.htm in a docs\ folder in the zipfile
                      • probably also put README and LICENSE in the docs\ folder
                      • when installed via Plugins Admin, everything in the docs\ folder in your zipfile will end up in <n++installation>\plugins\docs\Compose\, which is where documentation is expected to reside
                        → you could have your Help button go to the local docs\Compose\help.htm if it’s there, but fall back to opening https://coises.github.io/Compose-for-NotepadPlusPlus/help.htm if it’s missing

                    –
                    update: struck out invalid statements. See my research, below.

                    CoisesC 2 Replies Last reply Reply Quote 0
                    • CoisesC
                      Coises @PeterJones
                      last edited by

                      @PeterJones said in Compose for Notepad++ (another experimental plugin):

                      restructure the zipfile to match Plugins Admin expectations

                      • only have DLL and compose-default.jsonc in main folder
                      • definitely put the help.htm in a docs\ folder in the zipfile
                      • probably also put README and LICENSE in the docs\ folder
                      • when installed via Plugins Admin, everything in the docs\ folder in your zipfile will end up in <n++installation>\plugins\docs\Compose, which is where documentation is expected to reside
                        → you could have your Help button go to the local docs\Compose\help.htm if it’s there, but fall back to opening https://coises.github.io/Compose-for-NotepadPlusPlus/help.htm if it’s missing

                      Is that documented somewhere?

                      Are you sure about \plugins\docs\Compose\ ? There is no docs folder in Notepad++\plugins folder. Not a single plugin I have, including ConfigUpdater, has created such a thing. ConfigUpdater and PythonScript have doc (no s) folders within them — i.e., plugins\ConfigUpdater\doc and plugins\PythonScript\doc.

                      If Plugins Admin really created a separate Plugins\docs folder it would be a pain in the butt for people installing manually, or else plugin authors would have to check both places.

                      Perhaps there is a convention to put documentation in a doc sub-folder, but I fail to see what practical impact that has.

                      PeterJonesP 1 Reply Last reply Reply Quote 0
                      • PeterJonesP
                        PeterJones @Coises
                        last edited by PeterJones

                        @Coises said in Compose for Notepad++ (another experimental plugin):

                        @PeterJones said in Compose for Notepad++ (another experimental plugin):

                        restructure the zipfile to match Plugins Admin expectations

                        • only have DLL and compose-default.jsonc in main folder
                        • definitely put the help.htm in a docs\ folder in the zipfile
                        • probably also put README and LICENSE in the docs\ folder
                        • when installed via Plugins Admin, everything in the docs\ folder in your zipfile will end up in <n++installation>\plugins\docs\Compose, which is where documentation is expected to reside
                          → you could have your Help button go to the local docs\Compose\help.htm if it’s there, but fall back to opening https://coises.github.io/Compose-for-NotepadPlusPlus/help.htm if it’s missing

                        Is that documented somewhere?

                        It’s not in the User Manual yet … but I know that the standard structure for the Plugins Admin zipfiles are documented somewhere. Maybe back in the v7.6.x discussions in the forum, when Don was defining the new Plugins Admin interface. Because, for example, PythonScript has multiple versions of its zipfile, some without that hierarchy, and some specifically with Plugins Admin in the name.

                        Are you sure about \plugins\docs\Compose\ ? There is no docs folder in Notepad++\plugins folder.

                        I could’ve sworn PythonScript installation created c:\program files\Notepad++\plugins\doc\PythonScript – in that, that directory exists on my computer, and I didn’t create it. But I do also see the ...\plugins\PythonScript\doc directory.

                        Not a single plugin I have, including ConfigUpdater, has created such a thing.

                        I never actually checked that. I just thought that giving it the same structure I remembered was supposed to auto-populate that directory.

                        Perhaps there is a convention to put documentation in a doc sub-folder

                        I am quite confident that at one point, it was supposed to happen automatically when installing from Plugins Admin. I’m going to have to do more research on that.

                        –
                        update: struck out invalid statements. See my research, below.

                        PeterJonesP 1 Reply Last reply Reply Quote 0
                        • CoisesC
                          Coises @PeterJones
                          last edited by

                          @PeterJones said in Compose for Notepad++ (another experimental plugin):

                          1. For the user config file: it’s “nice” that you’re allowing the user to pick the file anywhere, but …
                            • even after reading the https://coises.github.io/Compose-for-NotepadPlusPlus/help.htm#userdef last night, by this morning,
                              • it wasn’t obvious to me that
                                1. that I’d be creating it from scratch, and
                                2. that I’d need to have created it and decided on my own location for it before choosing the menu command
                              • For example, on EnhanceAnyLexer plugin, it will create the config file for you if it doesn’t exist already, and the comments in the created file give you hints as to how to populate it
                            • Maybe have two menu options instead of one: “Create user definitions file” vs “Choose user definitions file”
                              • Create ⇒ have it default to being in the NPPM_GETPLUGINSCONFIGDIR alongside the Compose.json (maybe compose_userdef.jsonc),
                                • with maybe one dummy definition populated, or use your “simple example” from the help file
                                • open the file when you create it, so that you can immediately edit it
                              • Choose ⇒ use the existing “User definitions file…” action

                          Understood: At minimum, I have inadequate documentation; but beyond that, the workflow isn’t as user-friendly as it should be.

                          I don’t much like the idea of directing users to edit files anywhere under the %AppData% hierarchy as a “normal” thing. It is an option for more sophisticated users, of course; but my personal take is that such shenanigans should be reserved for exceptional situations. I did consider whether to give users the option to select a file that they control, or whether to maintain just one, fixed file in %AppData%\Notepad++\plugins\config\Compose and try to create a controlled editing environment for that. Both for simplicity and flexibility, I chose the former approach.

                          I do see the value of giving users a way to create a new user definitions file with some instructions and samples. I would still let the user choose the name and location upon saving it — perhaps defaulting to the user’s Documents folder. (I would not want to encourage them to put it anywhere under %AppData%, though of course I wouldn’t stop them, either.)

                          I’m using the complex, powerful and idiosyncratic Common Item Dialog to implement the User definitions file dialog. I suspect I could add a New File… button the same way I added the None button; that would probably be my first attempt. I’d want to monitor the tab in which the new file opens and prompt to load it as the user definitions file whenever the user saves it. I’d have to experiment with it to see if I can find a UI that feels intuitive.

                          Alternatively, as you suggest, I could just add a different menu item for creating a user definitions file as opposed to opening one.

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

                            @PeterJones said in Compose for Notepad++ (another experimental plugin):

                            I am quite confident that at one point, it was supposed to happen automatically when installing from Plugins Admin. I’m going to have to do more research on that.

                            Faulty memory from 8+ years ago.

                            Per https://community.notepad-plus-plus.org/post/36277, the OLD (pre-7.6, non-PluginsAdmin) method had plugin documents going into ...\plugins\doc\ , and the discussion then just involved copying the docs from the old location to a new folder. I really don’t know how this computer, which I set up in early 2025, still put PythonScript documentation into that directory. Maybe I did it manually (I don’t use the Plugins Admin for PythonScript, because I use PythonScript 3.0.x, not the 2.x).

                            But, anyway, you can ignore my suggestions regarding the doc/docs hierarchy at this point. Sorry for the misinformation.

                            1 Reply Last reply Reply Quote 0
                            • PeterJonesP
                              PeterJones @Coises
                              last edited by

                              I don’t much like the idea of directing users to edit files anywhere under the %AppData% hierarchy as a “normal” thing.

                              OTOH, the “normal thing” is for plugins to store all their configuration settings – whether GUI-edited or manually edited – in the AppData hierarchy. If you give them an “edit user definitions file” menu action, along with the others I recommended, they might not even know that the file they are editing is there.

                              But I’m a strong advocate of keeping all the plugin settings in the directory that Notepad++ defines as the standard place for plugin settings. Putting any settings file anywhere else will cause confusion for anyone who knows where plugins are supposed to keep their settings.

                              I suspect I could add a New File… button the same way I added the None button; that would probably be my first attempt.

                              That’d make sense.

                              I’d want to monitor the tab in which the new file opens and prompt to load it as the user definitions file whenever the user saves it. I’d have to experiment with it to see if I can find a UI that feels intuitive.

                              to me, even just supplying something like

                              {
                                  "CC"   : "\u2102",   // double-struck capital C
                                  "rx"   : "℞",        // prescription symbol
                                  "elr"  : "\u2107",   // Euler constant
                                  "plnk" : "\u210E",   // Planck constant
                                  "wf"   : "1060 W Addison St\r\nChicago, IL 60613"
                              }
                              // please edit these to be your desired definitions
                              

                              … would be a huge improvement

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