Skip to content
Snippets Groups Projects
Commit 2808b2e6 authored by Jack Chen (chendo)'s avatar Jack Chen (chendo)
Browse files

Re-added gnachman's mods to my shoddy Obj-C

parent 30656066
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -75,10 +75,10 @@ typedef struct PTYFontInfo PTYFontInfo;
 
// option to not render in bold
BOOL useBoldFont;
// Option to draw bold text as brighter colors.
BOOL useBrightBold;
// NSTextInput support
BOOL IM_INPUT_INSERT;
NSRange IM_INPUT_SELRANGE;
Loading
Loading
@@ -231,12 +231,14 @@ typedef struct PTYFontInfo PTYFontInfo;
 
ITermCursorType cursorType_;
 
// Trouter
Trouter* trouter;
NSMutableArray *workingDirectoryAtLines;
// Works around an apparent OS bug where we get drag events without a mousedown.
BOOL dragOk_;
// Semantic history controller
Trouter* trouter;
// Array of (line number, pwd) arrays, sorted by line number. Line numbers are absolute.
NSMutableArray *workingDirectoryAtLines;
}
 
+ (NSCursor *)textViewCursor;
Loading
Loading
@@ -437,12 +439,10 @@ typedef struct PTYFontInfo PTYFontInfo;
// Returns true if any character in the buffer is selected.
- (BOOL)isAnyCharSelected;
 
<<<<<<< HEAD
=======
- (void)clearMatches;
// Clear working directories for when buffer is cleared
- (void)clearWorkingDirectories;
>>>>>>> cross_repo_merge
- (void)clearMatches;
 
@end
 
