mirror of
https://github.com/qvacua/vimr.git
synced 2025-01-01 18:23:48 +03:00
Use private where appropriate
This commit is contained in:
parent
dcd79fbaa7
commit
0df758d275
@ -7,7 +7,7 @@ import Cocoa
|
|||||||
import RxSwift
|
import RxSwift
|
||||||
import EonilFileSystemEvents
|
import EonilFileSystemEvents
|
||||||
|
|
||||||
fileprivate let monitorDispatchQueue = DispatchQueue.global(qos: .userInitiated)
|
private let monitorDispatchQueue = DispatchQueue.global(qos: .userInitiated)
|
||||||
|
|
||||||
class FileMonitor: UiComponent {
|
class FileMonitor: UiComponent {
|
||||||
|
|
||||||
@ -59,9 +59,9 @@ class FileMonitor: UiComponent {
|
|||||||
.disposed(by: self.disposeBag)
|
.disposed(by: self.disposeBag)
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate let emit: (Action) -> Void
|
private let emit: (Action) -> Void
|
||||||
fileprivate let disposeBag = DisposeBag()
|
private let disposeBag = DisposeBag()
|
||||||
|
|
||||||
fileprivate var monitoredUrls = Set<URL>()
|
private var monitoredUrls = Set<URL>()
|
||||||
fileprivate var monitors = [URL: FileSystemEventMonitor]()
|
private var monitors = [URL: FileSystemEventMonitor]()
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,8 @@ import PureLayout
|
|||||||
import WebKit
|
import WebKit
|
||||||
import EonilFileSystemEvents
|
import EonilFileSystemEvents
|
||||||
|
|
||||||
fileprivate let fileSystemEventsLatency = 1.0
|
private let fileSystemEventsLatency = 1.0
|
||||||
fileprivate let monitorDispatchQueue = DispatchQueue.global(qos: .userInitiated)
|
private let monitorDispatchQueue = DispatchQueue.global(qos: .userInitiated)
|
||||||
|
|
||||||
class HtmlPreviewTool: NSView, UiComponent, WKNavigationDelegate {
|
class HtmlPreviewTool: NSView, UiComponent, WKNavigationDelegate {
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ class HtmlPreviewTool: NSView, UiComponent, WKNavigationDelegate {
|
|||||||
.disposed(by: self.disposeBag)
|
.disposed(by: self.disposeBag)
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate func reloadWebview(with url: URL) {
|
private func reloadWebview(with url: URL) {
|
||||||
self.webview.evaluateJavaScript("document.body.scrollTop") { (result, error) in
|
self.webview.evaluateJavaScript("document.body.scrollTop") { (result, error) in
|
||||||
self.scrollTop = result as? Int ?? 0
|
self.scrollTop = result as? Int ?? 0
|
||||||
|
|
||||||
@ -77,23 +77,23 @@ class HtmlPreviewTool: NSView, UiComponent, WKNavigationDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate func addViews() {
|
private func addViews() {
|
||||||
self.webview.configureForAutoLayout()
|
self.webview.configureForAutoLayout()
|
||||||
|
|
||||||
self.addSubview(self.webview)
|
self.addSubview(self.webview)
|
||||||
self.webview.autoPinEdgesToSuperviewEdges()
|
self.webview.autoPinEdgesToSuperviewEdges()
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate let emit: (UuidAction<Action>) -> Void
|
private let emit: (UuidAction<Action>) -> Void
|
||||||
fileprivate let uuid: String
|
private let uuid: String
|
||||||
|
|
||||||
fileprivate var mark = Token()
|
private var mark = Token()
|
||||||
fileprivate var scrollTop = 0
|
private var scrollTop = 0
|
||||||
|
|
||||||
fileprivate let webview: WKWebView
|
private let webview: WKWebView
|
||||||
fileprivate var monitor: FileSystemEventMonitor?
|
private var monitor: FileSystemEventMonitor?
|
||||||
|
|
||||||
fileprivate let disposeBag = DisposeBag()
|
private let disposeBag = DisposeBag()
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder: NSCoder) {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
@ -145,7 +145,7 @@ extension HtmlPreviewTool {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate func addViews() {
|
private func addViews() {
|
||||||
let selectHtmlFile = self.selectHtmlFile
|
let selectHtmlFile = self.selectHtmlFile
|
||||||
InnerToolBar.configureToStandardIconButton(button: selectHtmlFile, iconName: .fileCodeO)
|
InnerToolBar.configureToStandardIconButton(button: selectHtmlFile, iconName: .fileCodeO)
|
||||||
selectHtmlFile.toolTip = "Select the HTML file"
|
selectHtmlFile.toolTip = "Select the HTML file"
|
||||||
|
@ -21,7 +21,7 @@ class BuffersList: NSView,
|
|||||||
case open(NvimView.Buffer)
|
case open(NvimView.Buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate(set) var theme = Theme.default
|
private(set) var theme = Theme.default
|
||||||
|
|
||||||
required init(source: Observable<StateType>, emitter: ActionEmitter, state: StateType) {
|
required init(source: Observable<StateType>, emitter: ActionEmitter, state: StateType) {
|
||||||
self.emit = emitter.typedEmit()
|
self.emit = emitter.typedEmit()
|
||||||
@ -66,31 +66,31 @@ class BuffersList: NSView,
|
|||||||
.disposed(by: self.disposeBag)
|
.disposed(by: self.disposeBag)
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate let emit: (UuidAction<Action>) -> Void
|
private let emit: (UuidAction<Action>) -> Void
|
||||||
fileprivate let disposeBag = DisposeBag()
|
private let disposeBag = DisposeBag()
|
||||||
|
|
||||||
fileprivate let uuid: String
|
private let uuid: String
|
||||||
fileprivate var usesTheme: Bool
|
private var usesTheme: Bool
|
||||||
fileprivate var lastThemeMark = Token()
|
private var lastThemeMark = Token()
|
||||||
fileprivate var showsFileIcon: Bool
|
private var showsFileIcon: Bool
|
||||||
|
|
||||||
fileprivate let bufferList = NSTableView.standardTableView()
|
private let bufferList = NSTableView.standardTableView()
|
||||||
fileprivate let genericIcon: NSImage
|
private let genericIcon: NSImage
|
||||||
|
|
||||||
fileprivate var buffers = [NvimView.Buffer]()
|
private var buffers = [NvimView.Buffer]()
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder: NSCoder) {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate func updateTheme(_ theme: Marked<Theme>) {
|
private func updateTheme(_ theme: Marked<Theme>) {
|
||||||
self.theme = theme.payload
|
self.theme = theme.payload
|
||||||
self.bufferList.enclosingScrollView?.backgroundColor = self.theme.background
|
self.bufferList.enclosingScrollView?.backgroundColor = self.theme.background
|
||||||
self.bufferList.backgroundColor = self.theme.background
|
self.bufferList.backgroundColor = self.theme.background
|
||||||
self.lastThemeMark = theme.mark
|
self.lastThemeMark = theme.mark
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate func addViews() {
|
private func addViews() {
|
||||||
let scrollView = NSScrollView.standardScrollView()
|
let scrollView = NSScrollView.standardScrollView()
|
||||||
scrollView.borderType = .noBorder
|
scrollView.borderType = .noBorder
|
||||||
scrollView.documentView = self.bufferList
|
scrollView.documentView = self.bufferList
|
||||||
@ -99,7 +99,7 @@ class BuffersList: NSView,
|
|||||||
scrollView.autoPinEdgesToSuperviewEdges()
|
scrollView.autoPinEdgesToSuperviewEdges()
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate func adjustFileViewWidth() {
|
private func adjustFileViewWidth() {
|
||||||
let maxWidth = self.buffers.reduce(CGFloat(100)) { (curMaxWidth, buffer) in
|
let maxWidth = self.buffers.reduce(CGFloat(100)) { (curMaxWidth, buffer) in
|
||||||
return max(self.text(for: buffer).size().width, curMaxWidth)
|
return max(self.text(for: buffer).size().width, curMaxWidth)
|
||||||
}
|
}
|
||||||
@ -158,7 +158,7 @@ extension BuffersList {
|
|||||||
return cell
|
return cell
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate func text(for buffer: NvimView.Buffer) -> NSAttributedString {
|
private func text(for buffer: NvimView.Buffer) -> NSAttributedString {
|
||||||
guard let name = buffer.name else {
|
guard let name = buffer.name else {
|
||||||
return NSAttributedString(string: "No Name")
|
return NSAttributedString(string: "No Name")
|
||||||
}
|
}
|
||||||
@ -181,7 +181,7 @@ extension BuffersList {
|
|||||||
return rowText
|
return rowText
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate func icon(for buffer: NvimView.Buffer) -> NSImage? {
|
private func icon(for buffer: NvimView.Buffer) -> NSImage? {
|
||||||
if let url = buffer.url {
|
if let url = buffer.url {
|
||||||
return FileUtils.icon(forUrl: url)
|
return FileUtils.icon(forUrl: url)
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ class PreviewTool: NSView, UiComponent, WKNavigationDelegate {
|
|||||||
.disposed(by: self.disposeBag)
|
.disposed(by: self.disposeBag)
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate func addViews() {
|
private func addViews() {
|
||||||
self.webview.navigationDelegate = self
|
self.webview.navigationDelegate = self
|
||||||
self.userContentController.add(webviewMessageHandler, name: "com_vimr_tools_preview_markdown")
|
self.userContentController.add(webviewMessageHandler, name: "com_vimr_tools_preview_markdown")
|
||||||
self.webview.configureForAutoLayout()
|
self.webview.configureForAutoLayout()
|
||||||
@ -142,36 +142,36 @@ class PreviewTool: NSView, UiComponent, WKNavigationDelegate {
|
|||||||
self.webview.evaluateJavaScript("document.body.scrollTop = \(self.scrollTop)")
|
self.webview.evaluateJavaScript("document.body.scrollTop = \(self.scrollTop)")
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate let emit: (UuidAction<Action>) -> Void
|
private let emit: (UuidAction<Action>) -> Void
|
||||||
fileprivate let uuid: String
|
private let uuid: String
|
||||||
|
|
||||||
fileprivate let webview: WKWebView
|
private let webview: WKWebView
|
||||||
fileprivate let disposeBag = DisposeBag()
|
private let disposeBag = DisposeBag()
|
||||||
fileprivate let scheduler = ConcurrentDispatchQueueScheduler(qos: .userInitiated)
|
private let scheduler = ConcurrentDispatchQueueScheduler(qos: .userInitiated)
|
||||||
fileprivate var isOpen = false
|
private var isOpen = false
|
||||||
|
|
||||||
fileprivate var url: URL?
|
private var url: URL?
|
||||||
fileprivate var lastUpdateDate = Date.distantPast
|
private var lastUpdateDate = Date.distantPast
|
||||||
fileprivate var editorPosition = Marked(Position.beginning)
|
private var editorPosition = Marked(Position.beginning)
|
||||||
fileprivate var previewPosition = Position.beginning
|
private var previewPosition = Position.beginning
|
||||||
fileprivate var scrollTop = 0
|
private var scrollTop = 0
|
||||||
|
|
||||||
fileprivate let userContentController = WKUserContentController()
|
private let userContentController = WKUserContentController()
|
||||||
fileprivate let webviewMessageHandler = WebviewMessageHandler()
|
private let webviewMessageHandler = WebviewMessageHandler()
|
||||||
|
|
||||||
fileprivate let automaticForwardMenuItem = NSMenuItem(title: "Automatic Forward Search",
|
private let automaticForwardMenuItem = NSMenuItem(title: "Automatic Forward Search",
|
||||||
action: nil,
|
action: nil,
|
||||||
keyEquivalent: "")
|
keyEquivalent: "")
|
||||||
fileprivate let automaticReverseMenuItem = NSMenuItem(title: "Automatic Reverse Search",
|
private let automaticReverseMenuItem = NSMenuItem(title: "Automatic Reverse Search",
|
||||||
action: nil,
|
action: nil,
|
||||||
keyEquivalent: "")
|
keyEquivalent: "")
|
||||||
fileprivate let refreshOnWriteMenuItem = NSMenuItem(title: "Refresh on Write", action: nil, keyEquivalent: "")
|
private let refreshOnWriteMenuItem = NSMenuItem(title: "Refresh on Write", action: nil, keyEquivalent: "")
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder: NSCoder) {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate func forwardSearch(position: Position) {
|
private func forwardSearch(position: Position) {
|
||||||
self.webview.evaluateJavaScript("scrollToPosition(\(position.row), \(position.column));") { result, error in
|
self.webview.evaluateJavaScript("scrollToPosition(\(position.row), \(position.column));") { result, error in
|
||||||
if let scrollTop = result as? Int {
|
if let scrollTop = result as? Int {
|
||||||
self.scrollTop = scrollTop
|
self.scrollTop = scrollTop
|
||||||
@ -208,7 +208,7 @@ extension PreviewTool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate class WebviewMessageHandler: NSObject, WKScriptMessageHandler {
|
private class WebviewMessageHandler: NSObject, WKScriptMessageHandler {
|
||||||
|
|
||||||
var source: Observable<(Position, Int)> {
|
var source: Observable<(Position, Int)> {
|
||||||
return self.subject.asObservable()
|
return self.subject.asObservable()
|
||||||
|
@ -62,19 +62,19 @@ class UiRoot: UiComponent {
|
|||||||
self.mainWindows.values.forEach { $0.quitNeoVimWithoutSaving() }
|
self.mainWindows.values.forEach { $0.quitNeoVimWithoutSaving() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate let source: Observable<AppState>
|
private let source: Observable<AppState>
|
||||||
fileprivate let emitter: ActionEmitter
|
private let emitter: ActionEmitter
|
||||||
fileprivate let disposeBag = DisposeBag()
|
private let disposeBag = DisposeBag()
|
||||||
|
|
||||||
fileprivate let fileMonitor: FileMonitor
|
private let fileMonitor: FileMonitor
|
||||||
fileprivate let openQuicklyWindow: OpenQuicklyWindow
|
private let openQuicklyWindow: OpenQuicklyWindow
|
||||||
fileprivate let prefWindow: PrefWindow
|
private let prefWindow: PrefWindow
|
||||||
|
|
||||||
fileprivate var mainWindows = [String: MainWindow]()
|
private var mainWindows = [String: MainWindow]()
|
||||||
fileprivate var subjectForMainWindows = [String: PublishSubject<MainWindow.State>]()
|
private var subjectForMainWindows = [String: PublishSubject<MainWindow.State>]()
|
||||||
fileprivate var disposables = [String: Disposable]()
|
private var disposables = [String: Disposable]()
|
||||||
|
|
||||||
fileprivate func newMainWindow(with state: MainWindow.State) -> MainWindow {
|
private func newMainWindow(with state: MainWindow.State) -> MainWindow {
|
||||||
let subject = PublishSubject<MainWindow.State>()
|
let subject = PublishSubject<MainWindow.State>()
|
||||||
let source = self.source.mapOmittingNil { $0.mainWindows[state.uuid] }
|
let source = self.source.mapOmittingNil { $0.mainWindows[state.uuid] }
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ class UiRoot: UiComponent {
|
|||||||
return MainWindow(source: subject.asObservable(), emitter: self.emitter, state: state)
|
return MainWindow(source: subject.asObservable(), emitter: self.emitter, state: state)
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate func removeMainWindow(with uuid: String) {
|
private func removeMainWindow(with uuid: String) {
|
||||||
self.subjectForMainWindows[uuid]?.onCompleted()
|
self.subjectForMainWindows[uuid]?.onCompleted()
|
||||||
self.disposables[uuid]?.dispose()
|
self.disposables[uuid]?.dispose()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user