diff options
| -rw-r--r-- | server/src/Thermoprint/Server/Printer/Generic.hs | 13 | 
1 files changed, 7 insertions, 6 deletions
| diff --git a/server/src/Thermoprint/Server/Printer/Generic.hs b/server/src/Thermoprint/Server/Printer/Generic.hs index 24150cf..df84e06 100644 --- a/server/src/Thermoprint/Server/Printer/Generic.hs +++ b/server/src/Thermoprint/Server/Printer/Generic.hs | |||
| @@ -170,20 +170,21 @@ renderLine (cotext . Line -> word) = modify' $ insertWord | |||
| 170 | where | 170 | where | 
| 171 | insertWord doc | 171 | insertWord doc | 
| 172 | | TL.null wordTail = checkBreak $ doc' | 172 | | TL.null wordTail = checkBreak $ doc' | 
| 173 | | otherwise = checkBreak $ doc' { remainingSpace = space doc' - (wordTail' `mod` space doc') | 173 | | otherwise = checkBreak $ doc { remainingSpace = space doc - (word' `mod` space doc) | 
| 174 | , lines = (lines doc' |> currentLine doc') <> cs | 174 | , lines = (lines doc |> currentLine doc) <> cs | 
| 175 | , currentLine = c | 175 | , currentLine = c | 
| 176 | , overflows = overflows doc' + 1 + (toInteger $ Seq.length cs) | 176 | , overflows = overflows doc + (toInteger $ Seq.length cs) | 
| 177 | } | 177 | } | 
| 178 | where | 178 | where | 
| 179 | (wordInit, wordTail) = TL.splitAt (fromInteger $ remainingSpace doc) word | 179 | (wordInit, wordTail) = TL.splitAt (fromInteger $ remainingSpace doc) word | 
| 180 | word' = toInteger $ TL.length word | ||
| 180 | wordInit' = toInteger $ TL.length wordInit | 181 | wordInit' = toInteger $ TL.length wordInit | 
| 181 | wordTail' = toInteger $ TL.length wordTail | 182 | wordTail' = toInteger $ TL.length wordTail | 
| 182 | doc' = insertInit doc | 183 | doc' = insertInit doc | 
| 183 | insertInit doc@(Doc{..}) = doc { remainingSpace = remainingSpace - wordInit' | 184 | insertInit doc@(Doc{..}) = doc { remainingSpace = remainingSpace - wordInit' | 
| 184 | , currentLine = currentLine >> encode'' wordInit | 185 | , currentLine = currentLine >> encode'' wordInit | 
| 185 | } | 186 | } | 
| 186 | (cs :> c) = viewr . Seq.fromList . map encode'' $ TL.chunksOf (fromInteger $ space doc) wordTail | 187 | (cs :> c) = viewr . Seq.fromList . map encode'' $ TL.chunksOf (fromInteger $ space doc) word | 
| 187 | checkBreak doc@(Doc{..}) | 188 | checkBreak doc@(Doc{..}) | 
| 188 | | remainingSpace == 0 = doc { remainingSpace = space | 189 | | remainingSpace == 0 = doc { remainingSpace = space | 
| 189 | , lines = lines |> currentLine | 190 | , lines = lines |> currentLine | 
