2017-01-22 16:22:05 +03:00
|
|
|
/**
|
|
|
|
* Tae Won Ha - http://taewon.de - @hataewon
|
|
|
|
* See LICENSE
|
|
|
|
*/
|
2017-01-17 21:47:59 +03:00
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import RxSwift
|
|
|
|
|
2017-01-22 16:22:05 +03:00
|
|
|
struct AppState {
|
2017-01-17 21:47:59 +03:00
|
|
|
|
2017-02-20 20:04:45 +03:00
|
|
|
static let `default` = AppState(mainWindow: MainWindow.State.default)
|
2017-01-17 21:47:59 +03:00
|
|
|
|
2017-01-22 16:22:05 +03:00
|
|
|
var currentMainWindow: MainWindow.State
|
|
|
|
var mainWindows: [String: MainWindow.State] = [:]
|
2017-02-12 12:53:24 +03:00
|
|
|
var quitWhenNoMainWindow = false
|
2017-01-17 21:47:59 +03:00
|
|
|
|
2017-02-19 20:00:41 +03:00
|
|
|
let root = FileItem(URL(fileURLWithPath: "/", isDirectory: true))
|
|
|
|
|
2017-02-20 20:04:45 +03:00
|
|
|
init(mainWindow: MainWindow.State) {
|
2017-01-22 16:22:05 +03:00
|
|
|
self.currentMainWindow = mainWindow
|
2017-01-17 21:47:59 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-06 00:39:55 +03:00
|
|
|
struct PreviewState {
|
2017-02-03 00:39:05 +03:00
|
|
|
|
2017-02-07 00:54:22 +03:00
|
|
|
static let `default` = PreviewState()
|
2017-02-06 20:36:57 +03:00
|
|
|
|
|
|
|
enum Status {
|
|
|
|
|
|
|
|
case none
|
|
|
|
case notSaved
|
|
|
|
case error
|
|
|
|
case markdown
|
|
|
|
}
|
|
|
|
|
|
|
|
var status = Status.none
|
2017-02-06 00:39:55 +03:00
|
|
|
|
|
|
|
var buffer: URL?
|
|
|
|
var html: URL?
|
|
|
|
var server: URL?
|
2017-02-07 00:54:22 +03:00
|
|
|
|
2017-02-12 13:24:15 +03:00
|
|
|
var updateDate: Date
|
2017-02-07 00:54:22 +03:00
|
|
|
|
2017-02-12 15:41:12 +03:00
|
|
|
var editorPosition = Marked(Position.beginning)
|
|
|
|
var previewPosition = Marked(Position.beginning)
|
2017-02-11 20:32:22 +03:00
|
|
|
var ignoreNextForward = false
|
2017-02-12 18:40:49 +03:00
|
|
|
var forceNextReverse = false
|
2017-02-07 00:54:22 +03:00
|
|
|
|
|
|
|
init(status: Status = .none,
|
|
|
|
buffer: URL? = nil,
|
|
|
|
html: URL? = nil,
|
|
|
|
server: URL? = nil,
|
2017-02-12 13:24:15 +03:00
|
|
|
updateDate: Date = Date())
|
2017-02-07 00:54:22 +03:00
|
|
|
{
|
|
|
|
self.status = status
|
|
|
|
self.buffer = buffer
|
|
|
|
self.html = html
|
|
|
|
self.server = server
|
|
|
|
self.updateDate = updateDate
|
|
|
|
}
|
2017-02-03 00:39:05 +03:00
|
|
|
}
|
|
|
|
|
2017-01-17 21:47:59 +03:00
|
|
|
extension MainWindow {
|
|
|
|
|
2017-01-22 16:22:05 +03:00
|
|
|
struct State {
|
2017-01-17 21:47:59 +03:00
|
|
|
|
2017-02-04 17:34:13 +03:00
|
|
|
static let `default` = State(isAllToolsVisible: true, isToolButtonsVisible: true)
|
2017-01-17 21:47:59 +03:00
|
|
|
|
|
|
|
var isAllToolsVisible = true
|
|
|
|
var isToolButtonsVisible = true
|
|
|
|
|
2017-01-22 16:22:05 +03:00
|
|
|
////// transient
|
|
|
|
|
2017-02-06 00:39:55 +03:00
|
|
|
var preview = PreviewState.default
|
2017-02-07 00:54:22 +03:00
|
|
|
var previewTool = PreviewTool.State.default
|
|
|
|
|
2017-02-04 17:34:13 +03:00
|
|
|
var isClosed = false
|
2017-02-03 00:39:05 +03:00
|
|
|
|
2017-01-22 16:22:05 +03:00
|
|
|
// neovim
|
2017-01-17 21:47:59 +03:00
|
|
|
var uuid = UUID().uuidString
|
2017-01-22 16:22:05 +03:00
|
|
|
var currentBuffer: NeoVimBuffer?
|
2017-01-17 21:47:59 +03:00
|
|
|
var buffers = [NeoVimBuffer]()
|
|
|
|
var cwd = FileUtils.userHomeUrl
|
|
|
|
|
|
|
|
var isDirty = false
|
|
|
|
|
|
|
|
var font = NSFont.userFixedPitchFont(ofSize: 13)!
|
|
|
|
var linespacing: CGFloat = 1
|
|
|
|
var isUseLigatures = false
|
|
|
|
var isUseInteractiveZsh = false
|
|
|
|
|
|
|
|
// transient^2
|
|
|
|
var urlsToOpen = [URL: OpenMode]()
|
|
|
|
|
2017-02-04 17:34:13 +03:00
|
|
|
init(isAllToolsVisible: Bool, isToolButtonsVisible: Bool) {
|
2017-01-17 21:47:59 +03:00
|
|
|
self.isAllToolsVisible = isAllToolsVisible
|
|
|
|
self.isToolButtonsVisible = isToolButtonsVisible
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-07 00:54:22 +03:00
|
|
|
extension PreviewTool {
|
|
|
|
|
|
|
|
struct State {
|
|
|
|
|
|
|
|
static let `default` = State()
|
|
|
|
|
|
|
|
var isForwardSearchAutomatically = false
|
|
|
|
var isReverseSearchAutomatically = false
|
|
|
|
var isRefreshOnWrite = true
|
|
|
|
}
|
|
|
|
}
|