Skip to content

Commit 6827cb3

Browse files
author
Andrew Helsley
committed
Separate control of the vertical cursor guide from the horizontal guide.
1 parent 68e3d2e commit 6827cb3

23 files changed

+112
-5
lines changed

Interfaces/MainMenu.xib

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,12 @@ Gw
668668
<action selector="toggleCursorGuide:" target="-1" id="Vxk-ww-Ugb"/>
669669
</connections>
670670
</menuItem>
671+
<menuItem title="Show Vertical Cursor Guide" identifier="Show Vertical Cursor Guide" id="pPk-Wb-7b8">
672+
<modifierMask key="keyEquivalentModifierMask"/>
673+
<connections>
674+
<action selector="toggleVCursorGuide:" target="-1" id="9p8-5y-S8s"/>
675+
</connections>
676+
</menuItem>
671677
<menuItem title="Show Timestamps" keyEquivalent="E" identifier="Show Timestamps" id="TnF-kz-Lf0">
672678
<connections>
673679
<action selector="toggleShowTimestamps:" target="-1" id="oGg-h2-Ex7"/>

Interfaces/PreferencePanel.xib

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,6 +1545,7 @@ DQ
15451545
<outlet property="_useSmartCursorColor" destination="4889" id="GhQ-EU-ndl"/>
15461546
<outlet property="_useTabColor" destination="j7F-r8-oes" id="HoY-6m-E99"/>
15471547
<outlet property="_useUnderlineColor" destination="Cqf-RZ-UnO" id="HoY-6m-xxx"/>
1548+
<outlet property="_useVGuide" destination="CDY-GW-Oi5" id="31z-FX-BPt"/>
15481549
<outlet property="delegate" destination="HVI-63-mNz" id="NFg-pP-EcM"/>
15491550
<outlet property="view" destination="SCN-fS-hNB" id="yvb-17-eJa"/>
15501551
</connections>
@@ -2272,7 +2273,7 @@ DQ
22722273
</textFieldCell>
22732274
</textField>
22742275
<customView id="Yny-j0-8Wk" customClass="CPKColorWell">
2275-
<rect key="frame" x="304" y="73" width="32" height="21"/>
2276+
<rect key="frame" x="304" y="84" width="32" height="21"/>
22762277
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
22772278
<userDefinedRuntimeAttributes>
22782279
<userDefinedRuntimeAttribute type="boolean" keyPath="alphaAllowed" value="YES"/>
@@ -2323,7 +2324,7 @@ DQ
23232324
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
23242325
</customView>
23252326
<button id="Rpk-o3-4ec">
2326-
<rect key="frame" x="193" y="74" width="105" height="18"/>
2327+
<rect key="frame" x="173" y="85" width="105" height="18"/>
23272328
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
23282329
<buttonCell key="cell" type="check" title="Cursor guide" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="Ai2-im-FjJ">
23292330
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
@@ -2334,6 +2335,18 @@ DQ
23342335
<outlet property="nextKeyView" destination="4896" id="kw5-A8-LVc"/>
23352336
</connections>
23362337
</button>
2338+
<button id="CDY-GW-Oi5" userLabel="Use Vertical Guide">
2339+
<rect key="frame" x="173" y="65" width="148" height="18"/>
2340+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
2341+
<buttonCell key="cell" type="check" title="Vertical cursor guide" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="2Co-vY-kv7">
2342+
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
2343+
<font key="font" metaFont="system"/>
2344+
</buttonCell>
2345+
<connections>
2346+
<action selector="settingChanged:" target="p8i-eM-oBc" id="T94-1y-jPl"/>
2347+
<outlet property="nextKeyView" destination="4896" id="H8S-V8-cYY"/>
2348+
</connections>
2349+
</button>
23372350
<customView id="2286" customClass="CPKColorWell">
23382351
<rect key="frame" x="442" y="211" width="32" height="21"/>
23392352
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>

