Skip to content

Commit

Permalink
swift XVimMotion
Browse files Browse the repository at this point in the history
  • Loading branch information
pebble8888 committed May 23, 2020
1 parent 70c9453 commit 348f5bd
Show file tree
Hide file tree
Showing 25 changed files with 197 additions and 208 deletions.
3 changes: 3 additions & 0 deletions XVim2-Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@
#import "XVim2/Helper/rd_route.h"
#import "XVim2/Helper/Logger.h"

#import "XVimMotionOption.h"
#import "XVimMotionStyle.h"

#endif /* XVim2_Bridging_Header_h */
31 changes: 25 additions & 6 deletions XVim2.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
A2B52D3F1F514CC600D83C0A /* Logger.m in Sources */ = {isa = PBXBuildFile; fileRef = A2B52D3B1F514CC600D83C0A /* Logger.m */; };
A2B537B11F51C94400D83C0A /* NSObject+Swizzle.m in Sources */ = {isa = PBXBuildFile; fileRef = A2B537B01F51C94400D83C0A /* NSObject+Swizzle.m */; };
A2B5D78D2243319A00BD289D /* XcodeHeader in Resources */ = {isa = PBXBuildFile; fileRef = A2B5D78C2243319A00BD289D /* XcodeHeader */; };
A2C359962479552C00259730 /* XVimMotion.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2C359952479552C00259730 /* XVimMotion.swift */; };
A2D464BC20D4042B00A43EC7 /* SwiftLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2D464BB20D4042B00A43EC7 /* SwiftLogger.swift */; };
A2FB1EE12077B65100D3E634 /* File.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2FB1EE02077B65100D3E634 /* File.swift */; };
ED0DED611F8C2CEC00886F6B /* XVimZEvaluator.m in Sources */ = {isa = PBXBuildFile; fileRef = ED0DED5D1F8C2CDD00886F6B /* XVimZEvaluator.m */; };
Expand Down Expand Up @@ -90,7 +91,6 @@
EDF010681F6EEFFC00461B2C /* XVimEvaluator.m in Sources */ = {isa = PBXBuildFile; fileRef = EDF010551F6EEF0F00461B2C /* XVimEvaluator.m */; };
EDF010691F6EEFFC00461B2C /* XVimKeymap.m in Sources */ = {isa = PBXBuildFile; fileRef = EDF010661F6EEF1000461B2C /* XVimKeymap.m */; };
EDF0106A1F6EEFFC00461B2C /* XVimKeyStroke.m in Sources */ = {isa = PBXBuildFile; fileRef = EDF0105D1F6EEF1000461B2C /* XVimKeyStroke.m */; };
EDF0106B1F6EEFFC00461B2C /* XVimMotion.m in Sources */ = {isa = PBXBuildFile; fileRef = EDF0105B1F6EEF1000461B2C /* XVimMotion.m */; };
EDF0106C1F6EEFFC00461B2C /* XVimMotionEvaluator.m in Sources */ = {isa = PBXBuildFile; fileRef = EDF010601F6EEF1000461B2C /* XVimMotionEvaluator.m */; };
EDF0106D1F6EEFFC00461B2C /* XVimNumericEvaluator.m in Sources */ = {isa = PBXBuildFile; fileRef = EDF0105A1F6EEF1000461B2C /* XVimNumericEvaluator.m */; };
EDF0106E1F6EEFFC00461B2C /* XVimWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = EDF010581F6EEF0F00461B2C /* XVimWindow.m */; };
Expand Down Expand Up @@ -165,6 +165,7 @@
A2B537AF1F51C94400D83C0A /* NSObject+Swizzle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+Swizzle.h"; sourceTree = "<group>"; };
A2B537B01F51C94400D83C0A /* NSObject+Swizzle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+Swizzle.m"; sourceTree = "<group>"; };
A2B5D78C2243319A00BD289D /* XcodeHeader */ = {isa = PBXFileReference; lastKnownFileType = folder; path = XcodeHeader; sourceTree = "<group>"; };
A2C359952479552C00259730 /* XVimMotion.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XVimMotion.swift; sourceTree = "<group>"; };
A2D464BB20D4042B00A43EC7 /* SwiftLogger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SwiftLogger.swift; path = XVim2/Helper/SwiftLogger.swift; sourceTree = SOURCE_ROOT; };
A2ED76F823743EC700C81258 /* SourceEditorViewProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SourceEditorViewProtocol.h; path = XVim2/Xcode/SourceEditorViewProtocol.h; sourceTree = SOURCE_ROOT; };
A2FB1EE02077B65100D3E634 /* File.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = File.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -272,10 +273,9 @@
EDF010581F6EEF0F00461B2C /* XVimWindow.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XVimWindow.m; sourceTree = "<group>"; };
EDF010591F6EEF1000461B2C /* XVimMotionEvaluator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XVimMotionEvaluator.h; sourceTree = "<group>"; };
EDF0105A1F6EEF1000461B2C /* XVimNumericEvaluator.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XVimNumericEvaluator.m; sourceTree = "<group>"; };
EDF0105B1F6EEF1000461B2C /* XVimMotion.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XVimMotion.m; sourceTree = "<group>"; };
EDF0105C1F6EEF1000461B2C /* XVimKeymap.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XVimKeymap.h; sourceTree = "<group>"; };
EDF0105D1F6EEF1000461B2C /* XVimKeyStroke.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XVimKeyStroke.m; sourceTree = "<group>"; };
EDF0105E1F6EEF1000461B2C /* XVimMotion.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XVimMotion.h; sourceTree = "<group>"; };
EDF0105E1F6EEF1000461B2C /* XVimMotionStyle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XVimMotionStyle.h; sourceTree = "<group>"; };
EDF0105F1F6EEF1000461B2C /* XVimNumericEvaluator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XVimNumericEvaluator.h; sourceTree = "<group>"; };
EDF010601F6EEF1000461B2C /* XVimMotionEvaluator.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XVimMotionEvaluator.m; sourceTree = "<group>"; };
EDF010611F6EEF1000461B2C /* XVimMotionOption.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XVimMotionOption.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -562,8 +562,8 @@
A21B82F224794C88002F162A /* XVimMark.swift */,
EDFA14921F8564DA0039B439 /* XVimMarks.h */,
EDFA14941F8564DA0039B439 /* XVimMarks.m */,
EDF0105E1F6EEF1000461B2C /* XVimMotion.h */,
EDF0105B1F6EEF1000461B2C /* XVimMotion.m */,
EDF0105E1F6EEF1000461B2C /* XVimMotionStyle.h */,
A2C359952479552C00259730 /* XVimMotion.swift */,
EDF010611F6EEF1000461B2C /* XVimMotionOption.h */,
EDF010541F6EEF0F00461B2C /* XVimMotionType.h */,
ED0DED761F8C3BF100886F6B /* XVimOptions.h */,
Expand Down Expand Up @@ -601,6 +601,7 @@
A26E5C701F5145AB000BCC66 /* Frameworks */,
A26E5C711F5145AB000BCC66 /* Resources */,
A26E5C7F1F51466B000BCC66 /* CopyFiles */,
A2C359972479554F00259730 /* SwiftLint */,
);
buildRules = (
);
Expand Down Expand Up @@ -657,6 +658,24 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
A2C359972479554F00259730 /* SwiftLint */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = SwiftLint;
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nfi\n";
};
ED1286541F90B268007B6FC7 /* Write git revision */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -731,7 +750,6 @@
A2B537B11F51C94400D83C0A /* NSObject+Swizzle.m in Sources */,
EDF0106E1F6EEFFC00461B2C /* XVimWindow.m in Sources */,
EDD27BAE1F9B5EB30006471C /* XVimTester+Jump.m in Sources */,
EDF0106B1F6EEFFC00461B2C /* XVimMotion.m in Sources */,
ED548FDF1F8280B700A8069D /* XVimRegister.m in Sources */,
EDD27BA61F9B5EB30006471C /* XVimTester+Issues.m in Sources */,
EDD27BB11F9B5EB30006471C /* XVimTester+ExCmd.m in Sources */,
Expand All @@ -743,6 +761,7 @@
ED548FDA1F827EEC00A8069D /* XVimYankEvaluator.m in Sources */,
A29BA5722243D6160032C3E2 /* SourceEditorViewWrapper.s in Sources */,
A2D464BC20D4042B00A43EC7 /* SwiftLogger.swift in Sources */,
A2C359962479552C00259730 /* XVimMotion.swift in Sources */,
EDD27BAA1F9B5EB30006471C /* XVimTester+Register.m in Sources */,
A27AB88C236AAEBF00803BE1 /* XVimTestResultTableView.m in Sources */,
EDB8EF4F1F91F8DA004188F5 /* XVimConstants.m in Sources */,
Expand Down
5 changes: 2 additions & 3 deletions XVim2/Helper/SwiftLogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import Foundation

