mirror of
				https://github.com/sammy-ette/Hilbish
				synced 2025-08-10 02:52:03 +00:00 
			
		
		
		
	fix(greenhouse): fix toc disappearing on any key press
This commit is contained in:
		
							parent
							
								
									1f5ab90586
								
							
						
					
					
						commit
						ade14a6238
					
				@ -89,7 +89,7 @@ commander.register('greenhouse', function(args, sinks)
 | 
			
		||||
	gh:keybind('Enter', function(self)
 | 
			
		||||
		if self.isSpecial then
 | 
			
		||||
			self:jump(self.specialPageIdx)
 | 
			
		||||
			self:special(true)
 | 
			
		||||
			self:special(false)
 | 
			
		||||
		else
 | 
			
		||||
			if buffer:len() < 2 then return end
 | 
			
		||||
 | 
			
		||||
@ -118,5 +118,6 @@ commander.register('greenhouse', function(args, sinks)
 | 
			
		||||
		gh:addPage(page)
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	ansikit.hideCursor()
 | 
			
		||||
	gh:initUi()
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
@ -93,14 +93,25 @@ end
 | 
			
		||||
function Greenhouse:update()
 | 
			
		||||
	self:resize()
 | 
			
		||||
	if self.isSpecial then
 | 
			
		||||
		self:special()
 | 
			
		||||
		self:updateSpecial()
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	self:draw()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function Greenhouse:special()
 | 
			
		||||
	self.isSpecial = not self.isSpecial
 | 
			
		||||
 | 
			
		||||
function Greenhouse:special(val)
 | 
			
		||||
	self.isSpecial = val
 | 
			
		||||
	self:update()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function Greenhouse:toggleSpecial()
 | 
			
		||||
	self:special(not self.isSpecial)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
--- This function will be called when the special page
 | 
			
		||||
--- is on and needs to be updated.
 | 
			
		||||
function Greenhouse:updateSpecial()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function Greenhouse:toc(toggle)
 | 
			
		||||
@ -128,6 +139,9 @@ function Greenhouse:toc(toggle)
 | 
			
		||||
		tocText = tocText .. title .. '\n'
 | 
			
		||||
	end
 | 
			
		||||
	self.specialPage = Page('TOC', tocText)
 | 
			
		||||
	function self:updateSpecial()
 | 
			
		||||
		self:toc()
 | 
			
		||||
	end
 | 
			
		||||
	self:draw()
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@ -202,7 +216,6 @@ function Greenhouse:initUi()
 | 
			
		||||
	end)
 | 
			
		||||
 | 
			
		||||
	ansikit.screenAlt()
 | 
			
		||||
	ansikit.hideCursor()
 | 
			
		||||
	ansikit.clear(true)
 | 
			
		||||
	self:draw()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user