From 8fbaf169a43b4b61abac0bb3b55bacd8e63ff41d Mon Sep 17 00:00:00 2001 From: DFHack-Urist via GitHub Actions <63161697+DFHack-Urist@users.noreply.github.com> Date: Mon, 23 Jan 2023 07:14:54 +0000 Subject: [PATCH 1/3] Auto-update submodules scripts: master --- scripts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts b/scripts index 9666cb8eb..7f08c8c2b 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit 9666cb8ebcc51f8e4bb2fb99116636793a7e4270 +Subproject commit 7f08c8c2bad5b98db4846a857ca7d41c86929660 From a6b3de1afbff256e01aa8efe4c6a40bd51122dfe Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 23 Jan 2023 02:15:45 -0800 Subject: [PATCH 2/3] support scrolling to the beginning or end in Label --- docs/dev/Lua API.rst | 4 ++-- library/lua/gui/widgets.lua | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/dev/Lua API.rst b/docs/dev/Lua API.rst index 8b2d8b513..c696248ab 100644 --- a/docs/dev/Lua API.rst +++ b/docs/dev/Lua API.rst @@ -4684,8 +4684,8 @@ The Label widget implements the following methods: This method takes the number of lines to scroll as positive or negative integers or one of the following keywords: ``+page``, ``-page``, - ``+halfpage``, or ``-halfpage``. It returns the number of lines that were - actually scrolled (negative for scrolling up). + ``+halfpage``, ``-halfpage``, ``home``, or ``end``. It returns the number of + lines that were actually scrolled (negative for scrolling up). WrappedLabel class ------------------ diff --git a/library/lua/gui/widgets.lua b/library/lua/gui/widgets.lua index f56eff096..f0129ffe3 100644 --- a/library/lua/gui/widgets.lua +++ b/library/lua/gui/widgets.lua @@ -1315,6 +1315,7 @@ end function Label:scroll(nlines) if not nlines then return end + local text_height = math.max(1, self:getTextHeight()) if type(nlines) == 'string' then if nlines == '+page' then nlines = self.frame_body.height @@ -1324,12 +1325,15 @@ function Label:scroll(nlines) nlines = math.ceil(self.frame_body.height/2) elseif nlines == '-halfpage' then nlines = -math.ceil(self.frame_body.height/2) + elseif nlines == 'home' then + nlines = 1 - self.start_line_num + elseif nlines == 'end' then + nlines = text_height else error(('unhandled scroll keyword: "%s"'):format(nlines)) end end local n = self.start_line_num + nlines - local text_height = math.max(1, self:getTextHeight()) n = math.min(n, text_height - self.frame_body.height + 1) n = math.max(n, 1) nlines = n - self.start_line_num From f50cef93b1de6283e2c8e1cd16c3de51030514de Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 23 Jan 2023 02:16:56 -0800 Subject: [PATCH 3/3] update changelog --- docs/changelog.txt | 1 + scripts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index f83892e69..5e114c5e2 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -47,6 +47,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## API ## Lua +- ``widgets.Label``: ``label.scroll()`` now understands ``home`` and ``end`` keywords for scrolling to the top or bottom ## Removed diff --git a/scripts b/scripts index 7f08c8c2b..9666cb8eb 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit 7f08c8c2bad5b98db4846a857ca7d41c86929660 +Subproject commit 9666cb8ebcc51f8e4bb2fb99116636793a7e4270