mirror of
https://github.com/qvacua/vimr.git
synced 2024-11-27 14:14:19 +03:00
Adapt to sync neovim stop handling
This commit is contained in:
parent
2d64198e5c
commit
8241d596fd
@ -28,10 +28,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
case openInKeyWindow(urls: [URL], cwd: URL)
|
case openInKeyWindow(urls: [URL], cwd: URL)
|
||||||
|
|
||||||
case preferences
|
case preferences
|
||||||
|
|
||||||
case cancelQuit
|
|
||||||
case quitWithoutSaving
|
|
||||||
case quit
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBOutlet var debugMenu: NSMenuItem?
|
@IBOutlet var debugMenu: NSMenuItem?
|
||||||
@ -157,18 +153,16 @@ extension AppDelegate {
|
|||||||
alert.alertStyle = .warning
|
alert.alertStyle = .warning
|
||||||
|
|
||||||
if alert.runModal() == NSAlertSecondButtonReturn {
|
if alert.runModal() == NSAlertSecondButtonReturn {
|
||||||
self.emit(.quitWithoutSaving)
|
self.uiRoot.prepareQuit()
|
||||||
} else {
|
return .terminateNow
|
||||||
self.emit(.cancelQuit)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return .terminateCancel
|
return .terminateCancel
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.uiRoot.hasMainWindows {
|
if self.uiRoot.hasMainWindows {
|
||||||
self.emit(.quit)
|
self.uiRoot.prepareQuit()
|
||||||
|
return .terminateNow
|
||||||
return .terminateCancel
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// There are no open main window, then just quit.
|
// There are no open main window, then just quit.
|
||||||
|
@ -35,13 +35,6 @@ class AppDelegateReducer {
|
|||||||
case .preferences:
|
case .preferences:
|
||||||
state.preferencesOpen = Marked(true)
|
state.preferencesOpen = Marked(true)
|
||||||
|
|
||||||
case .cancelQuit:
|
|
||||||
state.quitWhenNoMainWindow = false
|
|
||||||
|
|
||||||
case .quitWithoutSaving, .quit:
|
|
||||||
state.mainWindows.keys.forEach { state.mainWindows[$0]?.close = true }
|
|
||||||
state.quitWhenNoMainWindow = true
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return StateActionPair(state: state, action: pair.action)
|
return StateActionPair(state: state, action: pair.action)
|
||||||
|
@ -175,12 +175,6 @@ class MainWindow: NSObject,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if state.close && !self.isClosing {
|
|
||||||
self.closeAllNeoVimWindowsWithoutSaving()
|
|
||||||
self.isClosing = true
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if state.viewToBeFocused != nil, case .neoVimView = state.viewToBeFocused! {
|
if state.viewToBeFocused != nil, case .neoVimView = state.viewToBeFocused! {
|
||||||
self.window.makeFirstResponder(self.neoVimView)
|
self.window.makeFirstResponder(self.neoVimView)
|
||||||
}
|
}
|
||||||
@ -216,10 +210,11 @@ class MainWindow: NSObject,
|
|||||||
|
|
||||||
self.updateNeoVimAppearance()
|
self.updateNeoVimAppearance()
|
||||||
}
|
}
|
||||||
},
|
}/*,
|
||||||
onCompleted: {
|
onCompleted: {
|
||||||
self.windowController.close()
|
NSLog("Completed!!!!")
|
||||||
})
|
// self.windowController.close()
|
||||||
|
}*/)
|
||||||
.disposed(by: self.disposeBag)
|
.disposed(by: self.disposeBag)
|
||||||
|
|
||||||
self.updateNeoVimAppearance()
|
self.updateNeoVimAppearance()
|
||||||
@ -234,6 +229,12 @@ class MainWindow: NSObject,
|
|||||||
self.windowController.showWindow(self)
|
self.windowController.showWindow(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The following should only be used when Cmd-Q'ing
|
||||||
|
func quitNeoVimWithoutSaving() {
|
||||||
|
self.isClosing = true
|
||||||
|
self.neoVimView.quitNeoVimWithoutSaving()
|
||||||
|
}
|
||||||
|
|
||||||
fileprivate let emit: (UuidAction<Action>) -> Void
|
fileprivate let emit: (UuidAction<Action>) -> Void
|
||||||
fileprivate let disposeBag = DisposeBag()
|
fileprivate let disposeBag = DisposeBag()
|
||||||
|
|
||||||
@ -275,10 +276,6 @@ class MainWindow: NSObject,
|
|||||||
|
|
||||||
fileprivate var isClosing = false
|
fileprivate var isClosing = false
|
||||||
|
|
||||||
fileprivate func closeAllNeoVimWindowsWithoutSaving() {
|
|
||||||
self.neoVimView.quitNeoVimWithoutSaving()
|
|
||||||
}
|
|
||||||
|
|
||||||
fileprivate func updateNeoVimAppearance() {
|
fileprivate func updateNeoVimAppearance() {
|
||||||
self.neoVimView.font = self.defaultFont
|
self.neoVimView.font = self.defaultFont
|
||||||
self.neoVimView.linespacing = self.linespacing
|
self.neoVimView.linespacing = self.linespacing
|
||||||
@ -331,6 +328,7 @@ extension MainWindow {
|
|||||||
|
|
||||||
func neoVimStopped() {
|
func neoVimStopped() {
|
||||||
self.isClosing = true
|
self.isClosing = true
|
||||||
|
self.windowController.close()
|
||||||
self.emit(self.uuidAction(for: .close))
|
self.emit(self.uuidAction(for: .close))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ struct AppState: SerializableState {
|
|||||||
var currentMainWindowUuid: String?
|
var currentMainWindowUuid: String?
|
||||||
|
|
||||||
var mainWindows: [String: MainWindow.State] = [:]
|
var mainWindows: [String: MainWindow.State] = [:]
|
||||||
var quitWhenNoMainWindow = false
|
|
||||||
|
|
||||||
var openQuickly = OpenQuicklyWindow.State.default
|
var openQuickly = OpenQuicklyWindow.State.default
|
||||||
|
|
||||||
@ -218,9 +217,6 @@ extension MainWindow {
|
|||||||
var appearance = AppearanceState.default
|
var appearance = AppearanceState.default
|
||||||
var useInteractiveZsh = false
|
var useInteractiveZsh = false
|
||||||
|
|
||||||
// transient^2
|
|
||||||
var close = false
|
|
||||||
|
|
||||||
// to be cleaned
|
// to be cleaned
|
||||||
var urlsToOpen = [URL: OpenMode]()
|
var urlsToOpen = [URL: OpenMode]()
|
||||||
var currentBufferToSet: NeoVimBuffer?
|
var currentBufferToSet: NeoVimBuffer?
|
||||||
|
@ -35,14 +35,15 @@ class UiRoot: UiComponent {
|
|||||||
self.mainWindows.keys
|
self.mainWindows.keys
|
||||||
.filter { !uuidsInState.contains($0) }
|
.filter { !uuidsInState.contains($0) }
|
||||||
.forEach(self.removeMainWindow)
|
.forEach(self.removeMainWindow)
|
||||||
|
|
||||||
if state.quitWhenNoMainWindow && self.mainWindows.isEmpty {
|
|
||||||
NSApp.terminate(self)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.disposed(by: self.disposeBag)
|
.disposed(by: self.disposeBag)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The following should only be used when Cmd-Q'ing
|
||||||
|
func prepareQuit() {
|
||||||
|
self.mainWindows.values.forEach { $0.quitNeoVimWithoutSaving() }
|
||||||
|
}
|
||||||
|
|
||||||
fileprivate let source: Observable<AppState>
|
fileprivate let source: Observable<AppState>
|
||||||
fileprivate let emitter: ActionEmitter
|
fileprivate let emitter: ActionEmitter
|
||||||
fileprivate let disposeBag = DisposeBag()
|
fileprivate let disposeBag = DisposeBag()
|
||||||
|
Loading…
Reference in New Issue
Block a user