Document the icat kitten

This commit is contained in:
Kovid Goyal 2018-06-02 14:45:46 +05:30
parent bd9a4e9cd8
commit 620782aa80
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 45 additions and 4 deletions

View File

@ -225,6 +225,10 @@ its advanced features. These programs are called kittens. They are used both
to add features to |kitty| itself and to create useful standalone programs. to add features to |kitty| itself and to create useful standalone programs.
Some prominent kittens: Some prominent kittens:
:doc:`icat <kittens/icat>`
Display images in the terminal
:doc:`diff <kittens/diff>` :doc:`diff <kittens/diff>`
A fast, side-by-side diff for the terminal with syntax highlighting and A fast, side-by-side diff for the terminal with syntax highlighting and
images images

29
docs/kittens/icat.rst Normal file
View File

@ -0,0 +1,29 @@
icat - Display images in the terminal
========================================
The ``icat`` kitten can be used to display arbitrary images in the |kitty|
terminal. Using it is as simple as::
kitty +kitten icat image.jpeg
It supports all image types supported by `ImageMagick
<https://www.imagemagick.org>`_. It even works over SSH. For details, see
the :doc:`kitty graphics protocol </graphics-protocol>`.
.. note::
`ImageMagick <https://www.imagemagick.org>`_ must be installed for ``icat`` to
work.
.. program:: kitty +kitten icat
The ``icat`` kitten has various command line arguments to allow it to be used
from inside other programs to display images. In particular, :option:`--place`,
:option:`--detect-support` and :option:`--print-window-size`.
Command Line Interface
--------------------------
.. include:: /generated/cli-kitten-icat.rst

View File

@ -245,12 +245,16 @@ def parse_place(raw):
return namedtuple('Place', 'width height left top')(w, h, l, t) return namedtuple('Place', 'width height left top')(w, h, l, t)
def main(args=sys.argv): help_text = (
msg = (
'A cat like utility to display images in the terminal.' 'A cat like utility to display images in the terminal.'
' You can specify multiple image files and/or directories.' ' You can specify multiple image files and/or directories.'
' Directories are scanned recursively for image files.') ' Directories are scanned recursively for image files.'
args, items = parse_args(args[1:], options_spec, 'image-file ...', msg, '{} icat'.format(appname)) )
usage = 'image-file ...'
def main(args=sys.argv):
args, items = parse_args(args[1:], options_spec, usage, help_text, '{} +kitten icat'.format(appname))
if args.print_window_size: if args.print_window_size:
screen_size_function.ans = None screen_size_function.ans = None
@ -320,3 +324,7 @@ def main(args=sys.argv):
if __name__ == '__main__': if __name__ == '__main__':
main() main()
elif __name__ == '__doc__':
sys.cli_docs['usage'] = usage
sys.cli_docs['options'] = options_spec
sys.cli_docs['help_text'] = help_text