Skip to content

Commit

Permalink
Disable undo/redo and cut on 3f menu
Browse files Browse the repository at this point in the history
  • Loading branch information
yury committed Sep 30, 2019
1 parent 2cb506d commit 9502767
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
3 changes: 3 additions & 0 deletions Blink/TermInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@

@interface UndoManager: NSUndoManager
@property (weak) id<UndoManagerDelegate> undoManagerDelegate;

- (void)skipNext;

@end

@interface TermInput : UITextView
Expand Down
38 changes: 25 additions & 13 deletions Blink/TermInput.m
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,17 @@ + (NSString *)FKEY:(NSInteger)number
@end


@implementation UndoManager
- (BOOL)canRedo
{
return YES;
@implementation UndoManager {
NSTimeInterval _startSkip;
}

- (BOOL)canUndo
{
return YES;

- (BOOL)canRedo {
return [self _canOperate];
}

- (BOOL)canUndo {
return [self _canOperate];
}

-(void)undo
Expand All @@ -214,6 +216,14 @@ - (void)redo
[_undoManagerDelegate redoWithManager:self];
}

- (void)skipNext {
_startSkip = [NSDate timeIntervalSinceReferenceDate];
}

- (BOOL)_canOperate {
return [NSDate timeIntervalSinceReferenceDate] - _startSkip > 0.5;
}

@end

@interface TermInput () <UndoManagerDelegate, UITextViewDelegate, NSTextStorageDelegate>
Expand Down Expand Up @@ -327,9 +337,8 @@ - (BOOL)hasText {
return YES;
}

- (NSUndoManager *)undoManager
{
return _cmdModifierSequence ? _undoManager : [super undoManager];
- (NSUndoManager *)undoManager {
return _undoManager;
}

- (UIKeyboardAppearance)_keyboardAppearance
Expand Down Expand Up @@ -748,9 +757,10 @@ - (void)unselect:(id)sender
[_device.view cleanSelection];
}

//- (UIEditingInteractionConfiguration)editingInteractionConfiguration {
// return UIEditingInteractionConfigurationNone;
//}
- (UIEditingInteractionConfiguration)editingInteractionConfiguration {
[_undoManager skipNext];
return UIEditingInteractionConfigurationDefault;
}

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
Expand All @@ -771,6 +781,8 @@ - (BOOL)canPerformAction:(SEL)action withSender:(id)sender
}

return NO;
} else if ([sender isEqual:@"UIEditingInteraction"]) {
return action != @selector(cut:);
}

// UIApplicationState appState = [[UIApplication sharedApplication] applicationState];
Expand Down

0 comments on commit 9502767

Please sign in to comment.