Skip to content

Commit

Permalink
[cli,tui] Set window title to "Term-Image"
Browse files Browse the repository at this point in the history
  • Loading branch information
AnonymouX47 committed Jun 25, 2022
1 parent 4d09813 commit 5a2976a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -48,6 +48,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [cli] `-multi` command-line option.
- [tui] Concurrent/Parallel frame rendering for TUI animations ([#42]).
- [cli,tui] `no multi`, `query timeout` and `style` config options.
- [cli,tui] Attempt to set window title at startup.
- [lib,cli,tui] Support for the Kitty terminal graphics protocol ([#39]).
- [lib,cli,tui] Automatic render style selection based on the detected terminal support ([#37]).

Expand Down
4 changes: 4 additions & 0 deletions term_image/__main__.py
Expand Up @@ -8,6 +8,7 @@
from threading import Event

from .exit_codes import FAILURE, INTERRUPTED, codes
from .utils import write_tty


def main() -> int:
Expand Down Expand Up @@ -51,6 +52,8 @@ def finish_multi_logging():

cli.interrupted = Event()
try:
write_tty(b"\033[22;2t") # Save window title
write_tty(b"\033]2;Term-Image\033\\") # Set window title
exit_code = cli.main()
except KeyboardInterrupt:
cli.interrupted.set() # Signal interruption to subprocesses and other threads.
Expand Down Expand Up @@ -90,6 +93,7 @@ def finish_multi_logging():
logger.info(f"Session ended with return-code {exit_code} ({codes[exit_code]})")
return exit_code
finally:
write_tty(b"\033[22;2t") # Restore window title
# Explicit cleanup is neccessary since the top-level `Image` widgets
# will still hold references to the `BaseImage` instances
if cli.url_images:
Expand Down

0 comments on commit 5a2976a

Please sign in to comment.