-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdevice.go
More file actions
127 lines (110 loc) · 4.74 KB
/
device.go
File metadata and controls
127 lines (110 loc) · 4.74 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package libghostty
/*
#include <ghostty/vt.h>
*/
import "C"
// ColorScheme identifies the terminal color scheme (light or dark).
// C: GhosttyColorScheme
type ColorScheme int
const (
// ColorSchemeLight indicates a light color scheme.
ColorSchemeLight ColorScheme = C.GHOSTTY_COLOR_SCHEME_LIGHT
// ColorSchemeDark indicates a dark color scheme.
ColorSchemeDark ColorScheme = C.GHOSTTY_COLOR_SCHEME_DARK
)
// DA1 conformance levels (Pp parameter).
// C: GHOSTTY_DA_CONFORMANCE_*
const (
DAConformanceVT100 = C.GHOSTTY_DA_CONFORMANCE_VT100
DAConformanceVT101 = C.GHOSTTY_DA_CONFORMANCE_VT101
DAConformanceVT102 = C.GHOSTTY_DA_CONFORMANCE_VT102
DAConformanceVT125 = C.GHOSTTY_DA_CONFORMANCE_VT125
DAConformanceVT131 = C.GHOSTTY_DA_CONFORMANCE_VT131
DAConformanceVT132 = C.GHOSTTY_DA_CONFORMANCE_VT132
DAConformanceVT220 = C.GHOSTTY_DA_CONFORMANCE_VT220
DAConformanceVT240 = C.GHOSTTY_DA_CONFORMANCE_VT240
DAConformanceVT320 = C.GHOSTTY_DA_CONFORMANCE_VT320
DAConformanceVT340 = C.GHOSTTY_DA_CONFORMANCE_VT340
DAConformanceVT420 = C.GHOSTTY_DA_CONFORMANCE_VT420
DAConformanceVT510 = C.GHOSTTY_DA_CONFORMANCE_VT510
DAConformanceVT520 = C.GHOSTTY_DA_CONFORMANCE_VT520
DAConformanceVT525 = C.GHOSTTY_DA_CONFORMANCE_VT525
DAConformanceLevel2 = C.GHOSTTY_DA_CONFORMANCE_LEVEL_2
DAConformanceLevel3 = C.GHOSTTY_DA_CONFORMANCE_LEVEL_3
DAConformanceLevel4 = C.GHOSTTY_DA_CONFORMANCE_LEVEL_4
DAConformanceLevel5 = C.GHOSTTY_DA_CONFORMANCE_LEVEL_5
)
// DA1 feature codes (Ps parameters).
// C: GHOSTTY_DA_FEATURE_*
const (
DAFeatureColumns132 = C.GHOSTTY_DA_FEATURE_COLUMNS_132
DAFeaturePrinter = C.GHOSTTY_DA_FEATURE_PRINTER
DAFeatureReGIS = C.GHOSTTY_DA_FEATURE_REGIS
DAFeatureSixel = C.GHOSTTY_DA_FEATURE_SIXEL
DAFeatureSelectiveErase = C.GHOSTTY_DA_FEATURE_SELECTIVE_ERASE
DAFeatureUserDefinedKeys = C.GHOSTTY_DA_FEATURE_USER_DEFINED_KEYS
DAFeatureNationalReplacement = C.GHOSTTY_DA_FEATURE_NATIONAL_REPLACEMENT
DAFeatureTechnicalCharacters = C.GHOSTTY_DA_FEATURE_TECHNICAL_CHARACTERS
DAFeatureLocator = C.GHOSTTY_DA_FEATURE_LOCATOR
DAFeatureTerminalState = C.GHOSTTY_DA_FEATURE_TERMINAL_STATE
DAFeatureWindowing = C.GHOSTTY_DA_FEATURE_WINDOWING
DAFeatureHorizontalScrolling = C.GHOSTTY_DA_FEATURE_HORIZONTAL_SCROLLING
DAFeatureANSIColor = C.GHOSTTY_DA_FEATURE_ANSI_COLOR
DAFeatureRectangularEditing = C.GHOSTTY_DA_FEATURE_RECTANGULAR_EDITING
DAFeatureANSITextLocator = C.GHOSTTY_DA_FEATURE_ANSI_TEXT_LOCATOR
DAFeatureClipboard = C.GHOSTTY_DA_FEATURE_CLIPBOARD
)
// DA2 device type identifiers (Pp parameter).
// C: GHOSTTY_DA_DEVICE_TYPE_*
const (
DADeviceTypeVT100 = C.GHOSTTY_DA_DEVICE_TYPE_VT100
DADeviceTypeVT220 = C.GHOSTTY_DA_DEVICE_TYPE_VT220
DADeviceTypeVT240 = C.GHOSTTY_DA_DEVICE_TYPE_VT240
DADeviceTypeVT330 = C.GHOSTTY_DA_DEVICE_TYPE_VT330
DADeviceTypeVT340 = C.GHOSTTY_DA_DEVICE_TYPE_VT340
DADeviceTypeVT320 = C.GHOSTTY_DA_DEVICE_TYPE_VT320
DADeviceTypeVT382 = C.GHOSTTY_DA_DEVICE_TYPE_VT382
DADeviceTypeVT420 = C.GHOSTTY_DA_DEVICE_TYPE_VT420
DADeviceTypeVT510 = C.GHOSTTY_DA_DEVICE_TYPE_VT510
DADeviceTypeVT520 = C.GHOSTTY_DA_DEVICE_TYPE_VT520
DADeviceTypeVT525 = C.GHOSTTY_DA_DEVICE_TYPE_VT525
)
// DeviceAttributes holds the response data for all three DA levels.
// The terminal fills whichever sub-struct matches the request type.
// C: GhosttyDeviceAttributes
type DeviceAttributes struct {
// Primary is the DA1 response data (CSI c).
Primary DeviceAttributesPrimary
// Secondary is the DA2 response data (CSI > c).
Secondary DeviceAttributesSecondary
// Tertiary is the DA3 response data (CSI = c).
Tertiary DeviceAttributesTertiary
}
// DeviceAttributesPrimary holds primary device attributes (DA1).
// C: GhosttyDeviceAttributesPrimary
type DeviceAttributesPrimary struct {
// ConformanceLevel is the Pp parameter. E.g. 62 for VT220.
ConformanceLevel uint16
// Features contains the DA1 feature codes (Ps parameters).
// Only the first NumFeatures entries are valid.
Features [64]uint16
// NumFeatures is the number of valid entries in Features.
NumFeatures int
}
// DeviceAttributesSecondary holds secondary device attributes (DA2).
// C: GhosttyDeviceAttributesSecondary
type DeviceAttributesSecondary struct {
// DeviceType is the terminal type identifier (Pp). E.g. 1 for VT220.
DeviceType uint16
// FirmwareVersion is the firmware/patch version number (Pv).
FirmwareVersion uint16
// ROMCartridge is the ROM cartridge registration number (Pc).
// Always 0 for emulators.
ROMCartridge uint16
}
// DeviceAttributesTertiary holds tertiary device attributes (DA3).
// C: GhosttyDeviceAttributesTertiary
type DeviceAttributesTertiary struct {
// UnitID is encoded as 8 uppercase hex digits in the response.
UnitID uint32
}