mirror of
https://github.com/qvacua/vimr.git
synced 2024-11-28 11:35:35 +03:00
GH-426 Move font related IBActions to NeoVimView
This commit is contained in:
parent
80093a99db
commit
0f4377b8c5
@ -59,27 +59,6 @@ class NeoVimWindow: NSObject, NSWindowDelegate, NeoVimViewDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - IBActions
|
||||
extension NeoVimWindow {
|
||||
|
||||
// FIXME: the following three actions should be implemented by NeoVimView...
|
||||
@IBAction func resetFontSize(_ sender: Any?) {
|
||||
self.neoVimView.font = self.defaultFont
|
||||
}
|
||||
|
||||
@IBAction func makeFontBigger(_ sender: Any?) {
|
||||
let curFont = self.neoVimView.font
|
||||
let font = self.fontManager.convert(curFont, toSize: min(curFont.pointSize + 1, NeoVimView.maxFontSize))
|
||||
self.neoVimView.font = font
|
||||
}
|
||||
|
||||
@IBAction func makeFontSmaller(_ sender: Any?) {
|
||||
let curFont = self.neoVimView.font
|
||||
let font = self.fontManager.convert(curFont, toSize: max(curFont.pointSize - 1, NeoVimView.minFontSize))
|
||||
self.neoVimView.font = font
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - NSWindowDelegate
|
||||
extension NeoVimWindow {
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class NeoVimView: NSView, NeoVimUiBridgeProtocol, NSUserInterfaceValidati
|
||||
self._linespacing = newValue
|
||||
self.drawer.linespacing = self.linespacing
|
||||
|
||||
self.updateFontMetaData()
|
||||
self.updateFontMetaData(self._font)
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,9 +81,8 @@ public class NeoVimView: NSView, NeoVimUiBridgeProtocol, NSUserInterfaceValidati
|
||||
}
|
||||
|
||||
self._font = newValue
|
||||
self.drawer.font = self.font
|
||||
|
||||
self.updateFontMetaData()
|
||||
self.updateFontMetaData(newValue)
|
||||
}
|
||||
}
|
||||
|
||||
@ -226,7 +225,9 @@ public class NeoVimView: NSView, NeoVimUiBridgeProtocol, NSUserInterfaceValidati
|
||||
NSLog("DEBUG 1 - End")
|
||||
}
|
||||
|
||||
fileprivate func updateFontMetaData() {
|
||||
fileprivate func updateFontMetaData(_ newFont: NSFont) {
|
||||
self.drawer.font = newFont
|
||||
|
||||
self.cellSize = self.drawer.cellSize
|
||||
self.descent = self.drawer.descent
|
||||
self.leading = self.drawer.leading
|
||||
@ -817,6 +818,26 @@ extension NeoVimView {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Font Menu Items
|
||||
extension NeoVimView {
|
||||
|
||||
@IBAction func resetFontSize(_ sender: Any?) {
|
||||
self.font = self._font
|
||||
}
|
||||
|
||||
@IBAction func makeFontBigger(_ sender: Any?) {
|
||||
let curFont = self.drawer.font
|
||||
let font = self.fontManager.convert(curFont, toSize: min(curFont.pointSize + 1, NeoVimView.maxFontSize))
|
||||
self.updateFontMetaData(font)
|
||||
}
|
||||
|
||||
@IBAction func makeFontSmaller(_ sender: Any?) {
|
||||
let curFont = self.drawer.font
|
||||
let font = self.fontManager.convert(curFont, toSize: max(curFont.pointSize - 1, NeoVimView.minFontSize))
|
||||
self.updateFontMetaData(font)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Key Events
|
||||
extension NeoVimView: NSTextInputClient {
|
||||
|
||||
@ -1054,7 +1075,7 @@ extension NeoVimView {
|
||||
|
||||
case NSEventPhase.ended, NSEventPhase.cancelled:
|
||||
self.isCurrentlyPinching = false
|
||||
self.font = self.fontManager.convert(self._font, toSize: resultingFontSize)
|
||||
self.updateFontMetaData(self.fontManager.convert(self._font, toSize: resultingFontSize))
|
||||
self.pinchTargetScale = 1
|
||||
|
||||
default:
|
||||
|
@ -502,27 +502,6 @@ extension MainWindow {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Font Menu Item Actions
|
||||
|
||||
extension MainWindow {
|
||||
|
||||
@IBAction func resetFontSize(_ sender: Any?) {
|
||||
self.neoVimView.font = self.defaultFont
|
||||
}
|
||||
|
||||
@IBAction func makeFontBigger(_ sender: Any?) {
|
||||
let curFont = self.neoVimView.font
|
||||
let font = self.fontManager.convert(curFont, toSize: min(curFont.pointSize + 1, NeoVimView.maxFontSize))
|
||||
self.neoVimView.font = font
|
||||
}
|
||||
|
||||
@IBAction func makeFontSmaller(_ sender: Any?) {
|
||||
let curFont = self.neoVimView.font
|
||||
let font = self.fontManager.convert(curFont, toSize: max(curFont.pointSize - 1, NeoVimView.minFontSize))
|
||||
self.neoVimView.font = font
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Tools Menu Item Actions
|
||||
|
||||
extension MainWindow {
|
||||
|
Loading…
Reference in New Issue
Block a user