Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    User Defined language multiple questions

    Help wanted · · · – – – · · ·
    udl
    2
    23
    2025
    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.
    • Spiralo-Idioide
      Spiralo-Idioide last edited by

      I tried to use user defined language feature of notepad++ to have highlighting on the textual version of the visual programing language GP Blocks, gpblocks.org.

      But I had multiple problems :

      • When I open a new file the blocks don’t act as excepted and I can’t fold and unfold them as I would Like. But they do work when I copy the text in a new File.

      • When variable contains numbers in it’s name and is inside parenthesis, the nuber are highlighted.

      Also there are some things I don’t know how to do :

      • Having a function list. If possible from all the files in my worspace and it would be perfect if they can be highlighted.

      • Having vars highlighted even all with the same color

      Thanks !

      Ekopalypse 1 Reply Last reply Reply Quote 1
      • Ekopalypse
        Ekopalypse @Spiralo-Idioide last edited by

        @Spiralo-Idioide

        Hard to say with such limited information unless one knows gpblocks and did already what you’re trying to do. For the rest of us it would help to provide the udl xml and an code example which could be used to do some tests. Screenshots wouldn’t be bad as well.

        1 Reply Last reply Reply Quote 1
        • Spiralo-Idioide
          Spiralo-Idioide last edited by

          Okep, just wait something like 10 mn

          1 Reply Last reply Reply Quote 1
          • Spiralo-Idioide
            Spiralo-Idioide last edited by

            Here is the XML file https://drive.google.com/file/d/1e7BbxeuNJ6yXQ7rteDmthfoUhzZrll2n/view?usp=sharing

            1 Reply Last reply Reply Quote 0
            • Spiralo-Idioide
              Spiralo-Idioide last edited by

              And a Gif https://www.noelshack.com/2019-27-5-1562357299-notepad.gif

              1 Reply Last reply Reply Quote 0
              • Ekopalypse
                Ekopalypse last edited by

                To add an image to a post you could use
                ![](https://image.noelshack.com/fichiers/2019/27/5/1562357299-notepad.gif)
                which then would render like

                to include text and don’t loose formatting enclose it in three tildes like
                ~~~ text ~~~

                1 Reply Last reply Reply Quote 2
                • Spiralo-Idioide
                  Spiralo-Idioide last edited by Spiralo-Idioide

                  Thanks, i’ll use those then.

                  Ekopalypse 1 Reply Last reply Reply Quote 0
                  • Ekopalypse
                    Ekopalypse @Spiralo-Idioide last edited by

                    @Spiralo-Idioide

                    Just for info, I’m waiting for the example code. Preferable the one used in the gif.

                    1 Reply Last reply Reply Quote 1
                    • Spiralo-Idioide
                      Spiralo-Idioide last edited by

                      So, the XML file.

                          <UserLang name="GP" ext="" udlVersion="2.1">
                              <Settings>
                                  <Global caseIgnored="no" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
                                  <Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
                              </Settings>
                              <KeywordLists>
                                  <Keywords name="Comments">00// 01 02 03 04</Keywords>
                                  <Keywords name="Numbers, prefix1"></Keywords>
                                  <Keywords name="Numbers, prefix2"></Keywords>
                                  <Keywords name="Numbers, extras1"></Keywords>
                                  <Keywords name="Numbers, extras2"></Keywords>
                                  <Keywords name="Numbers, suffix1"></Keywords>
                                  <Keywords name="Numbers, suffix2"></Keywords>
                                  <Keywords name="Numbers, range"></Keywords>
                                  <Keywords name="Operators1"></Keywords>
                                  <Keywords name="Operators2">== === + - / * &lt; &gt; &lt;= &gt;= != % isNil notNil compareFloats</Keywords>
                                  <Keywords name="Folders in code1, open">{</Keywords>
                                  <Keywords name="Folders in code1, middle"></Keywords>
                                  <Keywords name="Folders in code1, close">}</Keywords>
                                  <Keywords name="Folders in code2, open"></Keywords>
                                  <Keywords name="Folders in code2, middle"></Keywords>
                                  <Keywords name="Folders in code2, close"></Keywords>
                                  <Keywords name="Folders in comment, open"></Keywords>
                                  <Keywords name="Folders in comment, middle"></Keywords>
                                  <Keywords name="Folders in comment, close"></Keywords>
                                  <Keywords name="Keywords1">if else while animate for repeat waitUntil</Keywords>
                                  <Keywords name="Keywords2">to&#x000D;&#x000A;method&#x000D;&#x000A;return&#x000D;&#x000A;argCount&#x000D;&#x000A;arg&#x000D;&#x000A;defineClass&#x000D;&#x000A;lastReceiver&#x000D;&#x000A;call&#x000D;&#x000A;callWith&#x000D;&#x000A;function&#x000D;&#x000A;parse&#x000D;&#x000A;primitives&#x000D;&#x000A;comment&#x000D;&#x000A;globalFuncs</Keywords>
                                  <Keywords name="Keywords3">true false not and or</Keywords>
                                  <Keywords name="Keywords4">this</Keywords>
                                  <Keywords name="Keywords5"></Keywords>
                                  <Keywords name="Keywords6"></Keywords>
                                  <Keywords name="Keywords7"></Keywords>
                                  <Keywords name="Keywords8"></Keywords>
                                  <Keywords name="Delimiters">00&apos; 01 02&apos; 03( 04 05) 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23</Keywords>
                              </KeywordLists>
                              <Styles>
                                  <WordsStyle name="DEFAULT" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
                                  <WordsStyle name="COMMENTS" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
                                  <WordsStyle name="LINE COMMENTS" fgColor="5E86BD" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
                                  <WordsStyle name="NUMBERS" fgColor="FF00FF" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
                                  <WordsStyle name="KEYWORDS1" fgColor="C10000" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" />
                                  <WordsStyle name="KEYWORDS2" fgColor="000080" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" />
                                  <WordsStyle name="KEYWORDS3" fgColor="FF8000" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" />
                                  <WordsStyle name="KEYWORDS4" fgColor="129300" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" />
                                  <WordsStyle name="KEYWORDS5" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
                                  <WordsStyle name="KEYWORDS6" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
                                  <WordsStyle name="KEYWORDS7" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
                                  <WordsStyle name="KEYWORDS8" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
                                  <WordsStyle name="OPERATORS" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" />
                                  <WordsStyle name="FOLDER IN CODE1" fgColor="FF0000" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" />
                                  <WordsStyle name="FOLDER IN CODE2" fgColor="FF0000" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" />
                                  <WordsStyle name="FOLDER IN COMMENT" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
                                  <WordsStyle name="DELIMITERS1" fgColor="FF00FF" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
                                  <WordsStyle name="DELIMITERS2" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="100924419" />
                                  <WordsStyle name="DELIMITERS3" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
                                  <WordsStyle name="DELIMITERS4" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
                                  <WordsStyle name="DELIMITERS5" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
                                  <WordsStyle name="DELIMITERS6" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
                                  <WordsStyle name="DELIMITERS7" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
                                  <WordsStyle name="DELIMITERS8" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
                              </Styles>
                          </UserLang>
                      </NotepadPlus>
                      1 Reply Last reply Reply Quote 1
                      • Spiralo-Idioide
                        Spiralo-Idioide last edited by

                        Here is the code !

                        
                        method justToShowYouThingsAreStrange {
                          b1 = 2
                          b2 = 3
                          var = (b1 + b2)
                          }
                        
                        method project ProjectEditor { return project }
                        method stage ProjectEditor { return stage }
                        method library ProjectEditor { return library }
                        method scripter ProjectEditor { return scripter }
                        
                        to recover baseFilename {
                          // Save any projects in memory (usually only one) to files.
                          if (isNil baseFilename) { baseFilename = 'recovered' }
                          baseFilename = (withoutExtension (filePart baseFilename))
                          gc // dispose of unreachable projects
                          for editor (allInstances 'ProjectEditor') {
                        	fileName = (uniqueNameNotIn (listFiles (userHomePath)) baseFilename 'gpp')
                        	saveProject (project editor) (join (userHomePath) '/' fileName)
                          }
                        }
                        
                        to startProjectEditorFromMorphic {
                          // Start the project editor from the morphic background menu.
                          page = (global 'page')
                          if (not (confirm (global 'page') nil 'Enter project editor (current morphs will be lost)?')) {
                          	return
                          }
                          removeAllParts (morph page)
                          editor = (initialize (new 'ProjectEditor') (emptyProject))
                          addPart page editor
                          pageResized editor
                          developerModeChanged editor
                        }
                        
                        1 Reply Last reply Reply Quote 1
                        • Spiralo-Idioide
                          Spiralo-Idioide last edited by

                          The functions can be defined by ‘method’ (for class) or ‘to’ for global functions.

                          Ekopalypse 1 Reply Last reply Reply Quote 0
                          • Ekopalypse
                            Ekopalypse @Spiralo-Idioide last edited by

                            @Spiralo-Idioide

                            which npp version do you use? Can be found as debug-info from ? menu (last menu item). With 7.7.1 it seems that folding is correct, regardless whether I open a gp file or if using a new file. Btw. I have add the gp to the extensions in udl.

                            1 Reply Last reply Reply Quote 2
                            • Spiralo-Idioide
                              Spiralo-Idioide last edited by

                              Yes, I’m using 7.4.2. I’m going to update now.

                              Ekopalypse 2 Replies Last reply Reply Quote 0
                              • Ekopalypse
                                Ekopalypse @Spiralo-Idioide last edited by

                                @Spiralo-Idioide

                                don’t update. Download a zipped version and see if this changes what you want.
                                There are a lot of changes since 7.4, so you might run into other troubles.

                                1 Reply Last reply Reply Quote 2
                                • Ekopalypse
                                  Ekopalypse @Spiralo-Idioide last edited by

                                  @Spiralo-Idioide

                                  When variable contains numbers in it’s name and is inside parenthesis, the nuber are highlighted.

                                  Is caused by the delimiter2 setting to allow nesting with numbers. What do you try to achieve with this delimiter?

                                  1 Reply Last reply Reply Quote 1
                                  • Spiralo-Idioide
                                    Spiralo-Idioide last edited by

                                    I tried v7.7.1 and sadly it didn’t resolve my folding problem. And about the delimiter 2, I used it because if don’t numbers are not highlighted at all inside parenthesis.

                                    Ekopalypse 1 Reply Last reply Reply Quote 0
                                    • Spiralo-Idioide
                                      Spiralo-Idioide last edited by Spiralo-Idioide

                                      But in the folding problem is not my main question with the workaround of opening a new file. I’m more intrusted in the variables/functions highlighting. If you could help would be awesome anyway.

                                      1 Reply Last reply Reply Quote 0
                                      • Ekopalypse
                                        Ekopalypse @Spiralo-Idioide last edited by

                                        @Spiralo-Idioide

                                        I tried v7.7.1 and sadly it didn’t resolve my folding problem

                                        With the same code you sent? What exactly do you do to see this behavior.

                                        about the delimiter 2, I used it because if don’t numbers are not highlighted at all inside parenthesis

                                        What do you try to achieve with this delimiter? Why is it needed at all?

                                        1 Reply Last reply Reply Quote 0
                                        • Spiralo-Idioide
                                          Spiralo-Idioide last edited by Spiralo-Idioide

                                          I used delimiter 2 with parenthesis because when I’m not using it, numbers and strings are not highlighted at all, wich is kind of worse. But this is really not an issue. Just like the folding problem.

                                          Ekopalypse 1 Reply Last reply Reply Quote 0
                                          • Ekopalypse
                                            Ekopalypse @Spiralo-Idioide last edited by Ekopalypse

                                            @Spiralo-Idioide

                                            for function list you need to edit functionList.xml

                                            I added to the end of associationMap tag

                                            			<association id=    "gp_function"      userDefinedLangName="GP"                />
                                            			<association id=    "gp_function"      ext=".gp"                               />
                                            

                                            and a new parser tag

                                            			<parser
                                            				displayName="GP"
                                            				id         ="gp_function"
                                            			>
                                            				<!-- <classRange -->
                                            					<!-- mainExpr    ="(?&lt;=^class\x20).*?(?=\n\S|\Z)" -->
                                            				<!-- > -->
                                            					<!-- <className> -->
                                            						<!-- <nameExpr expr="\w+(?=[\(|:])" /> -->
                                            					<!-- </className> -->
                                            					<!-- <function -->
                                            						<!-- mainExpr="(?&lt;=def\x20).+?(?=:)" -->
                                            					<!-- > -->
                                            						<!-- <functionName> -->
                                            							<!-- <funcNameExpr expr=".*" /> -->
                                            						<!-- </functionName> -->
                                            					<!-- </function> -->
                                            				<!-- </classRange> -->
                                            				<function
                                            					mainExpr="(?m-s)(?&lt;=to\x20).+?(?={.*$)"
                                            				>
                                            					<functionName>
                                            						<nameExpr expr=".*" />
                                            					</functionName>
                                            				</function>
                                            			</parser>
                                            

                                            The open part is how a class and its methods are defined. Is not part of your sample code.

                                            Note, once you edit functionlist.xml you need to restart npp in order to make it work.

                                            1 Reply Last reply Reply Quote 3
                                            • First post
                                              Last post
                                            Copyright © 2014 NodeBB Forums | Contributors