Skip to content

Commit

Permalink
- v0.1 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
CiviledCode committed Oct 3, 2021
1 parent 86fd3f2 commit 96d32a1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion colors/color.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package colors

import "fmt"

// Color represents a renderable terminal color using standard ascii color codes.
// Color represents a renderable terminal color, defined using standard ascii color codes.
type Color interface {
// Compress condenses the color down into a string format that we can append to the end of an escape character.
Compress() string
Expand Down
13 changes: 7 additions & 6 deletions screen/screen.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func NewScreen() *Screen {
return &Screen{Terminal: t, ScreenCursor: Cursor{terminal: t}, running: true, InputManager: input.NewManager(t)}
}

// JumpLines jumps to a new clean portion of the screen. This creates a history, so it shouldn't be called frequently.
func (s *Screen) JumpLines() {
fmt.Fprint(s.Terminal, "\x1b[2J")
}
Expand Down Expand Up @@ -81,7 +82,8 @@ func (s *Screen) ClearLine() {
fmt.Fprint(s.Terminal, "\u001b[2K")
}

// ClearFromCursor sends an ASCII escape character to the Screen writer
// ClearFromCursor sends an ASCII escape character to the Screen writer to clear all content from the cursor to a point.
// If eof is true, this point is the end of the file. If not, it's the end of the current line.
func (s *Screen) ClearFromCursor(eof bool) {
if !eof {
fmt.Fprint(s.Terminal, "\u001B[0K")
Expand All @@ -90,9 +92,8 @@ func (s *Screen) ClearFromCursor(eof bool) {
}
}

// ClearToCursor sends an ASCII escape character to the Screen writer to clear all content from a starting point to the cursor.
// If bos is set to true, we start at the beginning of the Screen and clear all content to the cursor. If not, we clear all content from the start of the line
// to the cursor.
// ClearToCursor sends an ASCII escape character to the Screen writer to clear all content starting from a point to the cursor.
// If bos is true, the point starts at the start of the file. If not, it's at the start of the line.
func (s *Screen) ClearToCursor(bos bool) {
if !bos {
fmt.Fprint(s.Terminal, "\x1b[1K")
Expand All @@ -101,10 +102,10 @@ func (s *Screen) ClearToCursor(bos bool) {
}
}

// Close sets the Terminal to stop running.
// Close sets the terminal back in normal mode and signals that the screen should close.
// We do not clear the screen here because we don't know if we want to keep terminal output even after close.
func (s *Screen) Close() {
s.running = false
s.ClearLines()
s.ScreenCursor.Home()

err := s.Terminal.Restore()
Expand Down

0 comments on commit 96d32a1

Please # to comment.