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-02-27 23:17:40 +03:00
|
|
|
var openNewMainWindowOnLaunch = true
|
|
|
|
var openNewMainWindowOnReactivation = true
|
|
|
|
|
2017-02-28 00:45:26 +03:00
|
|
|
var preferencesOpen = Marked(false)
|
|
|
|
|
2017-02-20 21:33:22 +03:00
|
|
|
var mainWindowTemplate: MainWindow.State
|
|
|
|
var currentMainWindowUuid: String?
|
|
|
|
|
2017-01-22 16:22:05 +03:00
|
|
|
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 21:33:22 +03:00
|
|
|
var openQuickly = OpenQuicklyWindow.State.default
|
|
|
|
|
2017-02-20 20:04:45 +03:00
|
|
|
init(mainWindow: MainWindow.State) {
|
2017-02-20 21:33:22 +03:00
|
|
|
self.mainWindowTemplate = mainWindow
|
2017-02-24 00:15:35 +03:00
|
|
|
self.mainWindowTemplate.root = self.root
|
2017-02-20 21:33:22 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension OpenQuicklyWindow {
|
|
|
|
|
|
|
|
struct State {
|
|
|
|
|
|
|
|
static let `default` = State()
|
|
|
|
|
|
|
|
var flatFileItems = Observable<[FileItem]>.empty()
|
|
|
|
var cwd = FileUtils.userHomeUrl
|
2017-02-28 00:45:26 +03:00
|
|
|
var ignorePatterns = Set(["*/.git", "*.o", "*.d", "*.dia"].map(FileItemIgnorePattern.init))
|
2017-02-20 21:33:22 +03:00
|
|
|
var ignoreToken = Token()
|
|
|
|
|
|
|
|
var open = false
|
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-28 00:45:26 +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-02-28 11:53:27 +03:00
|
|
|
struct AppearanceState {
|
|
|
|
|
|
|
|
static let `default` = AppearanceState()
|
|
|
|
|
|
|
|
var font = NSFont.userFixedPitchFont(ofSize: 13)!
|
|
|
|
var linespacing: CGFloat = 1
|
|
|
|
var usesLigatures = false
|
|
|
|
}
|
|
|
|
|
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-25 00:47:32 +03:00
|
|
|
var focusedView = FocusableView.neoVimView
|
|
|
|
|
2017-02-24 00:15:35 +03:00
|
|
|
// must be replaced
|
|
|
|
var root = FileItem(URL(fileURLWithPath: "/", isDirectory: true))
|
2017-02-24 01:39:31 +03:00
|
|
|
var lastFileSystemUpdate = Marked(FileItem(URL(fileURLWithPath: "/", isDirectory: true)))
|
2017-02-24 00:15:35 +03:00
|
|
|
|
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-24 00:15:35 +03:00
|
|
|
var fileBrowserShowHidden = false
|
|
|
|
|
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
|
|
|
|
|
2017-02-28 11:53:27 +03:00
|
|
|
var appearance = AppearanceState.default
|
2017-01-17 21:47:59 +03:00
|
|
|
var isUseInteractiveZsh = false
|
|
|
|
|
|
|
|
// transient^2
|
2017-02-23 00:51:24 +03:00
|
|
|
var urlsToOpen = [Marked<[URL: OpenMode]>]()
|
2017-01-17 21:47:59 +03:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|