Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buffer refactor #535

Open
wants to merge 44 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
552460a
Make XVimBuffer a reality
JohnTheAppleSeed Nov 17, 2013
04a77f2
Migrate most of XVimTextStoring to XVimBuffer
JohnTheAppleSeed Nov 17, 2013
0211582
Have initializer that makes more sense
JohnTheAppleSeed Nov 18, 2013
e3bcb62
Rework undo to take complete ownership of some operations
JohnTheAppleSeed Nov 18, 2013
694d02e
Move xvim_incrementNumber to XVimBuffer, where it belongs
JohnTheAppleSeed Nov 19, 2013
01d9100
Disable GC on the XCode5 plugin
JohnTheAppleSeed Nov 19, 2013
b9709a6
Remove useless __USE_DVTKIT__ dependency
JohnTheAppleSeed Nov 19, 2013
1715526
Get rid of the lastVisual* properties on the XVim instance
JohnTheAppleSeed Nov 19, 2013
030a795
Reimplement paragraph moves using XVimBuffer clean methods
JohnTheAppleSeed Nov 20, 2013
eebc66a
Dead code
JohnTheAppleSeed Nov 20, 2013
98bb868
fix Off-by-one
JohnTheAppleSeed Nov 21, 2013
a776bfd
Try not to change -[XVimMotion motion] gratuitously
JohnTheAppleSeed Nov 20, 2013
4917b21
+load really isn't the place to initialize a bundle
JohnTheAppleSeed Nov 21, 2013
51f6b2d
Add an NSObject(XVimAdditions) category for swizzling
JohnTheAppleSeed Nov 21, 2013
09bc132
Have an XVimView much like we have an XVimBuffer
JohnTheAppleSeed Nov 21, 2013
f93d3a6
Get rid of IDEEditorAreaHook and just have a category with swizzling
JohnTheAppleSeed Nov 21, 2013
b7b911c
Remove now completely useless Hook
JohnTheAppleSeed Nov 21, 2013
3afd25b
Move the IDEWorkspaceWindowHook as a swizzle in XVimHookManager
JohnTheAppleSeed Nov 21, 2013
e73d9d5
wibble
JohnTheAppleSeed Nov 22, 2013
e234ef0
Get rid of Hooker, move DVTSourceTextScrollView to a swizzling class too
JohnTheAppleSeed Nov 22, 2013
559770f
Get rid of XVimTextViewProtocol
JohnTheAppleSeed Nov 22, 2013
c068d4a
Migrate scrolling and some drawing code to XVimView
JohnTheAppleSeed Nov 22, 2013
c55fcb6
Make the XCode project happier
JohnTheAppleSeed Nov 16, 2013
ea25af4
To help debugging: log exceptions to the console right away
JohnTheAppleSeed Nov 22, 2013
7533e08
Refactor character swaps operators into XVimBuffer
JohnTheAppleSeed Nov 22, 2013
598f882
Do not call xvim_replaceCharacters with a non printable one
JohnTheAppleSeed Nov 22, 2013
50b42ef
Refactor NSTextView(VimOperation) into the XVimView
JohnTheAppleSeed Nov 24, 2013
55acaf3
Force synthesizing properties
JohnTheAppleSeed Nov 23, 2013
f49d75d
Hunt of DVTKIT: Move -_indentCharacterRange into XVimTextStoring
JohnTheAppleSeed Nov 25, 2013
45b5e26
Begin to remove some things from the NSTextStorage category.
JohnTheAppleSeed Nov 25, 2013
0f824b8
Fix b_v_D
JohnTheAppleSeed Nov 25, 2013
890f5ad
Disable GC for XCode5, it's not a GC App anymore
JohnTheAppleSeed Nov 25, 2013
7e2d1c8
get rid of XVimMotionType.h, merge it in XVimMotion.h
JohnTheAppleSeed Nov 25, 2013
0c2519e
Move some more functions from the NSTextStorage category to XVimBuffer
JohnTheAppleSeed Nov 25, 2013
4fa859c
fix the release build
JohnTheAppleSeed Nov 25, 2013
a659427
Refactor -{prev,next}{,Line}:... in XVimBuffer
JohnTheAppleSeed Nov 25, 2013
4d73d39
Fix a few mistakes, and support movement |
JohnTheAppleSeed Nov 26, 2013
794f94d
Add UUID for XCode 5.0 DP
JohnTheAppleSeed Nov 26, 2013
ec162f0
Fixup position after undo
JohnTheAppleSeed Nov 26, 2013
832005e
This is now unused code
JohnTheAppleSeed Nov 26, 2013
6528a7c
Do not use straight @"\n" in the code
JohnTheAppleSeed Nov 27, 2013
934c8a2
Add some comments
JohnTheAppleSeed Nov 27, 2013
38e71db
Improve performance and correctness of the event handling code
JohnTheAppleSeed Nov 27, 2013
e11416a
Do not swizzle KV Observing and -dealloc on NSTextView
JohnTheAppleSeed Dec 1, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Hunt of DVTKIT: Move -_indentCharacterRange into XVimTextStoring
And implement all the forwarders all the way down.
JohnTheAppleSeed committed Nov 25, 2013
commit f49d75de100718b8369399c6e553808ebaefcb73
5 changes: 5 additions & 0 deletions XVim/DVTTextStorage+XVimTextStoring.m
Original file line number Diff line number Diff line change
@@ -70,6 +70,11 @@ - (NSUInteger)xvim_lineNumberAtIndex:(NSUInteger)index
return [self lineRangeForCharacterRange:NSMakeRange(index, 0)].location + 1;
}

