• Login
Community
  • Login

How to create a C# plugin?

Scheduled Pinned Locked Moved Notepad++ & Plugin Development
plugins
38 Posts 8 Posters 7.9k 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.
  • A
    Alan Kilborn @PeterJones
    last edited by Alan Kilborn Jun 4, 2025, 11:53 AM Jun 4, 2025, 11:49 AM

    @PeterJones said:

    The first paragraph of the Marker API docs say, “Markers appear in the selection margin to the left of the text.”

    It says that, but it is not 100% true.
    If one uses SC_MARK_BACKGROUND or SC_MARK_UNDERLINE, the result is not in the margin, but rather in the text itself (as the graphical image that shows the examples–above, in Peter’s most-recent post–implies).

    Entire-line coloring seems to be what @scampsd is trying to achieve, so perhaps using marker(s) with SC_MARK_BACKGROUND will be useful.

    S 1 Reply Last reply Jun 4, 2025, 12:18 PM Reply Quote 3
    • S
      scampsd @Alan Kilborn
      last edited by Jun 4, 2025, 12:18 PM

      @Alan-Kilborn Sorry for the late reply: I don’t have the time to work on this matter every day.

      If I understand well, I seem to have the following choices:

      1. Indicators : this is something which might work, but the provided example is based on the method Npp.notepad.AllocateIndicators(numberOfIndicators, out int[] indicators), which is not very clear yet.
      2. Styles : if I understood correctly, the maximum number of styles (being 5) is not only a limitation for Notepad++ users, but also for Notepad++ plugin developers.
      3. Markers : again another approach.

      If you don’t mind, I’d like to proceed with the “Indicators” approach, but then I need to understand the AllocateIndicators() method, and it looks really not simple: the provided example launches that method and as a result, a list of indicators seems to be linked with some individual characters, present in the text.
      I have done the following modifications to the example:

      for (int ii = firstIndicator; ii <= lastIndicator; ii++)
      {
          Npp.editor.SetIndicatorCurrent(ii);
          Npp.editor.IndicSetFore(ii, new Colour(255, 0, 0)); // Colour RED
          Npp.editor.IndicSetStyle(ii, IndicatorStyle.FULLBOX); // Use full rectangle
          Npp.editor.IndicatorFillRange(ii, 5); // Not one but five characters long
      }
      

      The result is the following:
      445a9474-8cc9-4a70-b8ea-666a8112e6cc-image.png

      Can anybody explain me why the mentioned indicators get linked to the 9th, the 10th, … up to the 14th character? How can I change that and link those indicators to other characters, words, lines, …?

      E M 2 Replies Last reply Jun 4, 2025, 12:27 PM Reply Quote 0
      • E
        Ekopalypse @scampsd
        last edited by Jun 4, 2025, 12:27 PM

        @scampsd said in How to create a C# plugin?:

        Can anybody explain me why the mentioned indicators get linked to the 9th, the 10th

        You have used the IDs as the starting position.

        SCI_INDICATORFILLRANGE(position start, position lengthFill)
        
        S 1 Reply Last reply Jun 4, 2025, 2:24 PM Reply Quote 2
        • M
          Mark Olson @scampsd
          last edited by Mark Olson Jun 4, 2025, 2:19 PM Jun 4, 2025, 2:11 PM

          @scampsd
          So the purpose of AllocateIndicators is to tell Notepad++ that you want to use a certain number of indicators. Based on how many indicators you requested, Notepad++ tells you which ones you can use (that’s the out int[] parameter). These are reserved for you for the rest of the session.

          Once you have the indicators, you customize their appearance using methods like IndicSetStyle and IndicSetFore. You can do this once at startup; once you’ve customized the style it stays that way for the rest of the session.

          To style a given region of a document with an indicator, use SetIndicatorCurrent and IndicatorFillRange.

          To find all the regions of a document that are styled with a given indicator, use IndicatorStart, IndicatorEnd, and IndicatorValueAt as shown in this example from JsonTools.

          1 Reply Last reply Reply Quote 1
          • S
            scampsd @Ekopalypse
            last edited by scampsd Jun 4, 2025, 2:25 PM Jun 4, 2025, 2:24 PM

            @Ekopalypse Thanks, I get that now.
            I’m succeeding colouring some pieces of text now but you might imagine the next question: the method Npp.editor.IndicatorFillRange(int start, int length) is, as you mentioned, depending on start integer and length integer, while I’m working with entire lines.

            I’m obviously capable to calculate the start and length, based on content of “| Trace |” or “| Debug |” and the newline characters (hardcoded "\r\n"), but I’m wondering if there’s not an easier way to work with lines of text in the editor.

            A M E 3 Replies Last reply Jun 4, 2025, 2:32 PM Reply Quote 0
            • A
              Alan Kilborn @scampsd
              last edited by Jun 4, 2025, 2:32 PM

              @scampsd said:

              an easier way to work with lines of text in the editor.

              I think you need to spend some time getting more familiar with the editor API, i.e., the Scintilla documentation (a portion of which was linked to earlier). It has everything you’ll need.

              P 1 Reply Last reply Jun 4, 2025, 4:51 PM Reply Quote 3
              • M
                Mark Olson @scampsd
                last edited by Mark Olson Jun 4, 2025, 4:40 PM Jun 4, 2025, 4:39 PM

                @scampsd

                I’m obviously capable to calculate the start and length

                Be careful! Notepad++ uses UTF-8 to encode its buffers so you need to use JsonParser.ExtraUTF8Bytes and JsonParser.ExtraUTF8BytesBetween if you want to convert between indices in your C# strings and positions in the document.

                EDIT: this is only necessary if your plugin will be running on files that contain non-ASCII characters.

                C 1 Reply Last reply Jun 4, 2025, 5:58 PM Reply Quote 1
                • P
                  PeterJones @Alan Kilborn
                  last edited by Jun 4, 2025, 4:51 PM

                  @Alan-Kilborn said in How to create a C# plugin?:

                  I think you need to spend some time getting more familiar with the editor API, i.e., the Scintilla documentation (a portion of which was linked to earlier). It has everything you’ll need.

                  While that is good advice, for someone just getting started, it’s knowing where to look in that rather big document, or the right search terms, that is the difficulty.

                  For example, I’m not sure it’s natural to me to look in the “Information” section to find the commands that convert between position and line, and whether to search for line start or start line or start of line or start of the line. (And of course, a search for line or start alone finds way too many to help narrow things down.) (And yes, I did intentionally pick those examples to throw @scampsd a bone to help narrow down the search range for solving the immediate problem.)

                  Even as someone who has done a lot of interacting with Scintilla through the PythonScript interface, I can find it difficult to find the right command that I’m looking for, because I use the wrong term, or I don’t go to the right subsection to find the right group of commands to be able to find the one I’m looking for.

                  A 1 Reply Last reply Jun 4, 2025, 9:01 PM Reply Quote 2
                  • C
                    Coises @Mark Olson
                    last edited by Coises Jun 4, 2025, 6:05 PM Jun 4, 2025, 5:58 PM

                    @Mark-Olson said in How to create a C# plugin?:

                    Notepad++ uses UTF-8 to encode its buffers

                    I don’t know C# or the C# interface, so this might not be relevant there, but in general, Notepad++ may work with Scintilla using UTF-8 or “ANSI” — ANSI being the system default Windows ANSI code page. SCI_GETCODEPAGE tells you which it is; in Notepad++ it is always either CP_ACP or CP_UTF8. (Defined, for example, here.)

                    I’m not sure how that translates to the C# functions you mentioned, but there are non-ASCII characters (128 of them, different ones for each code page) that can still be represented in ANSI mode. Like any ANSI character, they take up one position in Scintilla, not the number of positions the corresponding UTF-8 character would require.

                    R 1 Reply Last reply Jun 4, 2025, 6:21 PM Reply Quote 3
                    • R
                      rdipardo @Coises
                      last edited by rdipardo Jun 4, 2025, 6:44 PM Jun 4, 2025, 6:21 PM

                      @Coises said in How to create a C# plugin?:

                      I’m not sure how that translates to the C# functions you mentioned, but there are non-ASCII characters (128 of them, different ones for each code page) that can still be represented in ANSI mode.

                      See how my .NET Core template wraps all of Scintilla’s text manipulation APIs in a private method that takes account of the document’s encoding (which may be single-byte ASCII), converting to a properly encoded byte array before the window procedure call. (Note: CodePage is the name of an interface property, which .NET Framework apparently supports, since the class library is multi-targeted.)

                      1 Reply Last reply Reply Quote 2
                      • A
                        Alan Kilborn @PeterJones
                        last edited by Jun 4, 2025, 9:01 PM

                        I said:

                        I think you need to spend some time getting more familiar with the editor API, i.e., the Scintilla documentation (a portion of which was linked to earlier). It has everything you’ll need.

                        @PeterJones said:

                        While that is good advice, for someone just getting started, it’s knowing where to look in that rather big document, or the right search terms, that is the difficulty.


                        I said what I said because I was feeling like this topic was heading in the direction of potentially a lot of spoon-feeding. Everyone should spend time with the documentation when they’re using something new, and ask detailed questions when those questions are really needed.

                        1 Reply Last reply Reply Quote 2
                        • E
                          Ekopalypse @scampsd
                          last edited by Jun 5, 2025, 8:28 AM

                          @scampsd

                          Another possibility would be to use the internal search engine of Npp and thus avoid the encoding problem.
                          This means using SCI_SEARCHINTARGET with a corresponding regular expression in a loop and then SCI_GETTARGETSTART and SCI_GETTARGETEND to determine the positions. SCI_GETTARGETEND then becomes the next start position for SCI_SEARCHINTARGET …

                          S 1 Reply Last reply Jun 5, 2025, 9:06 AM Reply Quote 0
                          • S
                            scampsd @Ekopalypse
                            last edited by Jun 5, 2025, 9:06 AM

                            @Ekopalypse : Let me start by thanking all of you for the wonderful support I’m getting from you guys.

                            At this moment I’m at the stage that I’m having the following pieces of source code:

                            int iAmountOfLines = Npp.editor.GetLineCount();
                            for (int i = 0 ; i < iAmountOfLines; i++)
                            {
                                string strCurrentLine = Npp.editor.GetLine(i);
                                if (strCurrentLine.IndexOf(Txt_Trace) != -1)
                                {
                                    Npp.editor.SetIndicatorCurrent(0); // Trace
                                    Npp.editor.IndicatorFillRange(Npp.editor.GetLineEndPosition(i) - strCurrentLine.Length, Npp.editor.GetLineEndPosition(i));
                                }
                            

                            The “if”-clause is being repeated for all log levels, and it is currently giving the following output (not correct, but very promising 😀):
                            7bb5e778-de0d-4fb5-b4eb-d8a5b1574d2d-image.png

                            When seeing that, you might wonder how I have configured the corresponding colours. Well, me too 😥. Let me show you what I mean: this is what I see when I open the corresponding configuration form:

                            3de2b277-db29-4a8d-9f4a-00a70eb3d058-image.png

                            “But Dominique, you didn’t configure your colours?”

                            Well, I did, but I forgot two things:

                            1. Using the already configured colours while re-opening the configuration form, I’ll take care of that.
                            2. Saving the already configured colours in registry, in order to avoid needing to re-configure the whole thing every time I perform a test.

                            About that last part, I have the simple question: “Where?”.

                            For your information, this is what my registry looks like at “HKey_Local_Machine\SOFTWARE”:

                            340add9b-e8ce-4f00-8c6e-5fb880ee01f2-image.png

                            You might notice two things:

                            1. There is another tool (Mozilla), having its plugins configured around that place.
                            2. There are no Notepad++ plugins being configured around that place. (Although I have some Notepad++ plugins I’ve used before)

                            Can anybody confirm if I’m at the right spot for saving Notepad++ plugin configurations? If not, what’s a place which is better suited?

                            Thanks in advance (again)

                            E 1 Reply Last reply Jun 5, 2025, 9:40 AM Reply Quote 1
                            • E
                              Ekopalypse @scampsd
                              last edited by Jun 5, 2025, 9:40 AM

                              @scampsd

                              Although the registry is actually the Windows standard, I would personally avoid it and rather use the plugin config directory. Can be determined via NPPM_GETPLUGINSCONFIGDIR.
                              However, I would create a subdirectory with the plugin name and add a json, xml, toml … file there.

                              1 Reply Last reply Reply Quote 3
                              • S
                                scampsd
                                last edited by Jul 7, 2025, 7:56 AM

                                Good morning, guys.
                                Due to circumstances (I’m on holiday for supporting my sick mother), I don’t always have time to work on the plugin, hence my absence for some weeks.

                                I have decided to save the corresponding configurations in the registry anyway, but I’m doing this on user level (HKCU instead of HKLM). As a result, I don’t need administrator privileges for running the plugin. That part is working fine now.

                                I’m now back to the colouring, and there some things are going wrong, I believe it’s due to the 2-character end-of-line, shifting the colours in a wrong way.

                                Let me show you the code I currently have:

                                #region " Key texts "
                                public static string Txt_Trace     = "| Trace |";
                                public static string Txt_Debug     = "| Debug |";
                                ...
                                
                                // define EndOfLine character
                                public const string EndOfLine = "\r\n";
                                
                                // Create a testfile
                                Npp.notepad.FileNew();
                                string text = $"{Txt_Trace}   : Test 00\r\n" +
                                              $"{Txt_Debug}   : Test 01\r\n" +
                                              $"{Txt_Info}    : Test 02\r\n"  +
                                              $"{Txt_Fatal}   : Test 03\r\n" +
                                              $"{Txt_Error}   : Test 04\r\n" +
                                              $"{Txt_Warning} : Test 05\r\n" + 
                                              ...
                                
                                // Perform the colouring
                                int iAmountOfLines = Npp.editor.GetLineCount();
                                for (int i = 0 ; i < iAmountOfLines; i++)
                                {
                                    string strCurrentLine = Npp.editor.GetLine(i);
                                    int iStartPosition, iLength;
                                    iStartPosition = Npp.editor.GetLineEndPosition(i) + EndOfLine.Length - strCurrentLine.Length;
                                    if (i != 0) iStartPosition++; // in order to replace 0-18,18-36,36-54 by 0-18,19-37,38-56
                                    iLength = Npp.editor.GetLineEndPosition(i) + EndOfLine.Length;
                                
                                    if (strCurrentLine.IndexOf(Txt_Trace) != -1)   Npp.editor.SetIndicatorCurrent(0); // Trace
                                    if (strCurrentLine.IndexOf(Txt_Debug) != -1)   Npp.editor.SetIndicatorCurrent(1); // Debug
                                    if (strCurrentLine.IndexOf(Txt_Info) != -1)    Npp.editor.SetIndicatorCurrent(2); // Info
                                    if (strCurrentLine.IndexOf(Txt_Fatal) != -1)   Npp.editor.SetIndicatorCurrent(3); // Fatal
                                    if (strCurrentLine.IndexOf(Txt_Error) != -1)   Npp.editor.SetIndicatorCurrent(4); // Error
                                    if (strCurrentLine.IndexOf(Txt_Warning) != -1) Npp.editor.SetIndicatorCurrent(5); // Warning
                                    Npp.editor.IndicatorFillRange(iStartPosition, iLength);
                                }
                                

                                Something is terribly wrong, as you can see in the following result:
                                0cb08e55-fb52-4216-bb86-6f3148947b87-image.png

                                I’ve already been experimenting a lot, but I never get it exactly right.

                                Does anybody have an idea?
                                Thanks in advance

                                S 1 Reply Last reply Jul 7, 2025, 9:20 AM Reply Quote 0
                                • S
                                  scampsd @scampsd
                                  last edited by Jul 7, 2025, 9:20 AM

                                  I’ve modified the EndOfLine character from "\r\n" into "\n" and it’s already a lot better:

                                  public const string EndOfLine = "\n";
                                  

                                  Result:

                                  4140c264-0141-4340-9e15-0ff11e3e7606-image.png

                                  As you see, the colouring per line seems to be fine now.
                                  So let’s head to the following subject: the colouring is ugly, as you can see from the following form:

                                  e40f064c-7410-476f-af15-9b741b5655b2-image.png

                                  The “Trace” colour (being red) is not really red in the Notepad++ editor.
                                  The “Debug” colour (being green) is not really green in the Notepad++ editor.
                                  …

                                  Is there a way to make sure that the colours, as defined in the configuration form (and saved into registry) are well shown in the Notepad++ editor?

                                  In case of doubt, hereby the values in the registry:

                                  reg query "HKEY_CURRENT_USER\SOFTWARE\Notepad++Plugins\NLog_Integration" /S
                                  
                                  HKEY_CURRENT_USER\SOFTWARE\Notepad++Plugins\NLog_Integration
                                      Trace_Background      REG_DWORD    0xffff0000
                                      Debug_Background      REG_DWORD    0xff00ff00
                                      Info_Background       REG_DWORD    0xff0000ff
                                      Fatal_Background      REG_DWORD    0xffff00ff
                                      Error_Background      REG_DWORD    0xffff8000
                                      Warning_Background    REG_DWORD    0xff0000ff
                                  

                                  For your information: it’s not related to the style of the indicators, as they all have the same style (FULLBOX), as you can see:

                                  Npp.editor.IndicSetStyle(..., IndicatorStyle.FULLBOX);
                                  

                                  Is there any “indicator configuration” which means something like “Show the colour of an indicator exactly as meant”? (I know it sounds silly, but you get the idea 😀)

                                  Thanks in advance

                                  E 1 Reply Last reply Jul 7, 2025, 10:04 AM Reply Quote 0
                                  • E
                                    Ekopalypse @scampsd
                                    last edited by Jul 7, 2025, 10:04 AM

                                    @scampsd said in How to create a C# plugin?:

                                    As you see, the colouring per line seems to be fine now.

                                    I don’t think this is ok because, for example, the trace lines have different colors, which makes me suspect that you are somehow overlaying different colors.
                                    Can you define just one color and see if that makes a difference?

                                    S 1 Reply Last reply Jul 7, 2025, 12:16 PM Reply Quote 0
                                    • S
                                      scampsd @Ekopalypse
                                      last edited by scampsd Jul 7, 2025, 1:24 PM Jul 7, 2025, 12:16 PM

                                      @Ekopalypse You’re right: I’ve disabled all configurations, except for the “Trace” one (I used the red colour for that one), and apparently the first “Trace” line is red and the lines between the second and third “Trace” line are some kind of “dimmed” red:

                                      29553552-46cf-4531-81b8-e2b41f7c5507-image.png

                                      I honestly believe: either something is wrong with the indicator technology, either I’m using the indicator technology in a way it’s not supposed to (I already find it very strange I need to calculate positions of individual characters in order to highlight an entire line).

                                      Does anybody have an idea?
                                      Thanks

                                      P E 2 Replies Last reply Jul 7, 2025, 2:47 PM Reply Quote 0
                                      • P
                                        PeterJones @scampsd
                                        last edited by PeterJones Jul 7, 2025, 3:07 PM Jul 7, 2025, 2:47 PM

                                        @scampsd said in How to create a C# plugin?:

                                        apparently the first “Trace” line is red and the lines between the second and third “Trace” line are some kind of “dimmed” red:

                                        The first line is the line that has the caret. Notepad++ (and all scintilla-based editors) can highlight the “active line” differently than the others, and this does affect background colors of indicators or stylers.

                                        something is wrong with the indicator technology

                                        The “indicator” colors are applied with transparency. When Notepad++ uses indicators (for Smart Highlighting, Find Mark Style, and the style-a-token coloring – which use indicators under the hood), it seems to apply a transparency of about 60% (as described here ): with Notepad++'s usage, if you have a highlight of green RGB=[0,255,0], with a white RGB=[255,255,255] background, the actual color will be RGB=[155,255,155]

                                        Ah, here it is: in Scintilla, there is the SCI_INDICSETALPHA/SCI_INDICGETALPHA to set/get the alpha (transparency) value for the given indicator. [The alpha value can range from 0 (completely transparent) to 255 (no transparency)].

                                        If you don’t like the amount of transparency you are currently seeing, I’d try getting that value to see what the “default” is, and then setting it to something less transparent, to see if it’s more to your liking.

                                        But understand: Scintilla itself, or Notpead++'s settings for other Scintilla colors, may be also applying colors with some transparency that will combine taking higher priority above your non-transparent indicators, and you might not be able to get around that. I think this might actually be the case, because from what I can find, Notepad++ is setting alpha to 255 [no transparency] for the indicators, but it’s effectively getting 60% transparency, so there is some other color merging going on under the hood, as far as I can tell.


                                        update 1: no, Notepad++ is setting the value to 100 – I was reading that as “100%”, but it’s actually 100 out of a possible 255 – which is 39% of 255: since the scale is backward (with 0 being fully transparent and 255 being non-transparent, that means 61%, which is definitely “approximately 60%”). When I ran for i in range(44): console.write("indic#{:02d} => {}\n".format(i, editor.indicGetAlpha(i))) in PythonScript, it lists most indicators at about value=30/255 (which is mostly-transparent, about 90%).

                                        indic#00 => 30
                                        indic#01 => 30
                                        indic#02 => 30
                                        indic#03 => 30
                                        indic#04 => 30
                                        indic#05 => 30
                                        indic#06 => 30
                                        indic#07 => 30
                                        indic#08 => 70
                                        indic#09 => 30
                                        indic#10 => 30
                                        indic#11 => 30
                                        indic#12 => 30
                                        indic#13 => 55
                                        indic#14 => 30
                                        indic#15 => 30
                                        indic#16 => 30
                                        indic#17 => 30
                                        indic#18 => 30
                                        indic#19 => 30
                                        indic#20 => 30
                                        indic#21 => 100
                                        indic#22 => 100
                                        indic#23 => 100
                                        indic#24 => 100
                                        indic#25 => 100
                                        indic#26 => 100
                                        indic#27 => 100
                                        indic#28 => 100
                                        indic#29 => 100
                                        indic#30 => 30
                                        indic#31 => 100
                                        indic#32 => 30
                                        indic#33 => 30
                                        indic#34 => 30
                                        indic#35 => 30
                                        indic#36 => 30
                                        indic#37 => 30
                                        indic#38 => 30
                                        indic#39 => 30
                                        indic#40 => 30
                                        indic#41 => 30
                                        indic#42 => 30
                                        indic#43 => 30
                                        

                                        (Those values are just what mine happen to be at: I’ve got a lot of plugins and other such things, so other than recognizing Notepad++'s value of “100” for its indicators, I don’t know for sure what’s setting #8 to 70 or #13 to 55)


                                        update 2:
                                        Default token#1 indicator (alpha=30):
                                        afc823eb-a8de-47d7-bfc0-c7df32fdca24-image.png

                                        Change to alpha=10:
                                        12b3f0f5-f7b1-4146-8335-178bdfa1a7dd-image.png

                                        And alpha=255:
                                        5eb1bc37-3b49-41fb-9922-128e7d434c67-image.png

                                        In each of those images, the first line is the “active line” and the second is a non-active line, so you can see how active-line affects things.

                                        1 Reply Last reply Reply Quote 1
                                        • E
                                          Ekopalypse @scampsd
                                          last edited by Jul 7, 2025, 4:10 PM

                                          @scampsd said in How to create a C# plugin?:

                                          I honestly believe: either something is wrong with the indicator technology

                                          :-D I honestly think it’s more likely to be your code. :-D

                                          3a86925b-3adb-4922-a758-baef7efacc44-{7A4904B8-FF7A-4D1E-B3D8-C98B14A86EA7}.png

                                          just a quick demo - not production ready !!

                                          fn (e Editor) set_text() {
                                          	text := c"
                                          Trace_Background      REG_DWORD    0xff0000
                                          Debug_Background      REG_DWORD    0x00ff00
                                          Info_Background       REG_DWORD    0x0000ff
                                          Fatal_Background      REG_DWORD    0xff00ff
                                          Error_Background      REG_DWORD    0xff8000
                                          Warning_Background    REG_DWORD    0x0000ff
                                          "
                                          	e.call(sci_settext, 0, isize(text))
                                          
                                          }
                                          
                                          fn (e Editor) init_indicator() {
                                          	for i in 15..21 {
                                          		e.call(sci_indicsetstyle, usize(i), 7)
                                          		match i {
                                          			15 { e.call(sci_indicsetfore, usize(i), 0xff0000) }
                                          			16 { e.call(sci_indicsetfore, usize(i), 0x00ff00) }
                                          			17 { e.call(sci_indicsetfore, usize(i), 0x0000ff) }
                                          			18 { e.call(sci_indicsetfore, usize(i), 0xff00ff) }
                                          			19 { e.call(sci_indicsetfore, usize(i), 0xff8000) }
                                          			20 { e.call(sci_indicsetfore, usize(i), 0x0000ff) }
                                          			else {}
                                          		}
                                          		e.call(sci_indicsetalpha, usize(i), 55)
                                          		e.call(sci_indicsetoutlinealpha, usize(i), 255)
                                          	}
                                          }
                                          
                                          fn (e Editor) highlight_line(line int, indicator int) {
                                          	start_pos := e.call(sci_positionfromline, usize(line), 0)
                                          	length := e.call(sci_linelength, usize(line), 0)
                                          	e.call(sci_setindicatorcurrent, usize(indicator), 0)
                                          	e.call(sci_indicatorfillrange, usize(start_pos), isize(length))
                                          }
                                          
                                          pub fn (e Editor) test() {
                                          	e.init_indicator()
                                          	e.set_text()
                                          	line_count := e.call(sci_getlinecount, 0, 0)
                                          	for i:=0; i<line_count; i++ {
                                          		length := e.call(sci_linelength, usize(i), 0)
                                          		buffer := vcalloc(length+1)
                                          		e.call(sci_getline, usize(i), isize(buffer))
                                          		line_content := unsafe { cstring_to_vstring(buffer) }
                                          		if line_content.starts_with('Trace') {
                                          			e.highlight_line(i, 15)
                                          		} else if line_content.starts_with('Debug') {
                                          			e.highlight_line(i, 16)
                                          		} else if line_content.starts_with('Info') {
                                          			e.highlight_line(i, 17)
                                          		} else if line_content.starts_with('Fatal') {
                                          			e.highlight_line(i, 18)
                                          		} else if line_content.starts_with('Error') {
                                          			e.highlight_line(i, 19)
                                          		} else if line_content.starts_with('Warning') {
                                          			e.highlight_line(i, 20)
                                          		} else {
                                          			continue
                                          		}
                                          	}
                                          }
                                          
                                          P 1 Reply Last reply Jul 7, 2025, 4:24 PM Reply Quote 2
                                          • First post
                                            Last post
                                          The Community of users of the Notepad++ text editor.
                                          Powered by NodeBB | Contributors