Skip to content
Snippets Groups Projects
Commit c3b0f97a authored by George Nachman's avatar George Nachman
Browse files

Make the copy mode cursor fatter when selecting.

Scroll to the copy mode cursor when entering copy mode if it's going straight into selecting mode.
parent 8a063160
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -795,6 +795,7 @@ ITERM_WEAKLY_REFERENCEABLE
_copyModeState.start = sub.range.coordRange.start;
_copyModeState.coord = sub.range.coordRange.end;
}
[_textview scrollLineNumberRangeIntoView:VT100GridRangeMake(_copyModeState.coord.y, 1)];
} else {
if (_textview.selection.live) {
[_textview.selection endLiveSelection];
Loading
Loading
@@ -1984,6 +1985,7 @@ ITERM_WEAKLY_REFERENCEABLE
}
 
- (void)handleKeyPressInCopyMode:(NSEvent *)event {
BOOL wasSelecting = _copyModeState.selecting;
NSString *string = event.charactersIgnoringModifiers;
unichar code = [string length] > 0 ? [string characterAtIndex:0] : 0;
NSUInteger mask = (NSAlternateKeyMask | NSControlKeyMask | NSCommandKeyMask);
Loading
Loading
@@ -2126,7 +2128,7 @@ ITERM_WEAKLY_REFERENCEABLE
break;
}
}
if (moved) {
if (moved || (_copyModeState.selecting != wasSelecting)) {
if (self.copyMode) {
[_textview scrollLineNumberRangeIntoView:VT100GridRangeMake(_copyModeState.coord.y, 1)];
}
Loading
Loading
@@ -6785,6 +6787,10 @@ ITERM_WEAKLY_REFERENCEABLE
return _copyMode;
}
 
- (BOOL)textViewCopyModeSelecting {
return _copyModeState.selecting;
}
- (VT100GridCoord)textViewCopyModeCursorCoord {
return _copyModeState.coord;
}
Loading
Loading
Loading
Loading
@@ -188,6 +188,7 @@ typedef NS_ENUM(NSInteger, PTYTextViewSelectionExtensionUnit) {
- (void)textViewShowHoverURL:(NSString *)url;
 
- (BOOL)textViewCopyMode;
- (BOOL)textViewCopyModeSelecting;
- (VT100GridCoord)textViewCopyModeCursorCoord;
- (void)textViewDidSelectRangeForFindOnPage:(VT100GridCoordRange)range;
 
Loading
Loading
Loading
Loading
@@ -1125,6 +1125,7 @@ static const int kDragThreshold = 3;
_drawingHelper.asciiLigatures = _primaryFont.hasDefaultLigatures || _asciiLigatures;
_drawingHelper.nonAsciiLigatures = _secondaryFont.hasDefaultLigatures || _nonAsciiLigatures;
_drawingHelper.copyMode = _delegate.textViewCopyMode;
_drawingHelper.copyModeSelecting = _delegate.textViewCopyModeSelecting;
_drawingHelper.copyModeCursorCoord = _delegate.textViewCopyModeCursorCoord;
 
const NSRect *rectArray;
Loading
Loading
Loading
Loading
@@ -38,7 +38,7 @@ typedef struct {
@property(nonatomic, assign) id<iTermCursorDelegate> delegate;
 
+ (iTermCursor *)cursorOfType:(ITermCursorType)theType;
+ (instancetype)copyModeCursor;
+ (instancetype)copyModeCursorInSelectionState:(BOOL)selecting;
 
// No default implementation.
- (void)drawWithRect:(NSRect)rect
Loading
Loading
Loading
Loading
@@ -21,6 +21,7 @@
@end
 
@interface iTermCopyModeCursor : iTermCursor
@property (nonatomic) BOOL selecting;
@end
 
@implementation iTermCursor
Loading
Loading
@@ -41,8 +42,10 @@
}
}
 
+ (instancetype)copyModeCursor {
return [[[iTermCopyModeCursor alloc] init] autorelease];
+ (instancetype)copyModeCursorInSelectionState:(BOOL)selecting {
iTermCopyModeCursor *cursor = [[[iTermCopyModeCursor alloc] init] autorelease];
cursor.selecting = selecting;
return cursor;
}
 
- (void)drawWithRect:(NSRect)rect
Loading
Loading
@@ -134,16 +137,21 @@
rect.size.width * 2,
rect.size.height * heightFraction);
 
const CGFloat r = self.selecting ? 2 : 1;
NSBezierPath *path = [[[NSBezierPath alloc] init] autorelease];
path = [[[NSBezierPath alloc] init] autorelease];
[path moveToPoint:NSMakePoint(NSMinX(cursorRect), NSMinY(cursorRect))];
[path lineToPoint:NSMakePoint(NSMidX(cursorRect) - 1, NSMaxY(cursorRect))];
[path lineToPoint:NSMakePoint(NSMidX(cursorRect) - 1, NSMaxY(rect))];
[path lineToPoint:NSMakePoint(NSMidX(cursorRect) + 1, NSMaxY(rect))];
[path lineToPoint:NSMakePoint(NSMidX(cursorRect) + 1, NSMaxY(cursorRect))];
[path lineToPoint:NSMakePoint(NSMidX(cursorRect) - r, NSMaxY(cursorRect))];
[path lineToPoint:NSMakePoint(NSMidX(cursorRect) - r, NSMaxY(rect))];
[path lineToPoint:NSMakePoint(NSMidX(cursorRect) + r, NSMaxY(rect))];
[path lineToPoint:NSMakePoint(NSMidX(cursorRect) + r, NSMaxY(cursorRect))];
[path lineToPoint:NSMakePoint(NSMaxX(cursorRect), NSMinY(cursorRect))];
[path lineToPoint:NSMakePoint(NSMinX(cursorRect), NSMinY(cursorRect))];
[[NSColor whiteColor] set];
if (self.selecting) {
[[NSColor colorWithRed:0xc1 / 255.0 green:0xde / 255.0 blue:0xff / 255.0 alpha:1] set];
} else {
[[NSColor whiteColor] set];
}
[path fill];
 
[[NSColor blackColor] set];
Loading
Loading
Loading
Loading
@@ -112,6 +112,7 @@
 
// Are we in copy mode?
@property(nonatomic, assign) BOOL copyMode;
@property(nonatomic, assign) BOOL copyModeSelecting;
 
// Location of the copy-mode cursor
@property(nonatomic, assign) VT100GridCoord copyModeCursorCoord;
Loading
Loading
Loading
Loading
@@ -2267,7 +2267,7 @@ static BOOL iTermTextDrawingHelperIsCharacterDrawable(screen_char_t *c,
}
 
- (void)drawCopyModeCursor {
iTermCursor *cursor = [iTermCursor copyModeCursor];
iTermCursor *cursor = [iTermCursor copyModeCursorInSelectionState:self.copyModeSelecting];
cursor.delegate = self;
 
[self reallyDrawCursor:cursor
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment