BoraxTheClean / adaptable-antelopes

Code Jam 2021 adaptable antelopes team
MIT License
1 stars 0 forks source link

Marker/symbol to show if file is saved or not #12

Closed SharpBit closed 3 years ago

SharpBit commented 3 years ago
SharpBit commented 3 years ago

Tried using os.system to modify the title bar but got text_editor.py:72:1: S605 Starting a process with a shell, possible injection detected, security issue. when linting.

Seems to be no event that is called whenever a TextArea has its contents edited. There is accept_handler – Called when Enter is pressed (This should be a callable that takes a buffer as input). but that's only when Enter is pressed.

Maybe look into History

ghost commented 3 years ago

Just noticed the Buffer data structure has an on_text_changed callable, which sounds like what we're after. https://python-prompt-toolkit.readthedocs.io/en/master/pages/reference.html#module-prompt_toolkit.buffer

ghost commented 3 years ago

I think this is definitely doable by setting that callable to toggle an asterisk before the window title on a change to the text buffer. I could then write a function to remove the asterisk on saving and call it from within each of the save functions on successful save.