From 65d617e851339035611ed42872204088999acda1 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 6 Sep 2024 17:31:02 +0200 Subject: [PATCH] ui/Window: add method GetCursor() --- src/ui/Window.hxx | 7 +++++++ src/wreadln.cxx | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ui/Window.hxx b/src/ui/Window.hxx index 5d8b34ee..4cee902e 100644 --- a/src/ui/Window.hxx +++ b/src/ui/Window.hxx @@ -27,6 +27,13 @@ struct Window { return size; } + [[gnu::pure]] + const Point GetCursor() const noexcept { + Point p; + getyx(w, p.y, p.x); + return p; + } + [[gnu::pure]] unsigned GetWidth() const noexcept { return getmaxx(w); diff --git a/src/wreadln.cxx b/src/wreadln.cxx index 5820e21c..ddda3143 100644 --- a/src/wreadln.cxx +++ b/src/wreadln.cxx @@ -271,7 +271,7 @@ _wreadln(const Window window, /* make sure the cursor is visible */ curs_set(1); /* retrieve y and x0 position */ - getyx(window.w, wr.point.y, wr.point.x); + wr.point = window.GetCursor(); /* check the x1 value */ if (x1 <= (unsigned)wr.point.x || x1 > (unsigned)COLS) x1 = COLS;