1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-28 19:47:41 +03:00

GH-436 Add Theme to mainwindow

This commit is contained in:
Tae Won Ha 2017-06-25 11:46:43 +02:00
parent 0a21c43acd
commit 7164f47ad7
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
6 changed files with 55 additions and 1 deletions

View File

@ -152,6 +152,8 @@ extension NeoVimView {
self.bridgeLogger.debug(ColorUtils.colorIgnoringAlpha(fg))
self.grid.foreground = fg
self.delegate?.foregroundChanged(to: ColorUtils.colorIgnoringAlpha(fg))
}
}
@ -161,6 +163,8 @@ extension NeoVimView {
self.grid.background = bg
self.layer?.backgroundColor = ColorUtils.colorIgnoringAlpha(self.grid.background).cgColor
self.delegate?.backgroundChanged(to: ColorUtils.colorIgnoringAlpha(bg))
}
}
@ -169,6 +173,8 @@ extension NeoVimView {
self.bridgeLogger.debug(ColorUtils.colorIgnoringAlpha(sp))
self.grid.special = sp
self.delegate?.specialChanged(to: ColorUtils.colorIgnoringAlpha(sp))
}
}
@ -198,6 +204,10 @@ extension NeoVimView {
gui.async {
// self.bridgeLogger.debug("\(neoVimAutoCommandEventName(event)) -> \(bufferHandle)")
if event == .COLORSCHEME {
NSLog(self.agent.vimCommandOutput("hi")!)
}
if event == .BUFWINENTER || event == .BUFWINLEAVE {
self.bufferListChanged()
}
@ -206,6 +216,15 @@ extension NeoVimView {
self.tabChanged()
}
let output = "SpecialComment xxx links to Special\n" +
"Debug xxx links to Special\n" +
"FoldColmun xxx ctermfg=246 ctermbg=235 guifg=#909194 guibg=#44475a\n" +
"Normal xxx guifg=#f8f8f2 guibg=#282a36\n" +
"rubyClass xxx ctermfg=212 guifg=#ff79c6\n" +
"rubyFunction xxx ctermfg=84 guifg=#50fa7b\n" +
"rubyInterpolationDelimiter xxx cleared\n" +
"rubySymbol xxx ctermfg=141 guifg=#bd93f9"
if event == .BUFREADPOST || event == .BUFWRITEPOST {
self.currentBufferChanged(bufferHandle)
}

View File

@ -136,7 +136,7 @@ public class NeoVimView: NSView,
@IBAction public func debug1(_ sender: Any?) {
self.logger.debug("DEBUG 1 - Start")
NSApp.hide(self)
NSLog(self.agent.vimCommandOutput("hi")!)
self.logger.debug("DEBUG 1 - End")
}

View File

@ -16,6 +16,10 @@ public protocol NeoVimViewDelegate: class {
func tabChanged()
func currentBufferChanged(_ currentBuffer: NeoVimBuffer)
func foregroundChanged(to: NSColor)
func backgroundChanged(to: NSColor)
func specialChanged(to: NSColor)
func ipcBecameInvalid(reason: String)
func scroll()

View File

@ -39,6 +39,8 @@ class MainWindow: NSObject,
case setState(for: Tools, with: WorkspaceTool)
case setToolsState([(Tools, WorkspaceTool)])
case setTheme(Theme)
case close
}
@ -68,6 +70,14 @@ class MainWindow: NSObject,
case verticalSplit
}
struct Theme {
static let `default` = Theme()
var foreground = NSColor.black
var background = NSColor.white
}
required init(source: Observable<StateType>, emitter: ActionEmitter, state: StateType) {
self.emit = emitter.typedEmit()
self.uuid = state.uuid
@ -270,6 +280,8 @@ class MainWindow: NSObject,
fileprivate var linespacing: CGFloat
fileprivate var usesLigatures: Bool
fileprivate var theme = Theme.default
fileprivate let fontManager = NSFontManager.shared()
fileprivate let workspace: Workspace
@ -394,6 +406,20 @@ extension MainWindow {
self.currentBufferChanged(currentBuffer)
}
func foregroundChanged(to color: NSColor) {
self.theme.foreground = color
self.emit(uuidAction(for: .setTheme(self.theme)))
}
func backgroundChanged(to color: NSColor) {
self.theme.background = color
self.emit(uuidAction(for: .setTheme(self.theme)))
}
func specialChanged(to color: NSColor) {
// noop
}
func ipcBecameInvalid(reason: String) {
let alert = NSAlert()
alert.addButton(withTitle: "Close")

View File

@ -82,6 +82,9 @@ class MainWindowReducer {
case let .toggleToolButtons(value):
state.isToolButtonsVisible = value
case let .setTheme(theme):
state.theme = Marked(theme)
default:
return pair

View File

@ -208,6 +208,8 @@ extension MainWindow {
Tools.htmlPreview: true,
]
var theme = Marked(Theme.default)
////// transient
var lastFileSystemUpdate = Marked(FileUtils.userHomeUrl)