zscroll icon indicating copy to clipboard operation
zscroll copied to clipboard

Rewrite nearly from scratch using typer instead of argparse

Open noctuid opened this issue 2 years ago • 0 comments

This requires a hack to maintain backwards-compatibility (i.e. setting sys.argv and manually running a typer command to parse it), but argparse also required a hack to preprocess the arguments.

This is blocked by tiangolo/typer#387, which I have fixed locally (tests will not pass without typer as-is).

Functional improvements:

  • Typer gives nicer help text and can generate completions for different shells
  • --length now enforces the visual length of the entire text, making it possible to have zscroll take up a consistent amount of space even if after or before padding changes
  • Add --shift-count flag (partially addresses #21)
  • Allow using --match-text ".*" "" to just check the exit status of the corresponding match command

Code improvements:

  • Split into multiple files and organize better
  • Remove use of globals; instead create a Scroller class that stores used state
  • Remove various confusing or unnecessary variables and functions: last_hidden_was_wide, next_hidden_was_wide, pad_with_space, needs_scrolling, should_restart_printing, build_display_text, etc.
  • Simplify handling of full-width characters; it is only necessary to handle phasing out one side; the other side can automatically be handled when the visual length of the text is fixed (see visual_slice function that replaces make_visual_len)
  • Way more testing

Meta improvements:

  • Add .editorconfig file
  • Use ruff for linting (remove flake8, isort, etc.)
  • Additionally run tests on 3.10
  • Do all configuration in pyproject.toml (remove .pylintrc and tox.ini)
  • Switch from Makefile/make to poethepoet (fewer dependencies)
  • Stop using setup.py (unnecessary duplication and deprecated); use poetry (and eventually poeblix for data_files support) instead
  • Add a basic nix.shell file

noctuid avatar Mar 30 '23 18:03 noctuid