zufuliu / notepad4

Notepad4 (Notepad2⨯2, Notepad2++) is a light-weight Scintilla based text editor for Windows with syntax highlighting, code folding, auto-completion and API list for many programming languages and documents, bundled with file browser plugin matepath.
Other
3.13k stars 204 forks source link

Feature request: ANSYS(APDL) and ABAQUS #277

Open Diogo-Rossi opened 3 years ago

Diogo-Rossi commented 3 years ago

It is possible to add a user defined scheme, for a hypothetical language? Like it is done with UDL in Notepad++?

zufuliu commented 3 years ago

Implement UDL is bit complex than writing a lexer for a specific language, there are many 200 ~ 500 lines lexers at https://github.com/zufuliu/notepad2/tree/master/scintilla/lexers.

What language do you want to support?

Diogo-Rossi commented 3 years ago

I was thinking about to use for specific engineering software, like ANSYS and ABAQUS, which require input files with specific keywords

zufuliu commented 3 years ago

OK, I will add them later. SciTE already supports them.

Diogo-Rossi commented 3 years ago

Thank you. BTW, I think it would be good to maintain the "code folding by indentation" (that exists in plain text files) in these software schemes. Because that is good to organize data inside the files.

zufuliu commented 3 years ago

It looks I can not find any official or complete document for ANSYS and ABAQUS. For code folding, keyword based (*if, *endif) would be much simpler. only data lines (block) need be folded together, but I don't known what command starts a data block.

zufuliu commented 3 years ago

Schemes for ABAQUS and APDL were added by 66fa7adffa17b2418952e5e00dcac44f7af14852, but are far from complete or useful. You can add more commands, functions, and other words to https://github.com/zufuliu/notepad2/blob/master/tools/lang/ABAQUS.inp and https://github.com/zufuliu/notepad2/blob/master/tools/lang/APDL.apdl (I don't known the file extension for APDL), and then run https://github.com/zufuliu/notepad2/blob/master/tools/KeywordUpdate.py to update keyword list for the two schemes.

Diogo-Rossi commented 3 years ago

It looks I can not find any official or complete document for ANSYS and ABAQUS. For code folding, keyword based (*if, *endif) would be much simpler. only data lines (block) need be folded together, but I don't known what command starts a data block.

I found a list of keyword commands for Ansys APDL in this page and a documentation for Abaqus in this site (Maybe they are not for current version of these softwares, but the commands don't change so much from one release to another)

For code folding, I thought it is a good idea to keep the folding by indentation of plain text, because some keywords starts data block without close statements (like /PREP7 and /POST1 in Ansys and *NODE and *ELEMENT in Abaqus), while other keywords define blocks of data with start and closing statements (like DO/ENDDO in Ansys and ASSEMBLY/END ASSEMBLY in Abaqus) as in a more traditional programing language.

Besides, it happens that some keywords used to define blocks sometimes appears as options inside other keywords specification... to make it more complicated 😅 These are the reasons why I thought folding by indentation is a more general solution if folding is intended.

Thanks for the files and instructions. I'm not sure, but I think that the extension for APDL could be *.cdb And sorry for the delay: I was in a travel for the past 20 days,

zufuliu commented 3 years ago

Indentation based code folding implemented by d911f706e8f28b14cbce8a45f073090f6bcea8c3. I personally prefer keyword based code folding, please open https://github.com/zufuliu/notepad2/actions and test the builds (click the commit message, and then download artifacts zip). and decide which one (keyword based, indentation based) works better.

apdl-code-folding

Diogo-Rossi commented 3 years ago

I personally prefer keyword based code folding, please open https://github.com/zufuliu/notepad2/actions and test the builds (click the commit message, and then download artifacts zip). and decide which one (keyword based, indentation based) works better.

I did a small test with Abaqus files and... I think you're right: keyword based code folding works better.

I don't know how you handled the issue regarding commands that starts a data block without an ending statement... But seems it is working very well.

Thankyou very much.

zufuliu commented 3 years ago

I just treat line starts with a number as data line, then fold all consecutive data lines as a block.

Diogo-Rossi commented 3 years ago

Great strategy! If is it possible, could you please use the same strategy (used with numbers) to fold data lines in Abaqus that starts with non keywords?

I think this would be a solution for the following situation: Some numbers in data lines are atributes to parts of the model. Then, the name of the part comes first, followed by the numbers, like the image bellow.

image

So, this is a data block, but the lines don't start with numbers. Do you think the same strategy could be adopted in this situation? I mean: fold data lines in that starts with non keywords? (basically, lines that don't start with a *)

Thank you!

zufuliu commented 3 years ago

It's seems possible and not hard.