This repository has been archived by the owner on Dec 5, 2019. It is now read-only.
/
NSUndoManager+EditingAdditions.h
67 lines (58 loc) · 2.06 KB
/
NSUndoManager+EditingAdditions.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//
// NSUndoManager+EditingAdditions.h
// Wireframes
//
// Created by Josh Vera on 4/5/12.
// Copyright (c) 2012 Bitswift. All rights reserved.
//
#import <Foundation/Foundation.h>
/**
* Extensions to `NSUndoManager` to coordinate edits within a window.
*
* An edit grouping can be opened to guarantee only one user interface element
* is edited at one time.
*
* Since edit groupings are mutually exclusive, multiple edit groupings
* cannot be nested.
*/
@interface NSUndoManager (EditingAdditions)
/**
* @name Opening Editing Undo Groupings
*/
/**
* Invokes <tryEditGroupingWithActionName:> with a `nil` `actionName`.
*/
- (BOOL)tryEditGrouping __attribute__((warn_unused_result));
/**
* Attempts to open an edit grouping named `actionName` and immediately
* returns whether the attempt was successful.
*
* @param actionName The name of the action associated with undoing the edit grouping.
* If `actionName` is an empty string, the action name currently associated with the menu
* command is removed. The receiver's action name remains unchanged if this is `nil`.
*/
- (BOOL)tryEditGroupingWithActionName:(NSString *)actionName __attribute__((warn_unused_result));
/**
* Invokes <tryEditGroupingWithActionName:usingBlock:> with a `nil`
* `actionName`.
*/
- (BOOL)tryEditGroupingUsingBlock:(void (^)(void))block;
/**
* Attempts to open an edit grouping named `actionName`, executes the
* given block inside it, and closes the group. Returns whether the
* operation was successful.
*
* @param actionName The name of the action associated with undoing the edit grouping.
* If `actionName` is an empty string, the action name currently associated with the menu
* command is removed. The receiver's action name remains unchanged if this is `nil`.
*
* @param block The block to execute within the edit grouping.
*/
- (BOOL)tryEditGroupingWithActionName:(NSString *)actionName usingBlock:(void (^)(void))block;
/**
* Closes a previously opened edit grouping.
*
* @warning It is invalid to call this method without an open edit grouping.
*/
- (void)endEditGrouping;
@end