// global function
func log(_ s: String)
{
Logger.default().log(with: s)
func debugLog(_ str: String) {
Logger.default().log(with: str)
}
5 changes: 3 additions & 2 deletions XVim2/XVim/Evaluator/Operators/XVimTildeEvaluator.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,21 @@
#import "SourceEditorViewProtocol.h"
#import "XVim.h"
#import "XVimWindow.h"
#import "XVim2-Swift.h"

@implementation XVimTildeEvaluator

- (XVimEvaluator*)fixWithNoMotion:(NSUInteger)count
{
return [self _motionFixed:[XVimMotion style:MOTION_NONE type:CHARWISE_EXCLUSIVE count:count]];
return [self _motionFixed:[[XVimMotion alloc] initWithStyle:MOTION_NONE type:CHARWISE_EXCLUSIVE count:count]];
}

- (XVimEvaluator*)TILDE
{
if (self.numericArg < 1)
return nil;

let m = [XVimMotion style:MOTION_LINE_FORWARD type:LINEWISE count:self.numericArg - 1];
let m = [[XVimMotion alloc] initWithStyle:MOTION_LINE_FORWARD type:LINEWISE count:self.numericArg - 1];
return [self _motionFixed:m];
}

Expand Down
3 changes: 2 additions & 1 deletion XVim2/XVim/Evaluator/Operators/XVimUppercaseEvaluator.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#import "SourceEditorViewProtocol.h"
#import "XVim.h"
#import "XVimWindow.h"
#import "XVim2-Swift.h"

@implementation XVimUppercaseEvaluator

Expand All @@ -18,7 +19,7 @@ - (XVimEvaluator*)U
if (self.numericArg < 1)
return nil;

let m = [XVimMotion style:MOTION_LINE_FORWARD type:LINEWISE count:self.numericArg - 1];
let m = [[XVimMotion alloc] initWithStyle:MOTION_LINE_FORWARD type:LINEWISE count:self.numericArg - 1];
return [self _motionFixed:m];
}

