main.py 1.3 KB

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