mirror of
https://github.com/ksherlock/TwoTerm.git
synced 2025-02-02 18:33:25 +00:00
move cursor timer to category.
git-svn-id: svn://qnap.local/TwoTerm/trunk@2022 5590a31f-7b70-45f8-8c82-aa3a8e5f4507
This commit is contained in:
parent
75e06ed81f
commit
01d1a214c1
@ -72,6 +72,7 @@ private:
|
||||
BOOL _scanLines;
|
||||
BOOL _inResizeTo;
|
||||
|
||||
unsigned _cursorType;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@ -82,6 +83,7 @@ private:
|
||||
|
||||
@property (nonatomic, assign) BOOL scanLines;
|
||||
@property (nonatomic, assign) int fd;
|
||||
@property (nonatomic, assign) unsigned cursorType;
|
||||
|
||||
@property (nonatomic, retain) NSColor *foregroundColor;
|
||||
@property (nonatomic, retain) NSColor *backgroundColor;
|
||||
@ -96,9 +98,6 @@ private:
|
||||
//-(void)resizeTo: (iSize)size;
|
||||
-(void)resizeTo: (iSize)size animated: (BOOL)animated;
|
||||
|
||||
-(void)cursorTimer: (NSTimer *)timer;
|
||||
|
||||
-(void)setCursorType: (unsigned)cursorType;
|
||||
|
||||
|
||||
-(void)autoTypeText: (NSString *)text;
|
||||
@ -112,4 +111,14 @@ private:
|
||||
|
||||
@interface EmulatorView (ChildMonitor) <ChildMonitorDelegate>
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface EmulatorView (Cursor)
|
||||
|
||||
-(void)stopCursorTimer;
|
||||
-(void)cursorTimer: (NSTimer *)timer;
|
||||
-(void)startCursorTimer;
|
||||
|
||||
|
||||
@end
|
@ -22,9 +22,106 @@
|
||||
|
||||
#import "ScanLineFilter.h"
|
||||
|
||||
|
||||
@implementation EmulatorView (Cursor)
|
||||
|
||||
-(void)startCursorTimer
|
||||
{
|
||||
// timers must be added/removed from the same thread.
|
||||
|
||||
if (_cursorTimer) return;
|
||||
|
||||
if ([NSThread isMainThread])
|
||||
{
|
||||
|
||||
_cursorOn = NO;
|
||||
_cursorTimer = [[NSTimer alloc] initWithFireDate: [NSDate date]
|
||||
interval: 0.5
|
||||
target: self
|
||||
selector: @selector(cursorTimer:)
|
||||
userInfo: nil
|
||||
repeats: YES ];
|
||||
[[NSRunLoop currentRunLoop] addTimer: _cursorTimer forMode: NSDefaultRunLoopMode];
|
||||
|
||||
/*
|
||||
_cursorTimer = [[NSTimer scheduledTimerWithTimeInterval: .5
|
||||
target: self
|
||||
selector: @selector(cursorTimer:)
|
||||
userInfo: nil
|
||||
repeats: YES] retain];
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
[self performSelectorOnMainThread: _cmd withObject: nil waitUntilDone: NO];
|
||||
}
|
||||
}
|
||||
|
||||
-(void)stopCursorTimer
|
||||
{
|
||||
if ([NSThread isMainThread])
|
||||
{
|
||||
[_cursorTimer invalidate];
|
||||
[_cursorTimer release];
|
||||
_cursorTimer = nil;
|
||||
}
|
||||
else
|
||||
{
|
||||
[self performSelectorOnMainThread: _cmd withObject: nil waitUntilDone: NO];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-(void)cursorTimer: (NSTimer *)timer
|
||||
{
|
||||
|
||||
_screen.lock();
|
||||
|
||||
_cursorOn = !_cursorOn;
|
||||
|
||||
iRect r(_screen.cursor(), iSize(1,1));
|
||||
|
||||
[self invalidateIRect: r];
|
||||
|
||||
_screen.unlock();
|
||||
}
|
||||
|
||||
-(void)setCursorType: (unsigned)cursorType
|
||||
{
|
||||
if (_cursorType == cursorType) return;
|
||||
|
||||
_cursorOn = NO;
|
||||
_cursorType = cursorType;
|
||||
|
||||
// todo -- set the cursor image...
|
||||
|
||||
if (cursorType == Screen::CursorTypeNone)
|
||||
{
|
||||
[self stopCursorTimer];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self startCursorTimer];
|
||||
}
|
||||
|
||||
|
||||
iRect r(_screen.cursor(), iSize(1,1));
|
||||
|
||||
[self invalidateIRect: r];
|
||||
}
|
||||
|
||||
-(unsigned)cursorType
|
||||
{
|
||||
return _cursorType;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation EmulatorView
|
||||
|
||||
@synthesize fd = _fd;
|
||||
//@synthesize cursorType = _cursorType;
|
||||
|
||||
@synthesize emulator = _emulator;
|
||||
|
||||
@synthesize foregroundColor = _foregroundColor;
|
||||
@ -542,19 +639,6 @@
|
||||
|
||||
|
||||
|
||||
-(void)cursorTimer: (NSTimer *)timer
|
||||
{
|
||||
|
||||
_screen.lock();
|
||||
|
||||
_cursorOn = !_cursorOn;
|
||||
|
||||
iRect r(_screen.cursor(), iSize(1,1));
|
||||
|
||||
[self invalidateIRect: r];
|
||||
|
||||
_screen.unlock();
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user