Skip to content

Implementation of required utilties #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
May 5, 2022
Merged

Implementation of required utilties #36

merged 13 commits into from
May 5, 2022

Conversation

AnonymouX47
Copy link
Owner

@AnonymouX47 AnonymouX47 commented May 4, 2022

Preparing for #23 and more.

  • Implements various utilities required for new features.
    • Non-blocking input.
    • Terminal querying.
    • Terminal window size derivation (in pixels).
    • Terminal cell size derivation (in pixels).
    • Input access synchronization.
  • The library now attempts to determine the proper terminal device to use when standard streams are redirected to files or pipes.
  • The library now attempts to use the size of the process' controlling terminal for all automatic sizing and size validation operations when all standard streams are redirected.

- Add: Added `.utils.no_redecorate()` decorator function.
- Change: Replaced boilerplate code in `.image.common._close_validate()`.
- Change: Renamed `.utils._color()` to `.utils.color()`.
- Add: Added `@cached` and `@terminal_size_cached` in `.utils`.
- Add: Added `OS_IS_UNIX`, `@unix_tty_only` and `_tty` in `.utils`.
- Change: Replaced `os_is_unix` in `.cli.main()` with `.utils.OS_IS_UNIX`.
- Add: Added `@.utils.lock_input`.
- Add: The `start()` and `run()` methods of `multiprocessing.Process` are now automatically overriden when `.utils` is loaded.
  - This is to export the lock required by `@.utils.lock_input` for input access synchronization.
- Add: Wrapped `urwid.raw_display.Screen.get_available_raw_input()` with `@.utils.lock_input` for input access synchronization.
@AnonymouX47 AnonymouX47 added enhancement New feature / Improvement suggestion or request lib Related to the library (Not to be used anymore) tui Related to the image viewer's TUI (Not to be used anymore) labels May 4, 2022
@AnonymouX47 AnonymouX47 added this to the 0.4.0 milestone May 4, 2022
@AnonymouX47 AnonymouX47 force-pushed the utils branch 2 times, most recently from ec2a77a to cf9d142 Compare May 4, 2022 17:27
- Add: Added `.utils.read_input()`.
- Add: Added `.utils.query_terminal()` to communicate with the terminal.
- Change: The active terminal is now discovered in the following order of priority:
  - STDOUT
  - STDIN
  - STDERR
  - /dev/tty
- Add: Added `.utils.get_terminal_size()`.
  - Attempts to get the size of the process' controlling terminal when standard streams are redirected.
- Change: Turned `shutil.get_terminal_size()` into a fallback and replaced it throughout the package.
- Add: Added `.utils.get_window_size()`.
- Add: Added `.utils.get_cell_size()`.
- Add: Added docs/source/reference/utils.rst.
- Change: Updated docstrings.
- Change: Updated `@.utils.unix_tty_only` to augment the docstring of the returned wrapper.
@AnonymouX47 AnonymouX47 changed the title Implementation of various utilties Implementation of required utilties May 5, 2022
@AnonymouX47 AnonymouX47 merged commit c8b1f5f into main May 5, 2022
@AnonymouX47 AnonymouX47 added the documentation Improvements or additions to documentation label May 5, 2022
@AnonymouX47 AnonymouX47 deleted the utils branch May 5, 2022 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature / Improvement suggestion or request lib Related to the library (Not to be used anymore) tui Related to the image viewer's TUI (Not to be used anymore)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant