Reflow Line Breaks by External Tool

main Alexey
Posts: 2245
Joined: 25.08.2021 18:15

Re: Reflow Line Breaks by External Tool

Post by main Alexey »

I added macro {SelectionAsTemp}. plugin is updated.
please test it, my test with "echo {SelectionAsTemp}" (echo is program on linux) works ok.
Random Void User
Posts: 22
Joined: 13.07.2024 21:19

Re: Reflow Line Breaks by External Tool

Post by Random Void User »

Python's subprocess module can feed an external process stdin. This tutorial uses a dummy process that prints stdin. Could this technique somehow use {SelectedText} without making a temp file?

Code: Select all

import subprocess
import sys

result = subprocess.run(
    [sys.executable, "-c", "import sys; print(sys.stdin.read())"], input=b"underwater"
)
main Alexey
Posts: 2245
Joined: 25.08.2021 18:15

Re: Reflow Line Breaks by External Tool

Post by main Alexey »

the python sample for selected-text is:

Code: Select all

import cudatext as app
sel = app.ed.get_text_sel()
print(sel)
how can I help more?
Random Void User
Posts: 22
Joined: 13.07.2024 21:19

Re: Reflow Line Breaks by External Tool

Post by Random Void User »

main Alexey wrote: 27.08.2024 09:42 I added macro {SelectionAsTemp}. plugin is updated.
please test it, my test with "echo {SelectionAsTemp}" (echo is program on linux) works ok.
Yes it works, thank you. I often work with unsaved documents, so the function text2temp in py/cuda_exttools/cd_exttools.py created a file called "_sel." for lack of naming tags. I will post separately about temp files in general.

I will play around with these ideas, thanks again for your quick feedback and tool updates.
Post Reply