main.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/usr/bin/env python
  2. # License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
  3. from kitty.typing import BossType
  4. from ..tui.handler import result_handler
  5. help_text = 'Input a Unicode character'
  6. usage = ''
  7. OPTIONS = '''
  8. --emoji-variation
  9. type=choices
  10. default=none
  11. choices=none,graphic,text
  12. Whether to use the textual or the graphical form for emoji. By default the
  13. default form specified in the Unicode standard for the symbol is used.
  14. --tab
  15. type=choices
  16. default=previous
  17. choices=previous,code,name,emoticons,favorites
  18. The initial tab to display. Defaults to using the tab from the previous kitten invocation.
  19. '''.format
  20. @result_handler(has_ready_notification=True)
  21. def handle_result(args: list[str], current_char: str, target_window_id: int, boss: BossType) -> None:
  22. w = boss.window_id_map.get(target_window_id)
  23. if w is not None:
  24. w.paste_text(current_char)
  25. def main(args: list[str]) -> str | None:
  26. raise SystemExit('This should be run as kitten unicode_input')
  27. if __name__ == '__main__':
  28. main([])
  29. elif __name__ == '__doc__':
  30. import sys
  31. cd = sys.cli_docs # type: ignore
  32. cd['usage'] = usage
  33. cd['options'] = OPTIONS
  34. cd['help_text'] = help_text
  35. cd['short_desc'] = 'Browse and select unicode characters by name'