...

Source file src/github.com/jedib0t/go-pretty/v6/text/cursor.go

Documentation: github.com/jedib0t/go-pretty/v6/text

     1  package text
     2  
     3  import (
     4  	"fmt"
     5  )
     6  
     7  // Cursor helps move the cursor on the console in multiple directions.
     8  type Cursor rune
     9  
    10  const (
    11  	// CursorDown helps move the Cursor Down X lines
    12  	CursorDown Cursor = 'B'
    13  
    14  	// CursorLeft helps move the Cursor Left X characters
    15  	CursorLeft Cursor = 'D'
    16  
    17  	// CursorRight helps move the Cursor Right X characters
    18  	CursorRight Cursor = 'C'
    19  
    20  	// CursorUp helps move the Cursor Up X lines
    21  	CursorUp Cursor = 'A'
    22  
    23  	// EraseLine helps erase all characters to the Right of the Cursor in the
    24  	// current line
    25  	EraseLine Cursor = 'K'
    26  )
    27  
    28  // Sprint prints the Escape Sequence to move the Cursor once.
    29  func (c Cursor) Sprint() string {
    30  	return fmt.Sprintf("%s%c", EscapeStart, c)
    31  }
    32  
    33  // Sprintn prints the Escape Sequence to move the Cursor "n" times.
    34  func (c Cursor) Sprintn(n int) string {
    35  	if c == EraseLine {
    36  		return c.Sprint()
    37  	}
    38  	return fmt.Sprintf("%s%d%c", EscapeStart, n, c)
    39  }
    40  

View as plain text