Page 1 of 2
Snippets for external command output?
Posted: 23.05.2022 21:23
by deHavilland
Hello,
It's been a pleasure to use CudaText so far. I have a question about snippets, as I couldn't find related information in the help documentation.
I have a lot of scripts and programs that output text, which I use in the text editor.
For example a program that outputs a schedule outline in Markdown, starting with the current time. Or a script that brings in text from a given external text file, in a specific format.
Typically I would type the snippet name and press (tab) in my editor to see it replaced by the command output.
Is there a way to do this in CudaText? Thank you.
Posted: 24.05.2022 16:48
by main Alexey
I don't get the idea - e.g. you type what? and what command is executed from this snippet name? how command is defined for the snippet?
CudaText "Snippets" plugin
https://wiki.freepascal.org/CudaText_plugins#Snippets
can insert fixed text which is defined in the snippet storage (one snippet name - one fixed text, no command is used)
Posted: 24.05.2022 19:11
by deHavilland
Here are some examples, I have about 90 of these in the configuration.
Code: Select all
wk=\n{command:cat /home/user/Dropbox/User/Writing/Current\ Writing\ Projects/Weeklies.md}\n\n
ak=\n{command:cat /home/user/Dropbox/Client\ Notes/notes/Active-Client-Projects.md}\n\n
sk=\n{command:/home/user/Dropbox/bin/schedwriter}\n\n
st={command:/home/user/Dropbox/bin/stockprices}
These are placed in the snippets configuration file of my other editor.
Then if I type wk, ak, sk, or st and press the tab key, the corresponding command is executed and the output is placed at my cursor. Usually it is multiple lines of output.
It seems this may not be possible? But I'm curious if there could be any workarounds to get the same result. Thank you.
Posted: 24.05.2022 19:17
by main Alexey
'of my editor' - what editor do you use, Sublime? Atom?
it is interesting idea! to support {command:xxxx}. It is worth to support it. I will try that later.
Posted: 24.05.2022 19:46
by Hobbes
Do you mean support it in something like Vim command mode? a command line (like some CAD Software)? or something different?
In any case, it would be a good idea.
Posted: 24.05.2022 20:17
by deHavilland
main Alexey wrote:'of my editor' - what editor do you use, Sublime? Atom?
it is interesting idea! to support {command:xxxx}. It is worth to support it. I will try that later.
I'm glad to hear you think so. This editor is Geany.
Do you mean support it in something like Vim command mode? a command line (like some CAD Software)? or something different?
The documentation is here:
https://www.geany.org/manual/current/in ... e-snippets
There is no command mode or command line mode, just typing in the document at your cursor. But I wouldn't be angry if those others were also supported.

Posted: 24.05.2022 20:50
by main Alexey
I changed the Snippets plugin. please test.
"Plugins / Addon Manager / Install from git", enter URL
https://github.com/cudatext-addons/cuda_snippets
The macro ${cmd:xxxxxxxxxx} was added.
I tested it on a new snippet with such body:
result: ${cmd:cat ~/paste.txt}
on Ubuntu.
You can add snippet via "Plugins / snippets / Add-edit snippets".
Posted: 24.05.2022 21:25
by deHavilland
main Alexey wrote:I changed the Snippets plugin. please test.
"Plugins / Addon Manager / Install from git", enter URL
https://github.com/cudatext-addons/cuda_snippets
The macro ${cmd:xxxxxxxxxx} was added.
I tested it on a new snippet with such body:
That was fast! This works well for me overall; I tested it with some of my scripts already and the results look good.
One issue comes up though, this is a Pascal program and somehow after execution the editor moves my cursor very far to the right (horizontal scrollbar becomes tiny) after execution, without adding actual spaces to the file.
Can I ask if this happens for you too? Version 1.165.0
.pas w/ x64 executable download
Posted: 25.05.2022 07:21
by main Alexey
ah, it moves caret to the right when you have MUTLILINE output? it's a issue. plugin doesn't calculate caret pos OK. to fix.
Posted: 25.05.2022 08:19
by main Alexey
I updated plugin, fixing the caret pos.
fixed in Git.
to update it: Plugins / Addon Manager / Update, and check item for 'Snippets'.