Loading
Loading
@@ -530,7 +530,7 @@ typedef enum {
// Return the number of pixels tall to draw the cursor.
- (float)cursorHeight;
 
// Draw the contents of the input method editor beginning at some location,
// Draw the contents of the input method editor beginning at some location,
// usually the cursor position.
// xStart, yStart: cell coordinates
// width, height: cell width, height of screen
Loading
Loading
Loading
Loading
@@ -855,7 +855,9 @@ static void reapchild(int n)
 
pid_t ppid = taskAllInfo.pbsd.pbi_ppid;
if (ppid == parentPid) {
long long birthday = taskAllInfo.pbsd.pbi_start_tvsec * 1000000 + taskAllInfo.pbsd.pbi_start_tvusec;
// This works with 10.6 sdk:
//long long birthday = taskAllInfo.pbsd.pbi_start_tvsec * 1000000 + taskAllInfo.pbsd.pbi_start_tvusec;
long long birthday = taskAllInfo.pbsd.pbi_start.tv_sec * 1000000 + taskAllInfo.pbsd.pbi_start.tv_usec;
if (birthday < oldestTime || oldestTime == 0) {
oldestTime = birthday;
oldestPid = pids[i];
Loading
Loading
Loading
Loading
@@ -30,6 +30,7 @@
#define DEBUG_ALLOC 0
#define DEBUG_METHOD_TRACE 0
#define GREED_KEYDOWN 1
static const int MAX_WORKING_DIR_COUNT = 50;
//#define DEBUG_DRAWING
 
#define SWAPINT(a, b) { int temp; temp = a; a = b; b = temp; }
Loading
Loading
@@ -295,8 +296,8 @@ static NSImage* wrapToBottomImage = nil;
[fallbackFonts release];
[selectionScrollTimer release];
 
[trouter release];
[workingDirectoryAtLines release];
[trouter release];
 
[super dealloc];
}
Loading
Loading
@@ -2216,16 +2217,16 @@ static BOOL RectsEqual(NSRect* a, NSRect* b) {
[mouseDownEvent locationInWindow].y == [event locationInWindow].y) {
// Command click in place.
NSString *url = [self _getURLForX:x y:y];
if (url && [event modifierFlags] & NSShiftKeyMask) {
if (url && ([event modifierFlags] & NSShiftKeyMask)) {
// Cmd-shift click executes an alternate semantic history action.
NSString *fullPath = [trouter getFullPath:url
workingDirectory:[self getWorkingDirectoryAtLine:y + 1]
lineNumber:nil];
if ([trouter isDirectory:fullPath]) {
[self _changeDirectory:fullPath];
}
}
else {
} else {
[self _openURL:url atLine:y + 1];
}
} else {
Loading
Loading
@@ -2333,10 +2334,13 @@ static BOOL RectsEqual(NSRect* a, NSRect* b) {
 
if ([event modifierFlags] & NSCommandKeyMask) {
// Drag a file handle
NSString *path = [self _getURLForX: x y:y];
path = [trouter getFullPath:path workingDirectory:[self getWorkingDirectoryAtLine:y + 1] lineNumber:nil];
if (![[trouter fileManager] fileExistsAtPath:path])
NSString *path = [self _getURLForX:x y:y];
path = [trouter getFullPath:path
workingDirectory:[self getWorkingDirectoryAtLine:y + 1]
lineNumber:nil];
if (![[trouter fileManager] fileExistsAtPath:path]) {
return;
}
 
NSPoint dragPosition;
NSImage *dragImage;
Loading
Loading
@@ -2348,7 +2352,7 @@ static BOOL RectsEqual(NSRect* a, NSRect* b) {
 
dragImage = [[NSWorkspace sharedWorkspace] iconForFile:path];
dragPosition = [self convertPoint:[event locationInWindow] fromView:nil];
dragPosition.x -= [dragImage size].width/2;
dragPosition.x -= [dragImage size].width / 2;
 
[self dragImage:dragImage
at:dragPosition
Loading
Loading
@@ -5676,48 +5680,58 @@ static bool IsUrlChar(NSString* str)
}
 
 
- (void)logWorkingDirectoryAtLine:(long long) line {
[workingDirectoryAtLines addObject:[NSArray arrayWithObjects:[NSNumber numberWithLongLong:line], [[dataSource shellTask] getWorkingDirectory], nil]];
if ([workingDirectoryAtLines count] >= 1000) {
- (void)logWorkingDirectoryAtLine:(long long)line
{
[workingDirectoryAtLines addObject:[NSArray arrayWithObjects:
[NSNumber numberWithLongLong:line],
[[dataSource shellTask] getWorkingDirectory],
nil]];
if ([workingDirectoryAtLines count] > MAX_WORKING_DIR_COUNT) {
[workingDirectoryAtLines removeObjectAtIndex:0];
}
}
 
- (NSString *)getWorkingDirectoryAtLine:(long long) line {
- (NSString *)getWorkingDirectoryAtLine:(long long)line
{
// TODO: use a binary search if we make MAX_WORKING_DIR_COUNT large.
// Return current directory if not able to log via XTERMCC_WINDOW_TITLE
if ([workingDirectoryAtLines count] == 0) {
return [[dataSource shellTask] getWorkingDirectory];
}
long long previousLine = [[[workingDirectoryAtLines lastObject] objectAtIndex:0] longLongValue];
long long currentLine;
for (int i=[workingDirectoryAtLines count] - 2; i != -1; i--) {
for (int i = [workingDirectoryAtLines count] - 2; i != -1; i--) {
currentLine = [[[workingDirectoryAtLines objectAtIndex:i] objectAtIndex: 0] longLongValue];
if (currentLine < line && line <= previousLine)
if (currentLine < line && line <= previousLine) {
return [[workingDirectoryAtLines objectAtIndex:i] lastObject];
}
previousLine = currentLine;
}
return [[workingDirectoryAtLines lastObject] lastObject];
}
 
- (void)_changeDirectory:(NSString *)path {
- (void)_changeDirectory:(NSString *)path
{
// TODO: Make this more efficient by calculating the shortest path to target folder
[[dataSource shellTask] writeTask:[[NSString stringWithFormat:@"\3cd \"%@\"; ls\n", path] dataUsingEncoding:[[dataSource session] encoding]]];
}
 
- (void)_openURL:(NSString *)aURLString atLine:(long long)line {
- (void)_openURL:(NSString *)aURLString atLine:(long long)line
{
NSString* trimmedURLString;
trimmedURLString = [aURLString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *working_directory = [self getWorkingDirectoryAtLine:line];
[trouter openPath:trimmedURLString workingDirectory:working_directory];
NSString *workingDirectory = [self getWorkingDirectoryAtLine:line];
[trouter openPath:trimmedURLString workingDirectory:workingDirectory];
return;
}
 
Loading
Loading
Loading
Loading
@@ -1380,8 +1380,8 @@ static char* FormatCont(int c)
newTitle = [NSString stringWithFormat:@"%@: %@", [SESSION joblessDefaultName], newTitle];
}
[SESSION setWindowTitle:newTitle];
long long lineNumber = [self getLineNumber];
[[SESSION TEXTVIEW] logWorkingDirectoryAtLine: lineNumber];
long long lineNumber = [self absoluteLineNumberOfCursor];
[[SESSION TEXTVIEW] logWorkingDirectoryAtLine:lineNumber];
break;
case XTERMCC_WINICON_TITLE:
newTitle = [[token.u.string copy] autorelease];
Loading
Loading
@@ -1542,7 +1542,8 @@ static char* FormatCont(int c)
// NSLog(@"Done");
}
 
- (long long)getLineNumber {
- (long long)absoluteLineNumberOfCursor
{
return [self totalScrollbackOverflow] + [self numberOfLines] - [self height] + [self cursorY] - 1;
}
 
Loading
Loading
Loading
Loading
@@ -7,6 +7,8 @@
objects = {
 
/* Begin PBXBuildFile section */
1D06A050134CDBED00C414EF /* Trouter.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D06A04F134CDBED00C414EF /* Trouter.m */; };
1D06A052134CDBF800C414EF /* Trouter.h in Headers */ = {isa = PBXBuildFile; fileRef = 1D06A051134CDBF800C414EF /* Trouter.h */; };
1D1158CE13444D29009B366F /* iTerm2 Help in Resources */ = {isa = PBXBuildFile; fileRef = 1D1158C913444D29009B366F /* iTerm2 Help */; };
1D13EADC12113A2D00909F9C /* libncurses.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D13EADB12113A2D00909F9C /* libncurses.dylib */; };
1D173859126C820A004622DC /* FakeWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 1D173857126C820A004622DC /* FakeWindow.h */; };
Loading
Loading
@@ -211,8 +213,6 @@
1DE5EBE9122B892900C736B0 /* BookmarksWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DE5EBE7122B892900C736B0 /* BookmarksWindow.m */; };
1DEE9FDD11FCA60F009E18C9 /* credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 1DEE9FDB11FCA60F009E18C9 /* credits.rtf */; };
49A6E4091211CC6000D9AD6F /* Compatability.h in Headers */ = {isa = PBXBuildFile; fileRef = 49A6E4081211CC6000D9AD6F /* Compatability.h */; };
58C80B8F13446D4E00203E4E /* Trouter.h in Headers */ = {isa = PBXBuildFile; fileRef = 58C80B8D13446D4E00203E4E /* Trouter.h */; };
58C80B9013446D4E00203E4E /* Trouter.m in Sources */ = {isa = PBXBuildFile; fileRef = 58C80B8E13446D4E00203E4E /* Trouter.m */; };
874206490564169600CFC3F1 /* iTermApplicationDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 20D5CC6304E7AA0500000106 /* iTermApplicationDelegate.h */; };
8742064D0564169600CFC3F1 /* iTerm.icns in Resources */ = {isa = PBXBuildFile; fileRef = E8EDCE69015E0A5703000001 /* iTerm.icns */; };
8742064F0564169600CFC3F1 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = E8CF757F026DDAD703A80106 /* main.m */; };
Loading
Loading
@@ -279,6 +279,8 @@
/* Begin PBXFileReference section */
0464AB2F006CD2EC7F000001 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
0464AB30006CD2EC7F000001 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
1D06A04F134CDBED00C414EF /* Trouter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Trouter.m; sourceTree = "<group>"; };
1D06A051134CDBF800C414EF /* Trouter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Trouter.h; sourceTree = "<group>"; };
1D1158CA13444D29009B366F /* English */ = {isa = PBXFileReference; lastKnownFileType = folder; name = English; path = "English.lproj/iTerm2 Help"; sourceTree = "<group>"; };
1D13EADB12113A2D00909F9C /* libncurses.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libncurses.dylib; path = usr/lib/libncurses.dylib; sourceTree = SDKROOT; };
1D173857126C820A004622DC /* FakeWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FakeWindow.h; sourceTree = "<group>"; };
Loading
Loading
@@ -377,8 +379,6 @@
20E74F4804E9089700000106 /* ITAddressBookMgr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ITAddressBookMgr.h; sourceTree = "<group>"; };
20E74F4904E9089700000106 /* ITAddressBookMgr.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ITAddressBookMgr.m; sourceTree = "<group>"; };
49A6E4081211CC6000D9AD6F /* Compatability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Compatability.h; sourceTree = "<group>"; };
58C80B8D13446D4E00203E4E /* Trouter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Trouter.h; sourceTree = "<group>"; };
58C80B8E13446D4E00203E4E /* Trouter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Trouter.m; sourceTree = "<group>"; };
872EBC5304E42E320073D10E /* NSStringITerm.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = NSStringITerm.h; path = Headers/iTerm/NSStringITerm.h; sourceTree = "<group>"; };
872EBC5404E42E320073D10E /* PTYTextView.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = PTYTextView.h; path = Headers/iTerm/PTYTextView.h; sourceTree = "<group>"; };
872EBC5704E42E320073D10E /* PTYTabView.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = PTYTabView.h; path = Headers/iTerm/PTYTabView.h; sourceTree = "<group>"; };
Loading
Loading
@@ -589,8 +589,6 @@
0464AB0E006CD2EC7F000001 /* Classes */ = {
isa = PBXGroup;
children = (
58C80B8D13446D4E00203E4E /* Trouter.h */,
58C80B8E13446D4E00203E4E /* Trouter.m */,
1DE214E0128212EE004E3ADF /* Autocomplete.m */,
1D6C50A61226EEFB00E0AA3E /* BookmarkListView.m */,
1DCF3E8D122419D200AD56F1 /* BookmarkModel.m */,
Loading
Loading
@@ -631,6 +629,7 @@
F56B230B03A1B36701A8A066 /* PTYWindow.m */,
1D36155412CBF33E00803EA9 /* ScreenChar.m */,
1D2E813012A18F7500F3D71E /* SessionView.m */,
1D06A04F134CDBED00C414EF /* Trouter.m */,
1D44218B1290B34500891504 /* TextViewWrapper.m */,
E8CF7562026DDA6303A80106 /* VT100Screen.m */,
E8CF7563026DDA6303A80106 /* VT100Terminal.m */,
Loading
Loading
@@ -684,6 +683,7 @@
1D36155312CBF33E00803EA9 /* ScreenChar.h */,
1D2E812F12A18F7500F3D71E /* SessionView.h */,
1D44218A1290B34500891504 /* TextViewWrapper.h */,
1D06A051134CDBF800C414EF /* Trouter.h */,
872EBC5A04E42E320073D10E /* VT100Screen.h */,
872EBC6104E42E320073D10E /* VT100Terminal.h */,
1DCBC810126DD98200D5B961 /* WindowControllerInterface.h */,
Loading
Loading
@@ -1060,7 +1060,7 @@
1D85D1ED1306687700A3E998 /* RegexKitLite.h in Headers */,
1D237D28131D8741004DD60C /* FindView.h in Headers */,
1D237D94131D8D66004DD60C /* FindViewController.h in Headers */,
58C80B8F13446D4E00203E4E /* Trouter.h in Headers */,
1D06A052134CDBF800C414EF /* Trouter.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Loading
Loading
@@ -1335,7 +1335,7 @@
1D85D1EF1306687700A3E998 /* RegexKitLite.m in Sources */,
1D237D29131D8741004DD60C /* FindView.m in Sources */,
1D237D95131D8D66004DD60C /* FindViewController.m in Sources */,
58C80B9013446D4E00203E4E /* Trouter.m in Sources */,
1D06A050134CDBED00C414EF /* Trouter.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Loading
Loading
@@ -1493,12 +1493,12 @@
HEADER_SEARCH_PATHS = Headers/iTerm/;
INFOPLIST_FILE = iTerm.plist;
LINK_WITH_STANDARD_LIBRARIES = YES;
MACOSX_DEPLOYMENT_TARGET = 10.6;
MACOSX_DEPLOYMENT_TARGET = 10.5;
OTHER_LDFLAGS = "-licucore";
PRODUCT_NAME = iTerm;
SDKROOT = macosx10.6;
SDKROOT = macosx10.5;
SECTORDER_FLAGS = "";
VALID_ARCHS = "i386 x86_64";
VALID_ARCHS = "i386 x86_64 ppc";
WARNING_CFLAGS = "-Wall";
WRAPPER_EXTENSION = app;
ZERO_LINK = YES;
Loading
Loading
@@ -1531,11 +1531,11 @@
GCC_WARN_UNUSED_VALUE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = iTerm.plist;
MACOSX_DEPLOYMENT_TARGET = 10.6;
MACOSX_DEPLOYMENT_TARGET = 10.5;
OTHER_LDFLAGS = "-licucore";
PRODUCT_NAME = iTerm;
SDKROOT = macosx10.6;
VALID_ARCHS = "i386 x86_64";
SDKROOT = macosx10.5;
VALID_ARCHS = "i386 x86_64 ppc";
WARNING_CFLAGS = "-Wall";
WRAPPER_EXTENSION = app;
ZERO_LINK = NO;
Loading
Loading
@@ -1569,14 +1569,14 @@
GCC_WARN_UNUSED_VALUE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = iTerm.plist;
MACOSX_DEPLOYMENT_TARGET = 10.6;
MACOSX_DEPLOYMENT_TARGET = 10.5;
OTHER_LDFLAGS = "-licucore";
OTHER_REZFLAGS = "";
PRODUCT_NAME = iTerm;
REZ_EXECUTABLE = YES;
SDKROOT = macosx10.6;
SDKROOT = macosx10.5;
SECTORDER_FLAGS = "";
VALID_ARCHS = "i386 x86_64";
VALID_ARCHS = "i386 x86_64 ppc";
WARNING_CFLAGS = "-Wall";
WRAPPER_EXTENSION = app;
};
Loading
Loading
@@ -1592,7 +1592,7 @@
"\"$(SRCROOT)\"/build/Development",
);
GCC_C_LANGUAGE_STANDARD = c99;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_VERSION = 4.0;
GCC_WARN_CHECK_SWITCH_STATEMENTS = YES;
GCC_WARN_MISSING_PARENTHESES = YES;
GCC_WARN_PROTOTYPE_CONVERSION = NO;
Loading
Loading
@@ -1623,7 +1623,7 @@
"\"$(SRCROOT)\"/build/Development",
);
GCC_C_LANGUAGE_STANDARD = c99;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_VERSION = 4.0;
GCC_WARN_PROTOTYPE_CONVERSION = NO;
GCC_WARN_SIGN_COMPARE = NO;
MACOSX_DEPLOYMENT_TARGET = 10.5;
Loading
Loading
@@ -1647,7 +1647,7 @@
"$(FRAMEWORK_SEARCH_PATHS_QUOTED_1)",
"\"$(SRCROOT)\"/build/Development",
);
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_VERSION = 4.0;
GCC_WARN_PROTOTYPE_CONVERSION = NO;
GCC_WARN_SIGN_COMPARE = NO;
MACOSX_DEPLOYMENT_TARGET = 10.5;
Loading
Loading
@@ -1680,8 +1680,8 @@
);
PREBINDING = NO;
PRODUCT_NAME = Growl;
SDKROOT = macosx10.6;
VALID_ARCHS = "i386 x86_64";
SDKROOT = macosx10.5;
VALID_ARCHS = "i386 x86_64 ppc";
ZERO_LINK = YES;
};
name = Development;
Loading
Loading
@@ -1707,8 +1707,8 @@
);
PREBINDING = NO;
PRODUCT_NAME = Growl;
SDKROOT = macosx10.6;
VALID_ARCHS = "i386 x86_64";
SDKROOT = macosx10.5;
VALID_ARCHS = "i386 x86_64 ppc";
ZERO_LINK = NO;
};
name = Deployment;
Loading
Loading
@@ -1732,8 +1732,8 @@
);
PREBINDING = NO;
PRODUCT_NAME = Growl;
SDKROOT = macosx10.6;
VALID_ARCHS = "i386 x86_64";
SDKROOT = macosx10.5;
VALID_ARCHS = "i386 x86_64 ppc";
ZERO_LINK = YES;
};
name = Default;
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