github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/utils/readline/codes.go (about)

     1  package readline
     2  
     3  // Character codes
     4  const (
     5  	charCtrlA = iota + 1
     6  	charCtrlB
     7  	charCtrlC
     8  	charEOF
     9  	charCtrlE
    10  	charCtrlF
    11  	charCtrlG
    12  	charBackspace // ISO 646
    13  	charTab
    14  	charCtrlJ
    15  	charCtrlK
    16  	charCtrlL
    17  	charCtrlM
    18  	charCtrlN
    19  	charCtrlO
    20  	charCtrlP
    21  	charCtrlQ
    22  	charCtrlR
    23  	charCtrlS
    24  	charCtrlT
    25  	charCtrlU
    26  	charCtrlV
    27  	charCtrlW
    28  	charCtrlX
    29  	charCtrlY
    30  	charCtrlZ
    31  	charEscape
    32  	charCtrlSlash             // ^\
    33  	charCtrlCloseSquare       // ^]
    34  	charCtrlHat               // ^^
    35  	charCtrlUnderscore        // ^_
    36  	charBackspace2      = 127 // ASCII 1963
    37  )
    38  
    39  // Escape sequences
    40  var (
    41  	seqUp        = string([]byte{27, 91, 65})
    42  	seqDown      = string([]byte{27, 91, 66})
    43  	seqForwards  = string([]byte{27, 91, 67})
    44  	seqBackwards = string([]byte{27, 91, 68})
    45  	seqHome      = string([]byte{27, 91, 72})
    46  	seqHomeSc    = string([]byte{27, 91, 49, 126})
    47  	seqEnd       = string([]byte{27, 91, 70})
    48  	seqEndSc     = string([]byte{27, 91, 52, 126})
    49  	seqDelete    = string([]byte{27, 91, 51, 126})
    50  	seqShiftTab  = string([]byte{27, 91, 90})
    51  	seqPageUp    = string([]byte{27, 91, 53, 126})
    52  	seqPageDown  = string([]byte{27, 91, 54, 126})
    53  	seqOptUp     = string([]byte{27, 27, 91, 65})
    54  	seqOptDown   = string([]byte{27, 27, 91, 66})
    55  	seqOptLeft   = string([]byte{27, 27, 91, 68})
    56  	seqOptRight  = string([]byte{27, 27, 91, 67})
    57  	seqCtrlUp    = string([]byte{27, 91, 49, 59, 53, 65})
    58  	seqCtrlDown  = string([]byte{27, 91, 49, 59, 53, 66})
    59  	seqCtrlLeft  = string([]byte{27, 91, 49, 59, 53, 68})
    60  	seqCtrlRight = string([]byte{27, 91, 49, 59, 53, 67})
    61  
    62  	seqF1VT100 = string([]byte{27, 79, 80})
    63  	seqF2VT100 = string([]byte{27, 79, 81})
    64  	seqF3VT100 = string([]byte{27, 79, 82})
    65  	seqF4VT100 = string([]byte{27, 79, 83})
    66  	seqF1      = string([]byte{27, 91, 49, 49, 126})
    67  	seqF2      = string([]byte{27, 91, 49, 50, 126})
    68  	seqF3      = string([]byte{27, 91, 49, 51, 126})
    69  	seqF4      = string([]byte{27, 91, 49, 52, 126})
    70  	seqF5      = string([]byte{27, 91, 49, 53, 126})
    71  	seqF6      = string([]byte{27, 91, 49, 55, 126})
    72  	seqF7      = string([]byte{27, 91, 49, 56, 126})
    73  	seqF8      = string([]byte{27, 91, 49, 57, 126})
    74  	seqF9      = string([]byte{27, 91, 50, 48, 126})
    75  	seqF10     = string([]byte{27, 91, 50, 49, 126})
    76  	seqF11     = string([]byte{27, 91, 50, 51, 126})
    77  	seqF12     = string([]byte{27, 91, 50, 52, 126})
    78  
    79  	seqShiftF1  = string([]byte{27, 91, 49, 59, 50, 80})
    80  	seqShiftF2  = string([]byte{27, 91, 49, 59, 50, 81})
    81  	seqShiftF3  = string([]byte{27, 91, 49, 59, 50, 82})
    82  	seqShiftF4  = string([]byte{27, 91, 49, 59, 50, 83})
    83  	seqShiftF5  = string([]byte{27, 91, 49, 53, 59, 50, 126})
    84  	seqShiftF6  = string([]byte{27, 91, 49, 55, 59, 50, 126})
    85  	seqShiftF7  = string([]byte{27, 91, 49, 56, 59, 50, 126})
    86  	seqShiftF8  = string([]byte{27, 91, 49, 57, 59, 50, 126})
    87  	seqShiftF9  = string([]byte{27, 91, 50, 48, 59, 50, 126})
    88  	seqShiftF10 = string([]byte{27, 91, 50, 49, 59, 50, 126})
    89  	seqShiftF11 = string([]byte{27, 91, 50, 51, 59, 50, 126})
    90  	seqShiftF12 = string([]byte{27, 91, 50, 52, 59, 50, 126})
    91  )
    92  
    93  const (
    94  	//seqPosSave    = "\x1b[s"
    95  	//seqPosRestore = "\x1b[u"
    96  
    97  	seqClearLineAfter   = "\x1b[0k"
    98  	seqClearLineBefore  = "\x1b[1k"
    99  	seqClearLine        = "\x1b[2k"
   100  	seqClearScreenBelow = "\x1b[J"
   101  	seqClearScreen      = "\x1b[2J"
   102  
   103  	seqGetCursorPos = "\x1b6n" // response: "\x1b{Line};{Column}R"
   104  
   105  	seqSetCursorPosTopLeft = "\x1b[1;1H"
   106  	seqSaveBuffer          = "\x1b[?47h"
   107  	seqRestoreBuffer       = "\x1b[?47l" //+ curPosSave
   108  )
   109  
   110  // Text effects
   111  const (
   112  	seqReset      = "\x1b[0m"
   113  	seqBold       = "\x1b[1m"
   114  	seqUnderscore = "\x1b[4m"
   115  	seqBlink      = "\x1b[5m"
   116  )
   117  
   118  // Text colours
   119  const (
   120  	seqFgBlack   = "\x1b[30m"
   121  	seqFgRed     = "\x1b[31m"
   122  	seqFgGreen   = "\x1b[32m"
   123  	seqFgYellow  = "\x1b[33m"
   124  	seqFgBlue    = "\x1b[34m"
   125  	seqFgMagenta = "\x1b[35m"
   126  	seqFgCyan    = "\x1b[36m"
   127  	seqFgWhite   = "\x1b[37m"
   128  
   129  	/*seqFgBlackBright   = "\x1b[1;30m"
   130  	seqFgRedBright     = "\x1b[1;31m"
   131  	seqFgGreenBright   = "\x1b[1;32m"
   132  	seqFgYellowBright  = "\x1b[1;33m"
   133  	seqFgBlueBright    = "\x1b[1;34m"
   134  	seqFgMagentaBright = "\x1b[1;35m"
   135  	seqFgCyanBright    = "\x1b[1;36m"
   136  	seqFgWhiteBright   = "\x1b[1;37m"*/
   137  )
   138  
   139  // Background colours
   140  const (
   141  	seqBgBlack   = "\x1b[40m"
   142  	seqBgRed     = "\x1b[41m"
   143  	seqBgGreen   = "\x1b[42m"
   144  	seqBgYellow  = "\x1b[43m"
   145  	seqBgBlue    = "\x1b[44m"
   146  	seqBgMagenta = "\x1b[45m"
   147  	seqBgCyan    = "\x1b[46m"
   148  	seqBgWhite   = "\x1b[47m"
   149  
   150  	/*seqBgBlackBright   = "\x1b[1;40m"
   151  	seqBgRedBright     = "\x1b[1;41m"
   152  	seqBgGreenBright   = "\x1b[1;42m"
   153  	seqBgYellowBright  = "\x1b[1;43m"
   154  	seqBgBlueBright    = "\x1b[1;44m"
   155  	seqBgMagentaBright = "\x1b[1;45m"
   156  	seqBgCyanBright    = "\x1b[1;46m"
   157  	seqBgWhiteBright   = "\x1b[1;47m"*/
   158  )
   159  
   160  const (
   161  	seqEscape = "\x1b"
   162  
   163  	// generated using:
   164  	// a [a..z] -> foreach c { -> tr [:lower:] [:upper:] -> set C; out (seqAlt$C = "\x1b$c") }
   165  	seqAltA = "\x1ba"
   166  	seqAltB = "\x1bb"
   167  	seqAltC = "\x1bc"
   168  	seqAltD = "\x1bd"
   169  	seqAltE = "\x1be"
   170  	seqAltF = "\x1bf"
   171  	seqAltG = "\x1bg"
   172  	seqAltH = "\x1bh"
   173  	seqAltI = "\x1bi"
   174  	seqAltJ = "\x1bj"
   175  	seqAltK = "\x1bk"
   176  	seqAltL = "\x1bl"
   177  	seqAltM = "\x1bm"
   178  	seqAltN = "\x1bn"
   179  	seqAltO = "\x1bo"
   180  	seqAltP = "\x1bp"
   181  	seqAltQ = "\x1bq"
   182  	seqAltR = "\x1br"
   183  	seqAltS = "\x1bs"
   184  	seqAltT = "\x1bt"
   185  	seqAltU = "\x1bu"
   186  	seqAltV = "\x1bv"
   187  	seqAltW = "\x1bw"
   188  	seqAltX = "\x1bx"
   189  	seqAltY = "\x1by"
   190  	seqAltZ = "\x1bz"
   191  
   192  	/*seqAltShiftA = "\x1bA"
   193  	seqAltShiftB = "\x1bB"
   194  	seqAltShiftC = "\x1bC"
   195  	seqAltShiftD = "\x1bD"
   196  	seqAltShiftE = "\x1bE"
   197  	seqAltShiftF = "\x1bF"
   198  	seqAltShiftG = "\x1bG"
   199  	seqAltShiftH = "\x1bH"
   200  	seqAltShiftI = "\x1bI"
   201  	seqAltShiftJ = "\x1bJ"
   202  	seqAltShiftK = "\x1bK"
   203  	seqAltShiftL = "\x1bL"
   204  	seqAltShiftM = "\x1bM"
   205  	seqAltShiftN = "\x1bN"
   206  	seqAltShiftO = "\x1bO"
   207  	seqAltShiftP = "\x1bP"
   208  	seqAltShiftQ = "\x1bQ"
   209  	seqAltShiftR = "\x1bR"
   210  	seqAltShiftS = "\x1bS"
   211  	seqAltShiftT = "\x1bT"
   212  	seqAltShiftU = "\x1bU"
   213  	seqAltShiftV = "\x1bV"
   214  	seqAltShiftW = "\x1bW"
   215  	seqAltShiftX = "\x1bX"
   216  	seqAltShiftY = "\x1bY"
   217  	seqAltShiftZ = "\x1bZ"*/
   218  )