Skip to content

Commit 51d1fed

Browse files
author
Andrew Helsley
committed
Fill out cursor column tracking API.
1 parent ed11a8e commit 51d1fed

File tree

7 files changed

+19
-0
lines changed

7 files changed

+19
-0
lines changed

iTerm2XCTests/VT100GridTest.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ - (screen_char_t)gridBackgroundColorCode {
5353
- (void)gridCursorDidChangeLine {
5454
}
5555

56+
- (void)gridCursorDidChangeCol {
57+
}
58+
5659
- (iTermUnicodeNormalization)gridUnicodeNormalizationForm {
5760
return iTermUnicodeNormalizationNone;
5861
}

sources/PTYSession.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8313,6 +8313,7 @@ - (void)screenDidReset {
83138313
inProfile:_profile];
83148314
[_textview setNeedsDisplay:YES];
83158315
_screen.trackCursorLineMovement = NO;
8316+
_screen.trackCursorColMovement = NO;
83168317
}
83178318

83188319
- (void)screenDidAppendStringToCurrentLine:(NSString *)string {

sources/VT100Grid.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
- (iTermUnicodeNormalization)gridUnicodeNormalizationForm;
2222
- (void)gridCursorDidMove;
2323
- (void)gridCursorDidChangeLine;
24+
- (void)gridCursorDidChangeCol;
2425
@end
2526

2627
@interface VT100Grid : NSObject<NSCopying>

sources/VT100Grid.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ - (void)setCursorX:(int)cursorX {
183183
int newX = MIN(size_.width, MAX(0, cursorX));
184184
if (newX != cursor_.x) {
185185
cursor_.x = newX;
186+
[delegate_ gridCursorDidChangeCol];
186187
[delegate_ gridCursorDidMove];
187188
}
188189
}

sources/VT100Screen.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ extern int kVT100ScreenMinRows;
5858
@property(nonatomic, assign) BOOL saveToScrollbackInAlternateScreen;
5959
@property(nonatomic, retain) DVR *dvr;
6060
@property(nonatomic, assign) BOOL trackCursorLineMovement;
61+
@property(nonatomic, assign) BOOL trackCursorColMovement;
6162
@property(nonatomic, assign) BOOL appendToScrollbackWithStatusBar;
6263
@property(nonatomic, readonly) VT100GridAbsCoordRange lastCommandOutputRange;
6364
@property(nonatomic, assign) iTermUnicodeNormalization normalization;

sources/VT100Screen.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
NSString *const kScreenStateNextCommandOutputStartKey = @"Output Start";
5353
NSString *const kScreenStateCursorVisibleKey = @"Cursor Visible";
5454
NSString *const kScreenStateTrackCursorLineMovementKey = @"Track Cursor Line";
55+
NSString *const kScreenStateTrackCursorColMovementKey = @"Track Cursor Col";
5556
NSString *const kScreenStateLastCommandOutputRangeKey = @"Last Command Output Range";
5657
NSString *const kScreenStateShellIntegrationInstalledKey = @"Shell Integration Installed";
5758
NSString *const kScreenStateLastCommandMarkKey = @"Last Command Mark";
@@ -5307,6 +5308,12 @@ - (void)gridCursorDidChangeLine {
53075308
}
53085309
}
53095310

5311+
- (void)gridCursorDidChangeCol {
5312+
if (_trackCursorColMovement) {
5313+
[delegate_ screenCursorDidMoveToCol:currentGrid_.cursorX];
5314+
}
5315+
}
5316+
53105317
- (iTermUnicodeNormalization)gridUnicodeNormalizationForm {
53115318
return _normalization;
53125319
}
@@ -5364,6 +5371,7 @@ - (NSDictionary *)contentsDictionary {
53645371
kScreenStateNextCommandOutputStartKey: [NSDictionary dictionaryWithGridAbsCoord:_startOfRunningCommandOutput],
53655372
kScreenStateCursorVisibleKey: @(_cursorVisible),
53665373
kScreenStateTrackCursorLineMovementKey: @(_trackCursorLineMovement),
5374+
kScreenStateTrackCursorColMovementKey: @(_trackCursorColMovement),
53675375
kScreenStateLastCommandOutputRangeKey: [NSDictionary dictionaryWithGridAbsCoordRange:_lastCommandOutputRange],
53685376
kScreenStateShellIntegrationInstalledKey: @(_shellIntegrationInstalled),
53695377
kScreenStateLastCommandMarkKey: _lastCommandMark.guid ?: [NSNull null],
@@ -5478,6 +5486,7 @@ - (void)restoreFromDictionary:(NSDictionary *)dictionary
54785486
_startOfRunningCommandOutput = [screenState[kScreenStateNextCommandOutputStartKey] gridAbsCoord];
54795487
_cursorVisible = [screenState[kScreenStateCursorVisibleKey] boolValue];
54805488
_trackCursorLineMovement = [screenState[kScreenStateTrackCursorLineMovementKey] boolValue];
5489+
_trackCursorColMovement = [screenState[kScreenStateTrackCursorColMovementKey] boolValue];
54815490
_lastCommandOutputRange = [screenState[kScreenStateLastCommandOutputRangeKey] gridAbsCoordRange];
54825491
_shellIntegrationInstalled = [screenState[kScreenStateShellIntegrationInstalledKey] boolValue];
54835492

sources/VT100ScreenDelegate.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@
190190
// Only called if the trackCursorLineMovement property is set.
191191
- (void)screenCursorDidMoveToLine:(int)line;
192192

193+
// Only called if the trackCursorColMovement property is set.
194+
- (void)screenCursorDidMoveToCol:(int)col;
195+
193196
// Returns if there is a view.
194197
- (BOOL)screenHasView;
195198

0 commit comments

Comments
 (0)