• Login
Community
  • Login

UDL: Suffix Mode

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
54 Posts 8 Posters 19.8k 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
    Alexander Seidel
    last edited by Alexander Seidel Oct 9, 2019, 8:53 AM Oct 9, 2019, 8:51 AM

    Thanks for the quick work, Eko!
    Sadly, the code doesn’t work :(

    Now, I checked the conditional function, and noticed that getStyleAt returns 0 if the pos is out of bounds, but weirdly, when I use this line:

    if (pos >= 0) and (editor.getStyleAt(pos) == 0):
    

    the code works and does so just as I intended. Comment lines are not changed, but normal lines are.

    d6e787c3-dde6-403d-892e-79fbdb564fdb-image.png

    I really don’t get why it does, because I expected it to only return 0 in case of an error, and not for normal lines in the text, but apparently that’s how it works.

    Concerning the italic: Yes, I set a lot of variably type names like int and double to italic, but the language I’m programming in also has int(“4”) and string(4) as functions at the same time.

    E 2 Replies Last reply Oct 9, 2019, 11:54 AM Reply Quote 0
    • E
      Ekopalypse @Alexander Seidel
      last edited by Ekopalypse Oct 9, 2019, 11:57 AM Oct 9, 2019, 11:54 AM

      @Alexander-Seidel

      sorry, Hochmut kommt vor dem Fall, I didn’t test it otherwise I would have
      seen that paint_it is a staticmethod and as such it has no access to self object.

      Remove the @staticmethod decorator and add self to be the first parameter
      to paint_it like this

      
              def paint_it(self, color, pos, length):
                  if (pos >= 0) and (editor.getStyleAt(pos) not in self.excluded_styles):
                      editor.setIndicatorCurrent(0)
                      editor.setIndicatorValue(color)
                      editor.indicatorFillRange(pos, length)
      

      If you open the console window while having the old version running,
      you should see that it throws an error - so it didn’t do anything at all.

      getStyleAt returns the style id and you compare with style 0, so it works as long as the part to be colored is currently colored with the style 0.

      Which means, your code is good as well if you are only interested
      in modifying parts of code which are used by style 0.

      1 Reply Last reply Reply Quote 1
      • E
        Ekopalypse @Alexander Seidel
        last edited by Oct 9, 2019, 12:11 PM

        @Alexander-Seidel

        regarding the italic issue, what about using a delimiter with
        open int( and closing ) and setting it color to the default color?

        1 Reply Last reply Reply Quote 0
        • A
          Alexander Seidel
          last edited by Oct 9, 2019, 12:25 PM

          @Ekopalypse said in UDL: Suffix Mode:

          If

          I just used this line now:
          if pos >= 0 and (editor.getStyleAt(pos) not in [1, 2]):

          and nice tip for the italics! That worked perfectly. I first tried to just make a keyword int(, but that didn’t work.

          E 1 Reply Last reply Oct 9, 2019, 12:27 PM Reply Quote 2
          • E
            Ekopalypse @Alexander Seidel
            last edited by Oct 9, 2019, 12:27 PM

            @Alexander-Seidel

            or like this yes :-) Many roads to Rome I guess :-D

            1 Reply Last reply Reply Quote 0
            • B
              bruh
              last edited by Jan 1, 2021, 11:39 PM

              self.regexes[(0, self.rgb(79, 175, 239) | SC_INDICVALUEBIT)] = (r’fn[A-Za-z0-9_]+?$|([A-Za-z0-9_]+?$)', 1)

              Will adding ^\w+.(gif|png|jpg|jpeg)$ instead of r’fn[A-Za-z0-9_]+?$|([A-Za-z0-9_]+?$)’ make it work on .gif .png .jpg and .jpeg suffixes?

              E 1 Reply Last reply Jan 1, 2021, 11:44 PM Reply Quote 1
              • E
                Ekopalypse @bruh
                last edited by Jan 1, 2021, 11:44 PM

                @bruh said in UDL: Suffix Mode:

                ^\w+.(gif|png|jpg|jpeg)$

                you mean for highlighting?

                B 3 Replies Last reply Jan 2, 2021, 9:24 AM Reply Quote 0
                • B
                  bruh @Ekopalypse
                  last edited by Jan 2, 2021, 9:24 AM

                  @Ekopalypse Yeah highlighting the entire word thst contains .gif or the others

                  1 Reply Last reply Reply Quote 1
                  • B
                    bruh
                    last edited by Jan 2, 2021, 12:23 PM

                    This post is deleted!
                    1 Reply Last reply Reply Quote 0
                    • B
                      bruh @Ekopalypse
                      last edited by Jan 2, 2021, 12:35 PM

                      This post is deleted!
                      1 Reply Last reply Reply Quote 0
                      • B
                        bruh @Ekopalypse
                        last edited by Jan 2, 2021, 12:50 PM

                        @Ekopalypse Nvm yet again i just added everything ie [0-9a-zA-Z_/\-.|+-#$!"%&()=?*@'~\ˇ^\˘\°;:,{}\˛`\˙\´\¨\¸\ß\Ł\ł\¤\×\÷\č\ć\ž\đ\p\š\€\§] and it works xD sry for the spam

                        E 1 Reply Last reply Jan 2, 2021, 12:56 PM Reply Quote 1
                        • E
                          Ekopalypse @bruh
                          last edited by Jan 2, 2021, 12:56 PM

                          @bruh

                          … and it works

                          Great, if anything is unclear or I can do, let me know.

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