|
28 | 28 | #import <Foundation/Foundation.h> |
29 | 29 | #import <AppKit/AppKit.h> |
30 | 30 |
|
31 | | -@interface YCEditorView : NSView |
| 31 | +@class YCodeEditorDocument; |
| 32 | +@class YCodeSyntaxHighlighter; |
| 33 | +@class YCEditorLineNumberView; |
| 34 | + |
| 35 | +@interface YCEditorView : NSView <NSTextViewDelegate> |
32 | 36 | { |
| 37 | + NSScrollView *_scrollView; |
| 38 | + NSTextView *_textView; |
| 39 | + YCEditorLineNumberView *_lineNumberView; |
| 40 | + |
| 41 | + YCodeEditorDocument *_document; |
| 42 | + YCodeSyntaxHighlighter *_syntaxHighlighter; |
| 43 | + |
| 44 | + // Editor settings |
| 45 | + NSFont *_font; |
| 46 | + NSColor *_textColor; |
| 47 | + NSColor *_backgroundColor; |
| 48 | + NSColor *_selectionColor; |
| 49 | + NSColor *_currentLineColor; |
| 50 | + |
| 51 | + BOOL _showLineNumbers; |
| 52 | + BOOL _highlightCurrentLine; |
| 53 | + BOOL _autoIndent; |
| 54 | + BOOL _syntaxHighlighting; |
| 55 | + |
| 56 | + NSInteger _tabWidth; |
| 57 | + BOOL _useSpacesForTabs; |
| 58 | + |
| 59 | + // Find and replace |
| 60 | + NSString *_findString; |
| 61 | + NSString *_replaceString; |
| 62 | + BOOL _caseSensitive; |
| 63 | + BOOL _useRegex; |
| 64 | +} |
| 65 | + |
| 66 | +/** |
| 67 | + * Document association |
| 68 | + */ |
| 69 | +- (YCodeEditorDocument *)document; |
| 70 | +- (void)setDocument:(YCodeEditorDocument *)document; |
| 71 | + |
| 72 | +/** |
| 73 | + * Text view access |
| 74 | + */ |
| 75 | +- (NSTextView *)textView; |
| 76 | +- (NSScrollView *)scrollView; |
| 77 | + |
| 78 | +/** |
| 79 | + * Content management |
| 80 | + */ |
| 81 | +- (NSString *)text; |
| 82 | +- (void)setText:(NSString *)text; |
| 83 | +- (BOOL)hasSelection; |
| 84 | +- (NSString *)selectedText; |
| 85 | +- (NSRange)selectedRange; |
| 86 | +- (void)setSelectedRange:(NSRange)range; |
| 87 | + |
| 88 | +/** |
| 89 | + * Editor settings |
| 90 | + */ |
| 91 | +- (NSFont *)font; |
| 92 | +- (void)setFont:(NSFont *)font; |
| 93 | +- (NSColor *)textColor; |
| 94 | +- (void)setTextColor:(NSColor *)color; |
| 95 | +- (NSColor *)backgroundColor; |
| 96 | +- (void)setBackgroundColor:(NSColor *)color; |
| 97 | +- (BOOL)showLineNumbers; |
| 98 | +- (void)setShowLineNumbers:(BOOL)show; |
| 99 | +- (BOOL)highlightCurrentLine; |
| 100 | +- (void)setHighlightCurrentLine:(BOOL)highlight; |
| 101 | +- (NSInteger)tabWidth; |
| 102 | +- (void)setTabWidth:(NSInteger)width; |
| 103 | +- (BOOL)useSpacesForTabs; |
| 104 | +- (void)setUseSpacesForTabs:(BOOL)useSpaces; |
| 105 | + |
| 106 | +/** |
| 107 | + * Syntax highlighting |
| 108 | + */ |
| 109 | +- (BOOL)syntaxHighlighting; |
| 110 | +- (void)setSyntaxHighlighting:(BOOL)highlighting; |
| 111 | +- (YCodeSyntaxHighlighter *)syntaxHighlighter; |
| 112 | +- (void)applySyntaxHighlighting; |
| 113 | + |
| 114 | +/** |
| 115 | + * Text operations |
| 116 | + */ |
| 117 | +- (void)insertText:(NSString *)text; |
| 118 | +- (void)insertText:(NSString *)text atLocation:(NSUInteger)location; |
| 119 | +- (void)deleteSelectedText; |
| 120 | +- (void)selectAll; |
| 121 | +- (void)copy; |
| 122 | +- (void)cut; |
| 123 | +- (void)paste; |
33 | 124 |
|
| 125 | +/** |
| 126 | + * Line operations |
| 127 | + */ |
| 128 | +- (NSUInteger)currentLineNumber; |
| 129 | +- (NSUInteger)totalLineCount; |
| 130 | +- (NSRange)rangeOfLine:(NSUInteger)lineNumber; |
| 131 | +- (void)goToLine:(NSUInteger)lineNumber; |
| 132 | +- (void)selectLine:(NSUInteger)lineNumber; |
| 133 | + |
| 134 | +/** |
| 135 | + * Find and replace |
| 136 | + */ |
| 137 | +- (void)findText:(NSString *)searchText options:(NSStringCompareOptions)options; |
| 138 | +- (void)replaceText:(NSString *)searchText withText:(NSString *)replaceText options:(NSStringCompareOptions)options; |
| 139 | +- (void)findNext; |
| 140 | +- (void)findPrevious; |
| 141 | + |
| 142 | +/** |
| 143 | + * Indentation |
| 144 | + */ |
| 145 | +- (void)indentSelectedLines; |
| 146 | +- (void)unindentSelectedLines; |
| 147 | +- (void)commentSelectedLines; |
| 148 | +- (void)uncommentSelectedLines; |
| 149 | + |
| 150 | +/** |
| 151 | + * Folding (basic support) |
| 152 | + */ |
| 153 | +- (BOOL)canFoldAtLine:(NSUInteger)lineNumber; |
| 154 | +- (void)foldAtLine:(NSUInteger)lineNumber; |
| 155 | +- (void)unfoldAtLine:(NSUInteger)lineNumber; |
| 156 | + |
| 157 | +@end |
| 158 | + |
| 159 | +/** |
| 160 | + * Line number view |
| 161 | + */ |
| 162 | +@interface YCEditorLineNumberView : NSRulerView |
| 163 | +{ |
| 164 | + YCEditorView *_editorView; |
| 165 | + NSColor *_backgroundColor; |
| 166 | + NSColor *_textColor; |
| 167 | + NSFont *_font; |
34 | 168 | } |
35 | 169 |
|
| 170 | +- (instancetype)initWithEditorView:(YCEditorView *)editorView; |
| 171 | +- (YCEditorView *)editorView; |
| 172 | +- (void)setEditorView:(YCEditorView *)editorView; |
| 173 | + |
36 | 174 | @end |
37 | 175 |
|
38 | 176 | #endif // _YCEDITORVIEW_H_ |
|
0 commit comments