• Login
Community
  • Login

custom syntax highlighting [JS]

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
13 Posts 2 Posters 10.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.
  • W
    Wolf War
    last edited by Wolf War Apr 3, 2016, 8:19 PM Apr 3, 2016, 8:18 PM

    @Claudia-Frank said:

    keywordClass=“instreX”

    Hi @Claudia-Frank
    I’ve manged to do something but not good enough
    In theme that I’m using Waher-style I added new WordsStyle tag with unique name and ID…
    and it is recognized by app style editor (shown in list as MY_KEYWORDS)
    http://prntscr.com/anqf7m

    but any word that I add to it it, behaves like old predefined keywords style
    http://prntscr.com/anqfw5
    in this case chrome should be green as my costume keyword, but its colored as default keyword

    I think that klassKeyword plays roll in it… if I add keywordClass=“instre1” it’s like old keyword
    if I change instre to another number, no coloring… do I need to define that new instre eg instre2 somwhere else?

    1 Reply Last reply Reply Quote 0
    • C
      Claudia Frank
      last edited by Apr 3, 2016, 10:02 PM

      Yes, in langs.xml add a new keywords tag with your keywords.

      Cheers
      Claudia

      1 Reply Last reply Reply Quote 0
      • W
        Wolf War
        last edited by Apr 4, 2016, 10:15 PM

        @Claudia-Frank
        hmm I tried but without luck

        C 1 Reply Last reply Apr 4, 2016, 10:27 PM Reply Quote 0
        • C
          Claudia Frank @Wolf War
          last edited by Apr 4, 2016, 10:27 PM

          Hello @Wolf-War,

          as an example what I have done for python

          in langs.xml

              <Language name="python" ext="py pyw" commentLine="#">
                  <Keywords name="instre1">and as assert break class continue def del elif else except exec False finally for from global if import in is lambda None not or pass print raise return True try while with yield</Keywords>
                  <Keywords name="instre2">editor editor1 editor2 notepad console</Keywords>
              </Language>
          

          I added the a second keywords tag and named it instre2 with a given list of keywords.

          In Dark2012.xml (the theme that I use) I modified

              <LexerType name="python" desc="Python" ext="">
                  <WordsStyle name="DEFAULT" styleID="0" fgColor="C8C8C8" bgColor="1E1E1E" fontName="" fontStyle="0" fontSize="" />
                  <WordsStyle name="COMMENTLINE" styleID="1" fgColor="57A64A" bgColor="1E1E1E" fontName="" fontStyle="0" fontSize="" />
                  <WordsStyle name="NUMBER" styleID="2" fgColor="BD63C5" bgColor="1E1E1E" fontName="" fontStyle="1" fontSize="" />
                  <WordsStyle name="STRING" styleID="3" fgColor="D69D85" bgColor="1E1E1E" fontName="" fontStyle="0" fontSize="" />
                  <WordsStyle name="CHARACTER" styleID="4" fgColor="D69D85" bgColor="1E1E1E" fontName="" fontStyle="0" fontSize="" />
                  <WordsStyle name="KEYWORDS" styleID="5" fgColor="367DC6" bgColor="1E1E1E" fontName="" fontStyle="0" fontSize="" keywordClass="instre1" />
                  <WordsStyle name="TRIPLE" styleID="6" fgColor="C8C8C8" bgColor="1E1E1E" fontName="" fontStyle="0" fontSize="" />
                  <WordsStyle name="TRIPLEDOUBLE" styleID="7" fgColor="C8C8C8" bgColor="1E1E1E" fontName="" fontStyle="0" fontSize="" />
                  <WordsStyle name="CLASSNAME" styleID="8" fgColor="8080FF" bgColor="1E1E1E" fontName="" fontStyle="0" fontSize="" />
                  <WordsStyle name="DEFNAME" styleID="9" fgColor="8080FF" bgColor="1E1E1E" fontName="" fontStyle="0" fontSize="" />
                  <WordsStyle name="OPERATOR" styleID="10" fgColor="FF8000" bgColor="1E1E1E" fontName="" fontStyle="0" fontSize="" />
                  <WordsStyle name="IDENTIFIER" styleID="11" fgColor="8DA6CE" bgColor="1E1E1E" fontName="" fontStyle="0" fontSize="" />
                  <WordsStyle name="COMMENTBLOCK" styleID="12" fgColor="57A64A" bgColor="1E1E1E" fontName="" fontStyle="0" fontSize="" />
                  <WordsStyle name="DECORATOR" styleID="13" fgColor="D69D85" bgColor="1E1E1E" fontName="" fontStyle="0" fontSize="" />
                  <WordsStyle name="USERDEFINED" styleID="14" fgColor="D69D85" bgColor="1E1E1E" fontName="" fontStyle="0" fontSize="" keywordClass="instre2"/>
              </LexerType>
          

          the lexertype tag by adding a new word style with name USERDEFINED (can be any other name), styleID=14 (which was the next in row)
          and added keywordClass=“instre2” to reflect the changes in langs.xml.

          Did you do the same?

          Cheers
          Claudia

          1 Reply Last reply Reply Quote 0
          • W
            Wolf War
            last edited by Apr 5, 2016, 7:31 AM

            @Claudia-Frank
            thanx for your effort
            yes, I did that but in actual code there is not effect
            in Style Configurator everything is recognized (MY_KEYWORDS) but the words are not colored (green)

            Alt

            C 1 Reply Last reply Apr 5, 2016, 7:33 AM Reply Quote 0
            • C
              Claudia Frank @Wolf War
              last edited by Apr 5, 2016, 7:33 AM

              @Wolf-War
              can you point me to the location from where you’ve downloaded the waher style?
              I would give it a try to test and see what the problem is.

              Cheers
              Claudia

              1 Reply Last reply Reply Quote 0
              • W
                Wolf War
                last edited by Apr 5, 2016, 8:33 AM

                @Claudia-Frank
                I’m not sure where I download it from, long time ago
                but here is the file that I’m using (uploaded to Gdrive)

                C 1 Reply Last reply Apr 5, 2016, 9:21 AM Reply Quote 0
                • C
                  Claudia Frank @Wolf War
                  last edited by Apr 5, 2016, 9:21 AM

                  @Wolf-War

                  you are right, it doesn’t work with javascript.
                  First I tried my python changes, which worked fine but changing the same for javascript doesn’t work.
                  As you said, we are seeing the new keywords but different coloring doesn’t happen.

                  Need to investigate this.

                  Cheers
                  Claudia

                  1 Reply Last reply Reply Quote 0
                  • W
                    Wolf War
                    last edited by Apr 5, 2016, 9:32 AM

                    @Claudia-Frank
                    thank you for confirming this

                    C 1 Reply Last reply Apr 5, 2016, 11:46 PM Reply Quote 0
                    • C
                      Claudia Frank @Wolf War
                      last edited by Apr 5, 2016, 11:46 PM

                      @Wolf-War

                      ok, short answer, javascript doesn’t support it.

                      Longer answer javascript doesn’t support all keyword class names, which would be

                      • instre1
                      • instre2
                      • type1
                      • type2
                      • type3
                      • type4
                      • type5

                      It only supports instre1, instre2 and type1 - hardcoded in source (),
                      the same applies to the styles names like number, word, keyword …
                      You can define a new style name but it never gets used.

                      Beside this, waher.xml has to name it javascript.js

                      <LexerType name="javascript.js" desc="JavaScript" ext="">
                      

                      as javascript has become the embedded one.

                      Cheers
                      Claudia

                      1 Reply Last reply Reply Quote 0
                      • W
                        Wolf War
                        last edited by Apr 6, 2016, 9:57 AM

                        @Claudia-Frank
                        ok, tnx again
                        at least I didn’t screw it :)
                        cheers

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