forked from macvim-dev/macvim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMMTextViewHelper.h
106 lines (94 loc) · 3.72 KB
/
MMTextViewHelper.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/* vi:set ts=8 sts=4 sw=4 ft=objc:
*
* VIM - Vi IMproved by Bram Moolenaar
* MacVim GUI port by Bjorn Winckler
*
* Do ":help uganda" in Vim to read copying and usage conditions.
* Do ":help credits" in Vim to see a list of people who contributed.
* See README.txt for an overview of the Vim source code.
*/
#import <Cocoa/Cocoa.h>
// Need Carbon for TIS...() functions
#import <Carbon/Carbon.h>
#define BLUE(argb) ((argb & 0xff)/255.0f)
#define GREEN(argb) (((argb>>8) & 0xff)/255.0f)
#define RED(argb) (((argb>>16) & 0xff)/255.0f)
#define ALPHA(argb) (((argb>>24) & 0xff)/255.0f)
#define COMPONENTS(argb) ((CGFloat[]){RED(argb), GREEN(argb), BLUE(argb), ALPHA(argb)})
@interface MMTextViewHelper : NSObject {
enum ScrollingDirection {
ScrollingDirectionUnknown = 0,
ScrollingDirectionVertical,
ScrollingDirectionHorizontal,
};
id textView;
BOOL isDragging;
int dragRow;
int dragColumn;
unsigned dragFlags;
NSPoint dragPoint;
BOOL isAutoscrolling;
int mouseShape;
NSColor *insertionPointColor;
BOOL interpretKeyEventsSwallowedKey;
NSEvent *currentEvent;
NSMutableDictionary *signImages;
BOOL useMouseTime;
NSDate *mouseDownTime;
CGFloat scrollingDeltaX;
CGFloat scrollingDeltaY;
enum ScrollingDirection scrollingDirection; ///< The fixed scrolling direction when using track pad (if configured to use it)
// Input Manager
NSRange imRange;
NSRange markedRange;
NSDictionary *markedTextAttributes;
NSMutableAttributedString *markedText;
int preEditRow; ///< The cursor's row. Note that this gets set no matter what. Doesn't matter if we are in pre-edit or not.
int preEditColumn; ///< The cursor's column.
BOOL imControl;
BOOL imState;
TISInputSourceRef lastImSource;
TISInputSourceRef asciiImSource;
}
- (id)init;
- (void)setTextView:(id)view;
- (void)setInsertionPointColor:(NSColor *)color;
- (NSColor *)insertionPointColor;
- (void)keyDown:(NSEvent *)event;
- (void)insertText:(id)string replacementRange:(NSRange)replacementRange;
- (void)doCommandBySelector:(SEL)selector;
- (void)scrollWheel:(NSEvent *)event;
- (void)mouseDown:(NSEvent *)event;
- (void)mouseUp:(NSEvent *)event;
- (void)mouseDragged:(NSEvent *)event;
- (void)mouseMoved:(NSEvent *)event;
- (void)swipeWithEvent:(NSEvent *)event;
- (void)pressureChangeWithEvent:(NSEvent *)event;
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender;
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender;
- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender;
- (void)setMouseShape:(int)shape;
- (void)changeFont:(id)sender;
- (NSImage *)signImageForName:(NSString *)imgName;
- (void)deleteImage:(NSString *)imgName;
// Input Manager
- (BOOL)hasMarkedText;
- (NSRange)markedRange;
- (NSDictionary *)markedTextAttributes;
- (void)setMarkedTextAttributes:(NSDictionary *)attr;
- (void)setMarkedText:(id)text selectedRange:(NSRange)range;
- (void)unmarkText;
- (NSMutableAttributedString *)markedText;
- (void)setPreEditRow:(int)row column:(int)col;
- (int)preEditRow;
- (int)preEditColumn;
- (void)setImRange:(NSRange)range;
- (NSRange)imRange;
- (void)setMarkedRange:(NSRange)range;
- (NSRect)firstRectForCharacterRange:(NSRange)range;
- (NSRect)firstRectForCharacterRange:(int)row column:(int)col length:(int)length;
- (void)setImControl:(BOOL)enable;
- (void)activateIm:(BOOL)enable;
- (BOOL)useInlineIm;
- (void)checkImState;
@end