lib: Remove unused Text utility functions.
This commit is contained in:
		
							parent
							
								
									bf22c3efdd
								
							
						
					
					
						commit
						0b419adba2
					
				| @ -6,7 +6,7 @@ | |||||||
| 
 | 
 | ||||||
| module Hledger.Utils.Text | module Hledger.Utils.Text | ||||||
|   ( |   ( | ||||||
|  -- -- * misc |   -- * misc | ||||||
|   -- lowercase, |   -- lowercase, | ||||||
|   -- uppercase, |   -- uppercase, | ||||||
|   -- underline, |   -- underline, | ||||||
| @ -14,12 +14,12 @@ module Hledger.Utils.Text | |||||||
|   textUnbracket, |   textUnbracket, | ||||||
|   wrap, |   wrap, | ||||||
|   textChomp, |   textChomp, | ||||||
|  -- -- quoting |   -- quoting | ||||||
|   quoteIfSpaced, |   quoteIfSpaced, | ||||||
|   textQuoteIfNeeded, |   textQuoteIfNeeded, | ||||||
|   -- singleQuoteIfNeeded, |   -- singleQuoteIfNeeded, | ||||||
|  -- -- quotechars, |   -- quotechars, | ||||||
|  -- -- whitespacechars, |   -- whitespacechars, | ||||||
|   escapeDoubleQuotes, |   escapeDoubleQuotes, | ||||||
|   -- escapeSingleQuotes, |   -- escapeSingleQuotes, | ||||||
|   -- escapeQuotes, |   -- escapeQuotes, | ||||||
| @ -28,39 +28,26 @@ module Hledger.Utils.Text | |||||||
|   stripquotes, |   stripquotes, | ||||||
|   -- isSingleQuoted, |   -- isSingleQuoted, | ||||||
|   -- isDoubleQuoted, |   -- isDoubleQuoted, | ||||||
|  -- -- * single-line layout |   -- * single-line layout | ||||||
|   -- elideLeft, |   -- elideLeft, | ||||||
|   textElideRight, |   textElideRight, | ||||||
|   formatText, |   formatText, | ||||||
|  -- -- * multi-line layout |   -- * multi-line layout | ||||||
|   textConcatTopPadded, |   textConcatTopPadded, | ||||||
|   textConcatBottomPadded, |   textConcatBottomPadded, | ||||||
|  -- concatOneLine, |  | ||||||
|  -- vConcatLeftAligned, |  | ||||||
|  -- vConcatRightAligned, |  | ||||||
|  -- padtop, |  | ||||||
|  -- padbottom, |  | ||||||
|  -- padleft, |  | ||||||
|  -- padright, |  | ||||||
|  -- cliptopleft, |  | ||||||
|  -- fitto, |  | ||||||
|   fitText, |   fitText, | ||||||
|   linesPrepend, |   linesPrepend, | ||||||
|   linesPrepend2, |   linesPrepend2, | ||||||
|   unlinesB, |   unlinesB, | ||||||
|  -- -- * wide-character-aware layout |   -- * wide-character-aware layout | ||||||
|   WideBuilder(..), |   WideBuilder(..), | ||||||
|   wbToText, |   wbToText, | ||||||
|   wbUnpack, |   wbUnpack, | ||||||
|   textWidth, |   textWidth, | ||||||
|   textTakeWidth, |   textTakeWidth, | ||||||
|  -- fitString, |   -- * Reading | ||||||
|  -- fitStringMulti, |  | ||||||
|   textPadLeftWide, |  | ||||||
|   textPadRightWide, |  | ||||||
|   -- -- * Reading |  | ||||||
|   readDecimal, |   readDecimal, | ||||||
|   -- -- * tests |   -- * tests | ||||||
|   tests_Text |   tests_Text | ||||||
|   ) |   ) | ||||||
| where | where | ||||||
| @ -207,71 +194,6 @@ textConcatBottomPadded :: [Text] -> Text | |||||||
| textConcatBottomPadded = TL.toStrict . renderRow def{tableBorders=False, borderSpaces=False} | textConcatBottomPadded = TL.toStrict . renderRow def{tableBorders=False, borderSpaces=False} | ||||||
|                        . Group NoLine . map (Header . textCell TopLeft) |                        . Group NoLine . map (Header . textCell TopLeft) | ||||||
| 
 | 
 | ||||||
| -- -- | Join multi-line strings horizontally, after compressing each of |  | ||||||
| -- -- them to a single line with a comma and space between each original line. |  | ||||||
| -- concatOneLine :: [String] -> String |  | ||||||
| -- concatOneLine strs = concat $ map ((intercalate ", ").lines) strs |  | ||||||
| 
 |  | ||||||
| -- -- | Join strings vertically, left-aligned and right-padded. |  | ||||||
| -- vConcatLeftAligned :: [String] -> String |  | ||||||
| -- vConcatLeftAligned ss = intercalate "\n" $ map showfixedwidth ss |  | ||||||
| --     where |  | ||||||
| --       showfixedwidth = printf (printf "%%-%ds" width) |  | ||||||
| --       width = maximum $ map length ss |  | ||||||
| 
 |  | ||||||
| -- -- | Join strings vertically, right-aligned and left-padded. |  | ||||||
| -- vConcatRightAligned :: [String] -> String |  | ||||||
| -- vConcatRightAligned ss = intercalate "\n" $ map showfixedwidth ss |  | ||||||
| --     where |  | ||||||
| --       showfixedwidth = printf (printf "%%%ds" width) |  | ||||||
| --       width = maximum $ map length ss |  | ||||||
| 
 |  | ||||||