Expand Down
3 changes: 2 additions & 1 deletion XVim2/XVim/Evaluator/Operators/XVimYankEvaluator.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#import "SourceEditorViewProtocol.h"
#import "XVim.h"
#import "XVimWindow.h"
#import "XVim2-Swift.h"

@implementation XVimYankEvaluator

Expand All @@ -21,7 +22,7 @@ - (XVimEvaluator*)y
if (self.numericArg < 1)
return nil;

let m = [XVimMotion style:MOTION_LINE_FORWARD type:LINEWISE option:MOPT_NONE count:self.numericArg - 1];
let m = [[XVimMotion alloc] initWithStyle:MOTION_LINE_FORWARD type:LINEWISE count:self.numericArg - 1];
return [self _motionFixed:m];
}

Expand Down
2 changes: 1 addition & 1 deletion XVim2/XVim/Evaluator/XVimGMotionEvaluator.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
#import "XVim.h"
#import "XVimCommandLineEvaluator.h"
#import "XVimKeyStroke.h"
#import "XVimMotion.h"
#import "XVimMotionEvaluator.h"
#import "XVimMotionOption.h"
#import "XVimWindow.h"
#import "XVimSearch.h"
#import "XVim2-Swift.h"

#ifdef TODO
#import "XVimCommandLineEvaluator.h"
Expand Down
2 changes: 1 addition & 1 deletion XVim2/XVim/Evaluator/XVimMotionEvaluator.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
//

