...

Source file src/github.com/gdamore/tcell/v2/terminfo/x/xterm/direct.go

Documentation: github.com/gdamore/tcell/v2/terminfo/x/xterm

     1  // Copyright 2021 The TCell Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use file except in compliance with the License.
     5  // You may obtain a copy of the license at
     6  //
     7  //    http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  // This terminal definition is derived from the xterm-256color definition, but
    16  // makes use of the RGB property these terminals have to support direct color.
    17  // The terminfo entry for this uses a new format for the color handling introduced
    18  // by ncurses 6.1 (and used by nobody else), so this override ensures we get
    19  // good handling even in the face of this.
    20  
    21  package xterm
    22  
    23  import "github.com/gdamore/tcell/v2/terminfo"
    24  
    25  func init() {
    26  
    27  	// derived from xterm-256color, but adds full RGB support
    28  	terminfo.AddTerminfo(&terminfo.Terminfo{
    29  		Name:          "xterm-direct",
    30  		Aliases:       []string{"xterm-truecolor"},
    31  		Columns:       80,
    32  		Lines:         24,
    33  		Colors:        256,
    34  		Bell:          "\a",
    35  		Clear:         "\x1b[H\x1b[2J",
    36  		EnterCA:       "\x1b[?1049h\x1b[22;0;0t",
    37  		ExitCA:        "\x1b[?1049l\x1b[23;0;0t",
    38  		ShowCursor:    "\x1b[?12l\x1b[?25h",
    39  		HideCursor:    "\x1b[?25l",
    40  		AttrOff:       "\x1b(B\x1b[m",
    41  		Underline:     "\x1b[4m",
    42  		Bold:          "\x1b[1m",
    43  		Dim:           "\x1b[2m",
    44  		Italic:        "\x1b[3m",
    45  		Blink:         "\x1b[5m",
    46  		Reverse:       "\x1b[7m",
    47  		EnterKeypad:   "\x1b[?1h\x1b=",
    48  		ExitKeypad:    "\x1b[?1l\x1b>",
    49  		SetFg:         "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m",
    50  		SetBg:         "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m",
    51  		SetFgBg:       "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;;%?%p2%{8}%<%t4%p2%d%e%p2%{16}%<%t10%p2%{8}%-%d%e48;5;%p2%d%;m",
    52  		SetFgRGB:      "\x1b[38;2;%p1%d;%p2%d;%p3%dm",
    53  		SetBgRGB:      "\x1b[48;2;%p1%d;%p2%d;%p3%dm",
    54  		SetFgBgRGB:    "\x1b[38;2;%p1%d;%p2%d;%p3%d;48;2;%p4%d;%p5%d;%p6%dm",
    55  		ResetFgBg:     "\x1b[39;49m",
    56  		AltChars:      "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~",
    57  		EnterAcs:      "\x1b(0",
    58  		ExitAcs:       "\x1b(B",
    59  		StrikeThrough: "\x1b[9m",
    60  		Mouse:         "\x1b[M",
    61  		SetCursor:     "\x1b[%i%p1%d;%p2%dH",
    62  		CursorBack1:   "\b",
    63  		CursorUp1:     "\x1b[A",
    64  		KeyUp:         "\x1bOA",
    65  		KeyDown:       "\x1bOB",
    66  		KeyRight:      "\x1bOC",
    67  		KeyLeft:       "\x1bOD",
    68  		KeyInsert:     "\x1b[2~",
    69  		KeyDelete:     "\x1b[3~",
    70  		KeyBackspace:  "\u007f",
    71  		KeyHome:       "\x1bOH",
    72  		KeyEnd:        "\x1bOF",
    73  		KeyPgUp:       "\x1b[5~",
    74  		KeyPgDn:       "\x1b[6~",
    75  		KeyF1:         "\x1bOP",
    76  		KeyF2:         "\x1bOQ",
    77  		KeyF3:         "\x1bOR",
    78  		KeyF4:         "\x1bOS",
    79  		KeyF5:         "\x1b[15~",
    80  		KeyF6:         "\x1b[17~",
    81  		KeyF7:         "\x1b[18~",
    82  		KeyF8:         "\x1b[19~",
    83  		KeyF9:         "\x1b[20~",
    84  		KeyF10:        "\x1b[21~",
    85  		KeyF11:        "\x1b[23~",
    86  		KeyF12:        "\x1b[24~",
    87  		KeyBacktab:    "\x1b[Z",
    88  		Modifiers:     1,
    89  		AutoMargin:    true,
    90  		TrueColor:     true,
    91  	})
    92  }
    93  

View as plain text