"Fossies" - the Fresh Open Source Software Archive

Member "buildah-1.23.1/vendor/github.com/morikuni/aec/aec.go" (28 Sep 2021, 2491 Bytes) of package /linux/misc/buildah-1.23.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Go source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 package aec
    2 
    3 import "fmt"
    4 
    5 // EraseMode is listed in a variable EraseModes.
    6 type EraseMode uint
    7 
    8 var (
    9     // EraseModes is a list of EraseMode.
   10     EraseModes struct {
   11         // All erase all.
   12         All EraseMode
   13 
   14         // Head erase to head.
   15         Head EraseMode
   16 
   17         // Tail erase to tail.
   18         Tail EraseMode
   19     }
   20 
   21     // Save saves the cursor position.
   22     Save ANSI
   23 
   24     // Restore restores the cursor position.
   25     Restore ANSI
   26 
   27     // Hide hides the cursor.
   28     Hide ANSI
   29 
   30     // Show shows the cursor.
   31     Show ANSI
   32 
   33     // Report reports the cursor position.
   34     Report ANSI
   35 )
   36 
   37 // Up moves up the cursor.
   38 func Up(n uint) ANSI {
   39     if n == 0 {
   40         return empty
   41     }
   42     return newAnsi(fmt.Sprintf(esc+"%dA", n))
   43 }
   44 
   45 // Down moves down the cursor.
   46 func Down(n uint) ANSI {
   47     if n == 0 {
   48         return empty
   49     }
   50     return newAnsi(fmt.Sprintf(esc+"%dB", n))
   51 }
   52 
   53 // Right moves right the cursor.
   54 func Right(n uint) ANSI {
   55     if n == 0 {
   56         return empty
   57     }
   58     return newAnsi(fmt.Sprintf(esc+"%dC", n))
   59 }
   60 
   61 // Left moves left the cursor.
   62 func Left(n uint) ANSI {
   63     if n == 0 {
   64         return empty
   65     }
   66     return newAnsi(fmt.Sprintf(esc+"%dD", n))
   67 }
   68 
   69 // NextLine moves down the cursor to head of a line.
   70 func NextLine(n uint) ANSI {
   71     if n == 0 {
   72         return empty
   73     }
   74     return newAnsi(fmt.Sprintf(esc+"%dE", n))
   75 }
   76 
   77 // PreviousLine moves up the cursor to head of a line.
   78 func PreviousLine(n uint) ANSI {
   79     if n == 0 {
   80         return empty
   81     }
   82     return newAnsi(fmt.Sprintf(esc+"%dF", n))
   83 }
   84 
   85 // Column set the cursor position to a given column.
   86 func Column(col uint) ANSI {
   87     return newAnsi(fmt.Sprintf(esc+"%dG", col))
   88 }
   89 
   90 // Position set the cursor position to a given absolute position.
   91 func Position(row, col uint) ANSI {
   92     return newAnsi(fmt.Sprintf(esc+"%d;%dH", row, col))
   93 }
   94 
   95 // EraseDisplay erases display by given EraseMode.
   96 func EraseDisplay(m EraseMode) ANSI {
   97     return newAnsi(fmt.Sprintf(esc+"%dJ", m))
   98 }
   99 
  100 // EraseLine erases lines by given EraseMode.
  101 func EraseLine(m EraseMode) ANSI {
  102     return newAnsi(fmt.Sprintf(esc+"%dK", m))
  103 }
  104 
  105 // ScrollUp scrolls up the page.
  106 func ScrollUp(n int) ANSI {
  107     if n == 0 {
  108         return empty
  109     }
  110     return newAnsi(fmt.Sprintf(esc+"%dS", n))
  111 }
  112 
  113 // ScrollDown scrolls down the page.
  114 func ScrollDown(n int) ANSI {
  115     if n == 0 {
  116         return empty
  117     }
  118     return newAnsi(fmt.Sprintf(esc+"%dT", n))
  119 }
  120 
  121 func init() {
  122     EraseModes = struct {
  123         All  EraseMode
  124         Head EraseMode
  125         Tail EraseMode
  126     }{
  127         Tail: 0,
  128         Head: 1,
  129         All:  2,
  130     }
  131 
  132     Save = newAnsi(esc + "s")
  133     Restore = newAnsi(esc + "u")
  134     Hide = newAnsi(esc + "?25l")
  135     Show = newAnsi(esc + "?25h")
  136     Report = newAnsi(esc + "6n")
  137 }