1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-25 14:52:19 +03:00

Merge remote-tracking branch 'origin/develop' into update-neovim

This commit is contained in:
Tae Won Ha 2019-03-05 09:20:42 +01:00
commit 2e04b325a9
34 changed files with 337 additions and 188 deletions

View File

@ -6,6 +6,8 @@ github "qvacua/CocoaFontAwesome" "master"
github "qvacua/CocoaMarkdown" "master"
github "qvacua/RxMessagePort" == 0.0.5
github "qvacua/RxNeovimApi" == 0.3.4
# remove after 10.12 update
github "qvacua/RxMsgpackRpc" == 0.0.7
github "sindresorhus/github-markdown-css" == 3.0.1
github "httpswift/swifter" == 1.4.5
github "a2/MessagePack.swift" == 3.0.0

View File

@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>SNAPSHOT-301</string>
<string>SNAPSHOT-302</string>
<key>CFBundleVersion</key>
<string>301</string>
<string>302</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>

View File

@ -8,15 +8,16 @@
#import "Logging.h"
#import "CocoaCategories.h"
// FileInfo and Boolean are #defined by Carbon and NeoVim: Since we don't need the Carbon versions of them, we rename
// them.
// FileInfo and Boolean are #defined by Carbon and NeoVim.
// Since we don't need the Carbon versions of them, we rename them.
#define FileInfo CarbonFileInfo
#define Boolean CarbonBoolean
#import <nvim/main.h>
// When #define'd you can execute the NvimServer binary and neovim will be started:
// When #define'd you can execute the NvimServer binary
// and neovim will be started:
// $ ./NvimServer local remote
#undef DEBUG_NEOVIM_SERVER_STANDALONE
//#define DEBUG_NEOVIM_SERVER_STANDALONE
@ -36,8 +37,12 @@ static CFDataRef data_async(CFDataRef data, argv_callback cb) {
return NULL;
}
static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFDataRef data, void *info) {
CFRetain(data); // release in the loop callbacks! (or in the case clause when not passed to the callback)
static CFDataRef local_server_callback(
CFMessagePortRef local, SInt32 msgid, CFDataRef data, void *info
) {
// release in the loop callbacks!
// (or in the case clause when not passed to the callback)
CFRetain(data);
switch (msgid) {
@ -108,12 +113,19 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
_remoteServerName = remoteServerName;
_nvimArgs = nvimArgs;
_localServerThread = [[NSThread alloc] initWithTarget:self selector:@selector(runLocalServer) object:nil];
_localServerThread = [
[NSThread alloc] initWithTarget:self
selector:@selector(runLocalServer)
object:nil
];
_localServerThread.name = localServerName;
[_localServerThread start];
#ifndef DEBUG_NEOVIM_SERVER_STANDALONE
_remoteServerPort = CFMessagePortCreateRemote(kCFAllocatorDefault, (__bridge CFStringRef) _remoteServerName);
_remoteServerPort = CFMessagePortCreateRemote(
kCFAllocatorDefault,
(__bridge CFStringRef) _remoteServerName
);
#endif
return self;
@ -157,7 +169,12 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
}
_localServerRunLoop = CFRunLoopGetCurrent();
CFRunLoopSourceRef runLoopSrc = CFMessagePortCreateRunLoopSource(kCFAllocatorDefault, _localServerPort, 0);
CFRunLoopSourceRef runLoopSrc
= CFMessagePortCreateRunLoopSource(
kCFAllocatorDefault,
_localServerPort,
0
);
CFRunLoopAddSource(_localServerRunLoop, runLoopSrc, kCFRunLoopCommonModes);
CFRelease(runLoopSrc);
@ -178,17 +195,21 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
#endif
if (_remoteServerPort == NULL) {
WLOG("Remote server is null: The msg (%lu) could not be sent.", (unsigned long) msgid);
WLOG("Remote server is null: The msg (%lu) could not be sent.",
(unsigned long) msgid);
return;
}
SInt32 responseCode = CFMessagePortSendRequest(_remoteServerPort, msgid, data, qTimeout, qTimeout, NULL, NULL);
SInt32 responseCode = CFMessagePortSendRequest(
_remoteServerPort, msgid, data, qTimeout, qTimeout, NULL, NULL
);
if (responseCode == kCFMessagePortSuccess) {
return;
}
WLOG("The msg (%lu) could not be sent: %d", (unsigned long) msgid, responseCode);
WLOG("The msg (%lu) could not be sent: %d",
(unsigned long) msgid, responseCode);
}
- (void)notifyReadiness {

View File

@ -18,9 +18,14 @@ NvimServer *_neovim_server;
static void observe_parent_termination() {
pid_t parentPID = getppid();
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_queue_t queue = dispatch_get_global_queue(
DISPATCH_QUEUE_PRIORITY_DEFAULT, 0
);
dispatch_source_t source = dispatch_source_create(
DISPATCH_SOURCE_TYPE_PROC, (uintptr_t) parentPID, DISPATCH_PROC_EXIT, queue
DISPATCH_SOURCE_TYPE_PROC,
(uintptr_t) parentPID,
DISPATCH_PROC_EXIT,
queue
);
if (source == NULL) {
@ -45,13 +50,17 @@ int main(int argc, const char *argv[]) {
NSArray<NSString *> *arguments = [NSProcessInfo processInfo].arguments;
NSString *remoteServerName = arguments[1];
NSString *localServerName = arguments[2];
NSArray<NSString *> *nvimArgs = argc > 3 ? [arguments subarrayWithRange:NSMakeRange(3, (NSUInteger) (argc - 3))]
: nil;
NSArray<NSString *> *nvimArgs = argc > 3
? [arguments subarrayWithRange:NSMakeRange(3, (NSUInteger) (argc - 3))]
: nil;
_neovim_server = [[NvimServer alloc] initWithLocalServerName:localServerName
remoteServerName:remoteServerName
nvimArgs:nvimArgs];
DLOG("Started neovim server '%s' with args '%@' and connected it with the remote agent '%s'.",
_neovim_server = [
[NvimServer alloc] initWithLocalServerName:localServerName
remoteServerName:remoteServerName
nvimArgs:nvimArgs
];
DLOG("Started neovim server '%s' with args '%@'"
" and connected it with the remote agent '%s'.",
localServerName.cstr, nvimArgs, remoteServerName.cstr);
[_neovim_server notifyReadiness];

View File

@ -42,9 +42,9 @@
4B0A1B142129F49500F1E02F /* SwiftCommonsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B0A1B132129F49500F1E02F /* SwiftCommonsTest.swift */; };
4B0A1B39212B332800F1E02F /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B0A1B38212B332800F1E02F /* Nimble.framework */; };
4B0A1B3B212B333700F1E02F /* Nimble.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B0A1B38212B332800F1E02F /* Nimble.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
4B177886201220F300E32FF0 /* SharedTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 1929B4F32708E99C40A57020 /* SharedTypes.h */; settings = {ATTRIBUTES = (Public, ); }; };
4B17E549209E3E4100265C1D /* RxNeovimApi.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B17E548209E3E4100265C1D /* RxNeovimApi.framework */; };
4B21ED53213D4AEC009FD017 /* CocoaCommons.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929B0C89838D8402BB80BFC /* CocoaCommons.swift */; };
4B4A48DC222C7C6A00C8E3A1 /* SharedTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B4A48DB222C7C6A00C8E3A1 /* SharedTypes.h */; settings = {ATTRIBUTES = (Public, ); }; };
4B8662E81FDC3F9F007F490D /* com.qvacua.NvimView.vim in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B8662E41FDC3D4F007F490D /* com.qvacua.NvimView.vim */; };
4B90F02E1FD2AFAE008A39E0 /* NvimView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B90F0101FD2AFAC008A39E0 /* NvimView.swift */; };
4B90F02F1FD2AFAE008A39E0 /* NvimView+Resize.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B90F0111FD2AFAC008A39E0 /* NvimView+Resize.swift */; };
@ -172,7 +172,6 @@
1929B0C89838D8402BB80BFC /* CocoaCommons.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CocoaCommons.swift; sourceTree = "<group>"; };
1929B22A0CAD417EC3790F02 /* NvimView+Objects.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NvimView+Objects.swift"; sourceTree = "<group>"; };
1929B47330DAD129520A2273 /* Typesetter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Typesetter.swift; sourceTree = "<group>"; };
1929B4F32708E99C40A57020 /* SharedTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedTypes.h; sourceTree = "<group>"; };
1929B52174EC68D2974B5BAE /* UiBridge.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UiBridge.swift; sourceTree = "<group>"; };
1929B60D1775A75D7C0F6721 /* SimpleCache.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SimpleCache.swift; sourceTree = "<group>"; };
1929B73455764E42DACF6BB8 /* Geometry.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Geometry.swift; sourceTree = "<group>"; };
@ -199,6 +198,8 @@
4B0A1B152129F49500F1E02F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4B0A1B38212B332800F1E02F /* Nimble.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nimble.framework; path = ../Carthage/Build/Mac/Nimble.framework; sourceTree = "<group>"; };
4B17E548209E3E4100265C1D /* RxNeovimApi.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RxNeovimApi.framework; path = ../Carthage/Build/Mac/RxNeovimApi.framework; sourceTree = "<group>"; };
4B4A48DA222C7C5600C8E3A1 /* SharedTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedTypes.h; sourceTree = "<group>"; };
4B4A48DB222C7C6A00C8E3A1 /* SharedTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedTypes.h; sourceTree = "<group>"; };
4B8662E41FDC3D4F007F490D /* com.qvacua.NvimView.vim */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.vim; path = com.qvacua.NvimView.vim; sourceTree = "<group>"; };
4B90F0041FD2AF59008A39E0 /* NvimView.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = NvimView.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4B90F0081FD2AF59008A39E0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@ -340,7 +341,6 @@
4BF1852121313EE400954FE7 /* DrawerDev */,
4B90F0051FD2AF59008A39E0 /* Products */,
4B90F06F1FD2B9F1008A39E0 /* Frameworks */,
1929B4F32708E99C40A57020 /* SharedTypes.h */,
);
sourceTree = "<group>";
};
@ -358,6 +358,7 @@
4B90F0061FD2AF59008A39E0 /* NvimView */ = {
isa = PBXGroup;
children = (
4B4A48DB222C7C6A00C8E3A1 /* SharedTypes.h */,
4B90F0081FD2AF59008A39E0 /* Info.plist */,
4B8662E41FDC3D4F007F490D /* com.qvacua.NvimView.vim */,
4BF18C5C1FD2EEE400DF95D1 /* NvimView.h */,
@ -389,6 +390,7 @@
4B90F0501FD2AFD3008A39E0 /* NvimServer */ = {
isa = PBXGroup;
children = (
4B4A48DA222C7C5600C8E3A1 /* SharedTypes.h */,
4B90F0511FD2AFD3008A39E0 /* main.m */,
4B90F0571FD2AFF7008A39E0 /* CocoaCategories.h */,
4B90F05A1FD2AFF7008A39E0 /* CocoaCategories.m */,
@ -436,7 +438,7 @@
buildActionMask = 2147483647;
files = (
4BF18C5D1FD2EEE400DF95D1 /* NvimView.h in Headers */,
4B177886201220F300E32FF0 /* SharedTypes.h in Headers */,
4B4A48DC222C7C6A00C8E3A1 /* SharedTypes.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -487,6 +489,7 @@
isa = PBXNativeTarget;
buildConfigurationList = 4B90F0531FD2AFD3008A39E0 /* Build configuration list for PBXNativeTarget "NvimServer" */;
buildPhases = (
4B4A48DE222C7E6800C8E3A1 /* ShellScript */,
4BE45C091FD2D92D005C0A95 /* ShellScript */,
4B90F04B1FD2AFD3008A39E0 /* Sources */,
4B90F04C1FD2AFD3008A39E0 /* Frameworks */,
@ -593,6 +596,23 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
4B4A48DE222C7E6800C8E3A1 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/bash;
shellScript = "if [[ $(md5 -q NvimView/SharedTypes.h) != $(md5 -q NvimServer/SharedTypes.h) ]]; then\n echo \"SharedTypes.h not equal!\"\n exit 1\nfi\n";
};
4BE45C091FD2D92D005C0A95 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
@ -783,7 +803,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 301;
CURRENT_PROJECT_VERSION = 302;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
@ -845,7 +865,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 301;
CURRENT_PROJECT_VERSION = 302;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
@ -874,7 +894,7 @@
COMBINE_HIDPI_IMAGES = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 301;
DYLIB_CURRENT_VERSION = 302;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../Carthage/Build/Mac";
FRAMEWORK_VERSION = A;
@ -896,7 +916,7 @@
COMBINE_HIDPI_IMAGES = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 301;
DYLIB_CURRENT_VERSION = 302;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../Carthage/Build/Mac";
FRAMEWORK_VERSION = A;

View File

@ -219,7 +219,7 @@ final class AttributesRunDrawer {
private func updateFontMetrics() {
self.cellSize = FontUtils.cellSize(
of: self.font, linespacing: linespacing
of: self.font, linespacing: self.linespacing
)
self.baselineOffset = self.cellSize.height - CTFontGetAscent(self.font)
self.descent = CTFontGetDescent(font)

View File

@ -32,8 +32,11 @@ extension FontTrait: Hashable {
final class FontUtils {
static func cellSize(of font: NSFont, linespacing: CGFloat) -> CGSize {
if let cached = cellSizeCache.object(forKey: font) {
return cached
if let cached = cellSizeWithDefaultLinespacingCache.object(forKey: font) {
return CGSize(
width: cached.width,
height: ceil(linespacing * cached.height)
)
}
let capitalM = [UniChar(0x004D)]
@ -46,11 +49,18 @@ final class FontUtils {
let descent = CTFontGetDescent(font)
let leading = CTFontGetLeading(font)
let cellSizeToCache = CGSize(
width: advancement.width,
height: ceil(ascent + descent + leading)
)
cellSizeWithDefaultLinespacingCache.set(
object: cellSizeToCache, forKey: font
)
let cellSize = CGSize(
width: advancement.width,
height: ceil(linespacing * (ascent + descent + leading))
height: ceil(linespacing * cellSizeToCache.height)
)
cellSizeCache.set(object: cellSize, forKey: font)
return cellSize
}
@ -87,4 +97,4 @@ final class FontUtils {
}
private let fontCache = SimpleCache<SizedFontTrait, NSFont>(countLimit: 100)
private let cellSizeCache = SimpleCache<NSFont, CGSize>(countLimit: 100)
private let cellSizeWithDefaultLinespacingCache = SimpleCache<NSFont, CGSize>(countLimit: 100)

View File

@ -15,9 +15,9 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>SNAPSHOT-301</string>
<string>SNAPSHOT-302</string>
<key>CFBundleVersion</key>
<string>301</string>
<string>302</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2017 Tae Won Ha. All rights reserved.</string>
<key>NSPrincipalClass</key>

View File

@ -1,37 +0,0 @@
/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
#ifdef DEBUG
#ifndef log4Debug
#define log4Debug(format, ...) printf("%s", [[NSString stringWithFormat:(@"[DEBUG] %s %@ %s - %d: " format "\n"), __TIME__, [[NSString stringWithUTF8String: __FILE__] lastPathComponent], __func__, __LINE__, ##__VA_ARGS__] UTF8String])
#endif
#ifndef log4Mark
#define log4Mark printf("%s", [[NSString stringWithFormat:(@"%s %s %s - %d\n"), __TIME__, __FILE__, __PRETTY_FUNCTION__, __LINE__] UTF8String])
#endif
#else
#define log4Debug(...)
#define log4Mark
#endif
#ifndef log4Info
#define log4Info(format, ...) printf("%s", [[NSString stringWithFormat:(@"[INFO] %s %@ %s - %d: " format "\n"), __TIME__, [[NSString stringWithUTF8String: __FILE__] lastPathComponent], __func__, __LINE__, ##__VA_ARGS__] UTF8String])
#endif
#ifndef log4Warn
#define log4Warn(format, ...) printf("%s", [[NSString stringWithFormat:(@"[WARN] %s %@ %s - %d: " format "\n"), __TIME__, [[NSString stringWithUTF8String: __FILE__] lastPathComponent], __func__, __LINE__, ##__VA_ARGS__] UTF8String])
#endif
#ifndef log4Error
#define log4Error(format, ...) printf("%s", [[NSString stringWithFormat:(@"[ERROR] %s %@ %s - %d: " format "\n"), __TIME__, [[NSString stringWithUTF8String: __FILE__] lastPathComponent], __func__, __LINE__, ##__VA_ARGS__] UTF8String])
#endif
#ifndef log4Fatal
#define log4Fatal(format, ...) printf("%s", [[NSString stringWithFormat:(@"[FATAL] %s %@ %s - %d: " format "\n"), __TIME__, [[NSString stringWithUTF8String: __FILE__] lastPathComponent], __func__, __LINE__, ##__VA_ARGS__] UTF8String])
#endif

View File

@ -5,11 +5,6 @@
import Foundation
let stdoutLogger = LogContext.stdoutLogger(as: "NvimView")
let logger = LogContext.fileLogger(
as: "NvimView", with: URL(fileURLWithPath: "/tmp/nvv.log")
)
class LogContext {
enum Level: String {

View File

@ -92,14 +92,14 @@ extension NvimView {
|| cursorRegion.bottom > self.ugrid.size.height - 1
|| cursorRegion.left < 0
|| cursorRegion.right > self.ugrid.size.width - 1 {
logger.error("\(cursorRegion) vs. \(self.ugrid.size)")
self.logger.error("\(cursorRegion) vs. \(self.ugrid.size)")
return
}
guard let cursorAttrs = self.cellAttributesCollection.attributes(
of: self.ugrid.cells[cursorPosition.row][cursorPosition.column].attrId
)?.reversed else {
stdoutLogger.error("Could not get the attributes" +
" at cursor: \(cursorPosition)")
self.stdoutLogger.error("Could not get the attributes" +
" at cursor: \(cursorPosition)")
return
}
@ -205,9 +205,9 @@ extension NvimView {
)
else {
// GH-666: FIXME: correct error handling
logger.error("row: \(row), range: \(range): " +
"Could not get CellAttributes with ID " +
"\(String(describing: cells.first?.attrId))")
self.logger.error("row: \(row), range: \(range): " +
"Could not get CellAttributes with ID " +
"\(String(describing: cells.first?.attrId))")
return nil
}

View File

@ -22,7 +22,7 @@ extension NvimView {
let cocoaHandledEvent
= NSTextInputContext.current?.handleEvent(event) ?? false
if self.keyDownDone && cocoaHandledEvent {
logger.debug("returning: key down done and cocoa handled event")
self.logger.debug("returning: key down done and cocoa handled event")
return
}
}
@ -52,7 +52,7 @@ extension NvimView {
}
public func insertText(_ object: Any, replacementRange: NSRange) {
logger.debug("\(object) with \(replacementRange)")
self.logger.debug("\(object) with \(replacementRange)")
let text: String
switch object {
@ -97,15 +97,15 @@ extension NvimView {
public override func doCommand(by aSelector: Selector) {
if self.responds(to: aSelector) {
logger.debug("calling \(aSelector)")
self.logger.debug("calling \(aSelector)")
self.perform(aSelector, with: self)
self.keyDownDone = true
return
}
logger.debug("\(aSelector) not implemented, " +
"forwarding input to neovim")
self.logger.debug("\(aSelector) not implemented, " +
"forwarding input to neovim")
self.keyDownDone = false
}
@ -168,8 +168,8 @@ extension NvimView {
selectedRange: NSRange,
replacementRange: NSRange
) {
logger.debug("object: \(object), selectedRange: \(selectedRange), " +
"replacementRange: \(replacementRange)")
self.logger.debug("object: \(object), selectedRange: \(selectedRange), " +
"replacementRange: \(replacementRange)")
defer { self.keyDownDone = true }
@ -197,15 +197,15 @@ extension NvimView {
self.markedPosition = newMarkedPosition
logger.debug("Deleting \(replacementRange.length) " +
"and inputting \(self.markedText!)")
self.logger.debug("Deleting \(replacementRange.length) " +
"and inputting \(self.markedText!)")
try? self.bridge.deleteCharacters(
replacementRange.length,
andInputEscapedString: self.vimPlainString(self.markedText!)
).wait()
} else {
logger.debug("Deleting \(oldMarkedTextLength) " +
"and inputting \(self.markedText!)")
self.logger.debug("Deleting \(oldMarkedTextLength) " +
"and inputting \(self.markedText!)")
try? self.bridge.deleteCharacters(
oldMarkedTextLength,
andInputEscapedString: self.vimPlainString(self.markedText!)
@ -216,7 +216,7 @@ extension NvimView {
}
public func unmarkText() {
logger.mark()
self.logger.mark()
let position = self.markedPosition
self.ugrid.unmarkCell(at: position)
@ -241,7 +241,7 @@ extension NvimView {
// When the app starts and the Hangul input method is selected,
// this method gets called very early...
guard self.ugrid.hasData else {
logger.debug("No data in UGrid!")
self.logger.debug("No data in UGrid!")
return .notFound
}
@ -253,13 +253,13 @@ extension NvimView {
length: 0
)
logger.debug("Returning \(result)")
self.logger.debug("Returning \(result)")
return result
}
public func markedRange() -> NSRange {
guard let marked = self.markedText else {
logger.debug("No marked text, returning not found")
self.logger.debug("No marked text, returning not found")
return .notFound
}
@ -268,7 +268,7 @@ extension NvimView {
length: marked.count
)
logger.debug("Returning \(result)")
self.logger.debug("Returning \(result)")
return result
}
@ -281,7 +281,7 @@ extension NvimView {
actualRange: NSRangePointer?
) -> NSAttributedString? {
logger.debug("\(aRange)")
self.logger.debug("\(aRange)")
if aRange.location == NSNotFound {
return nil
}
@ -297,7 +297,7 @@ extension NvimView {
return nil
}
logger.debug("\(position) ... \(inclusiveEndPosition)")
self.logger.debug("\(position) ... \(inclusiveEndPosition)")
let string = self.ugrid.cells[position.row...inclusiveEndPosition.row]
.map { row in
row.filter { cell in
@ -311,10 +311,10 @@ extension NvimView {
let delta = aRange.length - string.utf16.count
if delta != 0 {
logger.debug("delta = \(delta)!")
self.logger.debug("delta = \(delta)!")
}
logger.debug("returning '\(string)'")
self.logger.debug("returning '\(string)'")
return NSAttributedString(string: string)
}
@ -331,7 +331,7 @@ extension NvimView {
return CGRect.zero
}
logger.debug("\(aRange)-> \(position.row):\(position.column)")
self.logger.debug("\(aRange)-> \(position.row):\(position.column)")
let resultInSelf = self.rect(forRow: position.row, column: position.column)
let result = self.window?.convertToScreen(
@ -345,7 +345,7 @@ extension NvimView {
let position = self.position(at: aPoint)
let result = self.ugrid.flatCharIndex(forPosition: position)
logger.debug("\(aPoint) -> \(position) -> \(result)")
self.logger.debug("\(aPoint) -> \(position) -> \(result)")
return result
}

View File

@ -65,7 +65,7 @@ extension NvimView {
}
private func launchNeoVim(_ size: Size) {
logger.info("=== Starting neovim...")
self.logger.info("=== Starting neovim...")
let sockPath = URL(
fileURLWithPath: NSTemporaryDirectory()
).appendingPathComponent("vimr_\(self.uuid).sock").path
@ -75,16 +75,16 @@ extension NvimView {
switch msg {
case let .notification(method, params):
logger.debug("NOTIFICATION: \(method): \(params)")
self.logger.debug("NOTIFICATION: \(method): \(params)")
guard method == NvimView.rpcEventName else { return }
self.eventsSubject.onNext(.rpcEvent(method, params))
self.eventsSubject.onNext(.rpcEvent(params))
case let .error(_, msg):
logger.debug("MSG ERROR: \(msg)")
self.logger.debug("MSG ERROR: \(msg)")
default:
logger.debug("???: This should not happen")
self.logger.debug("???: This should not happen")
break
}

View File

@ -172,7 +172,7 @@ extension NvimView {
)
.andThen(self.bridge.notifyReadinessForRpcEvents())
.subscribe(onCompleted: {
logger.debug("GUIEnter aucmd fired")
self.logger.debug("GUIEnter aucmd fired")
})
.disposed(by: self.disposeBag)
@ -216,7 +216,7 @@ extension NvimView {
private func doRawLine(data: [MessagePackValue]) -> (Bool, Int) {
guard data.count == 7 else {
stdoutLogger.error(
self.stdoutLogger.error(
"Data has wrong number of elements: \(data.count) instead of 7"
)
return (false, Int.max)
@ -231,7 +231,7 @@ extension NvimView {
let attrIds = data[6].arrayValue?.compactMap({ $0.intValue })
else {
stdoutLogger.error("Values could not be read from: \(data)")
self.stdoutLogger.error("Values could not be read from: \(data)")
return (false, Int.max)
}

View File

@ -55,7 +55,7 @@ public class NvimView: NSView,
case scroll
case cursor(Position)
case rpcEvent(String, [MessagePack.MessagePackValue])
case rpcEvent([MessagePack.MessagePackValue])
case rpcEventSubscribed
case initVimError
@ -228,13 +228,13 @@ public class NvimView: NSView,
switch msg {
case .ready:
logger.info("Nvim is ready")
self.logger.info("Nvim is ready")
case .initVimError:
self.eventsSubject.onNext(.initVimError)
case .unknown:
logger.error("Unknown message from NvimServer")
self.logger.error("Unknown message from NvimServer")
case let .resize(value):
self.resize(value)
@ -329,9 +329,9 @@ public class NvimView: NSView,
}
@IBAction public func debug1(_ sender: Any?) {
logger.debug("DEBUG 1 - Start")
self.logger.debug("DEBUG 1 - Start")
// noop
logger.debug("DEBUG 1 - End")
self.logger.debug("DEBUG 1 - End")
}
// MARK: - Internal
@ -386,6 +386,12 @@ public class NvimView: NSView,
shouldLogDebug: nil
)
let logger = LogContext.fileLogger(
as: NvimView.self, with: URL(fileURLWithPath: "/tmp/nvv.log")
)
let stdoutLogger = LogContext.stdoutLogger(as: NvimView.self)
let sourceFileUrls: [URL]
let rpcEventSubscribedCondition = NSCondition()

View File

@ -0,0 +1,60 @@
/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
#import <Foundation/Foundation.h>
typedef NS_OPTIONS(NSUInteger, FontTrait) {
FontTraitNone = 0,
FontTraitItalic = (1 << 0),
FontTraitBold = (1 << 1),
FontTraitUnderline = (1 << 2),
FontTraitUndercurl = (1 << 3)
};
typedef NS_ENUM(NSInteger, RenderDataType) {
RenderDataTypeRawLine,
RenderDataTypeGoto,
RenderDataTypeScroll,
};
typedef NS_ENUM(NSInteger, NvimServerMsgId) {
NvimServerMsgIdServerReady = 0,
NvimServerMsgIdNvimReady,
NvimServerMsgIdResize,
NvimServerMsgIdClear,
NvimServerMsgIdSetMenu,
NvimServerMsgIdBusyStart,
NvimServerMsgIdBusyStop,
NvimServerMsgIdModeChange,
NvimServerMsgIdBell,
NvimServerMsgIdVisualBell,
NvimServerMsgIdFlush,
NvimServerMsgIdHighlightAttrs,
NvimServerMsgIdSetTitle,
NvimServerMsgIdStop,
NvimServerMsgIdOptionSet,
NvimServerMsgIdDirtyStatusChanged,
NvimServerMsgIdCwdChanged,
NvimServerMsgIdColorSchemeChanged,
NvimServerMsgIdDefaultColorsChanged,
NvimServerMsgIdAutoCommandEvent,
NvimServerMsgIdRpcEventSubscribed,
NvimServerMsgIdDebug1,
};
typedef NS_ENUM(NSInteger, NvimBridgeMsgId) {
NvimBridgeMsgIdAgentReady = 0,
NvimBridgeMsgIdReadyForRpcEvents,
NvimBridgeMsgIdInput,
NvimBridgeMsgIdDeleteInput,
NvimBridgeMsgIdResize,
NvimBridgeMsgIdScroll,
NvimBridgeMsgIdFocusGained,
NvimBridgeMsgIdDebug1,
};

View File

@ -267,7 +267,7 @@ final class UGrid: CustomStringConvertible {
}
func resize(_ size: Size) {
logger.debug(size)
self.logger.debug(size)
self.size = size
self.cursorPosition = .zero
@ -306,7 +306,7 @@ final class UGrid: CustomStringConvertible {
}
func recomputeFlatIndices(rowStart: Int, rowEndInclusive: Int) {
logger.debug("Recomputing flat indices from row \(rowStart)")
self.logger.debug("Recomputing flat indices from row \(rowStart)")
var delta = 0
if rowStart > 0 {
@ -325,6 +325,10 @@ final class UGrid: CustomStringConvertible {
}
}
}
private let logger = LogContext.fileLogger(
as: UGrid.self, with: URL(fileURLWithPath: "/tmp/nvv.log")
)
}
private let clearString = " "

View File

@ -61,13 +61,13 @@ class UiBridge {
if let envDict = config.envDict {
self.envDict = envDict
logger.debug("using envs from vimr: \(envDict)")
self.logger.debug("using envs from vimr: \(envDict)")
} else {
let selfEnv = ProcessInfo.processInfo.environment
let shellUrl = URL(fileURLWithPath: selfEnv["SHELL"] ?? "/bin/bash")
let interactiveMode = shellUrl.lastPathComponent == "zsh" && !config.useInteractiveZsh ? false : true
self.envDict = ProcessUtils.envVars(of: shellUrl, usingInteractiveMode: interactiveMode)
logger.debug("using envs from login shell: \(self.envDict)")
self.logger.debug("using envs from login shell: \(self.envDict)")
}
self.queue = queue
@ -299,7 +299,7 @@ class UiBridge {
var env = self.envDict
env["NVIM_LISTEN_ADDRESS"] = listenAddress.path
stdoutLogger.debug("listen addr: \(listenAddress.path)")
self.stdoutLogger.debug("listen addr: \(listenAddress.path)")
let outPipe = Pipe()
let errorPipe = Pipe()
@ -326,6 +326,7 @@ class UiBridge {
}
private let logger = LogContext.fileLogger(as: UiBridge.self, with: URL(fileURLWithPath: "/tmp/nvv-bridge.log"))
private let stdoutLogger = LogContext.stdoutLogger(as: UiBridge.self)
private let uuid: UUID

View File

@ -1,45 +1,3 @@
set termguicolors
set mouse=a
set title
"function! s:VimRMakeSessionTemporary() abort
" call rpcnotify(0, 'com.qvacua.vimr.rpc-events.make-session-temporary')
"endfunction
"command! -nargs=0 VimRMakeSessionTemporary call s:VimRMakeSessionTemporary(<args>)
"
"function! s:VimRMaximizeWindow() abort
" call rpcnotify(0, 'com.qvacua.vimr.rpc-events.maximize-window')
"endfunction
"command! -nargs=0 VimRMaximizeWindow call s:VimRMaximizeWindow(<args>)
"
"" -1: hide, 0: toggle, 1: show
"function! s:VimRToggleTools(value) abort
" call rpcnotify(0, 'com.qvacua.vimr.rpc-events.toggle-tools', a:value)
"endfunction
"command! -nargs=0 VimRHideTools call s:VimRToggleTools(-1)
"command! -nargs=0 VimRToggleTools call s:VimRToggleTools(0)
"command! -nargs=0 VimRShowTools call s:VimRToggleTools(1)
"
"" -1: hide, 0: toggle, 1: show
"function! s:VimRToggleToolButtons(value) abort
" call rpcnotify(0, 'com.qvacua.vimr.rpc-events.toggle-tool-buttons', a:value)
"endfunction
"command! -nargs=0 VimRHideToolButtons call s:VimRToggleToolButtons(-1)
"command! -nargs=0 VimRToggleToolButtons call s:VimRToggleToolButtons(0)
"command! -nargs=0 VimRShowToolButtons call s:VimRToggleToolButtons(1)
"
"function! s:VimRToggleFullscreen() abort
" call rpcnotify(0, 'com.qvacua.vimr.rpc-events.toggle-fullscreen')
"endfunction
"command! -nargs=0 VimRToggleFullscreen call s:VimRToggleFullscreen(<args>)
"
"function! s:VimRTest() abort
" VimRMakeSessionTemporary
" VimRHideTools
" VimRMaximizeWindow
" normal o
"endfunction
"command! -nargs=0 VimRTest call s:VimRTest()
"
""au VimEnter * echo "hello"
""au GuiEnter * echo "world"

View File

@ -15,8 +15,8 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>SNAPSHOT-301</string>
<string>SNAPSHOT-302</string>
<key>CFBundleVersion</key>
<string>301</string>
<string>302</string>
</dict>
</plist>

View File

@ -80,12 +80,14 @@
1929BDC69A5F9D1661423488 /* ShortcutItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929BF230875DED6CD7AB3EB /* ShortcutItem.swift */; };
1929BDFDBDA7180D02ACB37E /* RxSwiftCommonsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929B6C215ACCBE12672A8D7 /* RxSwiftCommonsTest.swift */; };
1929BE0DAEE9664C5BCFA211 /* States.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929BB6608B4F0E037CA0F4C /* States.swift */; };
1929BE0EB11D6BBC46D448D2 /* RpcAppearanceEpic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929B230EE8F1428980988F0 /* RpcAppearanceEpic.swift */; };
1929BE0F64A6CE5BCE2A5092 /* MainWindow+Delegates.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929B714EB137AE448CE8ABD /* MainWindow+Delegates.swift */; };
1929BE2F3E0182CC51F2763A /* ThemedTableSubviews.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929BD2CA8DD198A6BCDBCB7 /* ThemedTableSubviews.swift */; };
1929BEAE0592096BC1191B67 /* PrefPane.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929B07A4A9209C88380E015 /* PrefPane.swift */; };
1929BEDE1BE950EDA9497363 /* GeneralPref.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929BB55946DAEBF55D24048 /* GeneralPref.swift */; };
1929BEFEABA0448306CDB6D4 /* FileItemIgnorePatternTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929BBC84557C8351EC6183E /* FileItemIgnorePatternTest.swift */; };
1929BF03FD6465F289AA80B2 /* ToolsPref.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929BB2AD21A10A0ECA66A5E /* ToolsPref.swift */; };
1929BF3253594E5B1908C6CE /* RpcAppearanceEpic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929B230EE8F1428980988F0 /* RpcAppearanceEpic.swift */; };
1929BF4FF30D9A9DE82C3052 /* FileUtilsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929B8042AC566CDF6C998A3 /* FileUtilsTest.swift */; };
1929BFC70581084B5CE04A5B /* MatcherTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929BFE179BCA3C75A13D71B /* MatcherTests.swift */; };
1929BFDE22D155F7C4B19E96 /* HtmlPreviewTool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929B85023B042C485409CE1 /* HtmlPreviewTool.swift */; };
@ -312,6 +314,7 @@
1929B14A5949FB64C4B2646F /* KeysPref.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeysPref.swift; sourceTree = "<group>"; };
1929B1558455B3A74D93EF2A /* OpenQuicklyFileViewRow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OpenQuicklyFileViewRow.swift; sourceTree = "<group>"; };
1929B1DC584C89C477E83FA2 /* HttpServerMiddleware.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HttpServerMiddleware.swift; sourceTree = "<group>"; };
1929B230EE8F1428980988F0 /* RpcAppearanceEpic.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RpcAppearanceEpic.swift; sourceTree = "<group>"; };
1929B34FC23D805A8B29E8F7 /* Context.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Context.swift; sourceTree = "<group>"; };
1929B364460D86F17E80943C /* PrefMiddleware.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PrefMiddleware.swift; sourceTree = "<group>"; };
1929B365A6434354B568B04F /* FileMonitor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FileMonitor.swift; sourceTree = "<group>"; };
@ -627,6 +630,7 @@
1929B5E773BDB3B4EE9D00C1 /* Reducers */,
1929BFA93DC859DD76C46192 /* Middlewares */,
1929BFC0A5A9C6DB09BE1368 /* Types.swift */,
1929BE4A67D96BD8BD8168C3 /* Epics */,
);
name = UI;
sourceTree = "<group>";
@ -681,6 +685,14 @@
name = "Open Quickly";
sourceTree = "<group>";
};
1929BE4A67D96BD8BD8168C3 /* Epics */ = {
isa = PBXGroup;
children = (
1929B230EE8F1428980988F0 /* RpcAppearanceEpic.swift */,
);
name = Epics;
sourceTree = "<group>";
};
1929BFA93DC859DD76C46192 /* Middlewares */ = {
isa = PBXGroup;
children = (
@ -1191,6 +1203,7 @@
1929B2D56C4652E251C23AD4 /* DefaultShortcuts.swift in Sources */,
1929B0C7150100A84FBDB8BF /* ShortcutItem.swift in Sources */,
1929B250DB3FB395A700FE8C /* RpcEvents.swift in Sources */,
1929BF3253594E5B1908C6CE /* RpcAppearanceEpic.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -1226,6 +1239,7 @@
1929B0244BD7111E168726CF /* DefaultShortcuts.swift in Sources */,
1929BDC69A5F9D1661423488 /* ShortcutItem.swift in Sources */,
1929B489A51FD5B13888A00C /* RpcEvents.swift in Sources */,
1929BE0EB11D6BBC46D448D2 /* RpcAppearanceEpic.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -1320,7 +1334,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 301;
CURRENT_PROJECT_VERSION = 302;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
@ -1378,7 +1392,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 301;
CURRENT_PROJECT_VERSION = 302;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;

View File

@ -3,5 +3,5 @@
* See LICENSE
*/
#import <NvimView/NvimView.h>
#import <NvimView/SharedTypes.h>
#import "NetUtils.h"

View File

@ -28,6 +28,7 @@ class Context: ReduxContext {
let httpMiddleware: HttpServerMiddleware = HttpServerMiddleware(port: baseServerUrl.port!)
let uiRootReducer = UiRootReducer()
let openQuicklyReducer = OpenQuicklyReducer()
let rpcEpic = RpcAppearanceEpic(emitter: self.actionEmitter)
// AppState
self.actionEmitter.observable
@ -52,6 +53,7 @@ class Context: ReduxContext {
middlewares: [
self.prefMiddleware.mainWindow.apply,
self.prefMiddleware.apply,
rpcEpic.apply,
])
.filter { $0.modified }
.subscribe(onNext: self.emitAppState)

View File

@ -1224,7 +1224,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>SNAPSHOT-301</string>
<string>SNAPSHOT-302</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
@ -1241,7 +1241,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>301</string>
<string>302</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.productivity</string>
<key>LSMinimumSystemVersion</key>

View File

@ -31,7 +31,7 @@ extension MainWindow {
self.window.setFrame(screen.frame, display: true)
case .toggleTools:
if params.count == 0 { return }
guard params.count == 1 else { return }
let param = params[0].integerValue
@ -44,7 +44,7 @@ extension MainWindow {
}
case .toggleToolButtons:
if params.count == 0 { return }
guard params.count == 1 else { return }
let param = params[0].integerValue
@ -59,6 +59,23 @@ extension MainWindow {
case .toggleFullScreen:
self.window.toggleFullScreen(self)
case .setFont:
guard params.count == 2 else { return }
guard let fontName = params[0].stringValue,
let fontSize = params[1].integerValue,
let font = NSFont(name: fontName, size: CGFloat(fontSize))
else {
return
}
self.emit(self.uuidAction(for: .setFont(font)))
case .setLinespacing:
guard params.count == 1 else { return }
guard let linespacing = params[0].floatValue else { return }
self.emit(self.uuidAction(for: .setLinespacing(CGFloat(linespacing))))
}
}

View File

@ -45,6 +45,10 @@ class MainWindow: NSObject,
case setTheme(Theme)
case close
// RPC actions
case setFont(NSFont)
case setLinespacing(CGFloat)
}
enum FocusableView {
@ -285,7 +289,7 @@ class MainWindow: NSObject,
fileLog.error("Got api error with msg '\(msg)' and error: \(error)")
break
case .rpcEvent(let method, let params):
case .rpcEvent(let params):
self.rpcEventAction(params: params)
case .rpcEventSubscribed:

View File

@ -0,0 +1,42 @@
/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Foundation
class RpcAppearanceEpic: EpicType {
typealias StateType = AppState
typealias ActionType = UuidAction<MainWindow.Action>
typealias EmitActionType = AppearancePref.Action
required init(emitter: ActionEmitter) {
self.emit = emitter.typedEmit()
}
func typedApply(
_ reduce: @escaping TypedActionReduceFunction
) -> TypedActionReduceFunction {
return { tuple in
let result = reduce(tuple)
switch tuple.action.payload {
case .setFont(let font):
self.emit(.setFont(font))
case .setLinespacing(let linespacing):
self.emit(.setLinespacing(linespacing))
default:
break
}
return result
}
}
private let emit: (EmitActionType) -> Void
}

View File

@ -14,4 +14,7 @@ enum RpcEvent: String, CaseIterable {
case toggleTools = "com.qvacua.vimr.rpc-events.toggle-tools"
case toggleToolButtons = "com.qvacua.vimr.rpc-events.toggle-tool-buttons"
case toggleFullScreen = "com.qvacua.vimr.rpc-events.toggle-fullscreen"
case setFont = "com.qvacua.vimr.rpc-events.set-font"
case setLinespacing = "com.qvacua.vimr.rpc-events.set-linespacing"
}

View File

@ -95,6 +95,13 @@ extension MiddlewareType {
}
}
protocol EpicType: MiddlewareType {
associatedtype EmitActionType
init(emitter: ActionEmitter)
}
protocol UiComponent {
associatedtype StateType

View File

@ -28,3 +28,13 @@ function! s:VimRToggleFullscreen() abort
call rpcnotify(0, 'com.qvacua.NvimView', 'toggle-fullscreen')
endfunction
command! -nargs=0 VimRToggleFullscreen call s:VimRToggleFullscreen(<args>)
function! s:VimRSetFontAndSize(font, size) abort
call rpcnotify(0, 'com.qvacua.NvimView', 'set-font', a:font, a:size)
endfunction
command! -nargs=* VimRSetFontAndSize call s:VimRSetFontAndSize(<args>)
function! s:VimRSetLinespacing(linespacing) abort
call rpcnotify(0, 'com.qvacua.NvimView', 'set-linespacing', a:linespacing)
endfunction
command! -nargs=1 VimRSetLinespacing call s:VimRSetLinespacing(<args>)

View File

@ -15,10 +15,10 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>SNAPSHOT-301</string>
<string>SNAPSHOT-302</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>301</string>
<string>302</string>
</dict>
</plist>

View File

@ -7,22 +7,22 @@
<description>Most recent changes with links to updates for VimR.</description>
<language>en</language>
<item>
<title>SNAPSHOT-300</title>
<title>SNAPSHOT-302</title>
<description><![CDATA[
<ul>
<li>GH-314: You can customize the key shortcut for all menu items in the <em>Shortcut</em> preferences pane.</li>
<li>GH-506: Set font, size and linespacing via <code>~/.config/nvim/ginit.vim</code>.</li>
</ul>
]]></description>
<releaseNotesLink>
https://github.com/qvacua/vimr/releases/tag/snapshot/300
https://github.com/qvacua/vimr/releases/tag/snapshot/302
</releaseNotesLink>
<pubDate>2019-02-28T01:35:36.184805</pubDate>
<pubDate>2019-03-05T09:14:18.762884</pubDate>
<minimumSystemVersion>10.10.0</minimumSystemVersion>
<enclosure url="https://github.com/qvacua/vimr/releases/download/snapshot/300/VimR-SNAPSHOT-300.tar.bz2"
sparkle:version="300"
sparkle:shortVersionString="SNAPSHOT-300"
sparkle:dsaSignature="MC0CFQDSCAZCOCs8Gdg/gdESlyjqXMdOagIUGuj2Qduyt10abGSs5wRuY4hj8a4="
length="14887427"
<enclosure url="https://github.com/qvacua/vimr/releases/download/snapshot/302/VimR-SNAPSHOT-302.tar.bz2"
sparkle:version="302"
sparkle:shortVersionString="SNAPSHOT-302"
sparkle:dsaSignature="MC0CFQC2CIhh9s/ypv/buT4NeP2+Un5IYAIUQXfPdSh2dbROxYJyZ4zx808ylV0="
length="15102917"
type="application/octet-stream"/>
</item>
</channel>

View File

@ -3,6 +3,7 @@
* GH-314: You can customize the key shortcut for all menu items in the *Shortcut* preferences pane.
* GH-501: Add key shortcuts to toggle the Buffer List, Markdown Preview, and HTML Preview tools.
* GH-649: Add commands that can control some of GUI elements.
* GH-506: Set font, size and linespacing via `~/.config/nvim/ginit.vim`.
* Draw the disclosure triangle in appropriate color of the current color scheme (and improve handling of changes of `cwd` in the file browser).
* ...