Menu

code folding for user defined language

b vindh
2009-04-17
2012-11-14
  • b vindh

    b vindh - 2009-04-17

    Hi,

    I am trying to create a user defined language for abaqus input files(.inp).

    i need to define code folding such a way that, all lines that occur between the lines that start with a '*' are to be folded.is it possible to achieve with the user define dialog? is there any alternate way of defining the folding rules?

    thanks

     
    • cchris

      cchris - 2009-04-24

      For a language to be known to be available, it must have entries in langs.xml and styleers.xml. Existing entries should give you a clue, as well as the source file you mention.

      With some care and observation, you can probably determine the style entries the lexer is aware of from the source, then design the entries in stylers.xml with everything black on white, and you have to figure entries in langs.xml according to your knowledge of the language. When this is done and works, use the Configure highliting dialog to get more decent colours.

      Note that I din't try to assemble this puzzle myself, but I'm sure it is not too hard. Granted, perhaps the lexer has a bug and that's why it is not included in the config files, I don't know. I don't have Abaqus files in order to assess that.

      CChris

       
    • cchris

      cchris - 2009-04-19

      There is a way, but it is not quite straightforward.

      As many posts here and on the Open Discussion forum show, lots of desired custom language definitions can't be completely handled by the User Defined Language system. There has to be an external lexer for your language, probably adapting an existing one. Some standard features would ideally creep in LexUser.cxx and be reflected in the UDL panel, but this is not exactly a one liner fix in N++.

      CChris

       
    • b vindh

      b vindh - 2009-04-21

      thanks...

      but, "http://wiki.codeblocks.org/index.php?title=Creating_a_custom_lexer_for_Code::Blocks_editor" says that, "support for code-folding can't be done from the lexer files. It must be done right in the Scintilla code.". guess its pretty much beyond of my reach.

      i have figured a workaround. since anything that follows two or more than two asterixes is a comment line, i simply defined **( and **) as the folding start and endings. not elegant but atleast i can manually fold the code!

      cheers

       
    • cchris

      cchris - 2009-04-22

      Support for folding - in general terms - has to be done in the code of the edit component indeed, and that is where it is in Scintilla. And I don't see many obvious changes that it should undergo.

      Supporting folding in some language means instructing Scintilla to fold a specific line in a document, and this is done by the lexer, which is a dll that could be written in any language as long as it can interface with the C++ written other components and meet their requirements. If you write your lexer in C++, then your dll must implement and export, among others

          virtual void Fold(unsigned int startPos, int lengthDoc, int initStyle, WordList *keywordlists[], Accessor &styler) const;

      (quoted from ExternalLexer.cxx).

      Browse the collection of Lex<language>.cxx files in the sources, and you will see that some of them do perform some folding of their own, drawing on Scintilla's builtin support.

      CChris

       
    • b vindh

      b vindh - 2009-04-23

      hi Chris

      i down loaded the notepad++ source code and found "LexAbaqus.cxx" in the "..\npp.5.3.1.src\scintilla\src" folder. the LexAbaqus.cxx seems to have syntax highlighting and the code folding defined. its written by Sergio Lucato and had been in release 1.75 of scintilla(22 November 2007).

      but abaqus doesnt show up in the language menu of notepad++ or scite. does this mean that the capability to handle abaqus files exist but has to be "activated"?

      thanks

       
  • aaron

    aaron - 2010-02-26

    Hi bvindh,
    Did you ever figure out how to get an abaqus input deck into a lexer?
    I would be very interested if you figured it out.
    Thanks,

     
  • cchris

    cchris - 2010-02-27

    Could you request the support for Abaqus on IdeaTorrent? Indeed there is a lexer in the source directory of Scintilla. It would just need to be integrated, ie add code in Notepad++ to read the extra entry in langs.xml, show configuration on the Styler Configurator and so on.

    CChris

     
MongoDB Logo MongoDB