mirror of
https://github.com/gnustep/apps-projectcenter.git
synced 2025-02-14 15:41:34 +00:00
Do not send double computeNewParenthesisNesting: on key pressed.
Furthermore, use a timer so that in case of rapid re-computing it gets invalidated before and only calculated at the last event.
This commit is contained in:
parent
01a3a61b2e
commit
4216c13cda
3 changed files with 29 additions and 9 deletions
|
@ -1,3 +1,10 @@
|
|||
2021-11-26 Riccardo Mottola <rm@gnu.org>
|
||||
|
||||
* Modules/Editors/ProjectCenter/PCEditor.m
|
||||
Do not send double computeNewParenthesisNesting: on key pressed.
|
||||
Furthermore, use a timer so that in case of rapid re-computing
|
||||
it gets invalidated before and only calculated at the last event.
|
||||
|
||||
2021-08-18 Riccardo Mottola <rm@gnu.org>
|
||||
|
||||
* Modules/Editors/ProjectCenter/PCEditor.m
|
||||
|
|
|
@ -85,6 +85,9 @@
|
|||
// of this method.
|
||||
BOOL editorTextViewIsPressingKey;
|
||||
|
||||
// Slightly delay drawing of highlit parentheses
|
||||
NSTimer *phlTimer;
|
||||
|
||||
// keep one undo manager for the editor
|
||||
NSUndoManager *undoManager;
|
||||
}
|
||||
|
|
|
@ -962,12 +962,6 @@ willChangeSelectionFromCharacterRange:(NSRange)oldSelectedCharRange
|
|||
|
||||
object = [notification object];
|
||||
|
||||
if (editorTextViewIsPressingKey == NO)
|
||||
{
|
||||
if (object == _intEditorView || object == _extEditorView)
|
||||
[self computeNewParenthesisNesting: object];
|
||||
}
|
||||
|
||||
NSLog(@"textViewDidChangeSelection");
|
||||
// calculate current line
|
||||
if ([object isKindOfClass:[NSTextView class]])
|
||||
|
@ -1009,7 +1003,6 @@ willChangeSelectionFromCharacterRange:(NSRange)oldSelectedCharRange
|
|||
- (void)editorTextViewWillPressKey:sender
|
||||
{
|
||||
editorTextViewIsPressingKey = YES;
|
||||
// NSLog(@"Will pressing key");
|
||||
|
||||
if (sender == _intEditorView || sender == _extEditorView)
|
||||
[self unhighlightCharacter: sender];
|
||||
|
@ -1019,9 +1012,20 @@ willChangeSelectionFromCharacterRange:(NSRange)oldSelectedCharRange
|
|||
|
||||
- (void)editorTextViewDidPressKey:sender
|
||||
{
|
||||
// NSLog(@"Did pressing key");
|
||||
if (sender == _intEditorView || sender == _extEditorView)
|
||||
[self computeNewParenthesisNesting: sender];
|
||||
{
|
||||
if (nil != phlTimer)
|
||||
{
|
||||
[phlTimer invalidate];
|
||||
phlTimer = nil;
|
||||
}
|
||||
|
||||
phlTimer = [NSTimer scheduledTimerWithTimeInterval:0.1
|
||||
target:self
|
||||
selector:@selector(computeNewParenthesisNestingFromTimer:)
|
||||
userInfo:sender
|
||||
repeats:NO];
|
||||
}
|
||||
else
|
||||
NSLog(@"PCEditor: unexpected sender");
|
||||
|
||||
|
@ -1408,6 +1412,12 @@ NSUInteger FindDelimiterInString(NSString * string,
|
|||
[textStorage endEditing];
|
||||
}
|
||||
|
||||
- (void)computeNewParenthesisNestingFromTimer:(NSTimer *)timer
|
||||
{
|
||||
phlTimer = nil;
|
||||
[self computeNewParenthesisNesting:[timer userInfo]];
|
||||
}
|
||||
|
||||
- (void)computeNewParenthesisNesting: (NSTextView *)editorView
|
||||
{
|
||||
NSRange selectedRange;
|
||||
|
|
Loading…
Reference in a new issue