Skip to content

Commit

Permalink
* Fixed a wrapping porblem under ANSI terminals.
Browse files Browse the repository at this point in the history
	* Incorporated the data processing thread into the data reading thread.
	* Find panel now will set the string system-wide.
	* Added an option in the terminal profile to allow default session name not to be overwritten
	  by dynamic tab name changes.
	* Double click on a parenthesis now selects everything between the pair of parenthesis.
	* Fixed bug that loses changes to 'Editors considered parts of word' text field.
	* Fixed the "show cursor" behavior in RESET.


git-svn-id: https://iterm.svn.sourceforge.net/svnroot/iterm/trunk@1485 a86d2aa4-6e2d-4ff4-9c10-3c044852e7c9
  • Loading branch information
yfabian committed Dec 9, 2006
1 parent 95a8f5b commit ff19dab
Show file tree
Hide file tree
Showing 23 changed files with 327 additions and 128 deletions.
14 changes: 14 additions & 0 deletions Changelog
@@ -1,3 +1,17 @@
2006-12-8 fabian

* Fixed a wrapping porblem under ANSI terminals.
* Incorporated the data processing thread into the data reading thread.
* Find panel now will set the string system-wide.
* Added an option in the terminal profile to allow default session name not to be overwritten
by dynamic tab name changes.
* Double click on a parenthesis now selects everything between the pair of parenthesis.

2006-12-7 fabian

* Fixed bug that loses changes to 'Editors considered parts of word' text field.
* Fixed the "show cursor" behavior in RESET.

2006-12-6 fabian

* An attempt to fix the closing window confirmation panel.
Expand Down
Binary file modified English.lproj/PreferencePanel.nib/keyedobjects.nib
Binary file not shown.
Binary file modified English.lproj/PreferencePanel.nib/objects.nib
Binary file not shown.
2 changes: 2 additions & 0 deletions English.lproj/ProfilesWindow.nib/classes.nib

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified English.lproj/ProfilesWindow.nib/keyedobjects.nib
Binary file not shown.
16 changes: 13 additions & 3 deletions FindPanelWindowController.m
Expand Up @@ -146,15 +146,25 @@ - (void) setDelegate: (id) theDelegate

- (void)setSearchString: (NSString *) aString
{
if (aString)
[searchStringField setStringValue: aString];
if (aString && [aString length]>0) {
[searchStringField setStringValue: aString];

}
else
[searchStringField setStringValue: @""];
}

- (NSString*)searchString;
{
return [searchStringField stringValue];
NSString *aString = [searchStringField stringValue];

if ([aString length]>0) {
NSPasteboard *pboard = [NSPasteboard pasteboardWithName: NSFindPboard];

[pboard declareTypes: [NSArray arrayWithObject: NSStringPboardType] owner: self];
[pboard setString: aString forType: NSStringPboardType];
}
return aString;
}

@end
Expand Down
8 changes: 3 additions & 5 deletions Headers/iTerm/PTYSession.h
Expand Up @@ -49,13 +49,9 @@

PseudoTerminal *parent; // parent controller
NSString *name;
NSString *defaultName;
NSString *windowTitle;

// semaphore to coordinate data read from task
MPSemaphoreID dataSemaphore;
// semaphore to coordinate thread
MPSemaphoreID threadEndSemaphore;