| -- -- | Convert a multi-line string to a rectangular string top-padded to the specified height. |  | ||||||
| -- padtop :: Int -> String -> String |  | ||||||
| -- padtop h s = intercalate "\n" xpadded |  | ||||||
| --     where |  | ||||||
| --       ls = lines s |  | ||||||
| --       sh = length ls |  | ||||||
| --       sw | null ls = 0 |  | ||||||
| --          | otherwise = maximum $ map length ls |  | ||||||
| --       ypadded = replicate (difforzero h sh) "" ++ ls |  | ||||||
| --       xpadded = map (padleft sw) ypadded |  | ||||||
| 
 |  | ||||||
| -- -- | Convert a multi-line string to a rectangular string bottom-padded to the specified height. |  | ||||||
| -- padbottom :: Int -> String -> String |  | ||||||
| -- padbottom h s = intercalate "\n" xpadded |  | ||||||
| --     where |  | ||||||
| --       ls = lines s |  | ||||||
| --       sh = length ls |  | ||||||
| --       sw | null ls = 0 |  | ||||||
| --          | otherwise = maximum $ map length ls |  | ||||||
| --       ypadded = ls ++ replicate (difforzero h sh) "" |  | ||||||
| --       xpadded = map (padleft sw) ypadded |  | ||||||
| 
 |  | ||||||
| -- -- | Convert a multi-line string to a rectangular string left-padded to the specified width. |  | ||||||
| -- -- Treats wide characters as double width. |  | ||||||
| -- padleft :: Int -> String -> String |  | ||||||
| -- padleft w "" = concat $ replicate w " " |  | ||||||
| -- padleft w s = intercalate "\n" $ map (printf (printf "%%%ds" w)) $ lines s |  | ||||||
| 
 |  | ||||||
| -- -- | Convert a multi-line string to a rectangular string right-padded to the specified width. |  | ||||||
| -- -- Treats wide characters as double width. |  | ||||||
| -- padright :: Int -> String -> String |  | ||||||
| -- padright w "" = concat $ replicate w " " |  | ||||||
| -- padright w s = intercalate "\n" $ map (printf (printf "%%-%ds" w)) $ lines s |  | ||||||
| 
 |  | ||||||
| -- -- | Clip a multi-line string to the specified width and height from the top left. |  | ||||||
| -- cliptopleft :: Int -> Int -> String -> String |  | ||||||
| -- cliptopleft w h = intercalate "\n" . take h . map (take w) . lines |  | ||||||
| 
 |  | ||||||
| -- -- | Clip and pad a multi-line string to fill the specified width and height. |  | ||||||
| -- fitto :: Int -> Int -> String -> String |  | ||||||
| -- fitto w h s = intercalate "\n" $ take h $ rows ++ repeat blankline |  | ||||||
| --     where |  | ||||||
| --       rows = map (fit w) $ lines s |  | ||||||
| --       fit w = take w . (++ repeat ' ') |  | ||||||
| --       blankline = replicate w ' ' |  | ||||||
| 
 |  | ||||||
| -- -- Functions below treat wide (eg CJK) characters as double-width. | -- -- Functions below treat wide (eg CJK) characters as double-width. | ||||||
| 
 | 
 | ||||||
| -- | General-purpose wide-char-aware single-line text layout function. | -- | General-purpose wide-char-aware single-line text layout function. | ||||||
| @ -306,31 +228,6 @@ fitText mminwidth mmaxwidth ellipsify rightside = clip . pad | |||||||
|         Nothing -> s |         Nothing -> s | ||||||
|       where sw = textWidth s |       where sw = textWidth s | ||||||
| 
 | 
 | ||||||
| -- -- | A version of fitString that works on multi-line strings, |  | ||||||
| -- -- separate for now to avoid breakage. |  | ||||||
| -- -- This will rewrite any line endings to unix newlines. |  | ||||||
| -- fitStringMulti :: Maybe Int -> Maybe Int -> Bool -> Bool -> String -> String |  | ||||||
| -- fitStringMulti mminwidth mmaxwidth ellipsify rightside s = |  | ||||||
| --   (intercalate "\n" . map (fitString mminwidth mmaxwidth ellipsify rightside) . lines) s |  | ||||||
| 
 |  | ||||||
| -- | Left-pad a text to the specified width. |  | ||||||
| -- Treats wide characters as double width. |  | ||||||
| -- Works on multi-line texts too (but will rewrite non-unix line endings). |  | ||||||
| textPadLeftWide :: Int -> Text -> Text |  | ||||||
| textPadLeftWide w "" = T.replicate w " " |  | ||||||
| textPadLeftWide w s  = T.intercalate "\n" $ map (fitText (Just w) Nothing False False) $ T.lines s |  | ||||||
| -- XXX not yet replaceable by |  | ||||||
| -- padLeftWide w = fitStringMulti (Just w) Nothing False False |  | ||||||
| 
 |  | ||||||
| -- | Right-pad a string to the specified width. |  | ||||||
| -- Treats wide characters as double width. |  | ||||||
| -- Works on multi-line strings too (but will rewrite non-unix line endings). |  | ||||||
| textPadRightWide :: Int -> Text -> Text |  | ||||||
| textPadRightWide w "" = T.replicate w " " |  | ||||||
| textPadRightWide w s  = T.intercalate "\n" $ map (fitText (Just w) Nothing False True) $ T.lines s |  | ||||||
| -- XXX not yet replaceable by |  | ||||||
| -- padRightWide w = fitStringMulti (Just w) Nothing False True |  | ||||||
| 
 |  | ||||||
| -- | Double-width-character-aware string truncation. Take as many | -- | Double-width-character-aware string truncation. Take as many | ||||||
| -- characters as possible from a string without exceeding the | -- characters as possible from a string without exceeding the | ||||||
| -- specified width. Eg textTakeWidth 3 "りんご" = "り". | -- specified width. Eg textTakeWidth 3 "りんご" = "り". | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user