HexFiend: HFController.h Source File

HexFiend

HFController.h
Go to the documentation of this file.
1 //
2 // HFController.h
3 // HexFiend_2
4 //
5 // Copyright 2007 ridiculous_fish. All rights reserved.
6 //
7
8 #import <Cocoa/Cocoa.h>
9
10 #import <HexFiend/HFTypes.h>
11
16 @class HFRepresenter, HFByteArray, HFFileReference, HFControllerCoalescedUndo, HFByteRangeAttributeArray;
17
21 typedef NS_OPTIONS(NSUInteger, HFControllerPropertyBits) {
22 HFControllerContentValue = 1 << 0,
23 HFControllerContentLength = 1 << 1,
24 HFControllerDisplayedLineRange = 1 << 2,
25 HFControllerSelectedRanges = 1 << 3,
26 HFControllerSelectionPulseAmount = 1 << 4,
27 HFControllerBytesPerLine = 1 << 5,
28 HFControllerBytesPerColumn = 1 << 6,
29 HFControllerEditable = 1 << 7,
30 HFControllerFont = 1 << 8,
31 HFControllerAntialias = 1 << 9,
32 HFControllerLineHeight = 1 << 10,
33 HFControllerViewSizeRatios = 1 << 11,
34 HFControllerByteRangeAttributes = 1 << 12,
35 HFControllerByteGranularity = 1 << 13,
36 HFControllerBookmarks = 1 << 14,
37 HFControllerColorBytes = 1 << 15,
38 HFControllerShowCallouts = 1 << 16,
39 HFControllerHideNullBytes = 1 << 17,
40 };
41
46 typedef NS_ENUM(NSInteger, HFControllerMovementDirection) {
47 HFControllerDirectionLeft,
48 HFControllerDirectionRight
49 };
50
55 typedef NS_ENUM(NSInteger, HFControllerSelectionTransformation) {
56 HFControllerDiscardSelection,
57 HFControllerShiftSelection,
58 HFControllerExtendSelection
59 };
60
65 typedef NS_ENUM(NSInteger, HFControllerMovementGranularity) {
66 HFControllerMovementByte,
67 HFControllerMovementColumn,
68 HFControllerMovementLine,
69 HFControllerMovementPage,
70 HFControllerMovementDocument
71 };
72
77 typedef NS_ENUM(NSInteger, HFEditMode) {
78 HFInsertMode,
79 HFOverwriteMode,
80 HFReadOnlyMode,
81 } ;
82
97 @interface HFController : NSObject <NSCoding> {
98 @private
99 NSMutableArray *representers;
100 HFByteArray *byteArray;
101 NSMutableArray *selectedContentsRanges;
102 HFRange displayedContentsRange;
103 HFFPRange displayedLineRange;
104 NSUInteger bytesPerLine;
105 NSUInteger bytesPerColumn;
106 CGFloat lineHeight;
107
108 NSUInteger currentPropertyChangeToken;
109 NSMutableArray *additionalPendingTransactions;
110 HFControllerPropertyBits propertiesToUpdateInCurrentTransaction;
111
112 NSUndoManager *undoManager;
113 NSMutableSet *undoOperations;
114 HFControllerCoalescedUndo *undoCoalescer;
115
116 unsigned long long selectionAnchor;
117 HFRange selectionAnchorRange;
118
119 CFAbsoluteTime pulseSelectionStartTime, pulseSelectionCurrentTime;
120 NSTimer *pulseSelectionTimer;
121
122 /* Basic cache support */
123 HFRange cachedRange;
124 NSData *cachedData;
125 NSUInteger cachedGenerationIndex;
126
127 struct {
128 unsigned antialias:1;
129 unsigned colorbytes:1;
130 unsigned showcallouts:1;
131 unsigned hideNullBytes:1;
132 HFEditMode editMode:2;
133 unsigned editable:1;
134 unsigned selectable:1;
135 unsigned selectionInProgress:1;
136 unsigned shiftExtendSelection:1;
137 unsigned commandExtendSelection:1;
138 unsigned livereload:1;
139 } _hfflags;
140 }
141
146 @property (readonly, copy) NSArray *representers;
148
150 - (void)addRepresenter:(HFRepresenter *)representer;
151
153 - (void)removeRepresenter:(HFRepresenter *)representer;
154
156
164 - (NSUInteger)beginPropertyChangeTransaction;
165
167 - (void)endPropertyChangeTransaction:(NSUInteger)token;
169
173
175 @property (nonatomic, strong) HFByteArray *byteArray;
176
178 - (void)replaceByteArray:(HFByteArray *)newArray;
180
186 - (unsigned long long)totalLineCount;
187
189 - (NSUInteger)bytesPerLine;
190
192 - (CGFloat)lineHeight;
193
195
199 //{@
200
202 - (void)pulseSelection;
203
205 - (double)selectionPulseAmount;
207
211 //{@
212
220 @property (nonatomic, copy) NSArray *selectedContentsRanges;
221
223 - (IBAction)selectAll:(id)sender;
224
226 - (unsigned long long)minimumSelectionLocation;
227
229 - (unsigned long long)maximumSelectionLocation;
230
232 - (HFByteArray *)byteArrayForSelectedContentsRanges;
234
235 /* Number of bytes used in each column for a text-style representer. */
236 @property (nonatomic) NSUInteger bytesPerColumn;
237
240 @property (nonatomic) HFEditMode editMode;
241
245 //{@
253 @property (nonatomic) HFFPRange displayedLineRange;
254
256 - (void)maximizeVisibilityOfContentsRange:(HFRange)range;
257
259 - (void)centerContentsRange:(HFRange)range;
260
262
264 @property (nonatomic, copy) NSFont *font;
265
268 @property (nonatomic, strong) NSUndoManager *undoManager;
269
271 @property (nonatomic) BOOL editable;
272
274 @property (nonatomic) BOOL shouldAntialias;
275
277 @property (nonatomic) BOOL shouldColorBytes;
278
280 @property (nonatomic) BOOL shouldShowCallouts;
281
283 @property (nonatomic) BOOL shouldHideNullBytes;
284
286 @property (nonatomic) BOOL shouldLiveReload;
287
294 - (void)representer:(HFRepresenter *)rep changedProperties:(HFControllerPropertyBits)properties;
296
301 - (void)beginSelectionWithEvent:(NSEvent *)event forByteIndex:(unsigned long long)byteIndex;
302
304 - (void)continueSelectionWithEvent:(NSEvent *)event forByteIndex:(unsigned long long)byteIndex;
305
307 - (void)endSelectionWithEvent:(NSEvent *)event forByteIndex:(unsigned long long)byteIndex;
308
313 - (void)scrollWithScrollEvent:(NSEvent *)scrollEvent;
314
316 - (void)scrollByLines:(long double)lines;
317
319
330 - (void)moveInDirection:(HFControllerMovementDirection)direction byByteCount:(unsigned long long)amountToMove withSelectionTransformation:(HFControllerSelectionTransformation)transformation usingAnchor:(BOOL)useAnchor;
331
333 - (void)moveInDirection:(HFControllerMovementDirection)direction withGranularity:(HFControllerMovementGranularity)granularity andModifySelection:(BOOL)extendSelection;
334 - (void)moveToLineBoundaryInDirection:(HFControllerMovementDirection)direction andModifySelection:(BOOL)extendSelection;
335
339
346 - (BOOL)insertByteArray:(HFByteArray *)byteArray replacingPreviousBytes:(unsigned long long)previousByteCount allowUndoCoalescing:(BOOL)allowUndoCoalescing;
347 - (BOOL)insertData:(NSData *)data replacingPreviousBytes:(unsigned long long)previousByteCount allowUndoCoalescing:(BOOL)allowUndoCoalescing;
348
350 - (void)deleteSelection;
351
353 - (void)deleteDirection:(HFControllerMovementDirection)direction;
354
356
361 - (NSData *)dataForRange:(HFRange)range;
362
364 - (void)copyBytes:(unsigned char *)bytes range:(HFRange)range;
365
367 - (HFByteRangeAttributeArray *)byteRangeAttributeArray;
368
370 - (HFByteRangeAttributeArray *)attributesForBytesInRange:(HFRange)range;
371
373 - (HFRange)rangeForBookmark:(NSInteger)bookmark;
374
376 - (void)setRange:(HFRange)range forBookmark:(NSInteger)bookmark;
377
379 - (NSIndexSet *)bookmarksInRange:(HFRange)range;
380
382 - (unsigned long long)contentsLength;
383
388 + (BOOL)prepareForChangeInFile:(NSURL *)targetFile fromWritingByteArray:(HFByteArray *)array;
389
391 - (BOOL)clearUndoManagerDependenciesOnRanges:(NSArray *)ranges inFile:(HFFileReference *)reference hint:(NSMutableDictionary *)hint;
393
394 @end
395
398 extern NSString * const HFControllerDidChangePropertiesNotification;
399
403 extern NSString * const HFControllerChangedPropertiesKey;
404
405
409 extern NSString * const HFPrepareForChangeInFileNotification;
410
414 extern NSString * const HFChangeInFileByteArrayKey;
415 extern NSString * const HFChangeInFileModifiedRangesKey;
416 extern NSString * const HFChangeInFileShouldCancelKey;
417 extern NSString * const HFChangeInFileHintKey;
418
-[HFController maximumSelectionLocation]
unsigned long long maximumSelectionLocation()
HFController::shouldShowCallouts
BOOL shouldShowCallouts
Definition: HFController.h:238
HFControllerMovementLine
Definition: HFController.h:68
-[HFController selectionPulseAmount]
double selectionPulseAmount()
HFController::bytesPerColumn
NSUInteger bytesPerColumn
Definition: HFController.h:194
HFControllerHideNullBytes
Definition: HFController.h:39
HFFileReference
A reference to an open file.
Definition: HFFileReference.h:19
HFControllerDidChangePropertiesNotification
NSString *const HFControllerDidChangePropertiesNotification
HFChangeInFileModifiedRangesKey
NSString *const HFChangeInFileModifiedRangesKey
A key in the HFPrepareForChangeInFileNotification specifying the array of HFRangeWrappers indicating ...
HFControllerShowCallouts
Definition: HFController.h:38
HFController::byteArray
HFByteArray * byteArray
Definition: HFController.h:133
HFControllerMovementGranularity
HFControllerMovementGranularity
Definition: HFController.h:65
-[HFController contentsLength]
unsigned long long contentsLength()
HFControllerFont
Definition: HFController.h:30
HFController
A central class that acts as the controller layer for HexFiend.framework.
Definition: HFController.h:97
HFControllerMovementDocument
Definition: HFController.h:70
HFRange
HFRange is the 64 bit analog of NSRange, containing a 64 bit location and length. ...
Definition: HFTypes.h:2
HFController::editMode
HFEditMode editMode
Definition: HFController.h:198
HFController::_hfflags
_hfflags
Definition: HFController.h:97
HFControllerChangedPropertiesKey
NSString *const HFControllerChangedPropertiesKey
A key in the HFControllerDidChangeProperties containing a bitmask of the changed properties, as a HFControllerPropertyBits.
HFControllerBytesPerColumn
Definition: HFController.h:28
HFChangeInFileByteArrayKey
NSString *const HFChangeInFileByteArrayKey
A key in the HFPrepareForChangeInFileNotification specifying the byte array that will be written...
HFByteRangeAttributeArray
A class that represents sets of attributes, attached to ranges of bytes.
Definition: HFByteRangeAttributeArray.h:13
HFPrepareForChangeInFileNotification
NSString *const HFPrepareForChangeInFileNotification
HFControllerDirectionLeft
Definition: HFController.h:47
HFEditMode
HFEditMode
Definition: HFController.h:77
HFControllerColorBytes
Definition: HFController.h:37
HFController::editable
BOOL editable
Definition: HFController.h:229
HFControllerDirectionRight
Definition: HFController.h:48
HFController::selectedContentsRanges
NSArray * selectedContentsRanges
Definition: HFController.h:178
HFControllerMovementPage
Definition: HFController.h:69
HFRepresenter
The principal view class of Hex Fiend&#39;s MVC architecture.
Definition: HFRepresenter.h:29
HFController::shouldColorBytes
BOOL shouldColorBytes
Definition: HFController.h:235
HFControllerContentLength
Definition: HFController.h:23
HFControllerMovementDirection
HFControllerMovementDirection
Definition: HFController.h:46
HFControllerLineHeight
Definition: HFController.h:32
HFController::shouldAntialias
BOOL shouldAntialias
Definition: HFController.h:232
HFControllerByteRangeAttributes
Definition: HFController.h:34
HFControllerAntialias
Definition: HFController.h:31
HFController::shouldHideNullBytes
BOOL shouldHideNullBytes
Definition: HFController.h:241
HFControllerDisplayedLineRange
Definition: HFController.h:24
HFControllerEditable
Definition: HFController.h:29
-[HFController byteArrayForSelectedContentsRanges]
HFByteArray * byteArrayForSelectedContentsRanges()
HFControllerDiscardSelection
Definition: HFController.h:56
HFController::representers
NSArray * representers
Gets the current array of representers attached to this controller.
Definition: HFController.h:105
-[HFController byteRangeAttributeArray]
HFByteRangeAttributeArray * byteRangeAttributeArray()
-[HFController totalLineCount]
unsigned long long totalLineCount()
HFControllerViewSizeRatios
Definition: HFController.h:33
HFController::font
NSFont * font
Definition: HFController.h:222
HFController::shouldLiveReload
BOOL shouldLiveReload
Definition: HFController.h:244
-[HFController deleteSelection]
void deleteSelection()
-[HFController bytesPerLine]
NSUInteger bytesPerLine()
HFControllerSelectionPulseAmount
Definition: HFController.h:26
HFInsertMode
Definition: HFController.h:78
HFChangeInFileHintKey
NSString *const HFChangeInFileHintKey
The hint parameter that you may pass to clearDependenciesOnRanges:inFile:hint:
-[HFController minimumSelectionLocation]
unsigned long long minimumSelectionLocation()
HFControllerPropertyBits
HFControllerPropertyBits
Definition: HFController.h:21
HFController::displayedLineRange
HFFPRange displayedLineRange
Definition: HFController.h:211
HFControllerExtendSelection
Definition: HFController.h:58
HFOverwriteMode
Definition: HFController.h:79
HFControllerBytesPerLine
Definition: HFController.h:27
HFByteArray
The principal Model class for HexFiend&#39;s MVC architecture.
Definition: HFByteArray.h:36
HFControllerMovementByte
Definition: HFController.h:66
HFChangeInFileShouldCancelKey
NSString *const HFChangeInFileShouldCancelKey
A key in the HFPrepareForChangeInFileNotification specifying an NSValue containing a pointer to a BOO...
HFFPRange
HFFPRange is a struct used for representing floating point ranges, similar to NSRange. It contains two long doubles.
Definition: HFTypes.h:10
HFControllerMovementColumn
Definition: HFController.h:67
HFController::undoManager
NSUndoManager * undoManager
Definition: HFController.h:226
HFReadOnlyMode
Definition: HFController.h:80
-[HFController beginPropertyChangeTransaction]
NSUInteger beginPropertyChangeTransaction()
HFControllerSelectedRanges
Definition: HFController.h:25
-[HFController pulseSelection]
void pulseSelection()
HFControllerShiftSelection
Definition: HFController.h:57
-[HFController lineHeight]
CGFloat lineHeight()
HFControllerByteGranularity
Definition: HFController.h:35
HFControllerSelectionTransformation
HFControllerSelectionTransformation
Definition: HFController.h:55
HFControllerContentValue
Definition: HFController.h:22
HFControllerBookmarks
Definition: HFController.h:36