1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-01 01:32:04 +03:00
vimr/VimR/States.swift

152 lines
3.2 KiB
Swift
Raw Normal View History

2017-01-22 16:22:05 +03:00
/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Foundation
import RxSwift
2017-01-22 16:22:05 +03:00
struct AppState {
2017-02-20 20:04:45 +03:00
static let `default` = AppState(mainWindow: MainWindow.State.default)
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)
var mainWindowTemplate: MainWindow.State
var currentMainWindowUuid: String?
2017-01-22 16:22:05 +03:00
var mainWindows: [String: MainWindow.State] = [:]
var quitWhenNoMainWindow = false
2017-02-19 20:00:41 +03:00
let root = FileItem(URL(fileURLWithPath: "/", isDirectory: true))
var openQuickly = OpenQuicklyWindow.State.default
2017-02-20 20:04:45 +03:00
init(mainWindow: MainWindow.State) {
self.mainWindowTemplate = mainWindow
self.mainWindowTemplate.root = self.root
}
}
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))
var ignoreToken = Token()
var open = false
}
}
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)
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
}
extension MainWindow {
2017-01-22 16:22:05 +03:00
struct State {
static let `default` = State(isAllToolsVisible: true, isToolButtonsVisible: true)
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
// must be replaced
var root = FileItem(URL(fileURLWithPath: "/", isDirectory: true))
var lastFileSystemUpdate = Marked(FileItem(URL(fileURLWithPath: "/", isDirectory: true)))
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
var fileBrowserShowHidden = false
var isClosed = false
2017-02-03 00:39:05 +03:00
2017-01-22 16:22:05 +03:00
// neovim
var uuid = UUID().uuidString
2017-01-22 16:22:05 +03:00
var currentBuffer: NeoVimBuffer?
var buffers = [NeoVimBuffer]()
var cwd = FileUtils.userHomeUrl
var isDirty = false
2017-02-28 11:53:27 +03:00
var appearance = AppearanceState.default
var isUseInteractiveZsh = false
// transient^2
2017-02-23 00:51:24 +03:00
var urlsToOpen = [Marked<[URL: OpenMode]>]()
init(isAllToolsVisible: Bool, isToolButtonsVisible: Bool) {
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
}
}