mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-09-11 11:25:57 +03:00
Deprecate wrapped line mark
This commit is contained in:
parent
86c9b9b5f3
commit
8cce278a92
@ -6,6 +6,7 @@
|
||||
### Improvements
|
||||
|
||||
- Change the filter field for the outline inspector to apply the selection of the filter history immediately.
|
||||
- Remove wrapped line marks in the line number view.
|
||||
|
||||
|
||||
### Fixes
|
||||
|
@ -34,7 +34,6 @@ final class LineNumberView: NSView {
|
||||
|
||||
let fontSize: CGFloat
|
||||
let charWidth: CGFloat
|
||||
let wrappedMarkGlyph: CGGlyph
|
||||
let digitGlyphs: [CGGlyph]
|
||||
let padding: CGFloat
|
||||
let tickLength: CGFloat
|
||||
@ -47,7 +46,6 @@ final class LineNumberView: NSView {
|
||||
|
||||
// prepare glyphs
|
||||
let font = CTFontCreateWithGraphicsFont(LineNumberView.lineNumberFont, self.fontSize, nil, nil)
|
||||
self.wrappedMarkGlyph = font.glyph(for: "-")
|
||||
self.digitGlyphs = (0...9).map { font.glyph(for: Character(String($0))) }
|
||||
|
||||
// calculate character width by assuming the font is monospace
|
||||
@ -310,9 +308,7 @@ final class LineNumberView: NSView {
|
||||
}
|
||||
|
||||
case .wrapped:
|
||||
// draw wrapped mark (-)
|
||||
let position = CGPoint(x: -drawingInfo.padding - drawingInfo.charWidth, y: y - lineOffset)
|
||||
context.showGlyphs([drawingInfo.wrappedMarkGlyph], at: [position])
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -225,29 +225,18 @@ final class PrintTextView: NSTextView, Themable {
|
||||
NSGraphicsContext.current?.cgContext.rotate(by: -.pi / 2)
|
||||
}
|
||||
|
||||
let options: NSTextView.LineEnumerationOptions = isVerticalText ? [.bySkippingWrappedLine] : []
|
||||
let range = (self.layoutManager as? PrintLayoutManager)?.visibleRange
|
||||
self.enumerateLineFragments(in: dirtyRect, for: range, options: options.union(.bySkippingExtraLine)) { (lineRect, line, lineNumber) in
|
||||
let numberString: String = switch line {
|
||||
case .new:
|
||||
if isVerticalText, lineNumber != 1, !lineNumber.isMultiple(of: 5) {
|
||||
"·" // draw number only every 5 times
|
||||
} else {
|
||||
String(lineNumber)
|
||||
}
|
||||
case .wrapped:
|
||||
"-"
|
||||
}
|
||||
self.enumerateLineFragments(in: dirtyRect, for: range, options: [.bySkippingWrappedLine, .bySkippingExtraLine]) { (lineRect, _, lineNumber) in
|
||||
// draw number only every 5 times
|
||||
let numberString = (!isVerticalText || lineNumber == 1 || lineNumber.isMultiple(of: 5)) ? String(lineNumber) : "·"
|
||||
|
||||
// adjust position to draw
|
||||
let width = CGFloat(numberString.count) * numberSize.width
|
||||
let point: NSPoint = if isVerticalText {
|
||||
NSPoint(x: -lineRect.midY - width / 2,
|
||||
y: horizontalOrigin - numberSize.height)
|
||||
} else {
|
||||
NSPoint(x: horizontalOrigin - width, // - width to align to right
|
||||
y: lineRect.minY + baselineOffset - numberAscender)
|
||||
}
|
||||
let point: NSPoint = isVerticalText
|
||||
? NSPoint(x: -lineRect.midY - width / 2,
|
||||
y: horizontalOrigin - numberSize.height)
|
||||
: NSPoint(x: horizontalOrigin - width, // - width to align to right
|
||||
y: lineRect.minY + baselineOffset - numberAscender)
|
||||
|
||||
// draw number
|
||||
NSAttributedString(string: numberString, attributes: attrs).draw(at: point)
|
||||
|
Loading…
Reference in New Issue
Block a user