iTerm2XCTests/VT100ScreenTest.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,12 @@ - (void)screenSetHighlightCursorLine:(BOOL)highlight {
748748
- (void)screenCursorDidMoveToLine:(int)line {
749749
}
750750

751+
- (void)screenSetHighlightCursorCol:(BOOL)highlight {
752+
}
753+
754+
- (void)screenCursorDidMoveToCol:(int)line {
755+
}
756+
751757
- (void)screenSaveScrollPosition {
752758
}
753759

sources/ITAddressBookMgr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
#define KEY_USE_UNDERLINE_COLOR @"Use Underline Color"
115115
#define KEY_CURSOR_BOOST @"Cursor Boost"
116116
#define KEY_USE_CURSOR_GUIDE @"Use Cursor Guide"
117+
#define KEY_USE_VERT_CURSOR_GUIDE @"Use Vertical Cursor Guide"
117118
#define KEY_CURSOR_GUIDE_COLOR @"Cursor Guide Color"
118119
#define KEY_BADGE_COLOR @"Badge Color"
119120

sources/Metal/Renderers/iTermCursorGuideRenderer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
1212
@interface iTermCursorGuideRenderer : NSObject<iTermMetalCellRenderer>
1313

1414
@property (nonatomic) BOOL enabled;
15+
@property (nonatomic) BOOL venabled;
1516

1617
- (nullable instancetype)initWithDevice:(id<MTLDevice>)device NS_DESIGNATED_INITIALIZER;
1718
- (instancetype)init NS_UNAVAILABLE;

sources/Metal/Renderers/iTermCursorGuideRenderer.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ - (void)drawWithFrameData:(iTermMetalFrameData *)frameData
141141
textures:@{ @(iTermTextureIndexPrimary): tState.texture } ];
142142
}
143143

