Community
    • Login

    Code folding possible for this ... ?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    5 Posts 2 Posters 2.1k 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.
    • Nicolas NickischN
      Nicolas Nickisch
      last edited by

      I have a software which uses a text file for defining special logic to control a model railroad.
      The lines or blocks I have in mind begins with “S:” or “A:”
      The rest of the line is the definition part.
      Those lines can grow pretty long. Therefore, I can put a ‘’ at the end of a line, press enter and continue the definition i the next line for readability. A definition is normally 5 or more lines long.
      I would like to have a kind of “code folding” which starts a block with the S: or A: phrase and stops at a pure Newline with no ‘’
      Is this possible?

      1 Reply Last reply Reply Quote 0
      • gstaviG
        gstavi
        last edited by

        A lexer can do it. I wrote a makefile lexer which can fold make rules which their syntax is similar enough to your description.
        But what you probably wanted to ask is whether this can be done with a user defined language. I have no experience with these.

        1 Reply Last reply Reply Quote 0
        • Nicolas NickischN
          Nicolas Nickisch
          last edited by

          Thnk you. I have to find out whart a lexer is.
          Those lines end with “, -”. Teh definition then continues in the next line.
          Definition itself ends with a newline (no “,” or anything else)

          1 Reply Last reply Reply Quote 0
          • gstaviG
            gstavi
            last edited by

            Lexer is short for Lexical Analyzer.
            It the part that “understands” the text of different languages and provides Notepad++ (or more accuretly Scintilla) with the information about text coloring and folding.
            Lexers for complicated common languages such as C are software modules that use complex internal logic dedicated for the task.
            Simpler languages can be defined as “User Defined Language” to save programming effort and provide flexebility.
            The predefined User Defined Language lexer analyzes the text according to configuration file that defines the language.
            I implemented 2 software lexers and no user defined languages.
            User define language is much easier to implement than dedicated software lexer and the trade off is that its logic to detect complex language constructs has limited power compared to software based Lexer. So the question, which I can’t answer, is whether your language is within this power or not.

            See ‘User Define language’ under ‘Languages’ menu.

            1 Reply Last reply Reply Quote 2
            • Nicolas NickischN
              Nicolas Nickisch
              last edited by

              I discovered already the UDL. But I am wondering if this can solve my problem.

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