Page 1 of 2
about user defined CodeTree
Posted: 12.08.2023 01:10
by SamC
Hello! I'm new to this software. The code tree function is very convient.
However,is it possible to define my own code tree?Like .rst file,there are levels in the code tree. I want to define my own level mark in .txt file. Such as *is level 1,** is level 2? (Not for .md file,mainly used for .py or .js or .txt file)
In spyder,there is a concept of cell,is it possible to define cell in CudaText with active cell filled with different background color?
Is it possible to assign Chinse charecter with different font,while English letters with another?
Thanks a lot!
Posted: 12.08.2023 09:08
by main Alexey
we can adjust code-tree using one of ways:
a. correct pascal code which is "reST code-tree helper", in source, in file cudatext/app/treehelper_rest.pas.
it has these characters for levels:
Code: Select all
const
cHeaderChars = '-=\''"`:^~_*+#<>';
b. you can write new 'reST tree helper" in python and put it into 'py' folder. (docs about tree-helpers are in the wiki
https://wiki.freepascal.org/CudaText_API .) this is slow way. pascal tree helper is much faster.
In spyder,there is a concept of cell,is it possible to define cell in CudaText with active cell filled
i did not understand this question.
pls, more details.
>>Is it possible to assign Chinse charecter with different font
sorry, no such a feature.
Posted: 12.08.2023 11:22
by SamC
Thanks!Furthermore,
1."reST code-tree helper" is a plugin? I didn't find this,and "cudatext/app/treehelper_rest.pas." didn't exist. No sub folder named /app. (cudatext-windows-amd64-1.196.0.0 is used)
2.For file type like .py, is it possible to add levels?
3.about the cell and question 1 and 2,pls also see the attachment. I want to know if cudatext can split cells by outline and by different colors for .py file.
Posted: 12.08.2023 14:25
by main Alexey
1. 'reST code-tree helper' is part of Pascal sources.
2. yes, it's possible if you make the custom code-tree helper written in Python.
https://wiki.freepascal.org/CudaText_API#TreeHelpers
3. OK, 'cells' is a custom feature. if you write the custom tree helper for Python lexer (written in Python), you can consider 'cells' there. the different way is to change the Python lexer file data/lexlib/Python.lcf. CudaText gives tutorials in the 'readme' folder - how to write lexers.
Posted: 13.08.2023 14:29
by SamC
Thanks!
1. I've check the online wiki page, and for the following sentence.
"CudaText contains built-in support for TreeHelpers. They build code-tree for additional lexers. TreeHelpers must be plugins, which have special install.inf file (Ini format)"
Does that mean if I want to add additional lexers(not in Pascal sources),I need to create a new plugin following the requirement on the wiki page?
2.And if I want to change the Pascal sources,I need to compile the code on GitHub rather than install the windows package on sourceforge?
3.By the way, It seems the console on CudaText can be used as python IDE, does it with the function of "run selection from editor'' like the ExTerminal plugin? I didn't find where to assign the hot key for it.
Posted: 13.08.2023 14:42
by main Alexey
>Does that mean if I want to add additional lexers(not in Pascal sources),I need to create a new plugin following the requirement on the wiki page?
yes, correct.
>And if I want to change the Pascal sources,I need to compile the code on GitHub
yes, correct.
>console on CudaText can be used as python IDE, does it with the function of "run selection from editor'' like the ExTerminal plugin?
you need the CudaExt plugin (lot of commands in it), it gives Command Palette item:
"misc: execute selected text in console".
you can assign any hotkey to any Command Palette item - F9 key.
Posted: 13.08.2023 14:58
by SamC
Got it!
The python version in console seems to be locked on the cuda folder.
Is it possible to use my own python path or install new packages for console?
Posted: 13.08.2023 15:04
by main Alexey
The python version in console seems to be locked on the cuda folder.
on Windows, CudaText uses Python from its folder.
but not on Unixes. it uses current OS's python there.
Is it possible to use my own python path or install new packages for console?
you can copy any folder to [cudatext]/py subdir, and it will be available for "import" python operator, in Console and plugins. because "py" dir is added to "sys.path".
Posted: 14.08.2023 02:29
by SamC
Thanks to your help,I'm trying on this,and further questions:
1.If I chang the contents in /cudatext/data/lexlib/Python.lcf&Python.cuda-lexmap, will it affect the code tree,or it just affect the highlighting on contents window?
2.I see some zip files in \CudaText_addons\treehelper,is it can be token as the example of the method "b. you can write new 'reST tree helper" in python and put it into 'py' folder. (docs about tree-helpers are in the wiki
https://wiki.freepascal.org/CudaText_API .) this is slow way. pascal tree helper is much faster."
Posted: 14.08.2023 06:22
by main Alexey
1. it will affect the code-tree too.
2. yes, files in \CudaText_addons\treehelper are examples of tree-helpers written in python.