mirror of
https://github.com/ksherlock/TwoTerm.git
synced 2024-09-28 14:54:46 +00:00
updates
git-svn-id: svn://qnap.local/TwoTerm/branches/frameless@2474 5590a31f-7b70-45f8-8c82-aa3a8e5f4507
This commit is contained in:
parent
a4d078bed5
commit
c8fa4a4896
@ -47,9 +47,7 @@ private:
|
|||||||
int _fd;
|
int _fd;
|
||||||
|
|
||||||
NSObject<Emulator> *_emulator;
|
NSObject<Emulator> *_emulator;
|
||||||
|
|
||||||
NSThread *_readerThread;
|
|
||||||
|
|
||||||
CharacterGenerator *_charGen;
|
CharacterGenerator *_charGen;
|
||||||
|
|
||||||
NSColor *_backgroundColor;
|
NSColor *_backgroundColor;
|
||||||
@ -91,7 +89,6 @@ private:
|
|||||||
|
|
||||||
//@property (nonatomic, assign) iPoint cursor;
|
//@property (nonatomic, assign) iPoint cursor;
|
||||||
|
|
||||||
-(void)startBackgroundReader;
|
|
||||||
-(void)dataAvailable;
|
-(void)dataAvailable;
|
||||||
-(void)invalidateIRect: (iRect)rect;
|
-(void)invalidateIRect: (iRect)rect;
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
_cursorOn = NO;
|
_cursorOn = NO;
|
||||||
_cursorTimer = [[NSTimer alloc] initWithFireDate: [NSDate date]
|
_cursorTimer = [[NSTimer alloc] initWithFireDate: [NSDate date]
|
||||||
interval: 0.5
|
interval: 0.5
|
||||||
target: self
|
target: self
|
||||||
selector: @selector(cursorTimer:)
|
selector: @selector(cursorTimer:)
|
||||||
userInfo: nil
|
userInfo: nil
|
||||||
@ -166,7 +166,7 @@
|
|||||||
_charGen = [[CharacterGenerator generator] retain];
|
_charGen = [[CharacterGenerator generator] retain];
|
||||||
|
|
||||||
_cursorImg = [[_charGen imageForCharacter: '_'] retain];
|
_cursorImg = [[_charGen imageForCharacter: '_'] retain];
|
||||||
|
_cursorType = Screen::CursorTypeUnderscore;
|
||||||
|
|
||||||
size = [_charGen characterSize];
|
size = [_charGen characterSize];
|
||||||
_charWidth = size.width;
|
_charWidth = size.width;
|
||||||
@ -253,13 +253,8 @@
|
|||||||
[self becomeFirstResponder];
|
[self becomeFirstResponder];
|
||||||
|
|
||||||
|
|
||||||
|
[self startCursorTimer];
|
||||||
|
|
||||||
_cursorTimer = [[NSTimer scheduledTimerWithTimeInterval: .5
|
|
||||||
target: self
|
|
||||||
selector: @selector(cursorTimer:)
|
|
||||||
userInfo: nil
|
|
||||||
repeats: YES] retain];
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
[[self window] display];
|
[[self window] display];
|
||||||
[[self window] setHasShadow: NO];
|
[[self window] setHasShadow: NO];
|
||||||
@ -279,13 +274,14 @@
|
|||||||
|
|
||||||
-(void)drawRect:(NSRect)dirtyRect
|
-(void)drawRect:(NSRect)dirtyRect
|
||||||
{
|
{
|
||||||
|
//NSLog(@"drawRect:");
|
||||||
|
|
||||||
//NSRect bounds = [self bounds];
|
//NSRect bounds = [self bounds];
|
||||||
|
|
||||||
NSRect screenRect = dirtyRect;
|
NSRect screenRect = dirtyRect;
|
||||||
|
|
||||||
unsigned x, y;
|
unsigned x, y;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
NSColor *currentFront;
|
NSColor *currentFront;
|
||||||
NSColor *currentBack;
|
NSColor *currentBack;
|
||||||
@ -442,7 +438,6 @@
|
|||||||
[_foregroundColor release];
|
[_foregroundColor release];
|
||||||
[_backgroundColor release];
|
[_backgroundColor release];
|
||||||
|
|
||||||
[_readerThread release];
|
|
||||||
|
|
||||||
[_emulator release];
|
[_emulator release];
|
||||||
[_cursorImg release];
|
[_cursorImg release];
|
||||||
@ -452,6 +447,8 @@
|
|||||||
|
|
||||||
-(void)keyDown:(NSEvent *)theEvent
|
-(void)keyDown:(NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
|
//NSLog(@"keyDown:");
|
||||||
|
|
||||||
OutputChannel channel(_fd);
|
OutputChannel channel(_fd);
|
||||||
iRect updateRect; // should be nil but whatever...
|
iRect updateRect; // should be nil but whatever...
|
||||||
|
|
||||||
@ -489,50 +486,13 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
-(void)startBackgroundReader
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (_readerThread) return;
|
|
||||||
|
|
||||||
_readerThread = [[NSThread alloc] initWithTarget: self selector: @selector(_readerThread) object: nil];
|
|
||||||
|
|
||||||
[_readerThread start];
|
|
||||||
}
|
|
||||||
-(void)_readerThread
|
|
||||||
{
|
|
||||||
// I would prefer to poll(2) but it's broken on os x for ptys.
|
|
||||||
|
|
||||||
int fd = _fd;
|
|
||||||
|
|
||||||
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
int n;
|
|
||||||
|
|
||||||
fd_set read_set;
|
|
||||||
fd_set error_set;
|
|
||||||
|
|
||||||
FD_ZERO(&read_set);
|
|
||||||
FD_SET(fd, &read_set);
|
|
||||||
FD_ZERO(&error_set);
|
|
||||||
FD_SET(fd, &error_set);
|
|
||||||
|
|
||||||
|
|
||||||
n = select(fd + 1, &read_set, NULL, &error_set, NULL);
|
|
||||||
|
|
||||||
if (n == 0) continue;
|
|
||||||
if (n < 0) break;
|
|
||||||
|
|
||||||
if (FD_ISSET(fd, &error_set)) break;
|
|
||||||
if (FD_ISSET(fd, &read_set)) [self dataAvailable];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
-(void)dataAvailable
|
-(void)dataAvailable
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//NSLog(@"data available");
|
||||||
|
|
||||||
typedef void (*ProcessCharFX)(id, SEL, uint8_t, Screen *, OutputChannel *);
|
typedef void (*ProcessCharFX)(id, SEL, uint8_t, Screen *, OutputChannel *);
|
||||||
|
|
||||||
ProcessCharFX fx;
|
ProcessCharFX fx;
|
||||||
@ -550,11 +510,13 @@
|
|||||||
ssize_t size;
|
ssize_t size;
|
||||||
|
|
||||||
|
|
||||||
|
// this should be a non-blocking read.
|
||||||
size = read(_fd, buffer, sizeof(buffer));
|
size = read(_fd, buffer, sizeof(buffer));
|
||||||
|
|
||||||
if (size == 0) break;
|
if (size == 0) break;
|
||||||
if (size < 0)
|
if (size < 0)
|
||||||
{
|
{
|
||||||
|
if (errno == EAGAIN) break; // non-blocking, no data available.
|
||||||
if (errno == EINTR || errno == EAGAIN) continue;
|
if (errno == EINTR || errno == EAGAIN) continue;
|
||||||
|
|
||||||
perror("[EmulatorView dataAvailable]");
|
perror("[EmulatorView dataAvailable]");
|
||||||
@ -578,15 +540,22 @@
|
|||||||
|
|
||||||
updateRect = _screen.endUpdate();
|
updateRect = _screen.endUpdate();
|
||||||
|
|
||||||
[self invalidateIRect: updateRect];
|
dispatch_async(dispatch_get_main_queue(), ^(){
|
||||||
|
|
||||||
|
[self invalidateIRect: updateRect];
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
[pool release];
|
[pool release];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// should be done in the main thread.
|
||||||
-(void)invalidateIRect: (iRect)updateRect
|
-(void)invalidateIRect: (iRect)updateRect
|
||||||
{
|
{
|
||||||
|
//NSLog(@"invalidateIRect");
|
||||||
|
|
||||||
NSRect rect;
|
NSRect rect;
|
||||||
|
|
||||||
if (updateRect.size.width <= 0 || updateRect.size.height <= 0) return;
|
if (updateRect.size.width <= 0 || updateRect.size.height <= 0) return;
|
||||||
@ -604,7 +573,19 @@
|
|||||||
rect.origin.x += _paddingLeft;
|
rect.origin.x += _paddingLeft;
|
||||||
rect.origin.y += _paddingTop;
|
rect.origin.y += _paddingTop;
|
||||||
|
|
||||||
[self setNeedsDisplayInRect: rect];
|
/*
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^(){
|
||||||
|
|
||||||
|
[self setNeedsDisplayInRect: rect];
|
||||||
|
|
||||||
|
//[self display];
|
||||||
|
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
[self setNeedsDisplayInRect: rect];
|
||||||
|
//[self display];
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -823,8 +804,40 @@
|
|||||||
|
|
||||||
-(void)childFinished: (ChildMonitor *)monitor
|
-(void)childFinished: (ChildMonitor *)monitor
|
||||||
{
|
{
|
||||||
|
// called from other thread.
|
||||||
|
|
||||||
NSLog(@"[process complete]");
|
NSLog(@"[process complete]");
|
||||||
// writeline "[process complete]"
|
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^(){
|
||||||
|
|
||||||
|
iRect updateRect;
|
||||||
|
|
||||||
|
[self setCursorType: Screen::CursorTypeNone];
|
||||||
|
//[self stopCursorTimer];
|
||||||
|
//_screen.setCursorType(Screen::CursorTypeNone);
|
||||||
|
|
||||||
|
_screen.beginUpdate();
|
||||||
|
|
||||||
|
_screen.setX(0);
|
||||||
|
_screen.incrementY();
|
||||||
|
|
||||||
|
for (const char *cp = "[Process completed]"; *cp; ++cp)
|
||||||
|
{
|
||||||
|
_screen.putc(*cp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
updateRect = _screen.endUpdate();
|
||||||
|
|
||||||
|
|
||||||
|
[self invalidateIRect: updateRect];
|
||||||
|
|
||||||
|
//[_emulator writeLine: @"[Process completed]"];
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -18,5 +18,6 @@
|
|||||||
|
|
||||||
-(void)adjustTitleBar;
|
-(void)adjustTitleBar;
|
||||||
|
|
||||||
|
-(void)setTitleTextColor: (NSColor *)color;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -84,11 +84,16 @@
|
|||||||
[_titleBarView setTitle: aString];
|
[_titleBarView setTitle: aString];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(void)setTitleTextColor: (NSColor *)color
|
||||||
|
{
|
||||||
|
[_titleBarView setTextColor: color];
|
||||||
|
}
|
||||||
-(void)setBackgroundColor:(NSColor *)color
|
-(void)setBackgroundColor:(NSColor *)color
|
||||||
{
|
{
|
||||||
NSLog(@"%@", color);
|
//NSLog(@"%@", color);
|
||||||
[super setBackgroundColor: color];
|
[super setBackgroundColor: color];
|
||||||
[_titleBarView setBackgroundColor: color];
|
[_titleBarView setBackgroundColor: color];
|
||||||
|
[_titleBarView setTextColor: [NSColor greenColor]];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)awakeFromNib
|
-(void)awakeFromNib
|
||||||
@ -125,6 +130,7 @@
|
|||||||
NSLog(@"%u", (int)[_titleBarView retainCount]);
|
NSLog(@"%u", (int)[_titleBarView retainCount]);
|
||||||
|
|
||||||
[_titleBarView setBackgroundColor: [NSColor blackColor]];
|
[_titleBarView setBackgroundColor: [NSColor blackColor]];
|
||||||
|
|
||||||
[_titleBarView setFrame: [themeView bounds]];
|
[_titleBarView setFrame: [themeView bounds]];
|
||||||
[_titleBarView setTitle: [self title]];
|
[_titleBarView setTitle: [self title]];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user