GithubHelp home page GithubHelp logo

cuda_exterminal's Introduction

ExTerminal

Advantages over Terminal+ plugin:

  • ExTerminal tries to mimic real interactive terminal behaviour. That means that you can use apps like nano/vim/htop/python inside it.
  • ...

Commands:

  • New terminal
  • Close all terminals
  • Run selection from editor
  • Run current file
  • Toggle focus terminal/editor

Configuration file

Menu "Options / Settings-plugins / ExTerminal / Config", [exterminal] section.

Setting Possible values Description
shell_* string shell to execute, for example - "bash" or "cmd.exe"
colors 0,1 enable terminal colors. (slows down terminal. will be optimized in the future.)
esc_focuses_editor 0,1 focus editor by pressing ESC key instead of sending it to terminal. Disabled by default.
Hint: Ctrl+[ key sends ESC code to the terminal, you can use it instead of ESC key
show_caption 0,1 show terminal header (title)
themed 0,1 use theme colors

cuda_exterminal's People

Contributors

cudatext-addons avatar veksha avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

cudatext-addons

cuda_exterminal's Issues

new update - crash if i enter 'ls'

Python 3.8.10
Init: cuda_breadcrumbs
Loaded session: "history session.json", 20ms, 1 file(s)
Init: cuda_hilite_occurrences
Startup: 230ms, plugins: 30ms (breadcrumbs 28ms, hilite_occurrences 6ms)
Init: cuda_example_terminal
Init: cudatext
Traceback (most recent call last):
  File "/home/user/cuda/cuda/app/py/cudatext.py", line 1232, in _dlg_proc_callback_proxy
    return _live[info](id_dlg, id_ctl, data=data)
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 247, in form_key_down
    if is_toggle_focus_hotkey(key, data):
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 476, in is_toggle_focus_hotkey
    for hotkey in get_hotkeys('toggle_focus'):
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 463, in get_hotkeys
    cfg_keys= [(cmd['key1'], cmd['key2'])
IndexError: list index out of range
ERROR: Exception in CudaText for cudatext._dlg_proc_callback_proxy: IndexError: list index out of range
Traceback (most recent call last):
  File "/home/user/cuda/cuda/app/py/cudatext.py", line 1232, in _dlg_proc_callback_proxy
    return _live[info](id_dlg, id_ctl, data=data)
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 247, in form_key_down
    if is_toggle_focus_hotkey(key, data):
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 476, in is_toggle_focus_hotkey
    for hotkey in get_hotkeys('toggle_focus'):
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 463, in get_hotkeys
    cfg_keys= [(cmd['key1'], cmd['key2'])
IndexError: list index out of range
ERROR: Exception in CudaText for cudatext._dlg_proc_callback_proxy: IndexError: list index out of range
Traceback (most recent call last):
  File "/home/user/cuda/cuda/app/py/cudatext.py", line 1232, in _dlg_proc_callback_proxy
    return _live[info](id_dlg, id_ctl, data=data)
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 247, in form_key_down
    if is_toggle_focus_hotkey(key, data):
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 476, in is_toggle_focus_hotkey
    for hotkey in get_hotkeys('toggle_focus'):
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 463, in get_hotkeys
    cfg_keys= [(cmd['key1'], cmd['key2'])
IndexError: list index out of range
ERROR: Exception in CudaText for cudatext._dlg_proc_callback_proxy: IndexError: list index out of range
Traceback (most recent call last):
  File "/home/user/cuda/cuda/app/py/cudatext.py", line 1232, in _dlg_proc_callback_proxy
    return _live[info](id_dlg, id_ctl, data=data)
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 247, in form_key_down
    if is_toggle_focus_hotkey(key, data):
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 476, in is_toggle_focus_hotkey
    for hotkey in get_hotkeys('toggle_focus'):
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 463, in get_hotkeys
    cfg_keys= [(cmd['key1'], cmd['key2'])
IndexError: list index out of range
ERROR: Exception in CudaText for cudatext._dlg_proc_callback_proxy: IndexError: list index out of range
Traceback (most recent call last):
  File "/home/user/cuda/cuda/app/py/cudatext.py", line 1232, in _dlg_proc_callback_proxy
    return _live[info](id_dlg, id_ctl, data=data)
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 247, in form_key_down
    if is_toggle_focus_hotkey(key, data):
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 476, in is_toggle_focus_hotkey
    for hotkey in get_hotkeys('toggle_focus'):
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 463, in get_hotkeys
    cfg_keys= [(cmd['key1'], cmd['key2'])
IndexError: list index out of range
ERROR: Exception in CudaText for cudatext._dlg_proc_callback_proxy: IndexError: list index out of range
Traceback (most recent call last):
  File "/home/user/cuda/cuda/app/py/cudatext.py", line 1232, in _dlg_proc_callback_proxy
    return _live[info](id_dlg, id_ctl, data=data)
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 247, in form_key_down
    if is_toggle_focus_hotkey(key, data):
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 476, in is_toggle_focus_hotkey
    for hotkey in get_hotkeys('toggle_focus'):
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 463, in get_hotkeys
    cfg_keys= [(cmd['key1'], cmd['key2'])
IndexError: list index out of range
ERROR: Exception in CudaText for cudatext._dlg_proc_callback_proxy: IndexError: list index out of range
Traceback (most recent call last):
  File "/home/user/cuda/cuda/app/py/cudatext.py", line 1232, in _dlg_proc_callback_proxy
    return _live[info](id_dlg, id_ctl, data=data)
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 247, in form_key_down
    if is_toggle_focus_hotkey(key, data):
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 476, in is_toggle_focus_hotkey
    for hotkey in get_hotkeys('toggle_focus'):
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 463, in get_hotkeys
    cfg_keys= [(cmd['key1'], cmd['key2'])
IndexError: list index out of range
ERROR: Exception in CudaText for cudatext._dlg_proc_callback_proxy: IndexError: list index out of range
Traceback (most recent call last):
  File "/home/user/cuda/cuda/app/py/cudatext.py", line 1232, in _dlg_proc_callback_proxy
    return _live[info](id_dlg, id_ctl, data=data)
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 247, in form_key_down
    if is_toggle_focus_hotkey(key, data):
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 476, in is_toggle_focus_hotkey
    for hotkey in get_hotkeys('toggle_focus'):
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 463, in get_hotkeys
    cfg_keys= [(cmd['key1'], cmd['key2'])
IndexError: list index out of range
ERROR: Exception in CudaText for cudatext._dlg_proc_callback_proxy: IndexError: list index out of range
Traceback (most recent call last):
  File "/home/user/cuda/cuda/app/py/cudatext.py", line 1232, in _dlg_proc_callback_proxy
    return _live[info](id_dlg, id_ctl, data=data)
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 247, in form_key_down
    if is_toggle_focus_hotkey(key, data):
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 476, in is_toggle_focus_hotkey
    for hotkey in get_hotkeys('toggle_focus'):
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 463, in get_hotkeys
    cfg_keys= [(cmd['key1'], cmd['key2'])
IndexError: list index out of range
ERROR: Exception in CudaText for cudatext._dlg_proc_callback_proxy: IndexError: list index out of range
Traceback (most recent call last):
  File "/home/user/cuda/cuda/app/py/cudatext.py", line 1232, in _dlg_proc_callback_proxy
    return _live[info](id_dlg, id_ctl, data=data)
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 247, in form_key_down
    if is_toggle_focus_hotkey(key, data):
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 476, in is_toggle_focus_hotkey
    for hotkey in get_hotkeys('toggle_focus'):
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 463, in get_hotkeys
    cfg_keys= [(cmd['key1'], cmd['key2'])
IndexError: list index out of range
ERROR: Exception in CudaText for cudatext._dlg_proc_callback_proxy: IndexError: list index out of range
Traceback (most recent call last):
  File "/home/user/cuda/cuda/app/py/cudatext.py", line 1232, in _dlg_proc_callback_proxy
    return _live[info](id_dlg, id_ctl, data=data)
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 247, in form_key_down
    if is_toggle_focus_hotkey(key, data):
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 476, in is_toggle_focus_hotkey
    for hotkey in get_hotkeys('toggle_focus'):
  File "/home/user/cuda/cuda/app/py/cuda_example_terminal/terminal.py", line 463, in get_hotkeys
    cfg_keys= [(cmd['key1'], cmd['key2'])
IndexError: list index out of range
ERROR: Exception in CudaText for cudatext._dlg_proc_callback_proxy: IndexError: list index out of range

thanks and suggestions…

Hi Yuriy! (Юрий!)
looks promising! very promising : - )
a few suggestions (not so critical, sure…), as potential enhancements…
• run selection from editor
• run current tab/file at exterminal
• shortcut for switch focus between exterminal and editor

Command history?

Does ExTerminal support command history? I tried Up/Down as well as Alt+Up/Alt+Down and Ctrl+Up/Ctrl+Down to get the previous/next command from the history - no luck. (I tried that under Windows).
In the same time, searching for a word "history" in the source code of the plugin creates an impression that there is a potential ability to have commands history.
Moreover, when I press PageUp/PageDown, I seem to get the very first and very last command from the command history.
How can I scroll through the command history in ExTerminal?

URL markers

Hi, @Alexey-T

I want ExTerminal to support URLs underline. they are working already, but in colorful mode underlined style is covered by my custom markers. I know that URL markers (id=-100) can't be removed, and it's okay, I want their underlined style to be on top of other attribs.

look at screenshot. only the first letter is underlined. (maybe it is covered by custom marker with len=1 and its len resized to 1? just a guess.)
without colors underline is ok for all letters.

image

Lexer: PAX_Pascal

when opening .pas file, CudaText tells that it can download PAX_Pascal lexer for this file.
but when you agree and install, it will not be added to lexer list.
I don't know what is PAX but i assume that at least it must be shown in lexer list after installing.

Constant 5% CPU usage under Windows

Once ExTerminal's window is shown, CudaText starts to consume 5% of CPU. Even when the ExTerminal's window is closed, the CPU consumption remains 5%.
After looking into the code, I've seemed to identify the potential fix.
The method run of the ControlTh class contains a while True loop that calls read() again and again. I believe this is the source of the CPU usage. The logical fix is to introduce some delay when nothing has been read from the pipe:

if s:
    pass;    DEBUG_READ and print(s)
    self.add_buf(s)
else:
    sleep(0.05) # reduces CPU usage while doing nothing!

I tested it under Windows, and this simple fix reduced the CPU usage from 5% to 0.5%.

current dir in terminal

  • pwd prints /home/user
  • now I open a project, open some file from it. pwd still prints the same. but I want that pwd prints folder of opened file
  • now I open some random file. pwd still prints the same.

Screenshot from 2022-07-02 09-00-09

cannot find Bash path

Ubuntu 20

[Errno 2] No such file or directory: ''
/bin/bash

main PC: I already have bash as /bin/bash so why the error??

better config() method

    def config(self):
        self.save_ops()
        file_open(ini)
        lines = [ed.get_text_line(i) for i in range(ed.get_line_count())]
        try:
            index = lines.index('['+section+']')
            ed.set_caret(0, index)
        except:
            pass

new error

Python 3.8.10
Init: cuda_project_man
Loading project: ~/cuda/cuda/app/settings/temporary.cuda-proj
Startup: 1360ms, plugins: 360ms (project_man 364ms)
Init: cuda_exterminal
Init: cudatext
Traceback (most recent call last):
  File "/home/user/cuda/cuda/app/py/cudatext.py", line 1169, in _timer_proc_callback_proxy
    return _live[info](tag)
  File "/home/user/cuda/cuda/app/py/cuda_exterminal/terminal.py", line 210, in timer_update
    self.screen.memo_update()
  File "/home/user/cuda/cuda/app/py/cuda_exterminal/memoscreen.py", line 117, in memo_update
    m = list(zip(*markers))
TypeError: 'NoneType' object is not iterable
ERROR: Exception in CudaText for cudatext._timer_proc_callback_proxy: TypeError: 'NoneType' object is not iterable
Traceback (most recent call last):
  File "/home/user/cuda/cuda/app/py/cudatext.py", line 1169, in _timer_proc_callback_proxy
    return _live[info](tag)
  File "/home/user/cuda/cuda/app/py/cuda_exterminal/terminal.py", line 210, in timer_update
    self.screen.memo_update()
  File "/home/user/cuda/cuda/app/py/cuda_exterminal/memoscreen.py", line 117, in memo_update
    m = list(zip(*markers))
TypeError: 'NoneType' object is not iterable
ERROR: Exception in CudaText for cudatext._timer_proc_callback_proxy: TypeError: 'NoneType' object is not iterable
Traceback (most recent call last):
  File "/home/user/cuda/cuda/app/py/cudatext.py", line 1169, in _timer_proc_callback_proxy
    return _live[info](tag)
  File "/home/user/cuda/cuda/app/py/cuda_exterminal/terminal.py", line 210, in timer_update
    self.screen.memo_update()
  File "/home/user/cuda/cuda/app/py/cuda_exterminal/memoscreen.py", line 117, in memo_update
    m = list(zip(*markers))
TypeError: 'NoneType' object is not iterable
ERROR: Exception in CudaText for cudatext._timer_proc_callback_proxy: TypeError: 'NoneType' object is not iterable
Traceback (most recent call last):
  File "/home/user/cuda/cuda/app/py/cudatext.py", line 1169, in _timer_proc_callback_proxy
    return _live[info](tag)
  File "/home/user/cuda/cuda/app/py/cuda_exterminal/terminal.py", line 210, in timer_update
    self.screen.memo_update()
  File "/home/user/cuda/cuda/app/py/cuda_exterminal/memoscreen.py", line 117, in memo_update
    m = list(zip(*markers))
TypeError: 'NoneType' object is not iterable
ERROR: Exception in CudaText for cudatext._timer_proc_callback_proxy: TypeError: 'NoneType' object is not iterable
Traceback (most recent call last):
  File "/home/user/cuda/cuda/app/py/cudatext.py", line 1169, in _timer_proc_callback_proxy
    return _live[info](tag)
  File "/home/user/cuda/cuda/app/py/cuda_exterminal/terminal.py", line 210, in timer_update
    self.screen.memo_update()
  File "/home/user/cuda/cuda/app/py/cuda_exterminal/memoscreen.py", line 117, in memo_update
    m = list(zip(*markers))
TypeError: 'NoneType' object is not iterable
ERROR: Exception in CudaText for cudatext._timer_proc_callback_proxy: TypeError: 'NoneType' object is not iterable
Traceback (most recent call last):
  File "/home/user/cuda/cuda/app/py/cudatext.py", line 1169, in _timer_proc_callback_proxy
    return _live[info](tag)
  File "/home/user/cuda/cuda/app/py/cuda_exterminal/terminal.py", line 210, in timer_update
    self.screen.memo_update()
  File "/home/user/cuda/cuda/app/py/cuda_exterminal/memoscreen.py", line 117, in memo_update
    m = list(zip(*markers))
TypeError: 'NoneType' object is not iterable
ERROR: Exception in CudaText for cudatext._timer_proc_callback_proxy: TypeError: 'NoneType' object is not iterable
Traceback (most recent call last):
  File "/home/user/cuda/cuda/app/py/cudatext.py", line 1169, in _timer_proc_callback_proxy
    return _live[info](tag)
  File "/home/user/cuda/cuda/app/py/cuda_exterminal/terminal.py", line 210, in timer_update
    self.screen.memo_update()
  File "/home/user/cuda/cuda/app/py/cuda_exterminal/memoscreen.py", line 117, in memo_update
    m = list(zip(*markers))
TypeError: 'NoneType' object is not iterable
ERROR: Exception in CudaText for cudatext._timer_proc_callback_proxy: TypeError: 'NoneType' object is not iterable
Traceback (most recent call last):
  File "/home/user/cuda/cuda/app/py/cudatext.py", line 1169, in _timer_proc_callback_proxy
    return _live[info](tag)
  File "/home/user/cuda/cuda/app/py/cuda_exterminal/terminal.py", line 210, in timer_update
    self.screen.memo_update()
  File "/home/user/cuda/cuda/app/py/cuda_exterminal/memoscreen.py", line 117, in memo_update
    m = list(zip(*markers))
TypeError: 'NoneType' object is not iterable
ERROR: Exception in CudaText for cudatext._timer_proc_callback_proxy: TypeError: 'NoneType' object is not iterable
Traceback (most recent call last):
  File "/home/user/cuda/cuda/app/py/cudatext.py", line 1169, in _timer_proc_callback_proxy
    return _live[info](tag)
  File "/home/user/cuda/cuda/app/py/cuda_exterminal/terminal.py", line 210, in timer_update
    self.screen.memo_update()
  File "/home/user/cuda/cuda/app/py/cuda_exterminal/memoscreen.py", line 117, in memo_update
    m = list(zip(*markers))
TypeError: 'NoneType' object is not iterable
ERROR: Exception in CudaText for cudatext._timer_proc_callback_proxy: TypeError: 'NoneType' object is not iterable
Saved session: "history session.json", 0 file(s), by timer at 10:54:28
Saved session: "history session.json", 0 file(s), by timer at 10:54:58

Esc key

consider to make Esc going to editor (focus editor). at least by option 'esc_focuses_editor=1'.

import cudatext_cmd as cmds
...
ed.cmd(cmds.cmd_FocusEditor)

Tabs

@Alexey-T
Given that we already have icons near bottom panel the tabs feature is not really necessary.
Also, floating mode can be removed too, because we can toggle floating mode of the whole bottom panel.

I'm trying to follow KISS principle. And I want to hear your point of view. What is the Cud's way.
Why Terminal+ implemented "tabs statusbar" and floating mode when all functionality was already present in Cud.

I mean:

  • tabs = icons in bottom panel
  • floating mode = floating bottom panel.

color markers performance

@Alexey-T, Hi. This is terminal emulator that can be better then Terminal+. This is work in progress, some bugs are present.
But the main thing that I want to deal with right now is colorizing speed.

I think this line is slowing down plugin a lot:

self.memo.attr(MARKERS_ADD, x=x, y=y, len=1, color_font=fg, color_bg=bg, font_bold=bold)

if this line somehow can be optimized in pascal code -> GOOD.
If not, we can think of another API that will be capable to colorize faster then markers.

try for yourself.
make sure you enable colors in config!
notice how without colors it's pretty fast, but colors slow down a lot.

Bash path must be the option

e.g. on linux it cann be '/bin/bash/ and /usr/bin/bash'.

Also, BSD systems and MacOS need their separate option, different from Linux one

"shell" for Windows
"shell_linux"
"shell_macos"
"shell_freebsd"
"shell_openbsd"
"shell_netbsd"
"shell_dragonfly"

command 'exit' in bash

user@user-HP-Pavilion-g6-Notebook-PC:~/Desktop$ exit                                                                          
exit                                                                                                                          
sdf                                                                                                                           
sfd                                                                                                                           
sdf                                                                                                                           
sdf                                                                                                                           

plugin is unresponsive now-- i type 'sdf' and nothing

[Not An Issue][Advice Needed] PseudoConsole Escape Codes

Let me ask you for advice, please.
Basing on the code of your plugin and on the article mentioned below, I tried to use the PseudoConsole technique in C++ code (under Windows 10). The article is:
https://learn.microsoft.com/en-us/windows/console/creating-a-pseudoconsole-session

I seemed to follow everything that you do in your Python code, as well as in the code from the mentioned article, but the actual result that I read from the PseudoConsole by ReadFile() is unexpectedly full of Escape Codes. For example:

awk --version
�[2J�[m�[Ha�]0;C:\tools\awk\awk.exe��[?25hwk version 20121220

tcc --version
�[2J�[m�[Htcc: error: invalid option -- '--version'
�]0;C:\tools\tcc\tcc.exe��[?25h

As far as I can see, these unreadable characters correspond to the ESC [ ... and ESC ] ... Escape Codes. I have no idea why they are read by ReadFile() and how can I get rid of them.

As your plugin's output does not contain anything like this, I'm hoping you might give me some hint if you faced something similar during development? And if you did, how have you fixed that?

Windows/Linux discrepancies

Hello @Alexey-T.
ExTerminal (or CudaText) has two issues.

  1. on Cud startup focus goes to Editor on Windows (not to opened ExTerminal), but on Linux it goes to ExTerminal (which is bad).
    (PROC_BOTTOMPANEL_ACTIVATE api behaves differently on Windows/Linux?)
  2. on Windows when I press any hotkey, for example ctrl-shift-p while ExTerminal is focused, this hotkey will not go outside of ExTerminal and nothing will happen, but on Linux it goes to main CudaText Window and invokes Command palette.
    (on_key_press, on_key_down behaves differently on Windows/Linux?)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.