diff --git a/CHANGELOG.md b/CHANGELOG.md index b596162..b853c4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # 🎀 Changelog +## Unreleased +## Added +- Page Up/Down keybinds for Greenhouse will now scroll up and down the size of the region (a page) + +## Changed +- Remove usage of `hilbish.goro` in Greenhouse. + ## [2.2.1] - 2023-12-26 ## Fixed - Removed a left over debug print @@ -693,6 +700,7 @@ This input for example will prompt for more input to complete: First "stable" release of Hilbish. +[2.2.2]: https://github.com/Rosettea/Hilbish/compare/v2.2.1...v2.2.2 [2.2.1]: https://github.com/Rosettea/Hilbish/compare/v2.2.0...v2.2.1 [2.2.0]: https://github.com/Rosettea/Hilbish/compare/v2.1.0...v2.2.0 [2.1.2]: https://github.com/Rosettea/Hilbish/compare/v2.1.1...v2.1.2 diff --git a/nature/greenhouse/init.lua b/nature/greenhouse/init.lua index ad5a04c..50d5fad 100644 --- a/nature/greenhouse/init.lua +++ b/nature/greenhouse/init.lua @@ -40,7 +40,9 @@ function Greenhouse:new(sink) self:jump(self.specialPageIdx) self:special(false) end - end + end, + ['Page-Down'] = function(self) self:scroll('down', {page = true}) end, + ['Page-Up'] = function(self) self:scroll('up', {page = true}) end } self.isSpecial = false self.specialPage = nil @@ -108,7 +110,9 @@ end function Greenhouse:render() end -function Greenhouse:scroll(direction) +function Greenhouse:scroll(direction, opts) + opts = opts or {} + if self.isSpecial then if direction == 'down' then self:next(true) @@ -122,10 +126,15 @@ function Greenhouse:scroll(direction) local oldOffset = self.offset local oldHorizOffset = self.horizOffset + local amount = self.step.vertical + if opts.page then + amount = self.region.height + end + if direction == 'down' then - self.offset = math.min(self.offset + self.step.vertical, math.max(1, #lines - self.region.height)) + self.offset = math.min(self.offset + amount, math.max(1, #lines - self.region.height)) elseif direction == 'up' then - self.offset = math.max(self.offset - self.step.vertical, 1) + self.offset = math.max(self.offset - amount, 1) end --[[ diff --git a/readline/codes.go b/readline/codes.go index dd8495d..7037e45 100644 --- a/readline/codes.go +++ b/readline/codes.go @@ -60,6 +60,8 @@ var ( seqAltF = string([]byte{27, 102}) seqAltR = string([]byte{27, 114}) // Used for alternative history seqAltBackspace = string([]byte{27, 127}) + seqPageUp = string([]byte{27, 91, 53, 126}) + seqPageDown = string([]byte{27, 91, 54, 126}) ) const ( @@ -185,6 +187,8 @@ func (rl *Instance) ReadChar() string { case seqHome, seqHomeSc: return "Home" case seqEnd, seqEndSc: return "End" case seqDelete, seqDelete2: return "Delete" + case seqPageUp: return "Page-Up" + case seqPageDown: return "Page-Down" } }