diff --git a/kitty_tests/Lenna.png b/kitty_tests/Lenna.png new file mode 100644 index 000000000..59ef68aab Binary files /dev/null and b/kitty_tests/Lenna.png differ diff --git a/kitty_tests/gr.py b/kitty_tests/gr.py index 9d3a53959..0247761c0 100644 --- a/kitty_tests/gr.py +++ b/kitty_tests/gr.py @@ -3,7 +3,6 @@ # License: GPL v3 Copyright: 2017, Kovid Goyal import os -import subprocess import sys import zlib from base64 import standard_b64encode @@ -40,6 +39,15 @@ def display(data, width, height, x, y, z, ncols=0, nrows=0): cmd.clear() +def display_png_file(path): + cmd = {'a': 'T', 't': 'f', 'f': '100'} + path = os.path.abspath(path) + if not isinstance(path, bytes): + path = path.encode(sys.getfilesystemencoding() or 'utf-8') + data = standard_b64encode(path) + write_gr_cmd(cmd, data) + + def main(): clear_screen() display(b'\xdd\xdd\xdd\xff', 1, 1, 0, 0, -10, 40, 20) @@ -48,14 +56,17 @@ def main(): move_cursor(5, 8) print('kitty is \033[3m\033[32mawesome\033[m!') move_cursor(0, 21) - if os.path.exists('/t/Lenna.png'): - print('Lenna...') - subprocess.check_call('python3 kitty/icat.py /t/Lenna.png'.split()) + print('Lenna...') + display_png_file('kitty_tests/Lenna.png') try: - raw_input() - except NameError: - input() + try: + raw_input() + except NameError: + input() + except (EOFError, KeyboardInterrupt): + pass if __name__ == '__main__': + os.chdir(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..')) main()