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

Add a man page toolbar button. Still needs a nice icon

parent 355be732
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -1543,6 +1543,12 @@
A68A3119186E2F54007F550F /* PopupModel.h in Headers */ = {isa = PBXBuildFile; fileRef = A68A3117186E2F54007F550F /* PopupModel.h */; };
A68E332B1DE6AFC6003F1D8E /* iTermTouchBarButton.h in Headers */ = {isa = PBXBuildFile; fileRef = A68E33291DE6AFC6003F1D8E /* iTermTouchBarButton.h */; };
A68E332C1DE6AFC6003F1D8E /* iTermTouchBarButton.m in Sources */ = {isa = PBXBuildFile; fileRef = A68E332A1DE6AFC6003F1D8E /* iTermTouchBarButton.m */; };
A68E33331DE746F5003F1D8E /* Add Mark Touch Bar Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = A68E332D1DE746F5003F1D8E /* Add Mark Touch Bar Icon.png */; };
A68E33341DE746F5003F1D8E /* Add Mark Touch Bar Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A68E332E1DE746F5003F1D8E /* Add Mark Touch Bar Icon@2x.png */; };
A68E33351DE746F5003F1D8E /* Next Mark Touch Bar Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = A68E332F1DE746F5003F1D8E /* Next Mark Touch Bar Icon.png */; };
A68E33361DE746F5003F1D8E /* Next Mark Touch Bar Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A68E33301DE746F5003F1D8E /* Next Mark Touch Bar Icon@2x.png */; };
A68E33371DE746F5003F1D8E /* Previous Mark Touch Bar Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = A68E33311DE746F5003F1D8E /* Previous Mark Touch Bar Icon.png */; };
A68E33381DE746F5003F1D8E /* Previous Mark Touch Bar Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A68E33321DE746F5003F1D8E /* Previous Mark Touch Bar Icon@2x.png */; };
A690F7011B424C55009F76D8 /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A690F7001B424C55009F76D8 /* Media.xcassets */; };
A690F7021B424C55009F76D8 /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A690F7001B424C55009F76D8 /* Media.xcassets */; };
A690F7031B424C55009F76D8 /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A690F7001B424C55009F76D8 /* Media.xcassets */; };
Loading
Loading
@@ -3276,6 +3282,12 @@
A68A3118186E2F54007F550F /* PopupModel.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = PopupModel.m; sourceTree = "<group>"; tabWidth = 4; };
A68E33291DE6AFC6003F1D8E /* iTermTouchBarButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iTermTouchBarButton.h; sourceTree = "<group>"; };
A68E332A1DE6AFC6003F1D8E /* iTermTouchBarButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = iTermTouchBarButton.m; sourceTree = "<group>"; };
A68E332D1DE746F5003F1D8E /* Add Mark Touch Bar Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Add Mark Touch Bar Icon.png"; path = "images/Add Mark Touch Bar Icon.png"; sourceTree = "<group>"; };
A68E332E1DE746F5003F1D8E /* Add Mark Touch Bar Icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Add Mark Touch Bar Icon@2x.png"; path = "images/Add Mark Touch Bar Icon@2x.png"; sourceTree = "<group>"; };
A68E332F1DE746F5003F1D8E /* Next Mark Touch Bar Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Next Mark Touch Bar Icon.png"; path = "images/Next Mark Touch Bar Icon.png"; sourceTree = "<group>"; };
A68E33301DE746F5003F1D8E /* Next Mark Touch Bar Icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Next Mark Touch Bar Icon@2x.png"; path = "images/Next Mark Touch Bar Icon@2x.png"; sourceTree = "<group>"; };
A68E33311DE746F5003F1D8E /* Previous Mark Touch Bar Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Previous Mark Touch Bar Icon.png"; path = "images/Previous Mark Touch Bar Icon.png"; sourceTree = "<group>"; };
A68E33321DE746F5003F1D8E /* Previous Mark Touch Bar Icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Previous Mark Touch Bar Icon@2x.png"; path = "images/Previous Mark Touch Bar Icon@2x.png"; sourceTree = "<group>"; };
A690F7001B424C55009F76D8 /* Media.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Media.xcassets; sourceTree = "<group>"; };
A693395A1851A61D00EBEA20 /* VT100ScreenMark.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = VT100ScreenMark.h; sourceTree = "<group>"; tabWidth = 4; };
A693395B1851A61D00EBEA20 /* VT100ScreenMark.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = VT100ScreenMark.m; sourceTree = "<group>"; tabWidth = 4; };
Loading
Loading
@@ -4199,6 +4211,12 @@
1D093C131217412B0029F9AD /* Images */ = {
isa = PBXGroup;
children = (
A68E332D1DE746F5003F1D8E /* Add Mark Touch Bar Icon.png */,
A68E332E1DE746F5003F1D8E /* Add Mark Touch Bar Icon@2x.png */,
A68E332F1DE746F5003F1D8E /* Next Mark Touch Bar Icon.png */,
A68E33301DE746F5003F1D8E /* Next Mark Touch Bar Icon@2x.png */,
A68E33311DE746F5003F1D8E /* Previous Mark Touch Bar Icon.png */,
A68E33321DE746F5003F1D8E /* Previous Mark Touch Bar Icon@2x.png */,
A69A15711D7FD78200A9E7EF /* TipCalendar.png */,
A69A15721D7FD78200A9E7EF /* TipCalendar@2x.png */,
A6339DD91D232DF2000BAD78 /* StatusItemAlt.png */,
Loading
Loading
@@ -6978,6 +6996,7 @@
A67D0D531A2EE12A003A8B35 /* GlobalSearch.xib in Resources */,
A67D0D8F1A2EE12A003A8B35 /* TmuxDashboard.xib in Resources */,
A66DB8331C8E4C2E00233E88 /* ChangeProfile@2x.png in Resources */,
A68E33381DE746F5003F1D8E /* Previous Mark Touch Bar Icon@2x.png in Resources */,
A67D0D351A2EE12A003A8B35 /* AddressBook.strings in Resources */,
A6EFF2311D2049A300806EEF /* Erase.png in Resources */,
A6339DD81D232CEE000BAD78 /* StatusItem@2x.png in Resources */,
Loading
Loading
@@ -7018,8 +7037,10 @@
A65B725D1B1A630100F947A7 /* CheckMark@2x.png in Resources */,
A686A1161C86A6CB0024C2DE /* NewOutputForDarkTheme@2x.png in Resources */,
1D8BBA701B30F7FB0005A852 /* Dismiss@2x.png in Resources */,
A68E33361DE746F5003F1D8E /* Next Mark Touch Bar Icon@2x.png in Resources */,
1D8BBA781B30FD230005A852 /* Later.png in Resources */,
1D8C6BF5126592DF00E2744E /* EncodingsWithLowerCase.plist in Resources */,
A68E33351DE746F5003F1D8E /* Next Mark Touch Bar Icon.png in Resources */,
A686A1151C86A6CB0024C2DE /* NewOutputForDarkTheme.png in Resources */,
1DC742A0127C96F90069594C /* IBarCursor.png in Resources */,
A6B70FC319830F0D007A4284 /* NewOutput@2x.png in Resources */,
Loading
Loading
@@ -7039,8 +7060,10 @@
A67D0D861A2EE12A003A8B35 /* PseudoTerminal.strings in Resources */,
A6FD85311B767D6300EB9DCE /* Hamburger@2x.png in Resources */,
1DA030F91328BD7C00D7E7DB /* wrap_to_bottom.png in Resources */,
A68E33371DE746F5003F1D8E /* Previous Mark Touch Bar Icon.png in Resources */,
A65B72B11B33C07D00F947A7 /* NextTip.png in Resources */,
1DA030FA1328BD7C00D7E7DB /* wrap_to_top.png in Resources */,
A68E33341DE746F5003F1D8E /* Add Mark Touch Bar Icon@2x.png in Resources */,
A67D0D6E1A2EE12A003A8B35 /* MainMenu.strings in Resources */,
A67D0D771A2EE12A003A8B35 /* PasteboardHistory.xib in Resources */,
1D395913134E75B5005A8021 /* SmartSelectionRules.plist in Resources */,
Loading
Loading
@@ -7116,6 +7139,7 @@
A67D0D8C1A2EE12A003A8B35 /* SplitPanel.xib in Resources */,
9DB3D6EC176CC47E0071CCF8 /* PrefsMouse.png in Resources */,
9DB3D6ED176CC47E0071CCF8 /* PrefsMouse@2x.png in Resources */,
A68E33331DE746F5003F1D8E /* Add Mark Touch Bar Icon.png in Resources */,
1DA76A241B308AD000CB272A /* iTermTipCardViewController.xib in Resources */,
9DB3D6F0176CCABE0071CCF8 /* PrefsArrangements.png in Resources */,
9DB3D6F1176CCABE0071CCF8 /* PrefsArrangements@2x.png in Resources */,
images/Add Mark Touch Bar Icon.png

754 B

images/Add Mark Touch Bar Icon@2x.png

1.44 KiB

images/Next Mark Touch Bar Icon.png

1.37 KiB

images/Next Mark Touch Bar Icon@2x.png

2.62 KiB

images/Previous Mark Touch Bar Icon.png

1.4 KiB

images/Previous Mark Touch Bar Icon@2x.png

2.7 KiB

Loading
Loading
@@ -87,6 +87,12 @@
static const NSInteger kMinimumUnicodeVersion = 8;
static const NSInteger kMaximumUnicodeVersion = 9;
 
static NSString *const iTermTouchBarIdentifierAddMark = @"iTermTouchBarIdentifierAddMark";
static NSString *const iTermTouchBarIdentifierNextMark = @"iTermTouchBarIdentifierNextMark";
static NSString *const iTermTouchBarIdentifierPreviousMark = @"iTermTouchBarIdentifierPreviousMark";
static NSString *const iTermTouchBarIdentifierManPage = @"iTermTouchBarIdentifierManPage";
// The format for a user defaults key that recalls if the user has already been pestered about
// outdated key mappings for a give profile. The %@ is replaced with the profile's GUID.
static NSString *const kAskAboutOutdatedKeyMappingKeyFormat = @"AskAboutOutdatedKeyMappingForGuid%@";
Loading
Loading
@@ -5928,13 +5934,39 @@ ITERM_WEAKLY_REFERENCEABLE
return _unicodeVersion;
}
 
- (void)textViewDidRefresh {
NSTouchBarItem *item = [[[_delegate realParentWindow] touchBar] itemForIdentifier:iTermTouchBarIdentifierManPage];
if (item) {
iTermTextExtractor *textExtractor = [[[iTermTextExtractor alloc] initWithDataSource:_screen] autorelease];
NSString *word = [textExtractor fastWordAt:VT100GridCoordMake(_screen.cursorX - 1, _screen.cursorY + _screen.numberOfScrollbackLines - 1)];
iTermTouchBarButton *button = (iTermTouchBarButton *)item.view;
if (word) {
button.title = [NSString stringWithFormat:@"Man Page for %@", word];
button.enabled = YES;
button.keyBindingAction = @{ @"command": [NSString stringWithFormat:@"man %@", [word stringWithEscapedShellCharacters]] };
} else {
button.title = @"Man Page";
button.enabled = NO;
button.keyBindingAction = nil;
}
}
}
- (NSTouchBar *)makeTouchBar {
NSTouchBar *touchBar = [[[NSTouchBar alloc] init] autorelease];
touchBar.delegate = self;
touchBar.customizationIdentifier = self.profile[KEY_ORIGINAL_GUID] ?: self.profile[KEY_GUID];
touchBar.defaultItemIdentifiers = @[ NSTouchBarItemIdentifierFlexibleSpace,
NSTouchBarItemIdentifierOtherItemsProxy ];
NSArray *ids = @[ NSTouchBarItemIdentifierFlexibleSpace ];
touchBar.defaultItemIdentifiers = @[ iTermTouchBarIdentifierManPage,
NSTouchBarItemIdentifierFlexibleSpace,
NSTouchBarItemIdentifierOtherItemsProxy,
iTermTouchBarIdentifierAddMark,
iTermTouchBarIdentifierPreviousMark,
iTermTouchBarIdentifierNextMark ];
NSArray *ids = @[ iTermTouchBarIdentifierManPage,
NSTouchBarItemIdentifierFlexibleSpace,
iTermTouchBarIdentifierAddMark,
iTermTouchBarIdentifierNextMark,
iTermTouchBarIdentifierPreviousMark ];
ids = [ids arrayByAddingObjectsFromArray:[iTermKeyBindingMgr sortedTouchBarKeysInDictionary:self.profile[KEY_TOUCHBAR_MAP]]];
ids = [ids arrayByAddingObjectsFromArray:[iTermKeyBindingMgr sortedTouchBarKeysInDictionary:[iTermKeyBindingMgr globalTouchBarMap]]];
touchBar.customizationAllowedItemIdentifiers = ids;
Loading
Loading
@@ -7714,6 +7746,40 @@ ITERM_WEAKLY_REFERENCEABLE
if (delegateItem) {
return delegateItem;
}
NSImage *image = nil;
SEL selector = NULL;
NSString *label = nil;
if ([identifier isEqualToString:iTermTouchBarIdentifierManPage]) {
selector = @selector(manPageTouchBarItemSelected:);
label = @"Man Page";
} else if ([identifier isEqualToString:iTermTouchBarIdentifierAddMark]) {
image = [NSImage imageNamed:@"Add Mark Touch Bar Icon"];
selector = @selector(addMarkTouchBarItemSelected:);
label = @"Add Mark";
} else if ([identifier isEqualToString:iTermTouchBarIdentifierNextMark]) {
image = [NSImage imageNamed:@"Next Mark Touch Bar Icon"];
selector = @selector(nextMarkTouchBarItemSelected:);
label = @"Next Mark";
} else if ([identifier isEqualToString:iTermTouchBarIdentifierPreviousMark]) {
image = [NSImage imageNamed:@"Previous Mark Touch Bar Icon"];
selector = @selector(previuosMarkTouchBarItemSelected:);
label = @"Previous Mark";
}
if (image || label) {
iTermTouchBarButton *button;
if (image) {
button = [iTermTouchBarButton buttonWithImage:image target:self action:selector];
} else {
button = [iTermTouchBarButton buttonWithTitle:label target:self action:selector];
}
NSCustomTouchBarItem *item = [[[NSCustomTouchBarItem alloc] initWithIdentifier:identifier] autorelease];
item.view = button;
item.customizationLabel = label;
return item;
}
NSDictionary *map = [iTermKeyBindingMgr touchBarItemsForProfile:self.profile];
NSDictionary *binding = map[identifier];
if (!binding) {
Loading
Loading
@@ -7723,7 +7789,7 @@ ITERM_WEAKLY_REFERENCEABLE
if (!binding) {
return nil;
}
NSCustomTouchBarItem *item = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
NSCustomTouchBarItem *item = [[[NSCustomTouchBarItem alloc] initWithIdentifier:identifier] autorelease];
iTermTouchBarButton *button = [iTermTouchBarButton buttonWithTitle:[iTermKeyBindingMgr touchBarLabelForBinding:binding]
target:self
action:@selector(touchBarItemSelected:)];
Loading
Loading
@@ -7742,4 +7808,30 @@ ITERM_WEAKLY_REFERENCEABLE
event:[NSApp currentEvent]];
}
 
- (void)addMarkTouchBarItemSelected:(id)sender {
[self screenSaveScrollPosition];
}
- (void)nextMarkTouchBarItemSelected:(id)sender {
[self nextMarkOrNote];
}
- (void)previuosMarkTouchBarItemSelected:(id)sender {
[self previousMarkOrNote];
}
- (void)manPageTouchBarItemSelected:(iTermTouchBarButton *)sender {
NSString *command = sender.keyBindingAction[@"command"];
if (command) {
[[iTermController sharedInstance] launchBookmark:nil
inTerminal:nil
withURL:nil
hotkeyWindowType:iTermHotkeyWindowTypeNone
makeKey:YES
canActivate:YES
command:command
block:nil];
}
}
@end
Loading
Loading
@@ -165,7 +165,7 @@ typedef NS_ENUM(NSInteger, PTYTextViewSelectionExtensionUnit) {
- (void)textViewResizeFrameIfNeeded;
 
- (NSInteger)textViewUnicodeVersion;
- (void)textViewDidRefresh;
@end
 
@interface PTYTextView : NSView <
Loading
Loading
Loading
Loading
@@ -902,7 +902,6 @@ static const int kDragThreshold = 3;
int scrollbackOverflow = [_dataSource scrollbackOverflow];
[_dataSource resetScrollbackOverflow];
[_delegate textViewResizeFrameIfNeeded];
// Perform adjustments if lines were lost from the head of the buffer.
BOOL userScroll = [(PTYScroller*)([[self enclosingScrollView] verticalScroller]) userScroll];
if (scrollbackOverflow > 0) {
Loading
Loading
@@ -931,6 +930,8 @@ static const int kDragThreshold = 3;
}
}
 
[_delegate textViewDidRefresh];
// See if any characters are dirty and mark them as needing to be redrawn.
// Return if anything was found to be blinking.
return [self updateDirtyRects] || [self isCursorBlinking];
Loading
Loading
Loading
Loading
@@ -3281,8 +3281,7 @@ ITERM_WEAKLY_REFERENCEABLE
VMARGIN * 2 + sessionSize.height * cellSize.height + decorationSize.height);
}
 
