mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 00:00:48 +00:00
* Source/NSTextView.m:
(drawRect:): Draw insertion point using _drawInsertionPointNow ivar. Cleanup code. (_blink:): Enable disabled insertion point blinking code. (updateInsertionPointStateAndRestartTimer:): Implement insertion point blinking. Removed TODO. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@24594 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7a6fe148b3
commit
3e37eb722a
1 changed files with 26 additions and 44 deletions
|
@ -3347,31 +3347,14 @@ Figure out how the additional layout stuff is supposed to work.
|
||||||
{
|
{
|
||||||
[self drawInsertionPointInRect: _insertionPointRect
|
[self drawInsertionPointInRect: _insertionPointRect
|
||||||
color: _insertionPointColor
|
color: _insertionPointColor
|
||||||
turnedOn: YES];
|
turnedOn: _drawInsertionPointNow];
|
||||||
}
|
}
|
||||||
#if 0 /* TODO: insertion point */
|
|
||||||
unsigned location = _layoutManager->_selected_range.location;
|
|
||||||
|
|
||||||
if (NSLocationInRange (location, drawnRange)
|
|
||||||
|| location == NSMaxRange (drawnRange))
|
|
||||||
{
|
|
||||||
if (_drawInsertionPointNow && viewIsPrinting != self)
|
|
||||||
{
|
|
||||||
[self drawInsertionPointInRect: _insertionPointRect
|
|
||||||
color: _insertionPointColor
|
|
||||||
turnedOn: YES];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void) updateInsertionPointStateAndRestartTimer: (BOOL)restartFlag
|
- (void) updateInsertionPointStateAndRestartTimer: (BOOL)restartFlag
|
||||||
{
|
{
|
||||||
/* TODO: this is a basic stopgap implementation; should work fine, but no
|
|
||||||
blinking. need to do a proper one once I know how */
|
|
||||||
|
|
||||||
NSRect new;
|
NSRect new;
|
||||||
|
|
||||||
if (!_layoutManager)
|
if (!_layoutManager)
|
||||||
|
@ -3404,19 +3387,19 @@ Figure out how the additional layout stuff is supposed to work.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!NSEqualRects(new, _insertionPointRect))
|
// Don't draw insertion point if there's no need
|
||||||
|
if (![self shouldDrawInsertionPoint] && !_drawInsertionPointNow)
|
||||||
{
|
{
|
||||||
[self setNeedsDisplayInRect: _insertionPointRect];
|
return;
|
||||||
_insertionPointRect = new;
|
|
||||||
[self setNeedsDisplayInRect: _insertionPointRect];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 /* TODO: old code for insertion point blinking. might be useful */
|
|
||||||
if (restartFlag)
|
if (restartFlag)
|
||||||
{
|
{
|
||||||
/* Start blinking timer if not yet started */
|
/* Start blinking timer if not yet started */
|
||||||
if (_insertionPointTimer == nil && [self shouldDrawInsertionPoint])
|
if (_insertionPointTimer == nil && [self shouldDrawInsertionPoint])
|
||||||
{
|
{
|
||||||
|
// NSLog(@"Start timer");
|
||||||
|
_insertionPointRect = new;
|
||||||
_insertionPointTimer = [NSTimer scheduledTimerWithTimeInterval: 0.5
|
_insertionPointTimer = [NSTimer scheduledTimerWithTimeInterval: 0.5
|
||||||
target: self
|
target: self
|
||||||
selector: @selector(_blink:)
|
selector: @selector(_blink:)
|
||||||
|
@ -3426,17 +3409,15 @@ Figure out how the additional layout stuff is supposed to work.
|
||||||
}
|
}
|
||||||
else if (_insertionPointTimer != nil)
|
else if (_insertionPointTimer != nil)
|
||||||
{
|
{
|
||||||
[_insertionPointTimer invalidate];
|
if (!NSEqualRects(new, _insertionPointRect))
|
||||||
DESTROY (_insertionPointTimer);
|
{
|
||||||
[self setNeedsDisplayInRect: oldInsertionPointRect
|
_drawInsertionPointNow = NO;
|
||||||
avoidAdditionalLayout: YES];
|
[self setNeedsDisplayInRect: _insertionPointRect
|
||||||
_insertionPointTimer = [NSTimer scheduledTimerWithTimeInterval: 0.5
|
avoidAdditionalLayout: YES];
|
||||||
target: self
|
_insertionPointRect = new;
|
||||||
selector: @selector(_blink:)
|
}
|
||||||
userInfo: nil
|
|
||||||
repeats: YES];
|
|
||||||
RETAIN (_insertionPointTimer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ok - blinking has just been turned on. Make sure we start
|
/* Ok - blinking has just been turned on. Make sure we start
|
||||||
* the on/off/on/off blinking from the 'on', because in that way
|
* the on/off/on/off blinking from the 'on', because in that way
|
||||||
* the user can see where the insertion point is as soon as
|
* the user can see where the insertion point is as soon as
|
||||||
|
@ -3446,18 +3427,21 @@ Figure out how the additional layout stuff is supposed to work.
|
||||||
[self setNeedsDisplayInRect: _insertionPointRect
|
[self setNeedsDisplayInRect: _insertionPointRect
|
||||||
avoidAdditionalLayout: YES];
|
avoidAdditionalLayout: YES];
|
||||||
}
|
}
|
||||||
else
|
else if ([self shouldDrawInsertionPoint] && (_insertionPointTimer != nil))
|
||||||
{
|
{
|
||||||
if (_insertionPointTimer != nil)
|
// restartFlag is set to NO when control resigns first responder status
|
||||||
{
|
// or window resings key window status. So we invalidate timer to
|
||||||
[self setNeedsDisplayInRect: oldInsertionPointRect
|
// avoid extra method calls
|
||||||
avoidAdditionalLayout: YES];
|
// NSLog(@"Stop timer");
|
||||||
[_insertionPointTimer invalidate];
|
[_insertionPointTimer invalidate];
|
||||||
DESTROY (_insertionPointTimer);
|
DESTROY (_insertionPointTimer);
|
||||||
|
|
||||||
}
|
_drawInsertionPointNow = NO;
|
||||||
|
[self setNeedsDisplayInRect: _insertionPointRect
|
||||||
|
avoidAdditionalLayout: YES];
|
||||||
|
|
||||||
|
_insertionPointRect = new;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
[self _updateInputMethodWithInsertionPoint: _insertionPointRect.origin];
|
[self _updateInputMethodWithInsertionPoint: _insertionPointRect.origin];
|
||||||
}
|
}
|
||||||
|
@ -4693,7 +4677,6 @@ configuation! */
|
||||||
|
|
||||||
- (void) _blink: (NSTimer *)t
|
- (void) _blink: (NSTimer *)t
|
||||||
{
|
{
|
||||||
#if 0 /* TODO: insertion point */
|
|
||||||
if (_drawInsertionPointNow)
|
if (_drawInsertionPointNow)
|
||||||
{
|
{
|
||||||
_drawInsertionPointNow = NO;
|
_drawInsertionPointNow = NO;
|
||||||
|
@ -4709,7 +4692,6 @@ configuation! */
|
||||||
event processing in the gui runloop, we need to manually update
|
event processing in the gui runloop, we need to manually update
|
||||||
the window. */
|
the window. */
|
||||||
[self displayIfNeeded];
|
[self displayIfNeeded];
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue