Community
    • Login

    Notepad++ styles

    Scheduled Pinned Locked Moved General Discussion
    20 Posts 5 Posters 15.6k 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.
    • David BaileyD
      David Bailey
      last edited by

      I am wondering whether to make a plugin that would use special comments (analogous to my NamedBookmarks plugin) to create styled regions of text that would be preserved from one invocation of NP++ to the next.

      Q1 Are these styles accessible from the plugin API?
      Q2 Is there a way to invoke plugin code whenever a file is loaded into NP++?
      Q3 (my main question) - I have tried to manually create a style that uses a different font size (for headings etc) but have failed to get one of these to display with a larger font.

      My aim would be to allow the creation of text documents that would be formatted with headings etc (inside NP++), and yet be compilable code!

      David

      Claudia FrankC 1 Reply Last reply Reply Quote 0
      • dailD
        dail
        last edited by dail

        1. Yes. You can modify styles from a plugin.
        2. Yes. Notepad++ will send notifications that let you know when certain events occur, such as opening files, switching to a new file, etc.
        3. Something to keep in mind is that the lexer (e.g. C++, XML, Python, etc) determines what area’s get specific styles. For example “numbers” within C++ get style number “4”. If you wanted numbers to have a larger font size this would easily be doable with a plugin.

        I’m not sure if it is really recommended to “restyle” parts of a document but it is doable (this is how N++ makes URL links “clickable”). There are some things to watch out for, like making sure whatever style number you pick doesn’t interfere with the current lexer since it uses it’s own style numbers.

        Another option may be indicators. These have the benefit of not interfering with styling, but you can’t change the font size which is what you seem to be needing.

        1 Reply Last reply Reply Quote 0
        • Claudia FrankC
          Claudia Frank @David Bailey
          last edited by

          @David-Bailey

          are you looking for something like this?

          Cheers
          Claudia

          Alan KilbornA 1 Reply Last reply Reply Quote 0
          • Alan KilbornA
            Alan Kilborn @Claudia Frank
            last edited by

            @Claudia-Frank

            Perhaps I’m naive but doesn’t something like that violate the fixed pitch mantra of pure text editors? How would one column-select a block with that going on?

            Claudia FrankC David BaileyD 2 Replies Last reply Reply Quote 0
            • Claudia FrankC
              Claudia Frank @Alan Kilborn
              last edited by

              @Alan-Kilborn

              the text isn’t changed, just the view and yes, the block select looks interesting,
              meaning doesn’t work correctly anymore ;-)

              Cheers
              Claudia

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

                It would be awesome to be scrolling through some code and see a comment like "Never Ever Change This: " in that size! :-D

                David BaileyD Claudia FrankC Jim DaileyJ 3 Replies Last reply Reply Quote 0
                • David BaileyD
                  David Bailey @Alan Kilborn
                  last edited by

                  @Alan-Kilborn

                  "It would be awesome to be scrolling through some code and see a comment like "Never Ever Change This: "

                  That is exactly the sort of thing I have in mind, but unfortunately it looks as if all the styles are in use to display syntactic elements. I hadn’t realised that syntax colouring uses the styles - I think there would need to be some spare styles before what I have in mind would work.

                  David

                  Alan KilbornA 1 Reply Last reply Reply Quote 0
                  • Alan KilbornA
                    Alan Kilborn @David Bailey
                    last edited by

                    @David-Bailey

                    HAHA. No, I meant it the other way: It would be really depressing to see such a comment in code! And being bigger than normal size would just make it worse. :-)

                    David BaileyD 1 Reply Last reply Reply Quote 0
                    • David BaileyD
                      David Bailey @Alan Kilborn
                      last edited by

                      @Alan-Kilborn said:

                      @Claudia-Frank

                      Perhaps I’m naive but doesn’t something like that violate the fixed pitch mantra of pure text editors? How would one column-select a block with that going on?

                      LibreOffice can manage that trick - so why not NP++?

                      David

                      1 Reply Last reply Reply Quote 0
                      • David BaileyD
                        David Bailey @Alan Kilborn
                        last edited by

                        @Alan-Kilborn said:

                        @David-Bailey

                        HAHA. No, I meant it the other way: It would be really depressing to see such a comment in code! And being bigger than normal size would just make it worse. :-)

                        Well of course, if I wrote such a plugin, I’d provide a way to turn it off!

                        My idea was more that a program could show some structure rather like a DOC file. Large programs could be easier to read if they were like that.

                        David

                        Claudia FrankC 1 Reply Last reply Reply Quote 0
                        • Claudia FrankC
                          Claudia Frank @Alan Kilborn
                          last edited by

                          @Alan-Kilborn said:

                          It would be awesome to be scrolling through some code and see a comment like "Never Ever Change This: " in that size! :-D

                          Means in the future UDL version we need three types of comments.
                          Line comments, block comments and hysteria comments ;-D

                          Cheers
                          Claudia

                          1 Reply Last reply Reply Quote 0
                          • Claudia FrankC
                            Claudia Frank @David Bailey
                            last edited by

                            @David-Bailey

                            but unfortunately it looks as if all the styles are in use to display syntactic elements.

                            don’t understand this? If you are writing your own plugin you’re free to use the styles for whatever you want. What am I missing?

                            Cheers
                            Claudia

                            David BaileyD 1 Reply Last reply Reply Quote 0
                            • dailD
                              dail
                              last edited by

                              I guess some clarification would be required.

                              As @Claudia-Frank pointed out you are certainly able to write your own lexer and this would give you control over all of the styles to do whatever you want.

                              My assumption (whether right or wrong) was to work with existing lexers so that for example you could have a certain comment in C++ that would trigger certain sections to get styled differently.

                              Either way it is possible to do what you are wanting, just not easily.

                              1 Reply Last reply Reply Quote 0
                              • David BaileyD
                                David Bailey @Claudia Frank
                                last edited by

                                .

                                @Claudia-Frank said:

                                @David-Bailey

                                but unfortunately it looks as if all the styles are in use to display syntactic elements.
                                @Claudia Frank

                                don’t understand this? If you are writing your own plugin you’re free to use the styles for whatever you want. What am I missing?

                                Well with only 5 styles, if I wanted to grab one to create a heading style for example with a large bold font, that would clash with the syntax colouring if it used that same style - at best a user would have to choose syntax colouring or my plugin - one or the other. I consider syntax colouring very important, so I don’t imagine I would turn on my plugin if I couldn’t use syntax colouring! . However, if there were some spare styles - 10 say, I could dedicate one for headings and not mess up the syntax colouring.

                                Obviously, a heading would be part of a comment as far as syntax was concerned.

                                David

                                Claudia FrankC 1 Reply Last reply Reply Quote 0
                                • Claudia FrankC
                                  Claudia Frank @David Bailey
                                  last edited by Claudia Frank

                                  @David-Bailey

                                  Why do you think only 5 Styles are left?
                                  Think about the 8 possible keyword groups for an UDL.
                                  Each could be assigned with a different style if needed.
                                  Scintilla defines the style range from 0-255. See here.

                                  I assume I still have a misunderstanding.

                                  Cheers
                                  Claudia

                                  David BaileyD 1 Reply Last reply Reply Quote 0
                                  • David BaileyD
                                    David Bailey @Claudia Frank
                                    last edited by David Bailey

                                    @Claudia-Frank said:

                                    @David-Bailey

                                    Why do you think only 5 Styles are left?
                                    Think about the 8 possible keyword groups for an UDL.
                                    Each could be assigned with a different style if needed.
                                    Scintilla defines the style range from 0-255. See here.

                                    I assume I still have a misunderstanding.
                                    .
                                    .
                                    Ah - I had simply assumed there were 5 styles available because there are only 5 styles referenced in the shortcut mapper - your information is very interesting.
                                    David

                                    Claudia FrankC 1 Reply Last reply Reply Quote 0
                                    • Claudia FrankC
                                      Claudia Frank @David Bailey
                                      last edited by Claudia Frank

                                      @David-Bailey

                                      Ah, I see - but those aren’t scintilla styles at all - these are indicators.
                                      Might be a little bit confusing too ;-)

                                      Cheers
                                      Claudia

                                      1 Reply Last reply Reply Quote 0
                                      • David BaileyD
                                        David Bailey
                                        last edited by David Bailey

                                        Claudia,

                                        So can you tell me what the relationship is between ‘indicators’ and Scintilla styles? What happens if I mess with Scintilla styles inside NP++?

                                        However, I did notice in the Scintilla documentation that the vertical size of the characters is fixed. You can actually see that in the screen image that you posted - because you have used one large font, the rest of the text is spaced out ridiculously - so I don’t think my idea is practical - at least not to create something with headings and subheadings.

                                        David

                                        Claudia FrankC 1 Reply Last reply Reply Quote 0
                                        • Claudia FrankC
                                          Claudia Frank @David Bailey
                                          last edited by

                                          @David-Bailey

                                          with a style you can define different attributes to each of the chars in your text.
                                          Forground color, background color, which Font to use, if bold, italic etc…
                                          basically what you can do if using wordpad.

                                          An indicator is more like a rectangle overlaying the chars.

                                          If your plugin defines the current document as a container you have the full access in regards of styling.
                                          Notepad might jump in when someone defines a hyper link, therefore I would say, don’t use styles which
                                          are defined by npp (I assume everything within global section of stylers.xml)

                                          Cheers
                                          Claudia

                                          1 Reply Last reply Reply Quote 0
                                          • Jim DaileyJ
                                            Jim Dailey @Alan Kilborn
                                            last edited by Jim Dailey

                                            @Alan-Kilborn You could always include this (see http://patorjk.com/software/taag/#p=display&h=1&f=Small&t=Never change this!):

                                             _  _                           _                             _    _     _      _ 
                                            | \| | ___ __ __ ___  _ _   __ | |_   __ _  _ _   __ _  ___  | |_ | |_  (_) ___| |
                                            | .` |/ -_)\ V // -_)| '_| / _|| ' \ / _` || ' \ / _` |/ -_) |  _|| ' \ | |(_-<|_|
                                            |_|\_|\___| \_/ \___||_|   \__||_||_|\__,_||_||_|\__, |\___|  \__||_||_||_|/__/(_)
                                                                                              |___/                            
                                            

                                            :-)

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