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:
Kelvin Sherlock 2016-07-06 19:12:51 +00:00
parent 3efa5f6b2a
commit edee5557b3
4 changed files with 11 additions and 125 deletions

View File

@ -11,7 +11,6 @@
@class EmulatorView;
@class CurveView;
@class ChildMonitor;
@protocol Emulator;
@ -26,8 +25,6 @@
NSObject <Emulator> *_emulator;
ChildMonitor *_childMonitor;
int _child;
int _fd;
@ -40,8 +37,6 @@
@property (nonatomic, retain) NSDictionary *parameters;
@property (nonatomic, retain) IBOutlet ChildMonitor *childMonitor;
@property (nonatomic, retain) IBOutlet EmulatorView *emulatorView;
@property (nonatomic, retain) IBOutlet CurveView *curveView;

View File

@ -35,9 +35,6 @@
@synthesize parameters = _parameters;
@synthesize childMonitor = _childMonitor;
+(id)new
{
return [[self alloc] initWithWindowNibName: @"TermWindow"];
@ -45,9 +42,6 @@
-(void)dealloc
{
[_childMonitor release];
[_emulator release];
[_emulatorView release];
[_curveView release];
@ -224,7 +218,7 @@
dispatch_source_set_event_handler(_read_source, ^{
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;

View File

@ -88,7 +88,6 @@ private:
//@property (nonatomic, assign) iPoint cursor;
-(void)dataAvailable;
-(void)invalidateIRect: (iRect)rect;
//-(void)resizeTo: (iSize)size;

View File

@ -154,6 +154,7 @@
_paddingLeft = 8;
_paddingTop = 24;
_paddingBottom = 8;
//_foregroundColor = [[NSColor greenColor] retain];
@ -542,6 +543,13 @@
cmd = @selector(processCharacter: screen: output:);
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;
pool = [NSAutoreleasePool new];
_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.
-(void)invalidateIRect: (iRect)updateRect
@ -676,7 +622,7 @@
// TODO -- left/right padding...
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.
if (NSEqualSizes(newSize, bounds.size)) return;
@ -744,7 +690,7 @@
// user is resizing window.
// or zoom.
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.setSize(width, height, false);
@ -884,55 +830,7 @@
@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)