Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vertical Cursor Guide #383

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
68e3d2e
Render a vertical guide over the column the cursor is in (Metal View …
Mar 26, 2019
6827cb3
Separate control of the vertical cursor guide from the horizontal gu…
Mar 26, 2019
ed11a8e
Render a vertical cursor guide in the software rendered view (known i…
Mar 26, 2019
51d1fed
Fill out cursor column tracking API.
Mar 26, 2019
5b8119b
Fix names and style inconsistencies.
Apr 2, 2019
1b12bae
Rename a couple more "col" variables to use full names.
Apr 2, 2019
59f1be9
Fix bug with variable name type ("...Line" should be "...Column"). R…
Apr 2, 2019
683f718
Remove extraneous shared vertex buffer in favor of keeping more in th…
Apr 7, 2019
7af2a50
Remove bad boolean checks.
Apr 7, 2019
c8743a8
Use bounds from iTermCursorGuideRendererTransientState's cellConfigur…
Apr 7, 2019
1706bf1
Since [...textView setNeedsDisplayOnColumn...] is expensive (causes a…
Apr 7, 2019
933ed96
Factor out rectangle tessellation and vertex buffer creation.
Apr 7, 2019
7540e63
Do not double-draw the cursor guide under the cursor.
Apr 8, 2019
b7b9430
Render a vertical guide over the column the cursor is in (Metal View …
Mar 26, 2019
516e4bb
Separate control of the vertical cursor guide from the horizontal guide.
Mar 26, 2019
e99e660
Render a vertical cursor guide in the software rendered view.
Mar 26, 2019
139103b
Fill out cursor column tracking API.
Mar 26, 2019
025b02b
Fix bug with variable name type ("...Line" should be "...Column"). R…
Apr 2, 2019
921b5cf
Remove extraneous shared vertex buffer in favor of keeping more in th…
Apr 7, 2019
cd25d8c
Factor out rectangle tessellation and vertex buffer creation.
Apr 7, 2019
bdbe918
Use bounds from iTermCursorGuideRendererTransientState's cellConfigur…
Apr 7, 2019
48a48cc
Since [...textView setNeedsDisplayOnColumn...] is expensive (causes a…
Apr 7, 2019
262e707
Do not double-draw the cursor guide under the cursor.
Apr 8, 2019
64bf5c4
Fix style nits.
Apr 13, 2019
7c6142d
Fix rebase conflict.
Apr 13, 2019
a0bb3d5
Resolved conflicts with upstream branch.
Apr 13, 2019
1618e45
Remove merge/conflict resolution detritus.
Apr 13, 2019
7f4a4a4
Remove unused variable that seems to be causing CI build fails.
Apr 13, 2019
18c8e57
Add ability to render a vertical guide over the column the cursor is in.
Mar 26, 2019
c12ee73
Merged with upstream branch
Apr 18, 2019
66cf560
Remove code duplicated as a result of merge with upstream branch.
Apr 18, 2019
ed738eb
Disable code that references an undeclared identifier (brought in fro…
Apr 18, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Interfaces/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,12 @@ Gw
<action selector="toggleCursorGuide:" target="-1" id="Vxk-ww-Ugb"/>
</connections>
</menuItem>
<menuItem title="Show Vertical Cursor Guide" identifier="Show Vertical Cursor Guide" id="pPk-Wb-7b8">
ahelsley marked this conversation as resolved.
Show resolved Hide resolved
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleVCursorGuide:" target="-1" id="9p8-5y-S8s"/>
</connections>
</menuItem>
<menuItem title="Show Timestamps" keyEquivalent="E" identifier="Show Timestamps" id="TnF-kz-Lf0">
<connections>
<action selector="toggleShowTimestamps:" target="-1" id="oGg-h2-Ex7"/>
Expand Down
17 changes: 15 additions & 2 deletions Interfaces/PreferencePanel.xib
Original file line number Diff line number Diff line change
Expand Up @@ -1545,6 +1545,7 @@ DQ
<outlet property="_useSmartCursorColor" destination="4889" id="GhQ-EU-ndl"/>
<outlet property="_useTabColor" destination="j7F-r8-oes" id="HoY-6m-E99"/>
<outlet property="_useUnderlineColor" destination="Cqf-RZ-UnO" id="HoY-6m-xxx"/>
<outlet property="_useVGuide" destination="CDY-GW-Oi5" id="31z-FX-BPt"/>
<outlet property="delegate" destination="HVI-63-mNz" id="NFg-pP-EcM"/>
<outlet property="view" destination="SCN-fS-hNB" id="yvb-17-eJa"/>
</connections>
Expand Down Expand Up @@ -2272,7 +2273,7 @@ DQ
</textFieldCell>
</textField>
<customView id="Yny-j0-8Wk" customClass="CPKColorWell">
<rect key="frame" x="304" y="73" width="32" height="21"/>
<rect key="frame" x="304" y="84" width="32" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="boolean" keyPath="alphaAllowed" value="YES"/>
Expand Down Expand Up @@ -2323,7 +2324,7 @@ DQ
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
</customView>
<button id="Rpk-o3-4ec">
<rect key="frame" x="193" y="74" width="105" height="18"/>
<rect key="frame" x="173" y="85" width="105" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Cursor guide" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="Ai2-im-FjJ">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
Expand All @@ -2334,6 +2335,18 @@ DQ
<outlet property="nextKeyView" destination="4896" id="kw5-A8-LVc"/>
</connections>
</button>
<button id="CDY-GW-Oi5" userLabel="Use Vertical Guide">
<rect key="frame" x="173" y="65" width="148" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Vertical cursor guide" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="2Co-vY-kv7">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="settingChanged:" target="p8i-eM-oBc" id="T94-1y-jPl"/>
<outlet property="nextKeyView" destination="4896" id="H8S-V8-cYY"/>
</connections>
</button>
<customView id="2286" customClass="CPKColorWell">
<rect key="frame" x="442" y="211" width="32" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
Expand Down
15 changes: 15 additions & 0 deletions iTerm2XCTests/PTYTextViewTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,21 @@ - (void)testCursorGuide {
size:VT100GridSizeMake(5, 5)];
}

// Draws a cursor guide on the col with b.
- (void)testVCursorGuide {
[self doGoldenTestForInput:@"abcd\x1b[2A"
name:NSStringFromSelector(_cmd)
hook:^(PTYTextView *textView) {
textView.drawingHook = ^(iTermTextDrawingHelper *helper) {
helper.shouldDrawFilledInCursor = YES;
helper.highlightCursorCol = YES;
};
}
profileOverrides:nil
createGolden:YES
size:VT100GridSizeMake(5, 5)];
}

// Draws a badge which blends with nondefault background colors.
- (void)testBadge {
[self doGoldenTestForInput:@"\n\n\n\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\x1b[42mabc"
Expand Down
3 changes: 3 additions & 0 deletions iTerm2XCTests/VT100GridTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ - (screen_char_t)gridBackgroundColorCode {
- (void)gridCursorDidChangeLine {
}

- (void)gridCursorDidChangeCol {
ahelsley marked this conversation as resolved.
Show resolved Hide resolved
}

- (iTermUnicodeNormalization)gridUnicodeNormalizationForm {
return iTermUnicodeNormalizationNone;
}
Expand Down
6 changes: 6 additions & 0 deletions iTerm2XCTests/VT100ScreenTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,12 @@ - (void)screenSetHighlightCursorLine:(BOOL)highlight {
- (void)screenCursorDidMoveToLine:(int)line {
}

- (void)screenSetHighlightCursorCol:(BOOL)highlight {
}

- (void)screenCursorDidMoveToCol:(int)line {
}

- (void)screenSaveScrollPosition {
}

Expand Down
1 change: 1 addition & 0 deletions sources/ITAddressBookMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
#define KEY_USE_UNDERLINE_COLOR @"Use Underline Color"
#define KEY_CURSOR_BOOST @"Cursor Boost"
#define KEY_USE_CURSOR_GUIDE @"Use Cursor Guide"
#define KEY_USE_VERT_CURSOR_GUIDE @"Use Vertical Cursor Guide"
#define KEY_CURSOR_GUIDE_COLOR @"Cursor Guide Color"
#define KEY_BADGE_COLOR @"Badge Color"

Expand Down
1 change: 1 addition & 0 deletions sources/Metal/Infrastructure/iTermMetalRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ NS_CLASS_AVAILABLE(10_11, NA)
@interface iTermMetalRendererTransientState : NSObject
@property (nonatomic, strong, readonly) __kindof iTermRenderConfiguration *configuration;
@property (nonatomic, strong) id<MTLBuffer> vertexBuffer;
@property (nonatomic, strong) id<MTLBuffer> vvertexBuffer;
@property (nonatomic, readonly) iTermMetalBufferPoolContext *poolContext;
@property (nonatomic, weak) iTermMetalDebugInfo *debugInfo;
@property (nonatomic, strong) NSImage *renderedOutputForDebugging;
Expand Down
5 changes: 3 additions & 2 deletions sources/Metal/Renderers/iTermCursorGuideRenderer.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#import <Foundation/Foundation.h>

#import "iTermMetalCellRenderer.h"
#import "VT100GridTypes.h"

NS_ASSUME_NONNULL_BEGIN

@interface iTermCursorGuideRendererTransientState : iTermMetalCellRendererTransientState
// set to -1 if cursor's row is not currently visible.
- (void)setRow:(int)row;
- (void)setCursorCoord:(VT100GridCoord)coord within:(VT100GridSize)bounds;
ahelsley marked this conversation as resolved.
Show resolved Hide resolved
@end

@interface iTermCursorGuideRenderer : NSObject<iTermMetalCellRenderer>

@property (nonatomic) BOOL enabled;
@property (nonatomic) BOOL venabled;

- (nullable instancetype)initWithDevice:(id<MTLDevice>)device NS_DESIGNATED_INITIALIZER;
- (instancetype)init NS_UNAVAILABLE;
Expand Down
53 changes: 42 additions & 11 deletions sources/Metal/Renderers/iTermCursorGuideRenderer.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
@interface iTermCursorGuideRendererTransientState()
@property (nonatomic, strong) id<MTLTexture> texture;
@property (nonatomic) int row;
@property (nonatomic) int col;
@end

@implementation iTermCursorGuideRendererTransientState {
int _row;
int _col;
}

- (void)setRow:(int)row {
_row = row;
- (void)setCursorCoord:(VT100GridCoord)coord within:(VT100GridSize)bounds {
_row = (0 <= coord.y && coord.y < bounds.height) ? coord.y : -1;
_col = (0 <= coord.x && coord.x < bounds.width) ? coord.x : -1;
}

- (void)initializeVerticesWithPool:(iTermMetalBufferPool *)verticesPool {
Expand All @@ -35,6 +38,23 @@ - (void)initializeVerticesWithPool:(iTermMetalBufferPool *)verticesPool {
self.vertexBuffer = [verticesPool requestBufferFromContext:self.poolContext
withBytes:vertices
checkIfChanged:YES];

const CGRect vQuad = CGRectMake(self.margins.left + self.col * cellSize.width,
self.margins.top,
cellSize.width,
cellSize.height * gridSize.height);
const iTermVertex vvertices[] = {
{ { CGRectGetMaxX(vQuad), CGRectGetMinY(vQuad) }, { CGRectGetMaxX(textureFrame), CGRectGetMinY(textureFrame) } },
{ { CGRectGetMinX(vQuad), CGRectGetMinY(vQuad) }, { CGRectGetMinX(textureFrame), CGRectGetMinY(textureFrame) } },
{ { CGRectGetMinX(vQuad), CGRectGetMaxY(vQuad) }, { CGRectGetMinX(textureFrame), CGRectGetMaxY(textureFrame) } },

{ { CGRectGetMaxX(vQuad), CGRectGetMinY(vQuad) }, { CGRectGetMaxX(textureFrame), CGRectGetMinY(textureFrame) } },
{ { CGRectGetMinX(vQuad), CGRectGetMaxY(vQuad) }, { CGRectGetMinX(textureFrame), CGRectGetMaxY(textureFrame) } },
{ { CGRectGetMaxX(vQuad), CGRectGetMaxY(vQuad) }, { CGRectGetMaxX(textureFrame), CGRectGetMaxY(textureFrame) } },
};
self.vvertexBuffer = [verticesPool requestBufferFromContext:self.poolContext
withBytes:vvertices
checkIfChanged:YES];
}

- (void)writeDebugInfoToFolder:(NSURL *)folder {
Expand Down Expand Up @@ -106,19 +126,30 @@ - (void)setColor:(NSColor *)color {
- (void)drawWithFrameData:(iTermMetalFrameData *)frameData
transientState:(__kindof iTermMetalCellRendererTransientState *)transientState {
iTermCursorGuideRendererTransientState *tState = transientState;
if (tState.row < 0) {
// Cursor is offscreen. We set it to -1 to signal this.
if (tState.row < 0 || tState.col < 0) {
return;
}

[tState initializeVerticesWithPool:_cellRenderer.verticesPool];
[_cellRenderer drawWithTransientState:tState
renderEncoder:frameData.renderEncoder
numberOfVertices:6
numberOfPIUs:0
vertexBuffers:@{ @(iTermVertexInputIndexVertices): tState.vertexBuffer }
fragmentBuffers:@{}
textures:@{ @(iTermTextureIndexPrimary): tState.texture } ];
if (tState.row >= 0 && self.enabled) {
[_cellRenderer drawWithTransientState:tState
renderEncoder:frameData.renderEncoder
numberOfVertices:6
numberOfPIUs:0
vertexBuffers:@{ @(iTermVertexInputIndexVertices): tState.vertexBuffer }
fragmentBuffers:@{}
textures:@{ @(iTermTextureIndexPrimary): tState.texture } ];
}

if (tState.col >= 0 && self.venabled) {
[_cellRenderer drawWithTransientState:tState
renderEncoder:frameData.renderEncoder
numberOfVertices:6
numberOfPIUs:0
vertexBuffers:@{ @(iTermVertexInputIndexVertices): tState.vvertexBuffer }
fragmentBuffers:@{}
textures:@{ @(iTermTextureIndexPrimary): tState.texture } ];
ahelsley marked this conversation as resolved.
Show resolved Hide resolved
}
}

#pragma mark - Private
Expand Down
1 change: 1 addition & 0 deletions sources/Metal/iTermMetalDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ NS_CLASS_AVAILABLE(10_11, NA)
@property (nonatomic, readonly) BOOL showBroadcastStripes;
@property (nonatomic, readonly) NSColor *cursorGuideColor;
@property (nonatomic, readonly) BOOL cursorGuideEnabled;
@property (nonatomic, readonly) BOOL cursorVGuideEnabled;
@property (nonatomic, readonly) vector_float4 fullScreenFlashColor;
@property (nonatomic, readonly) BOOL timestampsEnabled;
@property (nonatomic, readonly) NSColor *timestampsBackgroundColor;
Expand Down
13 changes: 5 additions & 8 deletions sources/Metal/iTermMetalDriver.m
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,8 @@ - (BOOL)shouldCreateIntermediateRenderPassDescriptor:(iTermMetalFrameData *)fram
if (!_broadcastStripesRenderer.rendererDisabled && frameData.perFrameState.showBroadcastStripes) {
return YES;
}
if (!_cursorGuideRenderer.rendererDisabled && frameData.perFrameState.cursorGuideEnabled) {
if (!_cursorGuideRenderer.rendererDisabled && (frameData.perFrameState.cursorGuideEnabled
|| frameData.perFrameState.cursorVGuideEnabled)) {
ahelsley marked this conversation as resolved.
Show resolved Hide resolved
return YES;
}

Expand Down Expand Up @@ -970,6 +971,7 @@ - (void)updateCursorGuideRendererForFrameData:(iTermMetalFrameData *)frameData {
}
[_cursorGuideRenderer setColor:frameData.perFrameState.cursorGuideColor];
_cursorGuideRenderer.enabled = frameData.perFrameState.cursorGuideEnabled;
_cursorGuideRenderer.venabled = frameData.perFrameState.cursorVGuideEnabled;
ahelsley marked this conversation as resolved.
Show resolved Hide resolved
}

- (void)updateTimestampsRendererForFrameData:(iTermMetalFrameData *)frameData {
Expand Down Expand Up @@ -1219,13 +1221,8 @@ - (void)populateHighlightRowRendererTransientStateWithFrameData:(iTermMetalFrame

- (void)populateCursorGuideRendererTransientStateWithFrameData:(iTermMetalFrameData *)frameData {
iTermCursorGuideRendererTransientState *tState = [frameData transientStateForRenderer:_cursorGuideRenderer];
iTermMetalCursorInfo *cursorInfo = frameData.perFrameState.metalDriverCursorInfo;
if (cursorInfo.coord.y >= 0 &&
cursorInfo.coord.y < frameData.gridSize.height) {
[tState setRow:frameData.perFrameState.metalDriverCursorInfo.coord.y];
} else {
[tState setRow:-1];
}
VT100GridCoord coord = frameData.perFrameState.metalDriverCursorInfo.coord;
[tState setCursorCoord:coord within:frameData.gridSize];
}

- (void)populateTimestampsRendererTransientStateWithFrameData:(iTermMetalFrameData *)frameData {
Expand Down
1 change: 1 addition & 0 deletions sources/PTYSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ typedef enum {
@property(nonatomic, readonly) BOOL hasSelection;

@property(nonatomic, assign) BOOL highlightCursorLine;
@property(nonatomic, assign) BOOL highlightCursorCol;

// Used to help remember total ordering on views while one is maximized
@property(nonatomic, assign) NSPoint savedRootRelativeOrigin;
Expand Down
36 changes: 36 additions & 0 deletions sources/PTYSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
static NSString *const SESSION_ARRANGEMENT_DIRECTORIES = @"Directories"; // Array of strings
static NSString *const SESSION_ARRANGEMENT_HOSTS = @"Hosts"; // Array of VT100RemoteHost
static NSString *const SESSION_ARRANGEMENT_CURSOR_GUIDE = @"Cursor Guide"; // BOOL
static NSString *const SESSION_ARRANGEMENT_VCURSOR_GUIDE = @"Vertical Cursor Guide"; // BOOL
static NSString *const SESSION_ARRANGEMENT_LAST_DIRECTORY = @"Last Directory"; // NSString
static NSString *const SESSION_ARRANGEMENT_LAST_DIRECTORY_IS_UNSUITABLE_FOR_OLD_PWD = @"Last Directory Is Remote"; // BOOL
static NSString *const SESSION_ARRANGEMENT_SELECTION = @"Selection"; // Dictionary for iTermSelection.
Expand Down Expand Up @@ -1175,6 +1176,9 @@ + (void)finishInitializingArrangementOriginatedSession:(PTYSession *)aSession
if (arrangement[SESSION_ARRANGEMENT_CURSOR_GUIDE]) {
aSession.textview.highlightCursorLine = [arrangement[SESSION_ARRANGEMENT_CURSOR_GUIDE] boolValue];
}
if (arrangement[SESSION_ARRANGEMENT_VCURSOR_GUIDE]) {
aSession.textview.highlightCursorLine = [arrangement[SESSION_ARRANGEMENT_VCURSOR_GUIDE] boolValue];
ahelsley marked this conversation as resolved.
Show resolved Hide resolved
}
aSession->_lastMark = [aSession.screen.lastMark retain];
aSession.lastRemoteHost = aSession.screen.lastRemoteHost;
if (arrangement[SESSION_ARRANGEMENT_LAST_DIRECTORY]) {
Expand Down Expand Up @@ -2360,6 +2364,7 @@ - (void)writeTaskNoBroadcast:(NSString *)string

- (void)handleKeyPressInCopyMode:(NSEvent *)event {
[self.textview setNeedsDisplayOnLine:_copyModeState.coord.y];
[self.textview setNeedsDisplayOnCol:_copyModeState.coord.x];
ahelsley marked this conversation as resolved.
Show resolved Hide resolved
BOOL wasSelecting = _copyModeState.selecting;
NSString *string = event.charactersIgnoringModifiers;
unichar code = [string length] > 0 ? [string characterAtIndex:0] : 0;
Expand Down Expand Up @@ -2511,6 +2516,7 @@ - (void)handleKeyPressInCopyMode:(NSEvent *)event {
[_textview scrollLineNumberRangeIntoView:VT100GridRangeMake(_copyModeState.coord.y, 1)];
}
[self.textview setNeedsDisplayOnLine:_copyModeState.coord.y];
[self.textview setNeedsDisplayOnCol:_copyModeState.coord.x];
}
}

Expand Down Expand Up @@ -3463,6 +3469,8 @@ - (void)loadInitialColorTable
}
_textview.highlightCursorLine = [iTermProfilePreferences boolForKey:KEY_USE_CURSOR_GUIDE
inProfile:_profile];
_textview.highlightCursorCol = [iTermProfilePreferences boolForKey:KEY_USE_VERT_CURSOR_GUIDE
inProfile:_profile];
}

- (NSColor *)tabColorInProfile:(NSDictionary *)profile
Expand Down Expand Up @@ -3645,6 +3653,8 @@ - (void)setPreferencesFromAddressBookEntry:(NSDictionary *)aePrefs {
if (!_cursorGuideSettingHasChanged) {
_textview.highlightCursorLine = [iTermProfilePreferences boolForKey:KEY_USE_CURSOR_GUIDE
inProfile:aDict];
_textview.highlightCursorCol = [iTermProfilePreferences boolForKey:KEY_USE_VERT_CURSOR_GUIDE
inProfile:aDict];
}

for (i = 0; i < 16; i++) {
Expand Down Expand Up @@ -4371,6 +4381,7 @@ - (NSDictionary *)arrangementWithContents:(BOOL)includeContents {
[NSDictionary dictionaryWithGridCoordRange:range];
result[SESSION_ARRANGEMENT_ALERT_ON_NEXT_MARK] = @(_alertOnNextMark);
result[SESSION_ARRANGEMENT_CURSOR_GUIDE] = @(_textview.highlightCursorLine);
result[SESSION_ARRANGEMENT_VCURSOR_GUIDE] = @(_textview.highlightCursorCol);
if (self.lastDirectory) {
result[SESSION_ARRANGEMENT_LAST_DIRECTORY] = self.lastDirectory;
result[SESSION_ARRANGEMENT_LAST_DIRECTORY_IS_UNSUITABLE_FOR_OLD_PWD] = @(self.lastDirectoryIsUnsuitableForOldPWD);
Expand Down Expand Up @@ -8298,8 +8309,11 @@ - (void)screenDidReset {
_cursorGuideSettingHasChanged = NO;
_textview.highlightCursorLine = [iTermProfilePreferences boolForKey:KEY_USE_CURSOR_GUIDE
inProfile:_profile];
_textview.highlightCursorCol = [iTermProfilePreferences boolForKey:KEY_USE_VERT_CURSOR_GUIDE
inProfile:_profile];
[_textview setNeedsDisplay:YES];
_screen.trackCursorLineMovement = NO;
_screen.trackCursorColMovement = NO;
}

- (void)screenDidAppendStringToCurrentLine:(NSString *)string {
Expand Down Expand Up @@ -8570,6 +8584,28 @@ - (BOOL)highlightCursorLine {
return _textview.highlightCursorLine;
}

- (void)screenCursorDidMoveToCol:(int)col {
if (_textview.cursorVisible) {
ahelsley marked this conversation as resolved.
Show resolved Hide resolved
[_textview setNeedsDisplayOnCol:col];
}
}

- (void)screenSetHighlightCursorCol:(BOOL)highlight {
_cursorGuideSettingHasChanged = YES;
self.highlightCursorCol = highlight;
}

- (void)setHighlightCursorCol:(BOOL)highlight {
_cursorGuideSettingHasChanged = YES;
_textview.highlightCursorCol = highlight;
[_textview setNeedsDisplay:YES];
_screen.trackCursorColMovement = highlight;
}

- (BOOL)highlightCursorCol {
return _textview.highlightCursorCol;
}

- (BOOL)screenHasView {
return _textview != nil;
}
Expand Down
4 changes: 4 additions & 0 deletions sources/PTYTextView.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ typedef NS_ENUM(NSInteger, PTYTextViewSelectionExtensionUnit) {
// Draw a highlight along the entire line the cursor is on.
@property(nonatomic, assign) BOOL highlightCursorLine;

// Draw a highlight along the entire column the cursor is in.
@property(nonatomic, assign) BOOL highlightCursorCol;

// Use the non-ascii font? If not set, use the regular font for all characters.
@property(nonatomic, assign) BOOL useNonAsciiFont;

Expand Down Expand Up @@ -461,6 +464,7 @@ typedef void (^PTYTextViewDrawingHookBlock)(iTermTextDrawingHelper *);
// onscreen is blinking.
- (BOOL)refresh;
- (void)setNeedsDisplayOnLine:(int)line;
- (void)setNeedsDisplayOnCol:(int)col;

// selection
- (IBAction)selectAll:(id)sender;
Expand Down
Loading