forked from greatyingzi/MTerminal-Jailed
-
Notifications
You must be signed in to change notification settings - Fork 1
/
VT100.h
132 lines (126 loc) · 3.44 KB
/
VT100.h
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
128
129
130
131
132
#import <UIKit/UIKit.h>
@class VT100;
typedef enum {
kVT100KeyTab='\t',
kVT100KeyEnter='\n',
kVT100KeyEsc=033,
kVT100KeyBackArrow=0x100,
kVT100KeyInsert,
kVT100KeyDelete,
kVT100KeyPageUp,
kVT100KeyPageDown,
kVT100KeyUpArrow,
kVT100KeyDownArrow,
kVT100KeyLeftArrow,
kVT100KeyRightArrow,
kVT100KeyHome,
kVT100KeyEnd,
} VT100Key;
typedef struct screen_char_t {
unichar c;
unsigned char bgcolor;
unsigned char fgcolor;
bool bgcolor_isset:1;
bool fgcolor_isset:1;
enum {
kFontWeightNormal,
kFontWeightBold,
kFontWeightFaint,
} weight:2;
bool italicize:1;
enum {
kUnderlineNone,
kUnderlineSingle,
kUnderlineDouble,
} underline:2;
bool blink:1;
bool inverse:1;
bool hidden:1;
bool strikethrough:1;
bool wrapped:1;
} screen_char_t;
typedef struct screen_line_t {
volatile _Atomic(int32_t) retain_count;
size_t size;// size of character buffer in bytes
screen_char_t buf[];// the actual characters
} screen_line_t;
@protocol VT100Delegate
-(BOOL)terminalShouldReportChanges:(VT100*)terminal;
-(void)terminal:(VT100*)terminal changed:(CFSetRef)changes deleted:(CFSetRef)deletions inserted:(CFSetRef)insertions bell:(BOOL)bell;
@end
@interface VT100 : NSObject {
// bit fields
bool bDECBKM:1,mDECBKM:1;
bool bDECCKM:1,mDECCKM:1;
bool bDECOM:1,mDECOM:1,swapDECOM:1;
bool bDECAWM:1,mDECAWM:1,swapDECAWM:1;
bool bDECTCEM:1,mDECTCEM:1;
bool bIRM:1;
bool bLNM:1;
bool bPastEOL:1;
bool bTrackChanges:1;
// sequence parser
enum {
kSequenceNone,
kSequenceESC,
kSequenceCSI,
kSequenceDEC,
kSequenceSCS,
kSequenceIgnore,
kSequencePossibleST,
kSequenceSkipNext,
} sequence;
enum {
kCSIModifierNone,
kCSIModifierQM,
kCSIModifierGT,
kCSIModifierEQ,
} CSIModifier;
unsigned int SCSIndex;
unsigned long CSIParam;
CFMutableArrayRef CSIParams;
CFMutableStringRef OSCString;
// screen settings
CFIndex currentIndex;
CFIndex cursorX,saveCursorX,swapCursorX;
CFIndex cursorY,saveCursorY,swapCursorY;
CFIndex windowTop,swapWindowTop;
CFIndex windowBottom,swapWindowBottom;
CFIndex screenWidth,swapScreenWidth;
CFIndex screenHeight,swapScreenHeight;
// graphical settings
screen_char_t nullChar,saveNullChar,swapNullChar;
unsigned char glCharset,saveGLCharset,swapGLCharset;
unsigned char charsets[4],saveCharsets[4],swapCharsets[4];
// multi-byte character encoding
unsigned char* encbuf;
CFIndex encbuf_size,encbuf_index;
// tab stops
bool* tabstops;
size_t tabstops_size;
// line buffers
CFMutableArrayRef lineBuffer;
CFArrayRef swapLineBuffer;
screen_line_t* currentLine;
// change tracking
CFMutableArrayRef indexMap;
CFMutableSetRef linesChanged;
CFIndex indexTop,prevCursorX,prevCursorY;
// pty process
int ptyfd;
}
@property(nonatomic,assign) id<VT100Delegate> delegate;
@property(nonatomic,assign) CFStringEncoding encoding;
@property(nonatomic,readonly) CFStringRef title;
@property(nonatomic,readonly) pid_t processID;
@property(nonatomic,readonly) BOOL bellDeferred;
@property(nonatomic, readonly) void ptyRead;
-(id)initWithWidth:(CFIndex)_screenWidth height:(CFIndex)_screenHeight;
-(CFIndex)numberOfLines;
-(screen_char_t*)charactersAtLineIndex:(CFIndex)index length:(CFIndex*)length cursorColumn:(CFIndex*)cursorColumn;
-(CFStringRef)copyProcessName;
-(BOOL)isRunning;
-(void)sendKey:(VT100Key)key;
-(void)sendString:(CFStringRef)string;
-(void)setWidth:(CFIndex)newWidth height:(CFIndex)newHeight;
@end