#import "XVimEvaluator.h"
#import "XVimMotion.h"
#import "XVimNumericEvaluator.h"
#import "XVim2-Swift.h"

@class XVimMark;

Expand Down
1 change: 0 additions & 1 deletion XVim2/XVim/Evaluator/XVimNormalEvaluator.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#import "XVimKeymapProvider.h"
#import "XVimMarkSetEvaluator.h"
#import "XVimMarks.h"
#import "XVimMotion.h"
#import "XVimOptions.h"
#import "XVimRegister.h"
#import "XVimRegisterEvaluator.h"
Expand Down
2 changes: 1 addition & 1 deletion XVim2/XVim/Evaluator/XVimTextObjectEvaluator.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

#import "XVimEvaluator.h"
#import "XVimMotion.h"
#import "XVim2-Swift.h"

@class XVimOperatorAction;

Expand Down
3 changes: 2 additions & 1 deletion XVim2/XVim/Evaluator/XVimTextObjectEvaluator.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import "XVimKeymapProvider.h"
#import "XVimMotionOption.h"
#import "XVimWindow.h"
#import "XVim2-Swift.h"

@interface XVimTextObjectEvaluator () {
BOOL _inner;
Expand All @@ -33,7 +34,7 @@ - (XVimMotion*)motion
{
var opt = _inner ? MOPT_TEXTOBJECT_INNER : MOPT_NONE;
opt |= _bigword ? MOPT_BIGWORD : MOPT_NONE;
return [XVimMotion style:_textobject type:CHARWISE_INCLUSIVE option:opt count:[self numericArg]];
return [[XVimMotion alloc] initWithStyle:_textobject type:CHARWISE_INCLUSIVE option:opt count:[self numericArg]];
}

- (XVimEvaluator*)defaultNextEvaluator { return nil; }
Expand Down
1 change: 1 addition & 0 deletions XVim2/XVim/Evaluator/XVimVisualEvaluator.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#import "XVimUppercaseEvaluator.h"
#import "XVimWindow.h"
#import "XVimYankEvaluator.h"
#import "XVim2-Swift.h"

static NSString* MODE_STRINGS[] = { @"", @"-- VISUAL --", @"-- VISUAL LINE --", @"-- VISUAL BLOCK --" };

Expand Down
2 changes: 1 addition & 1 deletion XVim2/XVim/NSTextStorage+VimOperation.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@


#import "XVimDefs.h"
#import "XVimMotion.h"
#import "XVimTextStoring.h"
#import "XVim2-Swift.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down
7 changes: 3 additions & 4 deletions XVim2/XVim/XVimMark.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import Foundation
@objc public var line: Int = NSNotFound
@objc public var column: Int = NSNotFound
@objc public var document: String?

public override init() {
super.init()
}

@objc public init(line: Int, column: Int, document: String? = nil) {
super.init()
self.line = line
Expand All @@ -31,7 +31,7 @@ import Foundation
self.init(line: NSNotFound, column: NSNotFound)
}
}

@objc public func setMark(_ mark: XVimMark?) {
if let mark = mark {
self.line = mark.line
Expand All @@ -43,5 +43,4 @@ import Foundation
document = nil
}
}

}
98 changes: 0 additions & 98 deletions XVim2/XVim/XVimMotion.m

This file was deleted.

Loading

0 comments on commit 348f5bd

Please sign in to comment.