Debian Codegraph @

vt/cursor.go

raw symbols SCIP
1 // Copyright 2026 The TCell Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this 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 package vt
15
16 // CursorStyle represents the style of cursor, and covers the shape, whether it
17 // blinks, and whether it is visible. Cursor color is handled separately, if at all.
18 type CursorStyle byte
19
20 const (
21 SteadyBlock = CursorStyle(iota) // The default
22 SteadyBar
23 SteadyUnderline
24 BlinkingBlock = SteadyBlock | blinkingCursor
25 BlinkingBar = SteadyBar | blinkingCursor
26 BlinkingUnderline = SteadyUnderline | blinkingCursor
27
28 hiddenCursor = CursorStyle(1 << 7) // If set, cursor should be hidden
29 blinkingCursor = CursorStyle(1 << 6) // If set, cursor should blink
30 )
31
32 func (cs CursorStyle) IsVisible() bool {
33 return cs&hiddenCursor == 0
34 }
35
36 func (cs CursorStyle) IsBlinking() bool {
37 return cs&blinkingCursor != 0
38 }
39
40 func (cs CursorStyle) Hide() CursorStyle {
41 return cs | hiddenCursor
42 }
43
44 func (cs CursorStyle) Show() CursorStyle {
45 return cs &^ hiddenCursor
46 }
47
48 func (cs CursorStyle) Blink() CursorStyle {
49 return cs | blinkingCursor
50 }
51
52 func (cs CursorStyle) Steady() CursorStyle {
53 return cs &^ blinkingCursor
54 }