1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-10-27 02:11:27 +03:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Tae Won Ha
793287470f
Update neovim 2022-05-17 20:14:34 +02:00
Tae Won Ha
c4da658e8c
Merge branch 'develop' into update-neovim 2022-05-17 20:13:53 +02:00
Tae Won Ha
8fb71aa4c2
Make framerate view toggleable 2022-05-14 19:09:50 +02:00
5 changed files with 57 additions and 46 deletions

@ -1 +1 @@
Subproject commit e781779051049cb07b8a95e19dfeb69ec25ef4f9
Subproject commit 0cf127915ae122bb23ee4ba0a52375fdb90c5a62

View File

@ -5,10 +5,33 @@
import Cocoa
import MessagePack
import PureLayout
import RxPack
import RxSwift
import SpriteKit
public extension NvimView {
func toggleFramerateView() {
// Framerate measurement; from https://stackoverflow.com/a/34039775
if self.framerateView == nil {
let sk = SKView(forAutoLayout: ())
sk.showsFPS = true
self.framerateView = sk
self.addSubview(sk)
sk.autoPinEdge(toSuperviewEdge: .top, withInset: 10)
sk.autoPinEdge(toSuperviewEdge: .right, withInset: 10)
sk.autoSetDimensions(to: CGSize(width: 60, height: 15))
return
}
self.framerateView?.removeAllConstraints()
self.framerateView?.removeFromSuperview()
self.framerateView = nil
}
func isBlocked() -> Single<Bool> {
self.api.getMode().map { dict in dict["blocking"]?.boolValue ?? false }
}
@ -36,7 +59,7 @@ public extension NvimView {
self.api
.getCurrentBuf()
.flatMap { self.neoVimBuffer(for: $0, currentBuffer: $0) }
.subscribe(on:self.scheduler)
.subscribe(on: self.scheduler)
}
func allBuffers() -> Single<[NvimView.Buffer]> {
@ -46,14 +69,14 @@ public extension NvimView {
self.neoVimBuffer(for: buf, currentBuffer: tuple.curBuf)
} }
.flatMap(Single.fromSinglesToSingleOfArray)
.subscribe(on:self.scheduler)
.subscribe(on: self.scheduler)
}
func isCurrentBufferDirty() -> Single<Bool> {
self
.currentBuffer()
.map(\.isDirty)
.subscribe(on:self.scheduler)
.subscribe(on: self.scheduler)
}
func allTabs() -> Single<[NvimView.Tabpage]> {
@ -68,13 +91,13 @@ public extension NvimView {
}
}
.flatMap(Single.fromSinglesToSingleOfArray)
.subscribe(on:self.scheduler)
.subscribe(on: self.scheduler)
}
func newTab() -> Completable {
self.api
.command(command: "tabe")
.subscribe(on:self.scheduler)
.subscribe(on: self.scheduler)
}
func open(urls: [URL]) -> Completable {
@ -96,13 +119,13 @@ public extension NvimView {
}
)
}
.subscribe(on:self.scheduler)
.subscribe(on: self.scheduler)
}
func openInNewTab(urls: [URL]) -> Completable {
Completable
.concat(urls.map { url in self.open(url, cmd: "tabe") })
.subscribe(on:self.scheduler)
.subscribe(on: self.scheduler)
}
func openInCurrentTab(url: URL) -> Completable {
@ -112,13 +135,13 @@ public extension NvimView {
func openInHorizontalSplit(urls: [URL]) -> Completable {
Completable
.concat(urls.map { url in self.open(url, cmd: "sp") })
.subscribe(on:self.scheduler)
.subscribe(on: self.scheduler)
}
func openInVerticalSplit(urls: [URL]) -> Completable {
Completable
.concat(urls.map { url in self.open(url, cmd: "vsp") })
.subscribe(on:self.scheduler)
.subscribe(on: self.scheduler)
}
func select(buffer: NvimView.Buffer) -> Completable {
@ -132,7 +155,7 @@ public extension NvimView {
return self.api.command(command: "tab sb \(buffer.handle)")
}
.subscribe(on:self.scheduler)
.subscribe(on: self.scheduler)
}
func goTo(line: Int) -> Completable {
@ -143,37 +166,37 @@ public extension NvimView {
func closeCurrentTab() -> Completable {
self.api
.command(command: "q")
.subscribe(on:self.scheduler)
.subscribe(on: self.scheduler)
}
func saveCurrentTab() -> Completable {
self.api
.command(command: "w")
.subscribe(on:self.scheduler)
.subscribe(on: self.scheduler)
}
func saveCurrentTab(url: URL) -> Completable {
self.api
.command(command: "w \(url.shellEscapedPath)")
.subscribe(on:self.scheduler)
.subscribe(on: self.scheduler)
}
func closeCurrentTabWithoutSaving() -> Completable {
self.api
.command(command: "q!")
.subscribe(on:self.scheduler)
.subscribe(on: self.scheduler)
}
func quitNeoVimWithoutSaving() -> Completable {
self.api
.command(command: "qa!")
.subscribe(on:self.scheduler)
.subscribe(on: self.scheduler)
}
func vimOutput(of command: String) -> Single<String> {
self.api
.exec(src: command, output: true)
.subscribe(on:self.scheduler)
.subscribe(on: self.scheduler)
}
func cursorGo(to position: Position) -> Completable {
@ -182,7 +205,7 @@ public extension NvimView {
.flatMapCompletable { curWin in
self.api.winSetCursor(window: curWin, pos: [position.row, position.column])
}
.subscribe(on:self.scheduler)
.subscribe(on: self.scheduler)
}
func didBecomeMain() -> Completable { self.bridge.focusGained(true) }
@ -217,13 +240,13 @@ public extension NvimView {
isListed: listed
)
}
.subscribe(on:self.scheduler)
.subscribe(on: self.scheduler)
}
private func open(_ url: URL, cmd: String) -> Completable {
self.api
.command(command: "\(cmd) \(url.shellEscapedPath)")
.subscribe(on:self.scheduler)
.subscribe(on: self.scheduler)
}
private func neoVimWindow(

View File

@ -11,6 +11,7 @@ import os
import RxPack
import RxSwift
import Tabs
import SpriteKit
public enum FontSmoothing: String, Codable, CaseIterable {
case systemSetting
@ -320,6 +321,8 @@ public class NvimView: NSView,
var lastMode = CursorModeShape.normal
var framerateView: SKView?
// MARK: - Private
private var _linespacing = NvimView.defaultLinespacing

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="19529" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="20037" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="19529"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="20037"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="Application" customModule="VimR" customModuleProvider="target">
@ -278,10 +278,16 @@
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Debug" id="FMz-3N-3Eu">
<items>
<menuItem title="Debug 1" id="IFh-6Q-w93">
<menuItem title="Toggle framerate" id="IFh-6Q-w93">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="debug1:" target="-1" id="OSW-j0-HVo"/>
<action selector="toggleFramerate:" target="-1" id="aiC-vI-URv"/>
</connections>
</menuItem>
<menuItem title="Debug 1" id="xDg-6f-7Ea">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="debug1:" target="-1" id="mc6-WI-31Q"/>
</connections>
</menuItem>
<menuItem title="Debug 2" id="tWe-ll-a9P">

View File

@ -8,9 +8,6 @@ import NvimView
import os
import PureLayout
import RxSwift
#if FRAMERATE
import SpriteKit
#endif
import Tabs
import Workspace
@ -222,17 +219,6 @@ class MainWindow: NSObject,
self.window.makeFirstResponder(self.neoVimView)
self.openInitialUrlsAndGoToLine(urlsToOpen: state.urlsToOpen)
// Framerate measurement; from https://stackoverflow.com/a/34039775
// Add `-D FRAMERATE` to "Other Swift Flags" of the VimR target.
#if FRAMERATE
let sk = SKView(forAutoLayout: ())
sk.showsFPS = true
self.neoVimView.addSubview(sk)
sk.autoPinEdge(toSuperviewEdge: .top, withInset: 10)
sk.autoPinEdge(toSuperviewEdge: .right, withInset: 10)
sk.autoSetDimensions(to: CGSize(width: 60, height: 15))
#endif
}
func uuidAction(for action: Action) -> UuidAction<Action> {
@ -248,14 +234,7 @@ class MainWindow: NSObject,
self.neoVimView.quitNeoVimWithoutSaving()
}
@IBAction func debug2(_: Any?) {
var theme = Theme.default
theme.foreground = .blue
theme.background = .yellow
theme.highlightForeground = .orange
theme.highlightBackground = .red
self.emit(self.uuidAction(for: .setTheme(theme)))
}
@IBAction func toggleFramerate(_: Any?) { self.neoVimView.toggleFramerateView() }
// MARK: - Private