about adding file in tab to project and snippets

Post Reply
SamC
Posts: 207
Joined: 12.08.2023 00:49

about adding file in tab to project and snippets

Post 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!
main Alexey
Posts: 2245
Joined: 25.08.2021 18:15

Post 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.
main Alexey
Posts: 2245
Joined: 25.08.2021 18:15

Post by main Alexey »

3. we can insert items from Snippet Panel by _double click_. not by click. only click - selects item in panel.
main Alexey
Posts: 2245
Joined: 25.08.2021 18:15

Post 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).
SamC
Posts: 207
Joined: 12.08.2023 00:49

Post by SamC »

Got it!Very appreciate~
SamC
Posts: 207
Joined: 12.08.2023 00:49

Post 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!
main Alexey
Posts: 2245
Joined: 25.08.2021 18:15

Post 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)
Last edited by main Alexey on 21.08.2023 12:15, edited 1 time in total.
SamC
Posts: 207
Joined: 12.08.2023 00:49

Post by SamC »

The plugin is made and working well . Thanks!
Post Reply