25 lines
546 B
Nim
25 lines
546 B
Nim
# list of functions to generate escape sequences
|
|
# in the future, this can be expanded to support more platforms
|
|
|
|
import strformat
|
|
import strutils
|
|
|
|
func escSetCursorPos*(x, y: int): string =
|
|
&"\e[{y+1};{x+1}H"
|
|
|
|
const escGetCursorPos* = "\e[6n"
|
|
|
|
type InvalidResponseError* = object of CatchableError
|
|
|
|
func escAttributes*(attributes: seq[uint8]): string =
|
|
let joined = attributes.join(";")
|
|
&"\e[{joined}m"
|
|
|
|
func escEraseCharacters*(n: int): string =
|
|
&"\e[{n}X"
|
|
|
|
func escScroll*(n: int): string =
|
|
if n == 0:
|
|
""
|
|
else:
|
|
&"\e[{n}S" |