-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(term): move ansi subpackages to ansi
- Loading branch information
1 parent
218372c
commit 871d2af
Showing
27 changed files
with
683 additions
and
484 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 6 additions & 7 deletions
13
exp/term/ansi/sys/background_test.go → exp/term/ansi/background_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package style | ||
package ansi | ||
|
||
import ( | ||
"image/color" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
package ctrl | ||
package ansi | ||
|
||
// RequestXTVersion is a control sequence that requests the terminal's XTVERSION. It responds with a DSR sequence identifying the version. | ||
// | ||
// CSI > Ps q | ||
// DCS > | text ST | ||
// | ||
// See https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-PC-Style-Function-Keys | ||
const RequestXTVersion = "\x1b[" + ">0q" | ||
const RequestXTVersion = "\x1b[>0q" | ||
|
||
// RequestPrimaryDeviceAttributes is a control sequence that requests the | ||
// terminal's primary device attributes (DA1). | ||
// | ||
// CSI c | ||
// | ||
// See https://vt100.net/docs/vt510-rm/DA1.html | ||
const RequestPrimaryDeviceAttributes = "\x1b[" + "c" | ||
const RequestPrimaryDeviceAttributes = "\x1b[c" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
package ansi | ||
|
||
import "strconv" | ||
|
||
// SaveCursor (DECSC) is an escape sequence that saves the current cursor | ||
// position. | ||
// | ||
// See: https://vt100.net/docs/vt510-rm/DECSC.html | ||
const SaveCursor = "\x1b7" | ||
|
||
// RestoreCursor (DECRC) is an escape sequence that restores the cursor | ||
// position. | ||
// | ||
// See: https://vt100.net/docs/vt510-rm/DECRC.html | ||
const RestoreCursor = "\x1b8" | ||
|
||
// CursorUp (CUU) returns a sequence for moving the cursor up n cells. | ||
// | ||
// CSI n A | ||
// | ||
// See: https://vt100.net/docs/vt510-rm/CUU.html | ||
func CursorUp(n int) string { | ||
var s string | ||
if n > 1 { | ||
s = strconv.Itoa(n) | ||
} | ||
return "\x1b[" + s + "A" | ||
} | ||
|
||
// CursorUp1 is a sequence for moving the cursor up one cell. | ||
// | ||
// This is equivalent to CursorUp(1). | ||
const CursorUp1 = "\x1b[A" | ||
|
||
// CursorDown (CUD) returns a sequence for moving the cursor down n cells. | ||
// | ||
// CSI n B | ||
// | ||
// See: https://vt100.net/docs/vt510-rm/CUD.html | ||
func CursorDown(n int) string { | ||
var s string | ||
if n > 1 { | ||
s = strconv.Itoa(n) | ||
} | ||
return "\x1b[" + s + "B" | ||
} | ||
|
||
// CursorDown1 is a sequence for moving the cursor down one cell. | ||
// | ||
// This is equivalent to CursorDown(1). | ||
const CursorDown1 = "\x1b[B" | ||
|
||
// CursorRight (CUF) returns a sequence for moving the cursor right n cells. | ||
// | ||
// CSI n C | ||
// | ||
// See: https://vt100.net/docs/vt510-rm/CUF.html | ||
func CursorRight(n int) string { | ||
var s string | ||
if n > 1 { | ||
s = strconv.Itoa(n) | ||
} | ||
return "\x1b[" + s + "C" | ||
} | ||
|
||
// CursorRight1 is a sequence for moving the cursor right one cell. | ||
// | ||
// This is equivalent to CursorRight(1). | ||
const CursorRight1 = "\x1b[C" | ||
|
||
// CursorLeft (CUB) returns a sequence for moving the cursor left n cells. | ||
// | ||
// CSI n D | ||
// | ||
// See: https://vt100.net/docs/vt510-rm/CUB.html | ||
func CursorLeft(n int) string { | ||
var s string | ||
if n > 1 { | ||
s = strconv.Itoa(n) | ||
} | ||
return "\x1b[" + s + "D" | ||
} | ||
|
||
// CursorLeft1 is a sequence for moving the cursor left one cell. | ||
// | ||
// This is equivalent to CursorLeft(1). | ||
const CursorLeft1 = "\x1b[D" | ||
|
||
// CursorNextLine (CNL) returns a sequence for moving the cursor to the | ||
// beginning of the next line n times. | ||
// | ||
// CSI n E | ||
// | ||
// See: https://vt100.net/docs/vt510-rm/CNL.html | ||
func CursorNextLine(n int) string { | ||
var s string | ||
if n > 1 { | ||
s = strconv.Itoa(n) | ||
} | ||
return "\x1b[" + s + "E" | ||
} | ||
|
||
// CursorPreviousLine (CPL) returns a sequence for moving the cursor to the | ||
// beginning of the previous line n times. | ||
// | ||
// CSI n F | ||
// | ||
// See: https://vt100.net/docs/vt510-rm/CPL.html | ||
func CursorPreviousLine(n int) string { | ||
var s string | ||
if n > 1 { | ||
s = strconv.Itoa(n) | ||
} | ||
return "\x1b[" + s + "F" | ||
} | ||
|
||
// MoveCursor (CUP) returns a sequence for moving the cursor to the given row | ||
// and column. | ||
// | ||
// CSI n ; m H | ||
// | ||
// See: https://vt100.net/docs/vt510-rm/CUP.html | ||
func MoveCursor(row, col int) string { | ||
var r, c string | ||
if row > 1 { | ||
r = strconv.Itoa(row) | ||
} | ||
if col > 1 { | ||
c = strconv.Itoa(col) | ||
} | ||
return "\x1b[" + r + ";" + c + "H" | ||
} | ||
|
||
// MoveCursorZero is a sequence for moving the cursor to the upper left corner | ||
// of the screen. | ||
// This is equivalent to MoveCursor(1, 1). | ||
const MoveCursorZero = "\x1b[1;1H" | ||
|
||
// SaveCursorPosition (SCP or SCOSC) is a sequence for saving the cursor | ||
// position. | ||
// | ||
// CSI s | ||
// | ||
// This acts like Save, except the page number where the cursor is located is | ||
// not saved. | ||
// | ||
// See: https://vt100.net/docs/vt510-rm/SCOSC.html | ||
const SaveCursorPosition = "\x1b[s" | ||
|
||
// RestoreCursorPosition (RCP or SCORC) is a sequence for restoring the cursor | ||
// position. | ||
// | ||
// CSI u | ||
// | ||
// This acts like Restore, except the cursor stays on the same page where the | ||
// cursor was saved. | ||
// | ||
// See: https://vt100.net/docs/vt510-rm/SCORC.html | ||
const RestoreCursorPosition = "\x1b[u" |
Oops, something went wrong.