144-
if (tState.col >= 0 && self.enabled) {
144+
if (tState.col >= 0 && self.venabled) {
145145
[_cellRenderer drawWithTransientState:tState
146146
renderEncoder:frameData.renderEncoder
147147
numberOfVertices:6

sources/Metal/iTermMetalDriver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ NS_CLASS_AVAILABLE(10_11, NA)
6161
@property (nonatomic, readonly) BOOL showBroadcastStripes;
6262
@property (nonatomic, readonly) NSColor *cursorGuideColor;
6363
@property (nonatomic, readonly) BOOL cursorGuideEnabled;
64+
@property (nonatomic, readonly) BOOL cursorVGuideEnabled;
6465
@property (nonatomic, readonly) vector_float4 fullScreenFlashColor;
6566
@property (nonatomic, readonly) BOOL timestampsEnabled;
6667
@property (nonatomic, readonly) NSColor *timestampsBackgroundColor;

sources/Metal/iTermMetalDriver.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,8 @@ - (BOOL)shouldCreateIntermediateRenderPassDescriptor:(iTermMetalFrameData *)fram
644644
if (!_broadcastStripesRenderer.rendererDisabled && frameData.perFrameState.showBroadcastStripes) {
645645
return YES;
646646
}
647-
if (!_cursorGuideRenderer.rendererDisabled && frameData.perFrameState.cursorGuideEnabled) {
647+
if (!_cursorGuideRenderer.rendererDisabled && (frameData.perFrameState.cursorGuideEnabled
648+
|| frameData.perFrameState.cursorVGuideEnabled)) {
648649
return YES;
649650
}
650651

@@ -970,6 +971,7 @@ - (void)updateCursorGuideRendererForFrameData:(iTermMetalFrameData *)frameData {
970971
}
971972
[_cursorGuideRenderer setColor:frameData.perFrameState.cursorGuideColor];
972973
_cursorGuideRenderer.enabled = frameData.perFrameState.cursorGuideEnabled;
974+
_cursorGuideRenderer.venabled = frameData.perFrameState.cursorVGuideEnabled;
973975
}
974976

975977
- (void)updateTimestampsRendererForFrameData:(iTermMetalFrameData *)frameData {

sources/PTYSession.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@ typedef enum {
422422
@property(nonatomic, readonly) BOOL hasSelection;
423423

424424
@property(nonatomic, assign) BOOL highlightCursorLine;
425+
@property(nonatomic, assign) BOOL highlightCursorCol;
425426

426427
// Used to help remember total ordering on views while one is maximized
427428
@property(nonatomic, assign) NSPoint savedRootRelativeOrigin;

sources/PTYSession.m

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@
205205
static NSString *const SESSION_ARRANGEMENT_DIRECTORIES = @"Directories"; // Array of strings
206206
static NSString *const SESSION_ARRANGEMENT_HOSTS = @"Hosts"; // Array of VT100RemoteHost
207207
static NSString *const SESSION_ARRANGEMENT_CURSOR_GUIDE = @"Cursor Guide"; // BOOL
208+
static NSString *const SESSION_ARRANGEMENT_VCURSOR_GUIDE = @"Vertical Cursor Guide"; // BOOL
208209
static NSString *const SESSION_ARRANGEMENT_LAST_DIRECTORY = @"Last Directory"; // NSString
209210
static NSString *const SESSION_ARRANGEMENT_LAST_DIRECTORY_IS_UNSUITABLE_FOR_OLD_PWD = @"Last Directory Is Remote"; // BOOL
210211
static NSString *const SESSION_ARRANGEMENT_SELECTION = @"Selection"; // Dictionary for iTermSelection.
@@ -1175,6 +1176,9 @@ + (void)finishInitializingArrangementOriginatedSession:(PTYSession *)aSession
11751176
if (arrangement[SESSION_ARRANGEMENT_CURSOR_GUIDE]) {
11761177
aSession.textview.highlightCursorLine = [arrangement[SESSION_ARRANGEMENT_CURSOR_GUIDE] boolValue];
11771178
}
1179+
if (arrangement[SESSION_ARRANGEMENT_VCURSOR_GUIDE]) {
1180+
aSession.textview.highlightCursorLine = [arrangement[SESSION_ARRANGEMENT_VCURSOR_GUIDE] boolValue];
1181+
}
11781182
aSession->_lastMark = [aSession.screen.lastMark retain];
11791183
aSession.lastRemoteHost = aSession.screen.lastRemoteHost;
11801184
if (arrangement[SESSION_ARRANGEMENT_LAST_DIRECTORY]) {
@@ -3463,6 +3467,8 @@ - (void)loadInitialColorTable
34633467
}
34643468
_textview.highlightCursorLine = [iTermProfilePreferences boolForKey:KEY_USE_CURSOR_GUIDE
34653469
inProfile:_profile];
3470+
_textview.highlightCursorCol = [iTermProfilePreferences boolForKey:KEY_USE_VERT_CURSOR_GUIDE
3471+
inProfile:_profile];
34663472
}
34673473

34683474
- (NSColor *)tabColorInProfile:(NSDictionary *)profile
@@ -3645,6 +3651,8 @@ - (void)setPreferencesFromAddressBookEntry:(NSDictionary *)aePrefs {
36453651
if (!_cursorGuideSettingHasChanged) {
36463652
_textview.highlightCursorLine = [iTermProfilePreferences boolForKey:KEY_USE_CURSOR_GUIDE
36473653
inProfile:aDict];
3654+
_textview.highlightCursorCol = [iTermProfilePreferences boolForKey:KEY_USE_VERT_CURSOR_GUIDE
3655+
inProfile:aDict];
36483656
}
36493657

36503658
for (i = 0; i < 16; i++) {
@@ -4371,6 +4379,7 @@ - (NSDictionary *)arrangementWithContents:(BOOL)includeContents {
43714379
[NSDictionary dictionaryWithGridCoordRange:range];
43724380
result[SESSION_ARRANGEMENT_ALERT_ON_NEXT_MARK] = @(_alertOnNextMark);
43734381
result[SESSION_ARRANGEMENT_CURSOR_GUIDE] = @(_textview.highlightCursorLine);
4382+
result[SESSION_ARRANGEMENT_VCURSOR_GUIDE] = @(_textview.highlightCursorCol);
43744383
if (self.lastDirectory) {
43754384
result[SESSION_ARRANGEMENT_LAST_DIRECTORY] = self.lastDirectory;
43764385
result[SESSION_ARRANGEMENT_LAST_DIRECTORY_IS_UNSUITABLE_FOR_OLD_PWD] = @(self.lastDirectoryIsUnsuitableForOldPWD);
@@ -8298,6 +8307,8 @@ - (void)screenDidReset {
82988307
_cursorGuideSettingHasChanged = NO;
82998308
_textview.highlightCursorLine = [iTermProfilePreferences boolForKey:KEY_USE_CURSOR_GUIDE
83008309
inProfile:_profile];
8310+
_textview.highlightCursorCol = [iTermProfilePreferences boolForKey:KEY_USE_VERT_CURSOR_GUIDE
8311+
inProfile:_profile];
83018312
[_textview setNeedsDisplay:YES];
83028313
_screen.trackCursorLineMovement = NO;
83038314
}
@@ -8570,6 +8581,28 @@ - (BOOL)highlightCursorLine {
85708581
return _textview.highlightCursorLine;
85718582
}
85728583

8584+
- (void)screenCursorDidMoveToCol:(int)col {
8585+
if (_textview.cursorVisible) {
8586+
[_textview setNeedsDisplayOnCol:col];
8587+
}
8588+
}
8589+
8590+
- (void)screenSetHighlightCursorCol:(BOOL)highlight {
8591+
_cursorGuideSettingHasChanged = YES;
8592+
self.highlightCursorCol = highlight;
8593+
}
8594+
8595+
- (void)setHighlightCursorCol:(BOOL)highlight {
8596+
_cursorGuideSettingHasChanged = YES;
8597+
_textview.highlightCursorCol = highlight;
8598+
[_textview setNeedsDisplay:YES];
8599+
_screen.trackCursorColMovement = highlight;
8600+
}
8601+
8602+
- (BOOL)highlightCursorCol {
8603+
return _textview.highlightCursorCol;
8604+
}
8605+
85738606
- (BOOL)screenHasView {
85748607
return _textview != nil;
85758608
}

0 commit comments

Comments
 (0)