mirror of
https://github.com/qvacua/vimr.git
synced 2024-11-24 11:37:32 +03:00
Add SOME_NUMBER.cgf
This commit is contained in:
parent
24e1dc529d
commit
fa15b4cea3
@ -9,7 +9,10 @@ import CocoaMarkdown
|
|||||||
extension NSColor {
|
extension NSColor {
|
||||||
|
|
||||||
static var random: NSColor {
|
static var random: NSColor {
|
||||||
return NSColor(calibratedRed: CGFloat(drand48()), green: CGFloat(drand48()), blue: CGFloat(drand48()), alpha: 1.0)
|
return NSColor(calibratedRed: CGFloat.random(in: 0...1),
|
||||||
|
green: CGFloat.random(in: 0...1),
|
||||||
|
blue: CGFloat.random(in: 0...1),
|
||||||
|
alpha: 1.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
var hex: String {
|
var hex: String {
|
||||||
|
@ -316,7 +316,7 @@ extension AppearancePref {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func cappedLinespacing(_ linespacing: Float) -> CGFloat {
|
private func cappedLinespacing(_ linespacing: Float) -> CGFloat {
|
||||||
let cgfLinespacing = CGFloat(linespacing)
|
let cgfLinespacing = linespacing.cgf
|
||||||
|
|
||||||
guard cgfLinespacing >= NvimView.minLinespacing else {
|
guard cgfLinespacing >= NvimView.minLinespacing else {
|
||||||
return NvimView.defaultLinespacing
|
return NvimView.defaultLinespacing
|
||||||
@ -330,7 +330,7 @@ extension AppearancePref {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func cappedFontSize(_ size: Int) -> CGFloat {
|
private func cappedFontSize(_ size: Int) -> CGFloat {
|
||||||
let cgfSize = CGFloat(size)
|
let cgfSize = size.cgf
|
||||||
|
|
||||||
guard cgfSize >= NvimView.minFontSize else {
|
guard cgfSize >= NvimView.minFontSize else {
|
||||||
return NvimView.defaultFont.pointSize
|
return NvimView.defaultFont.pointSize
|
||||||
|
@ -179,7 +179,7 @@ extension BuffersList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.bufferList.tableColumns[0].width = max(
|
self.bufferList.tableColumns[0].width = max(
|
||||||
self.bufferList.tableColumns[0].width, cellWidth + CGFloat(10)
|
self.bufferList.tableColumns[0].width, cellWidth + 10.cgf
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ class FileOutlineView: NSOutlineView,
|
|||||||
}
|
}
|
||||||
private let treeController = NSTreeController()
|
private let treeController = NSTreeController()
|
||||||
|
|
||||||
private var cachedColumnWidth = CGFloat(20)
|
private var cachedColumnWidth = 20.cgf
|
||||||
private var usesTheme: Bool
|
private var usesTheme: Bool
|
||||||
private var lastFileSystemUpdateMark = Token()
|
private var lastFileSystemUpdateMark = Token()
|
||||||
private var showsFileIcon: Bool
|
private var showsFileIcon: Bool
|
||||||
@ -555,7 +555,7 @@ extension FileOutlineView {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let level = CGFloat(self.level(forRow: row))
|
let level = self.level(forRow: row).cgf
|
||||||
let width = level * self.indentationPerLevel + cellWidth
|
let width = level * self.indentationPerLevel + cellWidth
|
||||||
+ columnWidthRightPadding
|
+ columnWidthRightPadding
|
||||||
self.cachedColumnWidth = max(self.cachedColumnWidth, width)
|
self.cachedColumnWidth = max(self.cachedColumnWidth, width)
|
||||||
@ -667,5 +667,5 @@ private extension NSTreeNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private let columnWidthRightPadding = CGFloat(40)
|
private let columnWidthRightPadding = 40.cgf
|
||||||
private let triangleImageSize = CGFloat(18)
|
private let triangleImageSize = 18.cgf
|
||||||
|
@ -17,7 +17,7 @@ class ImageAndTextTableCell: NSTableCellView {
|
|||||||
|
|
||||||
// MARK: - API
|
// MARK: - API
|
||||||
static let font = NSFont.systemFont(ofSize: 12)
|
static let font = NSFont.systemFont(ofSize: 12)
|
||||||
static let widthWithoutText = CGFloat(2 + 16 + 4 + 2)
|
static let widthWithoutText = (2 + 16 + 4 + 2).cgf
|
||||||
|
|
||||||
static func width(with text: String) -> CGFloat {
|
static func width(with text: String) -> CGFloat {
|
||||||
let attrStr = NSAttributedString(string: text, attributes: [NSAttributedString.Key.font: ImageAndTextTableCell.font])
|
let attrStr = NSAttributedString(string: text, attributes: [NSAttributedString.Key.font: ImageAndTextTableCell.font])
|
||||||
|
@ -61,7 +61,7 @@ extension MainWindow {
|
|||||||
guard params.count == 2 else { return }
|
guard params.count == 2 else { return }
|
||||||
guard let fontName = params[0].stringValue,
|
guard let fontName = params[0].stringValue,
|
||||||
let fontSize = params[1].integerValue,
|
let fontSize = params[1].integerValue,
|
||||||
let font = NSFont(name: fontName, size: CGFloat(fontSize))
|
let font = NSFont(name: fontName, size: fontSize.cgf)
|
||||||
else {
|
else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -72,7 +72,7 @@ extension MainWindow {
|
|||||||
guard params.count == 1 else { return }
|
guard params.count == 1 else { return }
|
||||||
guard let linespacing = params[0].floatValue else { return }
|
guard let linespacing = params[0].floatValue else { return }
|
||||||
|
|
||||||
self.emit(self.uuidAction(for: .setLinespacing(CGFloat(linespacing))))
|
self.emit(self.uuidAction(for: .setLinespacing(linespacing.cgf)))
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,4 +149,4 @@ extension MainWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private let repIconToTitleGap = CGFloat(4.0)
|
private let repIconToTitleGap = (4.0).cgf
|
||||||
|
@ -97,14 +97,17 @@ class MainWindow: NSObject,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if state.activeTools[.htmlPreview] == true {
|
if state.activeTools[.htmlPreview] == true {
|
||||||
self.htmlPreview = HtmlPreviewTool(source: source, emitter: emitter, state: state)
|
self.htmlPreview = HtmlPreviewTool(source: source,
|
||||||
|
emitter: emitter,
|
||||||
|
state: state)
|
||||||
let htmlPreviewConfig = WorkspaceTool.Config(
|
let htmlPreviewConfig = WorkspaceTool.Config(
|
||||||
title: "HTML",
|
title: "HTML",
|
||||||
view: self.htmlPreview!,
|
view: self.htmlPreview!,
|
||||||
customToolbar: self.htmlPreview!.innerCustomToolbar
|
customToolbar: self.htmlPreview!.innerCustomToolbar
|
||||||
)
|
)
|
||||||
self.htmlPreviewContainer = WorkspaceTool(htmlPreviewConfig)
|
self.htmlPreviewContainer = WorkspaceTool(htmlPreviewConfig)
|
||||||
self.htmlPreviewContainer!.dimension = state.tools[.htmlPreview]?.dimension ?? 250
|
self.htmlPreviewContainer!.dimension = state.tools[.htmlPreview]?
|
||||||
|
.dimension ?? 250
|
||||||
tools[.htmlPreview] = self.htmlPreviewContainer
|
tools[.htmlPreview] = self.htmlPreviewContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,7 +321,8 @@ class MainWindow: NSObject,
|
|||||||
.andThen {
|
.andThen {
|
||||||
if state.preview.status == .markdown
|
if state.preview.status == .markdown
|
||||||
&& state.previewTool.isReverseSearchAutomatically
|
&& state.previewTool.isReverseSearchAutomatically
|
||||||
&& state.preview.previewPosition.hasDifferentMark(as: self.previewPosition) {
|
&& state.preview.previewPosition
|
||||||
|
.hasDifferentMark(as: self.previewPosition) {
|
||||||
|
|
||||||
self.previewPosition = state.preview.previewPosition
|
self.previewPosition = state.preview.previewPosition
|
||||||
return self.neoVimView.cursorGo(
|
return self.neoVimView.cursorGo(
|
||||||
@ -387,8 +391,11 @@ class MainWindow: NSObject,
|
|||||||
self.neoVimView.isLeftOptionMeta = state.isLeftOptionMeta
|
self.neoVimView.isLeftOptionMeta = state.isLeftOptionMeta
|
||||||
self.neoVimView.isRightOptionMeta = state.isRightOptionMeta
|
self.neoVimView.isRightOptionMeta = state.isRightOptionMeta
|
||||||
|
|
||||||
if self.neoVimView.trackpadScrollResistance != CGFloat(state.trackpadScrollResistance) {
|
if self.neoVimView.trackpadScrollResistance
|
||||||
self.neoVimView.trackpadScrollResistance = CGFloat(state.trackpadScrollResistance)
|
!= state.trackpadScrollResistance.cgf {
|
||||||
|
self.neoVimView.trackpadScrollResistance = CGFloat(
|
||||||
|
state.trackpadScrollResistance
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.neoVimView.usesLiveResize != state.useLiveResize {
|
if self.neoVimView.usesLiveResize != state.useLiveResize {
|
||||||
|
@ -93,7 +93,7 @@ class PrefUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static func saneLinespacing(_ fLinespacing: Float) -> CGFloat {
|
static func saneLinespacing(_ fLinespacing: Float) -> CGFloat {
|
||||||
let linespacing = CGFloat(fLinespacing)
|
let linespacing = fLinespacing.cgf
|
||||||
guard linespacing >= NvimView.minLinespacing && linespacing <= NvimView.maxLinespacing else {
|
guard linespacing >= NvimView.minLinespacing && linespacing <= NvimView.maxLinespacing else {
|
||||||
return NvimView.defaultLinespacing
|
return NvimView.defaultLinespacing
|
||||||
}
|
}
|
||||||
|
@ -193,13 +193,13 @@ struct AppearanceState: Codable {
|
|||||||
|
|
||||||
if let fontName = try container.decodeIfPresent(String.self, forKey: .editorFontName),
|
if let fontName = try container.decodeIfPresent(String.self, forKey: .editorFontName),
|
||||||
let fontSize = try container.decodeIfPresent(Float.self, forKey: .editorFontSize),
|
let fontSize = try container.decodeIfPresent(Float.self, forKey: .editorFontSize),
|
||||||
let font = NSFont(name: fontName, size: CGFloat(fontSize)) {
|
let font = NSFont(name: fontName, size: fontSize.cgf) {
|
||||||
self.font = font
|
self.font = font
|
||||||
} else {
|
} else {
|
||||||
self.font = NvimView.defaultFont
|
self.font = NvimView.defaultFont
|
||||||
}
|
}
|
||||||
|
|
||||||
self.linespacing = CGFloat(try container.decodeIfPresent(Float.self, forKey: .editorLinespacing) ?? 1.0)
|
self.linespacing = (try container.decodeIfPresent(Float.self, forKey: .editorLinespacing) ?? 1.0).cgf
|
||||||
self.usesLigatures = try container.decodeIfPresent(Bool.self, forKey: .editorUsesLigatures) ?? true
|
self.usesLigatures = try container.decodeIfPresent(Bool.self, forKey: .editorUsesLigatures) ?? true
|
||||||
|
|
||||||
self.usesTheme = try container.decodeIfPresent(Bool.self, forKey: .usesTheme) ?? true
|
self.usesTheme = try container.decodeIfPresent(Bool.self, forKey: .usesTheme) ?? true
|
||||||
@ -414,15 +414,24 @@ struct WorkspaceToolState: Codable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var location = WorkspaceBarLocation.left
|
var location = WorkspaceBarLocation.left
|
||||||
var dimension = CGFloat(200)
|
var dimension = 200.cgf
|
||||||
var open = false
|
var open = false
|
||||||
|
|
||||||
init(from decoder: Decoder) throws {
|
init(from decoder: Decoder) throws {
|
||||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
|
||||||
self.location = try container.decode(forKey: .location, default: WorkspaceToolState.default.location)
|
self.location = try container.decode(
|
||||||
self.dimension = CGFloat(try container.decode(forKey: .dimension, default: WorkspaceToolState.default.dimension))
|
forKey: .location,
|
||||||
self.open = try container.decode(forKey: .open, default: WorkspaceToolState.default.open)
|
default: WorkspaceToolState.default.location
|
||||||
|
)
|
||||||
|
self.dimension = try container.decode(
|
||||||
|
forKey: .dimension,
|
||||||
|
default: WorkspaceToolState.default.dimension
|
||||||
|
).cgf
|
||||||
|
self.open = try container.decode(
|
||||||
|
forKey: .open,
|
||||||
|
default: WorkspaceToolState.default.open
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use generated encode(to:)
|
// Use generated encode(to:)
|
||||||
|
@ -9,6 +9,20 @@ func identity<T>(_ input: T) -> T {
|
|||||||
return input
|
return input
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension BinaryFloatingPoint {
|
||||||
|
|
||||||
|
var cgf: CGFloat {
|
||||||
|
return CGFloat(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension FixedWidthInteger {
|
||||||
|
|
||||||
|
var cgf: CGFloat {
|
||||||
|
return CGFloat(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extension String {
|
extension String {
|
||||||
|
|
||||||
func without(prefix: String) -> String {
|
func without(prefix: String) -> String {
|
||||||
|
@ -67,7 +67,7 @@ class ThemedTableCell: NSTableCellView {
|
|||||||
|
|
||||||
// MARK: - API
|
// MARK: - API
|
||||||
static let font = NSFont.systemFont(ofSize: 12)
|
static let font = NSFont.systemFont(ofSize: 12)
|
||||||
static let widthWithoutText = CGFloat(2 + 16 + 4 + 2)
|
static let widthWithoutText = (2 + 16 + 4 + 2).cgf
|
||||||
|
|
||||||
// static func width(with text: String) -> CGFloat {
|
// static func width(with text: String) -> CGFloat {
|
||||||
// let attrStr = NSAttributedString(string: text, attributes: [NSAttributedString.Key.font: ThemedTableCell.font])
|
// let attrStr = NSAttributedString(string: text, attributes: [NSAttributedString.Key.font: ThemedTableCell.font])
|
||||||
|
@ -23,8 +23,8 @@ class InnerToolBar: NSView, NSUserInterfaceValidations {
|
|||||||
|
|
||||||
// MARK: - API
|
// MARK: - API
|
||||||
static let toolbarHeight = InnerToolBar.iconDimension
|
static let toolbarHeight = InnerToolBar.iconDimension
|
||||||
static let iconDimension = CGFloat(18)
|
static let iconDimension = 18.cgf
|
||||||
static let itemPadding = CGFloat(4)
|
static let itemPadding = 4.cgf
|
||||||
|
|
||||||
static func configureToStandardIconButton(
|
static func configureToStandardIconButton(
|
||||||
button: NSButton,
|
button: NSButton,
|
||||||
@ -138,7 +138,7 @@ class InnerToolBar: NSView, NSUserInterfaceValidations {
|
|||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
private static let separatorThickness = CGFloat(1)
|
private static let separatorThickness = 1.cgf
|
||||||
private static let height = InnerToolBar.iconDimension + 2 + 2 + InnerToolBar.separatorThickness
|
private static let height = InnerToolBar.iconDimension + 2 + 2 + InnerToolBar.separatorThickness
|
||||||
|
|
||||||
private let titleField = NSTextField(forAutoLayout: ())
|
private let titleField = NSTextField(forAutoLayout: ())
|
||||||
|
@ -51,14 +51,14 @@ private class ProxyBar: NSView {
|
|||||||
|
|
||||||
class WorkspaceBar: NSView, WorkspaceToolDelegate {
|
class WorkspaceBar: NSView, WorkspaceToolDelegate {
|
||||||
|
|
||||||
static private let separatorThickness = CGFloat(1)
|
static private let separatorThickness = 1.cgf
|
||||||
|
|
||||||
fileprivate(set) var tools = [WorkspaceTool]()
|
fileprivate(set) var tools = [WorkspaceTool]()
|
||||||
|
|
||||||
private weak var selectedTool: WorkspaceTool?
|
private weak var selectedTool: WorkspaceTool?
|
||||||
|
|
||||||
private var isMouseDownOngoing = false
|
private var isMouseDownOngoing = false
|
||||||
private var dragIncrement = CGFloat(1)
|
private var dragIncrement = 1.cgf
|
||||||
|
|
||||||
private var layoutConstraints = [NSLayoutConstraint]()
|
private var layoutConstraints = [NSLayoutConstraint]()
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ class WorkspaceBar: NSView, WorkspaceToolDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - API
|
// MARK: - API
|
||||||
static let minimumDimension = CGFloat(50)
|
static let minimumDimension = 50.cgf
|
||||||
|
|
||||||
let location: WorkspaceBarLocation
|
let location: WorkspaceBarLocation
|
||||||
var isButtonVisible = true {
|
var isButtonVisible = true {
|
||||||
@ -567,7 +567,7 @@ extension WorkspaceBar {
|
|||||||
|
|
||||||
private func resizeRect() -> CGRect {
|
private func resizeRect() -> CGRect {
|
||||||
let separatorRect = self.outerSeparatorRect()
|
let separatorRect = self.outerSeparatorRect()
|
||||||
let clickDimension = CGFloat(4)
|
let clickDimension = 4.cgf
|
||||||
|
|
||||||
switch self.location {
|
switch self.location {
|
||||||
case .top:
|
case .top:
|
||||||
|
Loading…
Reference in New Issue
Block a user