updates plug with all sorts of awesome improvements
This commit is contained in:
@@ -23,14 +23,14 @@ final class PageText {
|
||||
init(imageBase: URL, images: ImageCache = ImageCache(), bodySize: CGFloat = TextSize.standard) {
|
||||
self.imageBase = imageBase
|
||||
self.images = images
|
||||
font = PlakFonts.body(bodySize)
|
||||
font = PlakFonts.mono(bodySize)
|
||||
codeFont = PlakFonts.mono(round(bodySize * PageMetrics.codeScale))
|
||||
setBodySize(bodySize)
|
||||
}
|
||||
|
||||
/// The minimum line height lets a line with an image grow to the image.
|
||||
func setBodySize(_ size: CGFloat) {
|
||||
font = PlakFonts.body(size)
|
||||
font = PlakFonts.mono(size)
|
||||
codeFont = PlakFonts.mono(round(size * PageMetrics.codeScale))
|
||||
lineHeight = PageMetrics.lineHeight(font)
|
||||
let style = NSMutableParagraphStyle()
|
||||
@@ -314,6 +314,17 @@ extension NSString {
|
||||
PageFile.isBlank(substring(with: range))
|
||||
}
|
||||
|
||||
/// The start of the first line of the block that holds the line at `location`.
|
||||
func blockStart(at location: Int) -> Int {
|
||||
var start = lineStart(at: location)
|
||||
while start > 0 {
|
||||
let previous = lineStart(at: start - 1)
|
||||
if isBlankLine(NSRange(location: previous, length: start - 1 - previous)) { break }
|
||||
start = previous
|
||||
}
|
||||
return start
|
||||
}
|
||||
|
||||
/// The lines of the blocks an edit touches; an edit in blank lines also takes the block above and below.
|
||||
func blockRegion(around edit: NSRange) -> NSRange {
|
||||
var start = lineStart(at: edit.location)
|
||||
|
||||
Reference in New Issue
Block a user