- (void)toggleTraditionalFullScreenMode
{
- (void)toggleTraditionalFullScreenMode {
[SessionView windowDidResize];
PtyLog(@"toggleFullScreenMode called");
CGFloat savedToolbeltWidth = _contentView.toolbeltWidth;
Loading
Loading
@@ -3426,6 +3425,8 @@ ITERM_WEAKLY_REFERENCEABLE
[self refreshTools];
[self updateTabColors];
[self saveTmuxWindowOrigins];
[self updateTouchBarIfNeeded];
}
 
- (BOOL)fullScreen
Loading
Loading
@@ -3563,6 +3564,7 @@ ITERM_WEAKLY_REFERENCEABLE
[_didEnterLionFullscreen release];
_didEnterLionFullscreen = nil;
}
[self updateTouchBarIfNeeded];
}
 
- (void)windowWillExitFullScreen:(NSNotification *)notification
Loading
Loading
@@ -3598,6 +3600,7 @@ ITERM_WEAKLY_REFERENCEABLE
[self notifyTmuxOfWindowResize];
[self saveTmuxWindowOrigins];
[self.window makeFirstResponder:self.currentSession.textview];
[self updateTouchBarIfNeeded];
}
 
- (NSRect)windowWillUseStandardFrame:(NSWindow *)sender defaultFrame:(NSRect)defaultFrame
Loading
Loading
Loading
Loading
@@ -175,4 +175,9 @@ typedef NS_ENUM(NSUInteger, iTermTextExtractorTrimTrailingWhitespace) {
// on the same DWC.
- (BOOL)coord:(VT100GridCoord)coord1 isEqualToCoord:(VT100GridCoord)coord2;
 
// Gets the word at a location. Doesn't sweat fancy word segmentation, and won't return anything
// terribly long. Also uses a stricter definition of what characters can be in a word, excluding
// all punctuation except -.
- (NSString *)fastWordAt:(VT100GridCoord)location;
@end
Loading
Loading
@@ -80,6 +80,111 @@ const NSInteger kUnlimitedMaximumWordLength = NSIntegerMax;
_logicalWindow.length = dividerAfter - dividerBefore;
}
 
