plugin Terminal

Plugins for SynWrite and CudaText...
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

plugin Terminal

Post by Alexey »

Adds panel "Terminal" to the bottom panel of CudaText. It is emulation of terminal (default: Bash on Unix, Cmd on Windows). You can enter commands in this terminal, and see output from shell.
Limitation: don't use interactive commands, which need keyboard input.

Plugin has several options in the .ini file - call menu item Options/ Settings-plugins/ Terminal/ Config.

Hotkeys in the terminal:
- Down arrow: show last commands (history) menu
- Esc: close terminal and focus editor
- Break: interrupt/restart shell process
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

Update

2020.07.09.5
* change: on choosing item in drop-down menu, place item to input field
+ add: option 'dark_colors'
+ add: option 'shell_unix'
+ add: option 'shell_windows'
- fix: initially, input was not focused

2020.07.05
+ add: increase read buffer size (1 byte->6K) to not freeze on big tools output
+ add: option "max_buffer_size" (default 100K) to not take too much memory
Shovel
Posts: 141
Joined: 31.12.2019 10:16

Post by Shovel »

https://github.com/OlehL/cuda_differ/issues/82

A theoretical question of a noob regarding colored output: is just parsing the colors with ansiterm and colorizing text with 'Editor.attr' not a viable strategy? Haven't actually tried it, but it looks like it should work...
uvviewsoft
Posts: 392
Joined: 01.12.2020 13:46

Post by uvviewsoft »

I can only say about Cud's part: yes, we should place colors via Editor.attr. Python part is a puzzle for me.
Shovel
Posts: 141
Joined: 31.12.2019 10:16

Post by Shovel »

ansiterm parsing seems to work

Code: Select all

term = ansiterm.Ansiterm(25, 80)
term.feed(self.btext.decode('utf-8'))
ts = term.get_tiles(0, 25*80)
gives me red bold tiles in grep output. Will play with it more
uvviewsoft
Posts: 392
Joined: 01.12.2020 13:46

Post by uvviewsoft »

Good, let's test ansiterm.
Shovel
Posts: 141
Joined: 31.12.2019 10:16

Post by Shovel »

Well the parsing works: picture

"grep" and "ls" give colored output when I add "--color=always". But not with "--color=auto". I copied my working environment variables and it is still doesn't work. So I am kinda lost at the moment :)
Will try to look at how the "--color=auto" works in the sources...
uvviewsoft
Posts: 392
Joined: 01.12.2020 13:46

Post by uvviewsoft »

Some progress. I know that VSCode terminal plugin catches the colored output of 'ls' and other commands.
Shovel
Posts: 141
Joined: 31.12.2019 10:16

Post by Shovel »

A few things I found out:
You can trick the commands into thinking they are running in the terminal (that is what "ls" checks when "--color=auto") by running them thusly:

Code: Select all

script --return --quiet -c "ls -l --color=auto" /dev/null
(NOTE about "ls": by default coloring is disabled, but real terminal adds "--color=auto" with alias from ".bashrc")

Coloring large text one character at a time is a bad idea :D
For me parsing 2700 lines (100kB) of fully colored "ls" output takes 0.7s, and coloring it (self.memo.attr(MARKERS_ADD, ...) takes 2.3s. Quite a freeze

I hope this will be of some help.
In case it will help, here is my current terminal plugin code: github
And the parser I fixed a bit: github
uvviewsoft
Posts: 392
Joined: 01.12.2020 13:46

Post by uvviewsoft »

you can speed-up the MARKERS_ADD many calls:
MARKERS_ADD_MANY: Adds one or multiple fragments at once. Also returns number of fragments. Parameters:

"x", "y", "len": The same as for MARKERS_ADD, but can be also list/tuple of int. Lists/tuples must contain the equal number of elements (otherwise the minimal number of elements will be used).
other parameters: The same as for MARKERS_ADD.
Post Reply