Skip to content

Commit d7ac3f1

Browse files
Add fill Emphasis Style Option (#120)
### Description Adds an option to fill in the color emphasis style. ### Related Issues * N/A ### Checklist - [x] I read and understood the [contributing guide](https://github.com/CodeEditApp/CodeEdit/blob/main/CONTRIBUTING.md) as well as the [code of conduct](https://github.com/CodeEditApp/CodeEdit/blob/main/CODE_OF_CONDUCT.md) - [x] The issues this PR addresses are related to each other - [x] My changes generate no new warnings - [x] My code builds and runs on my machine - [x] My changes are all related to the related issue above - [x] I documented my code ### Screenshots N/A
1 parent e7f1580 commit d7ac3f1

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

Sources/CodeEditTextView/EmphasisManager/EmphasisManager.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,11 @@ public final class EmphasisManager {
233233
layer.fillColor = nil
234234
layer.opacity = emphasis.flash ? 0.0 : 1.0
235235
layer.zPosition = 1
236-
case .outline(let color):
236+
case let .outline(color, shouldFill):
237237
layer.cornerRadius = 2.5
238238
layer.borderColor = color.cgColor
239239
layer.borderWidth = 0.5
240-
layer.fillColor = nil
240+
layer.fillColor = shouldFill ? color.cgColor : nil
241241
layer.opacity = emphasis.flash ? 0.0 : 1.0
242242
layer.zPosition = 1
243243
}

Sources/CodeEditTextView/EmphasisManager/EmphasisStyle.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ public enum EmphasisStyle: Equatable {
1414
/// Underline emphasis with a line color
1515
case underline(color: NSColor)
1616
/// Outline emphasis with a border color
17-
case outline(color: NSColor)
17+
case outline(color: NSColor, fill: Bool = false)
1818

1919
public static func == (lhs: EmphasisStyle, rhs: EmphasisStyle) -> Bool {
2020
switch (lhs, rhs) {
2121
case (.standard, .standard):
2222
return true
2323
case (.underline(let lhsColor), .underline(let rhsColor)):
2424
return lhsColor == rhsColor
25-
case (.outline(let lhsColor), .outline(let rhsColor)):
26-
return lhsColor == rhsColor
25+
case let (.outline(lhsColor, lhsFill), .outline(rhsColor, rhsFill)):
26+
return lhsColor == rhsColor && lhsFill == rhsFill
2727
default:
2828
return false
2929
}

Sources/CodeEditTextView/TextView/TextView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import TextStory
3333
/// [`NSTextInputClient`](https://developer.apple.com/documentation/appkit/nstextinputclient) to work well with system
3434
/// text interactions such as inserting text and marked text.
3535
///
36-
public class TextView: NSView, NSTextContent {
36+
open class TextView: NSView, NSTextContent {
3737
// MARK: - Statics
3838

3939
/// The default typing attributes:
@@ -356,7 +356,7 @@ public class TextView: NSView, NSTextContent {
356356
setUpDragGesture()
357357
}
358358

359-
required init?(coder: NSCoder) {
359+
required public init?(coder: NSCoder) {
360360
fatalError("init(coder:) has not been implemented")
361361
}
362362

0 commit comments

Comments
 (0)