- (NSString *)fastWordAt:(VT100GridCoord)location {
location = [self coordLockedToWindow:location];
iTermTextExtractorClass theClass =
[self classForCharacter:[self characterAt:location]];
if (theClass == kTextExtractorClassDoubleWidthPlaceholder) {
VT100GridCoord predecessor = [self predecessorOfCoord:location];
if (predecessor.x != location.x || predecessor.y != location.y) {
return [self fastWordAt:predecessor];
}
} else if (theClass == kTextExtractorClassOther) {
return nil;
}
const int xLimit = [self xLimit];
const int width = [_dataSource width];
int numberOfLines = [_dataSource numberOfLines];
if (location.y >= numberOfLines) {
return nil;
}
__block int iterations = 0;
const int maxLength = 20;
const BOOL windowTouchesLeftMargin = (_logicalWindow.location == 0);
const BOOL windowTouchesRightMargin = (xLimit == width);
VT100GridCoordRange theRange = VT100GridCoordRangeMake(location.x,
location.y,
width,
location.y + 1);
__block BOOL foundWord = (theClass = kTextExtractorClassWord);
NSMutableString *word = [NSMutableString string];
if (theClass == kTextExtractorClassWord) {
// Search forward for the end of the word if the cursor was over a letter.
[self enumerateCharsInRange:VT100GridWindowedRangeMake(theRange,
_logicalWindow.location,
_logicalWindow.length)
charBlock:^BOOL(screen_char_t *currentLine, screen_char_t theChar, VT100GridCoord coord) {
if (++iterations == maxLength) {
return YES;
}
iTermTextExtractorClass newClass = [self classForCharacter:theChar broadDefinitionOfAlphanumeric:NO];
if (newClass == kTextExtractorClassWord) {
foundWord = YES;
if (theChar.complexChar ||
theChar.code < ITERM2_PRIVATE_BEGIN ||
theChar.code > ITERM2_PRIVATE_END) {
NSString *s = [self stringForCharacter:theChar];
[word appendString:s];
}
return NO;
} else {
return foundWord;
}
}
eolBlock:^BOOL(unichar code, int numPreceedingNulls, int line) {
return [self shouldStopEnumeratingWithCode:code
numNulls:numPreceedingNulls
windowTouchesLeftMargin:windowTouchesLeftMargin
windowTouchesRightMargin:windowTouchesRightMargin
ignoringNewlines:NO];
}];
}
if (iterations == maxLength) {
return nil;
}
// Search backward for the beginning of the word
theRange = VT100GridCoordRangeMake(0, 0, location.x, location.y);
[self enumerateInReverseCharsInRange:VT100GridWindowedRangeMake(theRange,
_logicalWindow.location,
_logicalWindow.length)
charBlock:^BOOL(screen_char_t theChar, VT100GridCoord coord) {
if (++iterations == maxLength) {
return YES;
}
iTermTextExtractorClass newClass = [self classForCharacter:theChar broadDefinitionOfAlphanumeric:NO];
if (newClass == kTextExtractorClassWord) {
foundWord = YES;
if (theChar.complexChar ||
theChar.code < ITERM2_PRIVATE_BEGIN ||
theChar.code > ITERM2_PRIVATE_END) {
NSString *s = [self stringForCharacter:theChar];
[word insertString:s atIndex:0];
}
return NO;
} else {
return foundWord;
}
}
eolBlock:^BOOL(unichar code, int numPreceedingNulls, int line) {
return [self shouldStopEnumeratingWithCode:code
numNulls:numPreceedingNulls
windowTouchesLeftMargin:windowTouchesLeftMargin
windowTouchesRightMargin:windowTouchesRightMargin
ignoringNewlines:NO];
}];
if (iterations == maxLength) {
return nil;
}
if (foundWord && word.length) {
return word;
} else {
return nil;
}
}
- (VT100GridWindowedRange)rangeForWordAt:(VT100GridCoord)location
maximumLength:(NSInteger)maximumLength {
location = [self coordLockedToWindow:location];
Loading
Loading
@@ -363,7 +468,7 @@ const NSInteger kUnlimitedMaximumWordLength = NSIntegerMax;
 
- (BOOL)isWhitelistedAlphanumericAtCoord:(VT100GridCoord)coord {
screen_char_t theChar = [self characterAt:coord];
return [self characterShouldBeTreatedAsAlphanumeric:ScreenCharToStr(&theChar)];
return [self characterShouldBeTreatedAsAlphanumeric:ScreenCharToStr(&theChar) broadDefinitionOfAlphanumeric:YES];
}
 
- (NSString *)stringForCharacter:(screen_char_t)theChar {
Loading
Loading
@@ -504,6 +609,11 @@ const NSInteger kUnlimitedMaximumWordLength = NSIntegerMax;
 
// Returns the class for a character.
- (iTermTextExtractorClass)classForCharacter:(screen_char_t)theCharacter {
return [self classForCharacter:theCharacter broadDefinitionOfAlphanumeric:YES];
}
- (iTermTextExtractorClass)classForCharacter:(screen_char_t)theCharacter
broadDefinitionOfAlphanumeric:(BOOL)broadDefinitionOfAlphanumeric {
if (!theCharacter.complexChar) {
if (theCharacter.code == TAB_FILLER) {
return kTextExtractorClassWhitespace;
Loading
Loading
@@ -524,7 +634,7 @@ const NSInteger kUnlimitedMaximumWordLength = NSIntegerMax;
}
 
if ([self characterIsAlphanumeric:asString] ||
[self characterShouldBeTreatedAsAlphanumeric:asString]) {
[self characterShouldBeTreatedAsAlphanumeric:asString broadDefinitionOfAlphanumeric:broadDefinitionOfAlphanumeric]) {
return kTextExtractorClassWord;
}
 
Loading
Loading
@@ -536,10 +646,16 @@ const NSInteger kUnlimitedMaximumWordLength = NSIntegerMax;
return (range.length == characterAsString.length);
}
 
- (BOOL)characterShouldBeTreatedAsAlphanumeric:(NSString *)characterAsString {
NSRange range = [[iTermPreferences stringForKey:kPreferenceKeyCharactersConsideredPartOfAWordForSelection]
rangeOfString:characterAsString];
return (range.length == characterAsString.length);
- (BOOL)characterShouldBeTreatedAsAlphanumeric:(NSString *)characterAsString
broadDefinitionOfAlphanumeric:(BOOL)broadDefinitionOfAlphanumeric {
if (broadDefinitionOfAlphanumeric) {
NSRange range = [[iTermPreferences stringForKey:kPreferenceKeyCharactersConsideredPartOfAWordForSelection]
rangeOfString:characterAsString];
return (range.length == characterAsString.length);
} else {
// The narrow definition only allows hyphen.
return [characterAsString isEqualToString:@"-"];
}
}
 
- (VT100GridWindowedRange)rangeOfParentheticalSubstringAtLocation:(VT100GridCoord)location {
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