-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinputhandler_dcs.go
More file actions
64 lines (55 loc) · 1.7 KB
/
inputhandler_dcs.go
File metadata and controls
64 lines (55 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package xterm
// Ported from xterm.js src/common/InputHandler.ts — DCS sequence handlers.
import "fmt"
// requestStatusString handles DECRQSS (DCS $ q Pt ST).
// It responds with DECRPSS containing the requested terminal setting.
//
// Supported requests:
// - "q → DECSCA (protection attribute): responds with 0 or 1
// - "p → DECSCL (conformance level): responds with 61;1
// - r → DECSTBM (scroll region): responds with top;bottom
// - m → SGR (graphic rendition): responds with 0m
// - ' 'q (SP q) → DECSCUSR (cursor style): responds with style number
//
// Unknown requests receive DCS 0 $ r ST.
func (h *InputHandler) requestStatusString(data string, params *Params) bool {
respond := func(s string) bool {
h.coreService.TriggerDataEvent("\x1b"+s+"\x1b\\", false, false)
return true
}
switch data {
case "\"q":
// DECSCA — protection attribute
p := 0
if h.curAttrData.IsProtected() != 0 {
p = 1
}
return respond(fmt.Sprintf("P1$r%d\"q", p))
case "\"p":
// DECSCL — conformance level (always report VT100 level 1)
return respond("P1$r61;1\"p")
case "r":
// DECSTBM — scroll region
buf := h.activeBuffer()
return respond(fmt.Sprintf("P1$r%d;%dr", buf.ScrollTop+1, buf.ScrollBottom+1))
case "m":
// SGR — graphic rendition (report default for now)
return respond("P1$r0m")
case " q":
// DECSCUSR — cursor style
styles := map[CursorStyle]int{
CursorStyleBlock: 2,
CursorStyleUnderline: 4,
CursorStyleBar: 6,
}
opts := h.optionsService.Options
style := styles[opts.CursorStyle]
if opts.CursorBlink {
style--
}
return respond(fmt.Sprintf("P1$r%d q", style))
default:
// Unknown request
return respond("P0$r")
}
}