PTYTask *SHELL;
VT100Terminal *TERMINAL;
NSString *TERM_VALUE;
Expand Down Expand Up @@ -152,6 +148,8 @@
- (void) setTabViewItem: (NSTabViewItem *) theTabViewItem;
- (NSString *) name;
- (void) setName: (NSString *) theName;
- (NSString *) defaultName;
- (void) setDefaultName: (NSString *) theName;
- (NSString *) uniqueID;
- (void) setUniqueID: (NSString *)uniqueID;
- (NSString *) windowTitle;
Expand Down
6 changes: 4 additions & 2 deletions Headers/iTerm/PTYTextView.h
@@ -1,5 +1,5 @@
// -*- mode:objc -*-
// $Id: PTYTextView.h,v 1.62 2006-12-06 01:58:34 yfabian Exp $
// $Id: PTYTextView.h,v 1.63 2006-12-09 02:33:45 yfabian Exp $
//
/*
** PTYTextView.h
Expand Down Expand Up @@ -225,6 +225,7 @@ enum { SELECT_CHAR, SELECT_WORD, SELECT_LINE };

// selection
- (IBAction) selectAll: (id) sender;
- (void) deselect;

// transparency
- (float) transparency;
Expand Down Expand Up @@ -313,7 +314,8 @@ enum { SELECT_CHAR, SELECT_WORD, SELECT_LINE };
- (void) _openURL: (NSString *) aURLString;
- (void) _clearCacheForColor:(int)colorIndex;
- (void) _clearCacheForBGColor:(int)colorIndex;
- (BOOL) _findString: (NSString *) aString forwardDirection: (BOOL) direction ignoringCase: (BOOL) ignoreCase;
- (BOOL) _findString: (NSString *) aString forwardDirection: (BOOL) direction ignoringCase: (BOOL) ignoreCase wrapping: (BOOL) wrapping;
- (BOOL) _findMatchingParenthesis: (NSString *) parenthesis withX:(int)X Y:(int)Y;
- (BOOL) _mouseDownOnSelection: (NSEvent *) theEvent;
- (void) _dragText: (NSString *) aString forEvent: (NSEvent *) theEvent;

Expand Down
2 changes: 2 additions & 0 deletions Headers/iTerm/iTermProfileWindowController.h
Expand Up @@ -113,6 +113,7 @@
IBOutlet NSButton *terminalDoubleWidth;
IBOutlet NSButton *terminalSendIdleChar;
IBOutlet NSTextField *terminalIdleChar;
IBOutlet NSButton *terminalAppendTitle;
IBOutlet NSButton *xtermMouseReporting;

NSString *selectedProfile;
Expand Down Expand Up @@ -162,6 +163,7 @@
- (IBAction) terminalSetDoubleWidth: (id) sender;
- (IBAction) terminalSetSendIdleChar: (id) sender;
- (IBAction) terminalSetXtermMouseReporting: (id) sender;
- (IBAction) terminalSetAppendTitle: (id) sender;

- (void)selectProfile:(NSString *)profile withInCategory: (int) category;

Expand Down
2 changes: 2 additions & 0 deletions Headers/iTerm/iTermTerminalProfileMgr.h
Expand Up @@ -71,6 +71,8 @@
- (void) setIdleChar: (char) idle forProfile: (NSString *) profileName;
- (BOOL) xtermMouseReportingForProfile: (NSString *) profileName;
- (void) setXtermMouseReporting: (BOOL) xtermMouseReporting forProfile: (NSString *) profileName;
- (BOOL) appendTitleForProfile: (NSString *) profileName;
- (void) setAppendTitle: (BOOL) appendTitle forProfile: (NSString *) profileName;

@end

Expand Down
131 changes: 55 additions & 76 deletions PTYSession.m
Expand Up @@ -97,13 +97,7 @@ - (id) init
#if DEBUG_ALLOC
NSLog(@"%s: 0x%x", __PRETTY_FUNCTION__, self);
#endif

// allocate a semaphore to coordinate data processing
MPCreateBinarySemaphore(&dataSemaphore);

// allocate a semaphore to coordinate with thread
MPCreateBinarySemaphore(&threadEndSemaphore);


// Allocate screen, shell, and terminal objects
SHELL = [[PTYTask alloc] init];
TERMINAL = [[VT100Terminal alloc] init];
Expand Down Expand Up @@ -184,6 +178,7 @@ - (void)initScreen: (NSRect) aRect width:(int)width height:(int) height
// initialize the screen
[SCREEN initScreenWithWidth:width Height:height];
[self setName:@"Shell"];
[self setDefaultName:@"Shell"];


[TEXTVIEW setDataSource: SCREEN];
Expand Down Expand Up @@ -234,8 +229,6 @@ - (void)startProgram:(NSString *)program
width:[SCREEN width]
height:[SCREEN height]];

// launch a thread to process the data read from the SHELL process
[NSThread detachNewThreadSelector: @selector(_processReadDataThread:) toTarget: self withObject: nil];

updateTimer = [[NSTimer scheduledTimerWithTimeInterval:0.002 * [[PreferencePanel sharedInstance] refreshRate]
target:self
Expand All @@ -257,22 +250,13 @@ - (void) terminate
EXIT = YES;
[SHELL stop];

// Bring the reading thread out of sleep
MPSignalSemaphore(dataSemaphore);

// wait till all the remaining data is processed
MPWaitOnSemaphore(threadEndSemaphore, kDurationForever);
MPDeleteSemaphore(threadEndSemaphore);

//stop the timer;
if (updateTimer) {
[updateTimer invalidate]; [updateTimer release]; updateTimer = nil;
}
// final update of display
[self updateDisplay];

// release the data processing semaphore
MPDeleteSemaphore(dataSemaphore);

[addressBookEntry release];
addressBookEntry = nil;
Expand Down Expand Up @@ -302,6 +286,7 @@ - (void)writeTask:(NSData *)data

[SHELL writeTask: data];
// Make sure we scroll down to the end
[TEXTVIEW deselect];
[TEXTVIEW scrollEnd];
[ptys setUserScroll: NO];
}
Expand All @@ -325,9 +310,29 @@ - (void)readTask:(char *)buf length:(int)length

[TERMINAL putStreamData:buf length:length];

// signal the data processing thread
MPSignalSemaphore(dataSemaphore);
VT100TCC token;

// while loop to process all the tokens we can get
while(!EXIT && TERMINAL && ((token = [TERMINAL getNextToken]),
token.type != VT100_WAIT && token.type != VT100CC_NULL))
{
// process token
if (token.type != VT100_SKIP)
{
if (token.type == VT100_NOTSUPPORT) {
//NSLog(@"%s(%d):not support token", __FILE__ , __LINE__);
}
else {
while ([SCREEN changeSize] != NO_CHANGE || [SCREEN changeTitle]) {
usleep(100000);
}

[SCREEN putToken:token];
newOutput=YES;
gettimeofday(&lastOutput, NULL);
}
}
} // end token processing loop
}

- (void)brokenPipe
Expand Down Expand Up @@ -1135,6 +1140,30 @@ - (void) setUniqueID: (NSString *)uniqueID
NSLog(@"Not allowed to set unique ID");
}

- (NSString *) defaultName
{
return (defaultName);
}

- (void) setDefaultName: (NSString *) theName
{
if([defaultName isEqualToString: theName])
return;

if(defaultName)
{
// clear the window title if it is not different
if([self windowTitle] == nil || [name isEqualToString: [self windowTitle]])
[self setWindowTitle: nil];
[defaultName release];
defaultName = nil;
}
if (!theName)
theName = NSLocalizedStringFromTableInBundle(@"Untitled",@"iTerm", [NSBundle bundleForClass: [self class]], @"Profiles");

defaultName = [theName retain];
}

- (NSString *) name
{
return (name);
Expand All @@ -1146,7 +1175,7 @@ - (void) setName: (NSString *) theName
return;

if(name)
{
{
// clear the window title if it is not different
if([self windowTitle] == nil || [name isEqualToString: [self windowTitle]])
[self setWindowTitle: nil];
Expand Down Expand Up @@ -1814,59 +1843,6 @@ -(void)handleTerminateScriptCommand: (NSScriptCommand *)command

@implementation PTYSession (Private)

// thread to process data read from the task being run
-(void)_processReadDataThread: (void *) arg
{
NSAutoreleasePool *arPool = [[NSAutoreleasePool alloc] init];
int iterationCount = 0;
VT100TCC token;

while(EXIT == NO)
{

// wait for data
MPWaitOnSemaphore(dataSemaphore, kDurationForever);

// inner while loop to process all the tokens we can get
while(!EXIT && TERMINAL && ((token = [TERMINAL getNextToken]),
token.type != VT100_WAIT && token.type != VT100CC_NULL))
{
// process token
if (token.type != VT100_SKIP)
{
if (token.type == VT100_NOTSUPPORT) {
//NSLog(@"%s(%d):not support token", __FILE__ , __LINE__);
}
else {
while ([SCREEN changeSize] != NO_CHANGE || [SCREEN changeTitle]) {
usleep(100000);
}

[SCREEN putToken:token];
newOutput=YES;
gettimeofday(&lastOutput, NULL);
}
}

// periodically refresh autoreleasepool
iterationCount++;
if(iterationCount % 100 == 0)
{
// refresh our autrelease pool
[arPool release];
arPool = [[NSAutoreleasePool alloc] init];
iterationCount = 0;
}
} // end token processing loop
} // end fetch new data loop

[arPool release];

MPSignalSemaphore(threadEndSemaphore);
[NSThread exit];

}

//Update the display if necessary
- (void)_updateTimer:(NSTimer *)aTimer
{
Expand All @@ -1889,15 +1865,18 @@ - (void)_updateTimer:(NSTimer *)aTimer
else {
updateCount++;
if ([SCREEN changeTitle]) {
NSString *newTitle = [SCREEN newTitle];
if ([[iTermTerminalProfileMgr singleInstance] appendTitleForProfile: [addressBookEntry objectForKey: @"Terminal Profile"]])
newTitle = [NSString stringWithFormat:@"%@: %@", defaultName, newTitle];
if ([SCREEN changeTitle]==XTERMCC_WIN_TITLE||[SCREEN changeTitle]==XTERMCC_WINICON_TITLE)
{
//NSLog(@"setting window title to %@", token.u.string);
[self setWindowTitle: [SCREEN newTitle]];
[self setWindowTitle: newTitle];
}
if ([SCREEN changeTitle]==XTERMCC_ICON_TITLE||[SCREEN changeTitle]==XTERMCC_WINICON_TITLE)
{
//NSLog(@"setting session title to %@", token.u.string);
[self setName: [SCREEN newTitle]];
[self setName: newTitle];
}
[SCREEN resetChangeTitle];
}
Expand Down

0 comments on commit ff19dab

Please sign in to comment.