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) {
30  HFControllerFont = 1 << 8,
40 };
41 
46 typedef NS_ENUM(NSInteger, HFControllerMovementDirection) {
49 };
50 
55 typedef NS_ENUM(NSInteger, HFControllerSelectionTransformation) {
59 };
60 
65 typedef NS_ENUM(NSInteger, HFControllerMovementGranularity) {
71 };
72 
77 typedef NS_ENUM(NSInteger, HFEditMode) {
81 } ;
82 
97 @interface HFController : NSObject <NSCoding> {
98 @private
99  NSMutableArray *representers;
100  HFByteArray *byteArray;
101  NSMutableArray *selectedContentsRanges;
102  HFRange displayedContentsRange;
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;
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 
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;
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 
unsigned long long maximumSelectionLocation()
BOOL shouldShowCallouts
Definition: HFController.h:238
Definition: HFController.h:68
double selectionPulseAmount()
NSUInteger bytesPerColumn
Definition: HFController.h:194
Definition: HFController.h:39
A reference to an open file.
Definition: HFFileReference.h:19
NSString *const HFControllerDidChangePropertiesNotification
NSString *const HFChangeInFileModifiedRangesKey
A key in the HFPrepareForChangeInFileNotification specifying the array of HFRangeWrappers indicating ...
Definition: HFController.h:38
HFByteArray * byteArray
Definition: HFController.h:133
HFControllerMovementGranularity
Definition: HFController.h:65
unsigned long long contentsLength()
Definition: HFController.h:30
A central class that acts as the controller layer for HexFiend.framework.
Definition: HFController.h:97
Definition: HFController.h:70
HFRange is the 64 bit analog of NSRange, containing a 64 bit location and length. ...
Definition: HFTypes.h:2
HFEditMode editMode
Definition: HFController.h:198
_hfflags
Definition: HFController.h:97
NSString *const HFControllerChangedPropertiesKey
A key in the HFControllerDidChangeProperties containing a bitmask of the changed properties, as a HFControllerPropertyBits.
Definition: HFController.h:28
NSString *const HFChangeInFileByteArrayKey
A key in the HFPrepareForChangeInFileNotification specifying the byte array that will be written...
A class that represents sets of attributes, attached to ranges of bytes.
Definition: HFByteRangeAttributeArray.h:13
NSString *const HFPrepareForChangeInFileNotification
Definition: HFController.h:47
HFEditMode
Definition: HFController.h:77
Definition: HFController.h:37
BOOL editable
Definition: HFController.h:229
Definition: HFController.h:48
NSArray * selectedContentsRanges
Definition: HFController.h:178
Definition: HFController.h:69
The principal view class of Hex Fiend&#39;s MVC architecture.
Definition: HFRepresenter.h:29
BOOL shouldColorBytes
Definition: HFController.h:235
Definition: HFController.h:23
HFControllerMovementDirection
Definition: HFController.h:46
Definition: HFController.h:32
BOOL shouldAntialias
Definition: HFController.h:232
Definition: HFController.h:34
Definition: HFController.h:31
BOOL shouldHideNullBytes
Definition: HFController.h:241
Definition: HFController.h:24
Definition: HFController.h:29
HFByteArray * byteArrayForSelectedContentsRanges()
Definition: HFController.h:56
NSArray * representers
Gets the current array of representers attached to this controller.
Definition: HFController.h:105
HFByteRangeAttributeArray * byteRangeAttributeArray()
unsigned long long totalLineCount()
Definition: HFController.h:33
NSFont * font
Definition: HFController.h:222
BOOL shouldLiveReload
Definition: HFController.h:244
void deleteSelection()
NSUInteger bytesPerLine()
Definition: HFController.h:26
Definition: HFController.h:78
NSString *const HFChangeInFileHintKey
The hint parameter that you may pass to clearDependenciesOnRanges:inFile:hint:
unsigned long long minimumSelectionLocation()
HFControllerPropertyBits
Definition: HFController.h:21
HFFPRange displayedLineRange
Definition: HFController.h:211
Definition: HFController.h:58
Definition: HFController.h:79
Definition: HFController.h:27
The principal Model class for HexFiend&#39;s MVC architecture.
Definition: HFByteArray.h:36
Definition: HFController.h:66
NSString *const HFChangeInFileShouldCancelKey
A key in the HFPrepareForChangeInFileNotification specifying an NSValue containing a pointer to a BOO...
HFFPRange is a struct used for representing floating point ranges, similar to NSRange. It contains two long doubles.
Definition: HFTypes.h:10
Definition: HFController.h:67
NSUndoManager * undoManager
Definition: HFController.h:226
Definition: HFController.h:80
NSUInteger beginPropertyChangeTransaction()
Definition: HFController.h:25
void pulseSelection()
Definition: HFController.h:57
CGFloat lineHeight()
Definition: HFController.h:35
HFControllerSelectionTransformation
Definition: HFController.h:55
Definition: HFController.h:22
Definition: HFController.h:36