processData no longer const

cursor blind thread no longer killed/restarted when cursor goes invisible.

git-svn-id: svn://qnap.local/TwoTerm/trunk@3175 5590a31f-7b70-45f8-8c82-aa3a8e5f4507
This commit is contained in:
Kelvin Sherlock 2017-02-21 03:22:17 +00:00
parent 102e7a824a
commit 451e5e4bed
8 changed files with 60 additions and 59 deletions

View File

@ -309,7 +309,7 @@
return self;
}
-(void)processData:(const uint8_t *)data length: (size_t)length screen:(Screen *)screen output:(OutputChannel *)output
-(void)processData:(uint8_t *)data length: (size_t)length screen:(Screen *)screen output:(OutputChannel *)output
{
const uint8_t *eof = nullptr;

View File

@ -41,7 +41,7 @@ extern "C" unsigned EventCharacters(NSEvent *event, std::u32string &rv);
@optional
-(void)processCharacter: (uint8_t)c screen: (Screen *)screen output: (OutputChannel *)output;
-(void)processData: (const uint8_t *)data length: (size_t)length screen: (Screen *)screen output: (OutputChannel *)output;
-(void)processData: (uint8_t *)data length: (size_t)length screen: (Screen *)screen output: (OutputChannel *)output;
@required

View File

@ -455,9 +455,11 @@
return self;
}
-(void)processData:(const uint8_t *)data length: (size_t)length screen:(Screen *)screen output:(OutputChannel *)output
-(void)processData: (uint8_t *)data length: (size_t)length screen:(Screen *)screen output:(OutputChannel *)output
{
std::transform(data, data + length, data, [](uint8_t c){ return c & 0x7f; });
const uint8_t *eof = nullptr;
const uint8_t *p = data;
const uint8_t *pe = data + length;

View File

@ -525,7 +525,7 @@ static void advance(Screen *screen, gsos_context &ctx) {
}
-(void)processData:(const uint8_t *)data length: (size_t)length screen:(Screen *)screen output:(OutputChannel *)output
-(void)processData: (uint8_t *)data length: (size_t)length screen:(Screen *)screen output:(OutputChannel *)output
{
const uint8_t *eof = nullptr;

View File

@ -346,7 +346,7 @@
term->c_cc[VKILL] = CTRL('X');
}
-(void)processData:(const uint8_t *)data length: (size_t)length screen:(Screen *)screen output:(OutputChannel *)output
-(void)processData: (uint8_t *)data length: (size_t)length screen:(Screen *)screen output:(OutputChannel *)output
{
const uint8_t *eof = nullptr;

View File

@ -191,6 +191,7 @@
if (fcntl(_fd, F_GETFL, &flags) < 0) flags = 0;
fcntl(_fd, F_SETFL, flags | O_NONBLOCK);
[_emulatorView childBegan];
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);

View File

@ -63,7 +63,7 @@ private:
CGFloat _paddingLeft;
CGFloat _paddingRight;
NSImage *_cursorImg;
//NSImage *_cursorImg;
NSTimer *_cursorTimer;
BOOL _cursorOn;
@ -73,6 +73,7 @@ private:
unsigned _cursorType;
NSImage *_cursors[4];
#ifdef __cplusplus
ring_buffer<1024> _debug_buffer;
@ -106,8 +107,9 @@ private:
-(IBAction)clearDebugData:(id)sender;
-(void)processData: (const uint8_t *)data size: (size_t)size;
-(void)processData: (uint8_t *)data size: (size_t)size;
-(void)childFinished: (int)status;
-(void)childBegan;
@end

View File

@ -14,8 +14,8 @@
#import "CharacterGenerator.h"
#import "VT52.h"
#import "VT100.h"
//#import "VT52.h"
//#import "VT100.h"
#include "OutputChannel.h"
@ -43,13 +43,6 @@
repeats: YES ];
[[NSRunLoop currentRunLoop] addTimer: _cursorTimer forMode: NSDefaultRunLoopMode];
/*
_cursorTimer = [[NSTimer scheduledTimerWithTimeInterval: .5
target: self
selector: @selector(cursorTimer:)
userInfo: nil
repeats: YES] retain];
*/
}
else
{
@ -64,6 +57,9 @@
[_cursorTimer invalidate];
[_cursorTimer release];
_cursorTimer = nil;
iRect r(_screen.cursor(), iSize(1,1));
[self invalidateIRect: r];
}
else
{
@ -74,6 +70,7 @@
-(void)cursorTimer: (NSTimer *)timer
{
if (_cursorType == Screen::CursorTypeNone) return;
_screen.lock();
@ -90,17 +87,19 @@
{
if (_cursorType == cursorType) return;
_cursorOn = NO;
_cursorType = cursorType;
iRect r(_screen.cursor(), iSize(1,1));
[self invalidateIRect: r];
}
-(unsigned)cursorType
{
return _cursorType;
}
#if 0
dispatch_async(dispatch_get_main_queue(), ^(){
// todo -- set the cursor image...
if (_cursorType == cursorType) return;
if (cursorType == Screen::CursorTypeNone)
{
[self stopCursorTimer];
}
else
{
unsigned char c;
switch (cursorType) {
default:
@ -109,21 +108,17 @@
case Screen::CursorTypeBlock: c = 0x80; break;
}
[_cursorImg release];
_cursorType = cursorType;
_cursorImg = [[_charGen imageForCharacter: c] retain];
[self startCursorTimer];
}
iRect r(_screen.cursor(), iSize(1,1));
[self invalidateIRect: r];
});
#endif
iRect r(_screen.cursor(), iSize(1,1));
[self invalidateIRect: r];
}
-(unsigned)cursorType
{
return _cursorType;
}
@end
@ -180,9 +175,14 @@
_charGen = [[CharacterGenerator generator] retain];
_cursorImg = [[_charGen imageForCharacter: '_'] retain];
_cursorType = Screen::CursorTypeUnderscore;
_cursors[Screen::CursorTypeNone] = nil;
_cursors[Screen::CursorTypeUnderscore] = [[_charGen imageForCharacter: '_'] retain];
_cursors[Screen::CursorTypePipe] = [[_charGen imageForCharacter: '|'] retain];
_cursors[Screen::CursorTypeBlock] = [[_charGen imageForCharacter: 0x80] retain];
size = [_charGen characterSize];
_charWidth = size.width;
_charHeight = size.height;
@ -441,14 +441,15 @@
[_foregroundColor setFill];
NSImage *img = _cursors[_cursorType];
NSCompositingOperation op = NSCompositingOperationCopy;
//if (_cursorType == Screen::CursorTypeBlock) op = NSCompositingOperationXOR;
[_cursorImg drawInRect: charRect
fromRect: NSZeroRect
operation: op
fraction: 1.0
respectFlipped: YES
hints: nil];
[img drawInRect: charRect
fromRect: NSZeroRect
operation: op
fraction: 1.0
respectFlipped: YES
hints: nil];
}
@ -473,8 +474,8 @@
[_emulator release];
[_cursorImg release];
//[_cursorImg release];
for (int i = 0; i < 4; ++i) [_cursors[i] release];
[super dealloc];
}
@ -520,6 +521,9 @@
channel.write([data bytes], length);
}
-(void)childBegan {
//[self startCursorTimer];
}
-(void)childFinished:(int)status {
@ -532,7 +536,7 @@
iRect updateRect;
[self setCursorType: Screen::CursorTypeNone];
//[self stopCursorTimer];
[self stopCursorTimer];
//_screen.setCursorType(Screen::CursorTypeNone);
#if 0
@ -610,7 +614,7 @@
[pb setData: [NSData dataWithBytes: rv.data() length: rv.length()] forType: NSStringPboardType];
}
-(void)processData:(const uint8_t *)buffer size:(size_t)size {
-(void)processData: (uint8_t *)buffer size:(size_t)size {
typedef void (*ProcessCharFX)(id, SEL, uint8_t, Screen *, OutputChannel *);
@ -618,14 +622,6 @@
iRect updateRect;
#if 0
FILE *debug = fopen("/tmp/debug.txt", "a");
fwrite(buffer, 1, size, debug);
fflush(debug);
fclose(debug);
#endif
_debug_buffer.write(buffer, size);
if ([_emulator respondsToSelector: @selector(processData:length:screen:output:)]) {