From 47e4b4c02108f6cfe8d895dc772ae95e8f85e5d8 Mon Sep 17 00:00:00 2001 From: mcarr823 <136939846+mcarr823@users.noreply.github.com> Date: Wed, 10 Jan 2024 15:43:28 +1100 Subject: [PATCH 1/2] Added stdin args to specify rows and cols. This is now required for screens with partial update support --- README.md | 2 ++ papertty/papertty.py | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5033838..5d8a676 100644 --- a/README.md +++ b/README.md @@ -386,6 +386,8 @@ Option | Description | Default `--portrait` | Enable portrait mode | disabled `--nofold` | Disable folding (ie. don't wrap to width) | disabled `--spacing` | Set line spacing | `0` +`--rows` | Set TTY rows (`--cols` required too) | *no default* +`--cols` | Set TTY columns (`--rows` required too) | *no default* ```sh diff --git a/papertty/papertty.py b/papertty/papertty.py index c016142..859eb5f 100755 --- a/papertty/papertty.py +++ b/papertty/papertty.py @@ -1185,8 +1185,10 @@ def scrub(settings, size): @click.option('--portrait', default=False, is_flag=True, help='Use portrait orientation', show_default=True) @click.option('--nofold', default=False, is_flag=True, help="Don't fold the input", show_default=True) @click.option('--spacing', default='0', help='Line spacing for the text, "auto" to automatically determine a good value', show_default=True) +@click.option('--rows', 'ttyrows', default=None, help='Set TTY rows (--cols required too)') +@click.option('--cols', 'ttycols', default=None, help='Set TTY columns (--rows required too)') @click.pass_obj -def stdin(settings, font, fontsize, width, portrait, nofold, spacing): +def stdin(settings, font, fontsize, width, portrait, nofold, spacing, ttyrows, ttycols): """Display standard input and leave it on screen""" settings.args['font'] = font settings.args['fontsize'] = fontsize @@ -1200,6 +1202,10 @@ def stdin(settings, font, fontsize, width, portrait, nofold, spacing): font_width = ptty.font.getsize('M')[0] max_width = int((ptty.driver.width - 8) / font_width) if portrait else int(ptty.driver.height / font_width) text = ptty.fold(text, width=max_width) + if ttyrows: + ptty.rows = int(ttyrows) + if ttycols: + ptty.cols = int(ttycols) ptty.showtext(text, fill=ptty.driver.black, portrait=portrait) From e7c9c7060d22c6bcc990a8ddaf64f494dc2c7ed4 Mon Sep 17 00:00:00 2001 From: mcarr823 <136939846+mcarr823@users.noreply.github.com> Date: Wed, 10 Jan 2024 15:44:51 +1100 Subject: [PATCH 2/2] Added flipx and flipy args for stdin mode --- README.md | 2 ++ papertty/papertty.py | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5d8a676..b0a3dda 100644 --- a/README.md +++ b/README.md @@ -388,6 +388,8 @@ Option | Description | Default `--spacing` | Set line spacing | `0` `--rows` | Set TTY rows (`--cols` required too) | *no default* `--cols` | Set TTY columns (`--rows` required too) | *no default* +`--flipx` | Mirror X axis (experimental / buggy) | disabled +`--flipy` | Mirror Y axis (experimental / buggy) | disabled ```sh diff --git a/papertty/papertty.py b/papertty/papertty.py index 859eb5f..a75b6e3 100755 --- a/papertty/papertty.py +++ b/papertty/papertty.py @@ -1187,8 +1187,10 @@ def scrub(settings, size): @click.option('--spacing', default='0', help='Line spacing for the text, "auto" to automatically determine a good value', show_default=True) @click.option('--rows', 'ttyrows', default=None, help='Set TTY rows (--cols required too)') @click.option('--cols', 'ttycols', default=None, help='Set TTY columns (--rows required too)') +@click.option('--flipx', default=False, is_flag=True, help='Flip X axis (EXPERIMENTAL/BROKEN)', show_default=False) +@click.option('--flipy', default=False, is_flag=True, help='Flip Y axis (EXPERIMENTAL/BROKEN)', show_default=False) @click.pass_obj -def stdin(settings, font, fontsize, width, portrait, nofold, spacing, ttyrows, ttycols): +def stdin(settings, font, fontsize, width, portrait, nofold, spacing, ttyrows, ttycols, flipx, flipy): """Display standard input and leave it on screen""" settings.args['font'] = font settings.args['fontsize'] = fontsize @@ -1206,7 +1208,8 @@ def stdin(settings, font, fontsize, width, portrait, nofold, spacing, ttyrows, t ptty.rows = int(ttyrows) if ttycols: ptty.cols = int(ttycols) - ptty.showtext(text, fill=ptty.driver.black, portrait=portrait) + textargs = {'portrait': portrait, 'flipx': flipx, 'flipy': flipy} + ptty.showtext(text, fill=ptty.driver.black, **textargs) @click.command()