Skip to content

Commit e429903

Browse files
committed
Add support for DECBI
1 parent 8954cd7 commit e429903

File tree

10 files changed

+58
-1
lines changed

10 files changed

+58
-1
lines changed

sources/VT100Grid.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
// Scroll the scroll region down by one line.
147147
- (void)scrollDown;
148148
- (void)moveContentLeft;
149+
- (void)moveContentRight;
149150

150151
// Clear scroll region, clear screen, move cursor and saved cursor to origin, leaving only the last
151152
// non-empty line at the top of the screen. Some lines may be left behind by giving a positive value

sources/VT100Grid.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,6 +1229,18 @@ - (void)moveContentLeft {
12291229
}
12301230
}
12311231

1232+
- (void)moveContentRight {
1233+
int x = 0;
1234+
if (self.useScrollRegionCols && self.cursorX >= self.leftMargin && self.cursorX <= self.rightMargin) {
1235+
// Cursor is within the scroll region so move the content within the scroll region.
1236+
x = self.leftMargin;
1237+
}
1238+
const screen_char_t c = [self defaultChar];
1239+
for (int i = self.topMargin; i <= self.bottomMargin; i++) {
1240+
[self insertChar:c externalAttributes:nil at:VT100GridCoordMake(x, i) times:1];
1241+
}
1242+
}
1243+
12321244
- (void)scrollRect:(VT100GridRect)rect downBy:(int)distance softBreak:(BOOL)softBreak {
12331245
DLog(@"scrollRect:%d,%d %dx%d downBy:%d",
12341246
rect.origin.x, rect.origin.y, rect.size.width, rect.size.height, distance);

sources/VT100OtherParser.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ + (void)decodeBytes:(unsigned char *)datap
126126
*rmlen = 2;
127127
break;
128128

129+
case '6':
130+
result->type = VT100_DECBI;
131+
*rmlen = 2;
132+
break;
133+
129134
case 'D':
130135
result->type = VT100CSI_IND;
131136
*rmlen = 2;

sources/VT100Screen.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3656,6 +3656,16 @@ - (void)terminalForwardIndex {
36563656
[delegate_ screenTriggerableChangeDidOccur];
36573657
}
36583658

3659+
- (void)terminalBackIndex {
3660+
if ((currentGrid_.cursorX == currentGrid_.leftMargin && ![self cursorOutsideLeftRightMargin] )||
3661+
currentGrid_.cursorX == 0) {
3662+
[currentGrid_ moveContentRight];
3663+
} else {
3664+
currentGrid_.cursorX -= 1;
3665+
}
3666+
[delegate_ screenTriggerableChangeDidOccur];
3667+
}
3668+
36593669
- (void)terminalResetPreservingPrompt:(BOOL)preservePrompt modifyContent:(BOOL)modifyContent {
36603670
if (modifyContent) {
36613671
const int linesToSave = [self numberOfLinesToPreserveWhenClearingScreen];

sources/VT100Terminal.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1938,6 +1938,10 @@ - (void)executeToken:(VT100Token *)token {
19381938
[self forwardIndex];
19391939
break;
19401940

1941+
case VT100_DECBI:
1942+
[self backIndex];
1943+
break;
1944+
19411945
case VT100CSI_PUSH_KEY_REPORTING_MODE:
19421946
[self pushKeyReportingFlags:token.csi->p[0]];
19431947
break;
@@ -3460,6 +3464,10 @@ - (void)forwardIndex {
34603464
[self.delegate terminalForwardIndex];
34613465
}
34623466

3467+
- (void)backIndex {
3468+
[self.delegate terminalBackIndex];
3469+
}
3470+
34633471
- (void)executeANSIRequestMode:(int)mode {
34643472
const iTermDECRPMSetting setting = [self settingForANSIRequestMode:mode];
34653473
[self.delegate terminalSendReport:[self decrpmForMode:mode setting:setting ansi:YES]];

sources/VT100TerminalDelegate.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@ typedef NS_ENUM(int, VT100TerminalColorIndex) {
120120
// Scroll up one line.
121121
- (void)terminalReverseIndex;
122122

123-
// Move cursor to the right one column, scrolling content left if at margin.
123+
// Move cursor to the right/left one column, scrolling content left/right if at margin.
124124
- (void)terminalForwardIndex;
125+
- (void)terminalBackIndex;
125126

126127
// Clear the screen, preserving the cursor's line.
127128
- (void)terminalResetPreservingPrompt:(BOOL)preservePrompt modifyContent:(BOOL)modifyContent;

sources/VT100Token.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ typedef enum {
120120
VT100CSI_DECRQM_DEC, // Request Mode - Host To Terminal (DEC Private)
121121
VT100CSI_DECRQM_ANSI, // Request Mode - Host To Terminal (ANSI)
122122
VT100_DECFI, // Forward Index
123+
VT100_DECBI, // Back Index
123124

124125
// https://sw.kovidgoyal.net/kitty/keyboard-protocol.html
125126
VT100CSI_PUSH_KEY_REPORTING_MODE,

sources/VT100Token.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ - (NSString *)codeName {
147147
@(VT100CSI_DECRQM_DEC): @"VT100CSI_DECRQM_DEC",
148148
@(VT100CSI_DECRQM_ANSI): @"VT100CSI_DECRQM_ANSI",
149149
@(VT100_DECFI): @"VT100_DECFI",
150+
@(VT100_DECBI): @"VT100_DECBI",
150151
@(VT100CSI_PUSH_KEY_REPORTING_MODE):@"VT100CSI_PUSH_KEY_REPORTING_MODE",
151152
@(VT100CSI_POP_KEY_REPORTING_MODE): @"VT100CSI_POP_KEY_REPORTING_MODE",
152153
@(VT100CSI_QUERY_KEY_REPORTING_MODE):@"VT100CSI_QUERY_KEY_REPORTING_MODE",

tests/decbi

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/tcsh
2+
echo -n 'hi[?69hNow is the time for all good men to come to the aid of their party.'
3+
4+
sleep 2
5+
while 1
6+
echo -n 6
7+
sleep 0.05
8+
end
9+

tests/decfi

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/tcsh
2+
echo -n 'hi[?69hNow is the time for all good men to come to the aid of their party.[?69l[?69h'
3+
4+
sleep 2
5+
while 1
6+
echo -n 9
7+
sleep 0.05
8+
end
9+

0 commit comments

Comments
 (0)