- (void)xvim_indentCharacterRange:(NSRange)range buffer:(XVimBuffer *)buffer
{
[self indentCharacterRange:range undoManager:buffer.undoManager];
}

@end

#if XVIM_XCODE_VERSION != 5
2 changes: 2 additions & 0 deletions XVim/XVimBuffer.h
Original file line number Diff line number Diff line change
@@ -313,4 +313,6 @@
// May return NSNotFound
- (NSUInteger)incrementNumberAtIndex:(NSUInteger)index by:(int64_t)offset;

- (void)indentCharacterRange:(NSRange)range;

@end
7 changes: 7 additions & 0 deletions XVim/XVimBuffer.m
Original file line number Diff line number Diff line change
@@ -769,4 +769,11 @@ - (NSUInteger)incrementNumberAtIndex:(NSUInteger)index by:(int64_t)offset
return index;
}

- (void)indentCharacterRange:(NSRange)range
{
if ([_textStorage respondsToSelector:@selector(xvim_indentCharacterRange:buffer:)]) {
[(id)_textStorage xvim_indentCharacterRange:range buffer:self];
}
}

@end
16 changes: 12 additions & 4 deletions XVim/XVimTextStoring.h
Original file line number Diff line number Diff line change
@@ -8,6 +8,8 @@

#import <Foundation/Foundation.h>

@class XVimBuffer;

/** @brief Protocol that can be implemented by your NSTextStorage.
*
* Implementing it will likely boost XVimBuffer performance significantly
@@ -19,14 +21,12 @@

@optional

#pragma mark *** Content & Lines access ***

@property (nonatomic, readonly) NSString *xvim_string;

@property (nonatomic, readonly) NSUInteger xvim_numberOfLines;

@property (nonatomic, readonly) NSUInteger xvim_tabWidth;

@property (nonatomic, readonly) NSUInteger xvim_indentWidth;

/** @brief returns the index range for the given line number
*
* @param[in] num
@@ -57,4 +57,12 @@
*/
- (NSUInteger)xvim_lineNumberAtIndex:(NSUInteger)index;

#pragma mark *** Indent ***

@property (nonatomic, readonly) NSUInteger xvim_tabWidth;

@property (nonatomic, readonly) NSUInteger xvim_indentWidth;

- (void)xvim_indentCharacterRange:(NSRange)range buffer:(XVimBuffer *)buffer;

@end
40 changes: 12 additions & 28 deletions XVim/XVimView.m
Original file line number Diff line number Diff line change
@@ -1656,55 +1656,39 @@ - (void)doJoin:(NSUInteger)count addSpace:(BOOL)addSpace
[self _syncState];
}

- (void)_indentCharacterRange:(NSRange)range
{
NSTextStorage *ts = _textView.textStorage;
XVimBuffer *buffer = self.buffer;

#ifdef __USE_DVTKIT__
#ifdef __XCODE5__
if ([ts isKindOfClass:[DVTTextStorage class]]) {
[(DVTTextStorage *)ts indentCharacterRange:range undoManager:buffer.undoManager];
}
return;
#else
if ([self.textStorage isKindOfClass:[DVTSourceTextStorage class]]) {
[(DVTSourceTextStorage *)ts indentCharacterRange:range undoManager:buffer.undoManager];
}
return;
#endif
#else
#error You must implement here
#endif

NSAssert(NO, @"You must implement here if you dont use this caregory with DVTSourceTextView");
}

- (void)doFilter:(XVimMotion*)motion
- (void)doFilter:(XVimMotion *)motion
{
XVimBuffer *buffer = self.buffer;

if (_insertionPoint == 0 && buffer.length == 0) {
return ;
}

NSUInteger insertionAfterFilter = _insertionPoint;
NSRange filterRange;
NSUInteger line, pos;

if (self.selectionMode == XVIM_VISUAL_NONE) {
XVimRange to = [self _getMotionRange:_insertionPoint motion:motion];
if (to.end == NSNotFound) {
return;
}
filterRange = [self _getOperationRange:to type:LINEWISE];
line = [buffer lineNumberAtIndex:filterRange.location];
} else {
XVimRange lines = [self _selectedLines];
NSUInteger from = [buffer indexOfLineNumber:lines.begin];
NSUInteger to = [buffer indexOfLineNumber:lines.end];

filterRange = [self _getOperationRange:XVimMakeRange(from, to) type:LINEWISE];
line = lines.begin;
}

[self _indentCharacterRange:filterRange];
[self _moveCursor:insertionAfterFilter preserveColumn:NO];
[buffer indentCharacterRange:filterRange];

pos = [buffer indexOfLineNumber:line];
pos = [buffer firstNonblankInLineAtIndex:pos allowEOL:YES];

[self _moveCursor:pos preserveColumn:NO];
self.selectionMode = XVIM_VISUAL_NONE;
[self _syncState];
}