From 809465f70417ca3c7122f635ea6a1f15914b2976 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 5 Mar 2026 21:01:36 +0100 Subject: bump --- TextViewport.hs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'TextViewport.hs') diff --git a/TextViewport.hs b/TextViewport.hs index f39ee84..b97936e 100644 --- a/TextViewport.hs +++ b/TextViewport.hs @@ -87,14 +87,25 @@ renderItem width itemIx (Item txt strategy) = -------------------------------------------------------------------------------- applyStrategy :: WrapStrategy -> Int -> Text -> [(Int, Text)] -applyStrategy NoWrap w t = - [(0, T.take w t)] +applyStrategy NoWrap _ t = + let ls = T.splitOn "\n" t + in zip (scanOffsets ls) ls applyStrategy FixedWidthWrap w t = - zip [0,w..] (chunkFixed w t) + concatMap chunkOne (T.splitOn "\n" t) + where + chunkOne line = + let chunks = chunkFixed w line + offs = scanOffsets chunks + in zip offs chunks applyStrategy (HyphenateWrap dict) w t = - hyphenateWrapped dict w t + concatMap wrapOne (T.splitOn "\n" t) + where + wrapOne line = + let chunks = wrapWithHyphenationTeXLite dict w line + offsets = scanOffsets chunks + in zip offsets chunks chunkFixed :: Int -> Text -> [Text] chunkFixed w t @@ -111,12 +122,6 @@ chunkFixed w t -- Hyphenation-aware wrapping (TeX-lite) -------------------------------------------------------------------------------- -hyphenateWrapped :: H.Hyphenator -> Int -> Text -> [(Int, Text)] -hyphenateWrapped dict w txt = - let chunks = wrapWithHyphenationTeXLite dict w txt - offsets = scanOffsets chunks - in zip offsets chunks - scanOffsets :: [Text] -> [Int] scanOffsets [] = [] scanOffsets (x:xs) = 0 : go (T.length x) xs @@ -160,9 +165,7 @@ lineCandidates dict width = go [] [] -- hyphenation candidates for this word hyphs = hyphenateWord dict w hyphCands = - [ let preTxt = baseTxt <> space <> pre <> "-" - preLen = T.length preTxt - in (preTxt, suf : ws, True) + [ (preTxt, suf : ws, True) | (pre, suf) <- hyphs , not (T.null pre) , let preTxt = baseTxt <> space <> pre <> "-" -- cgit v1.2.3