From 0a2455c8be3a355e8569ece41dc9691fc7cd5889 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 31 Aug 2022 20:58:22 +0530 Subject: [PATCH] Get scroll_window working --- gen-go-code.py | 2 +- kitty/rc/scroll_window.py | 2 +- tools/cmd/at/scroll_window.go | 30 +++++++++++++++--------------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/gen-go-code.py b/gen-go-code.py index 3af2730ec..2aebbbb65 100755 --- a/gen-go-code.py +++ b/gen-go-code.py @@ -246,7 +246,7 @@ def update_at_commands() -> None: os.remove(dest) with open(dest, 'w') as f: f.write(code) - print('\x1b[31mTODO\x1b[m: test send_text, env, scroll_window', file=sys.stderr) + print('\x1b[31mTODO\x1b[m: test send_text, env', file=sys.stderr) def main() -> None: diff --git a/kitty/rc/scroll_window.py b/kitty/rc/scroll_window.py index 8e09a78af..24543b747 100644 --- a/kitty/rc/scroll_window.py +++ b/kitty/rc/scroll_window.py @@ -69,7 +69,7 @@ using this option means that you will not be notified of failures. window.screen.reverse_scroll(int(abs(amt)), True) else: unit = 'page' if unit == 'p' else 'line' - if unit == 'page' and not amt.is_integer(): + if unit == 'page' and not isinstance(amt, int) and not amt.is_integer(): amt = round(window.screen.lines * amt) unit = 'line' direction = 'up' if amt < 0 else 'down' diff --git a/tools/cmd/at/scroll_window.go b/tools/cmd/at/scroll_window.go index d70a44052..7a4242b15 100644 --- a/tools/cmd/at/scroll_window.go +++ b/tools/cmd/at/scroll_window.go @@ -19,21 +19,21 @@ func parse_scroll_amount(amt string) ([]interface{}, error) { var mult float64 = 1 if strings.HasSuffix(amt, "-") && !unscroll { mult = -1 - q, err := strconv.ParseFloat(strings.TrimRight(amt, "+-plu"), 64) - if err != nil { - return ans, err - } - if !pages && q != float64(int(q)) { - return ans, fmt.Errorf("The number must be an integer") - } - ans[0] = q * mult - if pages { - ans[1] = "p" - } else if unscroll { - ans[1] = "u" - } else { - ans[1] = "l" - } + } + q, err := strconv.ParseFloat(strings.TrimRight(amt, "+-plu"), 64) + if err != nil { + return ans, err + } + if !pages && q != float64(int(q)) { + return ans, fmt.Errorf("The number must be an integer") + } + ans[0] = q * mult + if pages { + ans[1] = "p" + } else if unscroll { + ans[1] = "u" + } else { + ans[1] = "l" } } return ans, nil