mirror of
https://github.com/ksherlock/TwoTerm.git
synced 2025-02-11 04:30:53 +00:00
remove dead code, fix window bottom margin.
git-svn-id: svn://qnap.local/TwoTerm/trunk@3110 5590a31f-7b70-45f8-8c82-aa3a8e5f4507
This commit is contained in:
parent
3efa5f6b2a
commit
edee5557b3
@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
@class EmulatorView;
|
@class EmulatorView;
|
||||||
@class CurveView;
|
@class CurveView;
|
||||||
@class ChildMonitor;
|
|
||||||
|
|
||||||
@protocol Emulator;
|
@protocol Emulator;
|
||||||
|
|
||||||
@ -26,8 +25,6 @@
|
|||||||
|
|
||||||
NSObject <Emulator> *_emulator;
|
NSObject <Emulator> *_emulator;
|
||||||
|
|
||||||
ChildMonitor *_childMonitor;
|
|
||||||
|
|
||||||
int _child;
|
int _child;
|
||||||
|
|
||||||
int _fd;
|
int _fd;
|
||||||
@ -40,8 +37,6 @@
|
|||||||
|
|
||||||
@property (nonatomic, retain) NSDictionary *parameters;
|
@property (nonatomic, retain) NSDictionary *parameters;
|
||||||
|
|
||||||
@property (nonatomic, retain) IBOutlet ChildMonitor *childMonitor;
|
|
||||||
|
|
||||||
@property (nonatomic, retain) IBOutlet EmulatorView *emulatorView;
|
@property (nonatomic, retain) IBOutlet EmulatorView *emulatorView;
|
||||||
@property (nonatomic, retain) IBOutlet CurveView *curveView;
|
@property (nonatomic, retain) IBOutlet CurveView *curveView;
|
||||||
|
|
||||||
|
@ -35,9 +35,6 @@
|
|||||||
|
|
||||||
@synthesize parameters = _parameters;
|
@synthesize parameters = _parameters;
|
||||||
|
|
||||||
@synthesize childMonitor = _childMonitor;
|
|
||||||
|
|
||||||
|
|
||||||
+(id)new
|
+(id)new
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithWindowNibName: @"TermWindow"];
|
return [[self alloc] initWithWindowNibName: @"TermWindow"];
|
||||||
@ -45,9 +42,6 @@
|
|||||||
|
|
||||||
-(void)dealloc
|
-(void)dealloc
|
||||||
{
|
{
|
||||||
|
|
||||||
[_childMonitor release];
|
|
||||||
|
|
||||||
[_emulator release];
|
[_emulator release];
|
||||||
[_emulatorView release];
|
[_emulatorView release];
|
||||||
[_curveView release];
|
[_curveView release];
|
||||||
@ -224,7 +218,7 @@
|
|||||||
dispatch_source_set_event_handler(_read_source, ^{
|
dispatch_source_set_event_handler(_read_source, ^{
|
||||||
|
|
||||||
static uint8_t sbuffer[1024];
|
static uint8_t sbuffer[1024];
|
||||||
size_t estimated = dispatch_source_get_data(_read_source) + 1;
|
size_t estimated = dispatch_source_get_data(_read_source);
|
||||||
|
|
||||||
|
|
||||||
uint8_t *buffer = estimated > sizeof(sbuffer) ? (uint8_t *)malloc(estimated) : sbuffer;
|
uint8_t *buffer = estimated > sizeof(sbuffer) ? (uint8_t *)malloc(estimated) : sbuffer;
|
||||||
|
@ -88,7 +88,6 @@ private:
|
|||||||
|
|
||||||
//@property (nonatomic, assign) iPoint cursor;
|
//@property (nonatomic, assign) iPoint cursor;
|
||||||
|
|
||||||
-(void)dataAvailable;
|
|
||||||
-(void)invalidateIRect: (iRect)rect;
|
-(void)invalidateIRect: (iRect)rect;
|
||||||
|
|
||||||
//-(void)resizeTo: (iSize)size;
|
//-(void)resizeTo: (iSize)size;
|
||||||
|
@ -154,6 +154,7 @@
|
|||||||
|
|
||||||
_paddingLeft = 8;
|
_paddingLeft = 8;
|
||||||
_paddingTop = 24;
|
_paddingTop = 24;
|
||||||
|
_paddingBottom = 8;
|
||||||
|
|
||||||
|
|
||||||
//_foregroundColor = [[NSColor greenColor] retain];
|
//_foregroundColor = [[NSColor greenColor] retain];
|
||||||
@ -542,6 +543,13 @@
|
|||||||
cmd = @selector(processCharacter: screen: output:);
|
cmd = @selector(processCharacter: screen: output:);
|
||||||
fx = (ProcessCharFX)[_emulator methodForSelector: cmd];
|
fx = (ProcessCharFX)[_emulator methodForSelector: cmd];
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
FILE *debug = fopen("/tmp/debug.txt", "a");
|
||||||
|
fwrite(buffer, 1, size, debug);
|
||||||
|
fflush(debug);
|
||||||
|
fclose(debug);
|
||||||
|
#endif
|
||||||
|
|
||||||
NSAutoreleasePool *pool;
|
NSAutoreleasePool *pool;
|
||||||
pool = [NSAutoreleasePool new];
|
pool = [NSAutoreleasePool new];
|
||||||
_screen.beginUpdate();
|
_screen.beginUpdate();
|
||||||
@ -564,68 +572,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
-(void)dataAvailable
|
|
||||||
{
|
|
||||||
|
|
||||||
//NSLog(@"data available");
|
|
||||||
|
|
||||||
typedef void (*ProcessCharFX)(id, SEL, uint8_t, Screen *, OutputChannel *);
|
|
||||||
|
|
||||||
ProcessCharFX fx;
|
|
||||||
SEL cmd;
|
|
||||||
OutputChannel channel(_fd);
|
|
||||||
|
|
||||||
cmd = @selector(processCharacter: screen: output:);
|
|
||||||
fx = (ProcessCharFX)[_emulator methodForSelector: cmd];
|
|
||||||
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
NSAutoreleasePool *pool;
|
|
||||||
iRect updateRect;
|
|
||||||
uint8_t buffer[512];
|
|
||||||
ssize_t size;
|
|
||||||
|
|
||||||
|
|
||||||
// this should be a non-blocking read.
|
|
||||||
size = read(_fd, buffer, sizeof(buffer));
|
|
||||||
|
|
||||||
if (size == 0) break;
|
|
||||||
if (size < 0)
|
|
||||||
{
|
|
||||||
if (errno == EAGAIN) break; // non-blocking, no data available.
|
|
||||||
if (errno == EINTR || errno == EAGAIN) continue;
|
|
||||||
|
|
||||||
perror("[EmulatorView dataAvailable]");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
FILE *debug = fopen("/tmp/debug.txt", "a");
|
|
||||||
fwrite(buffer, 1, size, debug);
|
|
||||||
fflush(debug);
|
|
||||||
fclose(debug);
|
|
||||||
#endif
|
|
||||||
pool = [NSAutoreleasePool new];
|
|
||||||
_screen.beginUpdate();
|
|
||||||
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < size; ++i)
|
|
||||||
{
|
|
||||||
fx(_emulator,cmd, buffer[i], &_screen, &channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
updateRect = _screen.endUpdate();
|
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^(){
|
|
||||||
|
|
||||||
[self invalidateIRect: updateRect];
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
[pool release];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// should be done in the main thread.
|
// should be done in the main thread.
|
||||||
-(void)invalidateIRect: (iRect)updateRect
|
-(void)invalidateIRect: (iRect)updateRect
|
||||||
@ -676,7 +622,7 @@
|
|||||||
|
|
||||||
// TODO -- left/right padding...
|
// TODO -- left/right padding...
|
||||||
newSize.width = size.width * _charWidth + _paddingLeft * 2;
|
newSize.width = size.width * _charWidth + _paddingLeft * 2;
|
||||||
newSize.height = size.height * _charHeight + _paddingTop * 2;
|
newSize.height = size.height * _charHeight + _paddingTop + _paddingBottom;
|
||||||
|
|
||||||
// best case -- no change.
|
// best case -- no change.
|
||||||
if (NSEqualSizes(newSize, bounds.size)) return;
|
if (NSEqualSizes(newSize, bounds.size)) return;
|
||||||
@ -744,7 +690,7 @@
|
|||||||
// user is resizing window.
|
// user is resizing window.
|
||||||
// or zoom.
|
// or zoom.
|
||||||
unsigned width = floor((frameRect.size.width - _paddingLeft * 2) / _charWidth);
|
unsigned width = floor((frameRect.size.width - _paddingLeft * 2) / _charWidth);
|
||||||
unsigned height = floor((frameRect.size.height - _paddingTop * 2) / _charHeight);
|
unsigned height = floor((frameRect.size.height - _paddingTop - _paddingBottom) / _charHeight);
|
||||||
|
|
||||||
_screen.lock();
|
_screen.lock();
|
||||||
_screen.setSize(width, height, false);
|
_screen.setSize(width, height, false);
|
||||||
@ -884,55 +830,7 @@
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
@implementation EmulatorView (ChildMonitor)
|
|
||||||
|
|
||||||
-(void)childDataAvailable: (ChildMonitor *)monitor
|
|
||||||
{
|
|
||||||
// this is called from a separate thread.
|
|
||||||
[self dataAvailable];
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)childFinished: (ChildMonitor *)monitor
|
|
||||||
{
|
|
||||||
// called from other thread.
|
|
||||||
|
|
||||||
NSLog(@"[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
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
void ViewScreen::setSize(unsigned width, unsigned height)
|
void ViewScreen::setSize(unsigned width, unsigned height)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user