mirror of
				https://github.com/sammy-ette/Hilbish
				synced 2025-08-10 02:52:03 +00:00 
			
		
		
		
	feat: add page keys to greenhouse
This commit is contained in:
		
							parent
							
								
									db32fd7a87
								
							
						
					
					
						commit
						11323a70aa
					
				| @ -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 | ||||
|  | ||||
| @ -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 | ||||
| 
 | ||||
| --[[ | ||||
|  | ||||
| @ -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" | ||||
| 			} | ||||
| 	} | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user