chore: bump go version, comments, small fixes
This commit is contained in:
		@@ -34,6 +34,7 @@ func main() {
 | 
			
		||||
 | 
			
		||||
	loop := func() {
 | 
			
		||||
		ticker := time.NewTicker(250 * time.Millisecond)
 | 
			
		||||
		defer ticker.Stop()
 | 
			
		||||
		for {
 | 
			
		||||
			term.GoHome()
 | 
			
		||||
			front.PrintMe()
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										17
									
								
								term/term.go
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								term/term.go
									
									
									
									
									
								
							@@ -2,13 +2,16 @@ package term
 | 
			
		||||
 | 
			
		||||
import "fmt"
 | 
			
		||||
 | 
			
		||||
// CursorFlag is used as a parameter to function TurnCursor and
 | 
			
		||||
// describes if cursor should be displayed or not.
 | 
			
		||||
type CursorFlag bool
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	CursorOn  CursorFlag = true
 | 
			
		||||
	CursorOff CursorFlag = false
 | 
			
		||||
	CursorOn  CursorFlag = true  // Cursor should be visible
 | 
			
		||||
	CursorOff CursorFlag = false // Cursor should be hidden
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// TurnCursor turns the cursor on and off according to the parameter.
 | 
			
		||||
func TurnCursor(onOff CursorFlag) {
 | 
			
		||||
	if onOff == CursorOn {
 | 
			
		||||
		fmt.Printf("\033[?25h")
 | 
			
		||||
@@ -17,40 +20,50 @@ func TurnCursor(onOff CursorFlag) {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ClearScreen clears current screen.
 | 
			
		||||
func ClearScreen() {
 | 
			
		||||
	fmt.Printf("\033[2J")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ResetTerminal resets terminal (ESC c)
 | 
			
		||||
func ResetTerminal() {
 | 
			
		||||
	fmt.Printf("\033c")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GoHome moves cursor to the home position (upper left corner)
 | 
			
		||||
func GoHome() {
 | 
			
		||||
	fmt.Printf("\033[H")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// SaveCursor saves curent position of the SaveCursor
 | 
			
		||||
func SaveCursor() {
 | 
			
		||||
	fmt.Printf("\033[s")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// RestoreCursor restore cursor to the position saved previously with SaveCursor().
 | 
			
		||||
func RestoreCursor() {
 | 
			
		||||
	fmt.Printf("\033[u")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// EnableAlternateScreen switches the terminal to the alternative screen.
 | 
			
		||||
// The alternative screen doesn't have the scroll buffer.
 | 
			
		||||
func EnableAlternateScreen() {
 | 
			
		||||
	fmt.Printf("\033[?1049h")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DiableAlternateScreen switches the terminal to the primary screen.
 | 
			
		||||
func DisableAlternateScreen() {
 | 
			
		||||
	fmt.Printf("\033[?1049l")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StartFullscreen saves the cursor, enables alternate screen and clears it.
 | 
			
		||||
func StartFullscreen() {
 | 
			
		||||
	SaveCursor()
 | 
			
		||||
	EnableAlternateScreen()
 | 
			
		||||
	ClearScreen()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FinishFullscreen returns to the primary screen and restores the cursor.
 | 
			
		||||
func FinishFullscreen() {
 | 
			
		||||
	DisableAlternateScreen()
 | 
			
		||||
	RestoreCursor()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user