Page 1 of 1

about adding file in tab to project and snippets

Posted: 21.08.2023 00:48
by SamC
Hello,
1.The project must be a folder?Is it possible to add file in different path and already opened in tabs to certain project?
2. For markdown, any plugin for hotkey for ### ?(like ctrl+2 to insert ## )
3. For Snippet Panel,I've read the wiki page,but not very clear,could we insert the built-in snippet(like arrows, Greek Alphabet) just by click the one in panel?
4. For user defined snippet:I can't find the .txt file with snippet blow methioned?We can define snippet using .txt rather than .json?Maybe I misunderstand something...
Each snippet folder can contain one or more .txt files, in UTF-8 (no BOM) or UTF-16 (with BOM) encoding. Files have snippet per line, in the form "name=value" or simply "name" (if value missed, it equals to name).
Thanks!

Posted: 21.08.2023 05:41
by main Alexey
1. no, project is a _list of files/folders_. saved to a file nn.cuda-proj.
on the toolbar of Project Manager, you can see buttons: add file, add folder.

>Is it possible to add file in different path and already opened in tabs
yes, yes.

2. for Markdown, we have good plugin Markdown Editing. see its readme.txt.
I had shown you how to use a hotkey to insert any text? (via plugin)
make such a plugin to insert ##. bind it to hotkey Ctrl+2.

Posted: 21.08.2023 05:45
by main Alexey
3. we can insert items from Snippet Panel by _double click_. not by click. only click - selects item in panel.

Posted: 21.08.2023 05:51
by main Alexey
4. that wiki text is about Snippet PANEL plugin. not about Snippets plugin.
for Snippet Panel you can make more 'groups' in the listbox. make the folder in the:

* Folder CudaText/data/clips, which is absent by default, for custom user folders.

e.g. make folder [CudaText]/data/clips/my_clips to add group my_clips.
in my_clips, put .txt file:

Each snippet folder can contain one or more .txt files, in UTF-8 (no BOM) or UTF-16 (with BOM) encoding. Files have snippet per line, in the form "name=value" or simply "name" (if value missed, it equals to name).

Posted: 21.08.2023 06:44
by SamC
Got it!Very appreciate~

Posted: 21.08.2023 08:05
by SamC
main Alexey wrote:I had shown you how to use a hotkey to insert any text? (via plugin)
make such a plugin to insert ##. bind it to hotkey Ctrl+2.
Alexey, I've made that plugin.
And for toggle option(press ctrl+2 again to remove the ## ),that's a cudatext_api method or I need to get the line content and remove the ## by python string method?
If the later:
should I use the method below,could you Please provided a simple example about how to use a cuda api to do like change_text of the line with caret:
def set_text_line(self, index, text):
return ct.ed_set_text_line(self.h, index, esc_z(text))

Thanks a lot!

Posted: 21.08.2023 08:12
by main Alexey
yes, you need the API ed.set_text_line().

- plugin gets caret pos:

Code: Select all

x,y,x1,y1 = ed.get_carets()[0]
y is now current line index.

- plugin gets current line, s:

Code: Select all

s = ed.get_text_line(y)
- plugin changes s (it knows X offset in line, it is 'x'), and puts line:

Code: Select all

ed.set_text_line(y, s)

Posted: 21.08.2023 11:50
by SamC
The plugin is made and working well . Thanks!