CudaText icon indicating copy to clipboard operation
CudaText copied to clipboard

feature request - add api to print active events

Open badrelmers opened this issue 4 weeks ago • 3 comments

CudaText have already a big numbers of plugins, this will for sure make some CudaText parts slower when user install a lot of plugins, currently it is difficult to debug the current live events. I m suffering of some strange hangs of 1s, or slow caret movement...etc and other similar problems that do not happen with a clean cudatext with no plugins. chrome browser offer a similar function called getEventListeners which is very useful for debugging and understanding how events are handled

is it possible to add a similar thing that show the current active events, and preferably to which plugin they are attached?

another use case is when we set an event with app_proc(PROC_SET_EVENTS it resets all the events, so we have to set the events again, so we read install.inf and set those events, but if the plugin subscribes to events dynamically with app_proc(PROC_SET_EVENTS then it would be very useful to have a way to know which ones are active so we can resubscribe to them again easily.

i hope we can have

  • app_proc(PROC_GET_EVENTS, "cuda_myplugin") returns events of a specific plugin called cuda_myplugin
  • app_proc(PROC_GET_EVENTS_ALL...) returns events of all the plugins as : plugin1:event1,event2...etc and plugin2:event1,event2...etc ...etc

badrelmers avatar Dec 05 '25 01:12 badrelmers

this is not urgent, ie SyncEditing / SpellChecker / LSP work good w/o this API. so I agree, but will work later.

Alexey-T avatar Dec 05 '25 10:12 Alexey-T

app_proc(PROC_GET_EVENTS_ALL...) returns events of all the plugins

2nd action is redundant. we can reuse 1st action PROC_GET_EVENTS when 'text' param of app_proc is empty.

Alexey-T avatar Dec 05 '25 11:12 Alexey-T

thank you for considering this.

2nd action is redundant. we can reuse 1st action PROC_GET_EVENTS when 'text' param of app_proc is empty.

you are right

badrelmers avatar Dec 05 '25 13:12 badrelmers

first iteration done.

get updated 'cudatext.py' from github. beta win64: cudatext.zip

example of result:

>>> l=app_proc(PROC_EVENTS_ENUM,'')
>>> for i in l: print(i)
{'module': 'cuda_breadcrumbs', 'lex': [], 'keys': [], 'ev': [{'id': 'on_state', 'lazy': True, 'pr': 0}, {'id': 'on_focus', 'lazy': True, 'pr': 0}, {'id': 'on_open', 'lazy': False, 'pr': 0}, {'id': 'on_close', 'lazy': True, 'pr': 0}, {'id': 'on_save', 'lazy': False, 'pr': 0}]}
{'module': 'cuda_console_complete', 'lex': [], 'keys': [], 'ev': [{'id': 'on_save', 'lazy': True, 'pr': 0}, {'id': 'on_console_complete', 'lazy': False, 'pr': 0}]}
{'module': 'cuda_ext', 'lex': [], 'keys': [], 'ev': [{'id': 'on_console_nav', 'lazy': False, 'pr': 0}]}
{'module': 'cuda_git_status', 'lex': [], 'keys': [], 'ev': [{'id': 'on_change_slow', 'lazy': True, 'pr': 0}, {'id': 'on_state', 'lazy': True, 'pr': 0}, {'id': 'on_focus', 'lazy': True, 'pr': 0}, {'id': 'on_open', 'lazy': False, 'pr': 0}, {'id': 'on_save', 'lazy': False, 'pr': 0}]}
{'module': 'cuda_hilite_occurrences', 'lex': [], 'keys': [], 'ev': [{'id': 'on_change_slow', 'lazy': False, 'pr': 0}, {'id': 'on_caret', 'lazy': False, 'pr': 0}, {'id': 'on_scroll', 'lazy': False, 'pr': 0}, {'id': 'on_state', 'lazy': False, 'pr': 0}]}
{'module': 'cuda_html_tooltips', 'lex': ['regex:(.*HTML.*)|PHP|CSS|SCSS|Sass|LESS|Markdown'], 'keys': [], 'ev': [{'id': 'on_hotspot', 'lazy': False, 'pr': 0}, {'id': 'on_change_slow', 'lazy': False, 'pr': 0}, {'id': 'on_open', 'lazy': False, 'pr': 0}]}
{'module': 'cuda_lexer_detecter', 'lex': [], 'keys': [], 'ev': [{'id': 'on_open_none', 'lazy': False, 'pr': 0}]}
{'module': 'cuda_markdown_image', 'lex': ['Markdown'], 'keys': [], 'ev': [{'id': 'on_change_slow', 'lazy': False, 'pr': 0}, {'id': 'on_open', 'lazy': False, 'pr': 0}, {'id': 'on_lexer', 'lazy': False, 'pr': 0}]}
{'module': 'cuda_project_man', 'lex': [], 'keys': ['cuda-proj'], 'ev': [{'id': 'on_open_pre', 'lazy': False, 'pr': 0}]}
{'module': 'cuda_project_man', 'lex': [], 'keys': [], 'ev': [{'id': 'on_open', 'lazy': True, 'pr': 0}, {'id': 'on_tab_change', 'lazy': True, 'pr': 0}, {'id': 'on_delete_file', 'lazy': True, 'pr': 0}, {'id': 'on_exit', 'lazy': False, 'pr': 0}]}
{'module': 'cuda_sess_manager', 'lex': [], 'keys': ['cuda-session', 'synw-session'], 'ev': [{'id': 'on_open_pre', 'lazy': False, 'pr': 0}]}
{'module': 'cuda_snippets', 'lex': [], 'keys': ['9'], 'ev': [{'id': 'on_key', 'lazy': False, 'pr': 1}]}
{'module': 'cuda_sync_editing', 'lex': [], 'keys': [], 'ev': [{'id': 'on_key', 'lazy': True, 'pr': 0}, {'id': 'on_caret', 'lazy': False, 'pr': 0}, {'id': 'on_click', 'lazy': True, 'pr': 0}, {'id': 'on_click_gutter', 'lazy': True, 'pr': 0}, {'id': 'on_open_reopen', 'lazy': True, 'pr': 0}, {'id': 'on_close', 'lazy': True, 'pr': 0}]}
{'module': 'cuda_tabs_list', 'lex': [], 'keys': [], 'ev': [{'id': 'on_state_ed', 'lazy': True, 'pr': 0}, {'id': 'on_focus', 'lazy': True, 'pr': 0}, {'id': 'on_open', 'lazy': True, 'pr': 0}, {'id': 'on_tab_move', 'lazy': True, 'pr': 0}]}

Alexey-T avatar Dec 10 '25 11:12 Alexey-T

2nd iteration. app_proc param "text" can be empty or the module_name.

beta win64 cudatext.zip

Alexey-T avatar Dec 10 '25 11:12 Alexey-T

This is just perfect, it works perfectly, I love it. This is truly fantastic and will make developing plugins with dynamic events safer and easier. Thank you so so much.

badrelmers avatar Dec 10 '25 16:12 badrelmers