mirror of
https://github.com/gnustep/apps-projectcenter.git
synced 2025-02-15 08:00:56 +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>
|
2021-08-18 Riccardo Mottola <rm@gnu.org>
|
||||||
|
|
||||||
* Modules/Editors/ProjectCenter/PCEditor.m
|
* Modules/Editors/ProjectCenter/PCEditor.m
|
||||||
|
|
|
@ -85,6 +85,9 @@
|
||||||
// of this method.
|
// of this method.
|
||||||
BOOL editorTextViewIsPressingKey;
|
BOOL editorTextViewIsPressingKey;
|
||||||
|
|
||||||
|
// Slightly delay drawing of highlit parentheses
|
||||||
|
NSTimer *phlTimer;
|
||||||
|
|
||||||
// keep one undo manager for the editor
|
// keep one undo manager for the editor
|
||||||
NSUndoManager *undoManager;
|
NSUndoManager *undoManager;
|
||||||
}
|
}
|
||||||
|
|
|
@ -962,12 +962,6 @@ willChangeSelectionFromCharacterRange:(NSRange)oldSelectedCharRange
|
||||||
|
|
||||||
object = [notification object];
|
object = [notification object];
|
||||||
|
|
||||||
if (editorTextViewIsPressingKey == NO)
|
|
||||||
{
|
|
||||||
if (object == _intEditorView || object == _extEditorView)
|
|
||||||
[self computeNewParenthesisNesting: object];
|
|
||||||
}
|
|
||||||
|
|
||||||
NSLog(@"textViewDidChangeSelection");
|
NSLog(@"textViewDidChangeSelection");
|
||||||
// calculate current line
|
// calculate current line
|
||||||
if ([object isKindOfClass:[NSTextView class]])
|
if ([object isKindOfClass:[NSTextView class]])
|
||||||
|
@ -1009,7 +1003,6 @@ willChangeSelectionFromCharacterRange:(NSRange)oldSelectedCharRange
|
||||||
- (void)editorTextViewWillPressKey:sender
|
- (void)editorTextViewWillPressKey:sender
|
||||||
{
|
{
|
||||||
editorTextViewIsPressingKey = YES;
|
editorTextViewIsPressingKey = YES;
|
||||||
// NSLog(@"Will pressing key");
|
|
||||||
|
|
||||||
if (sender == _intEditorView || sender == _extEditorView)
|
if (sender == _intEditorView || sender == _extEditorView)
|
||||||
[self unhighlightCharacter: sender];
|
[self unhighlightCharacter: sender];
|
||||||
|
@ -1019,9 +1012,20 @@ willChangeSelectionFromCharacterRange:(NSRange)oldSelectedCharRange
|
||||||
|
|
||||||
- (void)editorTextViewDidPressKey:sender
|
- (void)editorTextViewDidPressKey:sender
|
||||||
{
|
{
|
||||||
// NSLog(@"Did pressing key");
|
|
||||||
if (sender == _intEditorView || sender == _extEditorView)
|
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
|
else
|
||||||
NSLog(@"PCEditor: unexpected sender");
|
NSLog(@"PCEditor: unexpected sender");
|
||||||
|
|
||||||
|
@ -1408,6 +1412,12 @@ NSUInteger FindDelimiterInString(NSString * string,
|
||||||
[textStorage endEditing];
|
[textStorage endEditing];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)computeNewParenthesisNestingFromTimer:(NSTimer *)timer
|
||||||
|
{
|
||||||
|
phlTimer = nil;
|
||||||
|
[self computeNewParenthesisNesting:[timer userInfo]];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)computeNewParenthesisNesting: (NSTextView *)editorView
|
- (void)computeNewParenthesisNesting: (NSTextView *)editorView
|
||||||
{
|
{
|
||||||
NSRange selectedRange;
|
NSRange selectedRange;
|
||||||
|
|
Loading…
Reference in a new issue