on master help sign in
Expunge stale TODOs littered throughout the library
commitc40f9575fa2c1bb0df174ff56f726abd2400005e authorJonathan Daugherty <cygnus@foobox.com> dateSun 22 Jan 2017, 09:53 (10 years ago) parent629cb6e
19 files changed+29−110
src/Data/Terminfo/Parse.hs−2 src/Graphics/Vty.hs−2 src/Graphics/Vty/Attributes.hs−2 src/Graphics/Vty/Attributes/Color240.hs−1 src/Graphics/Vty/DisplayAttributes.hs−4 src/Graphics/Vty/Image.hs−1 src/Graphics/Vty/Image/Internal.hs+1−15 src/Graphics/Vty/Input.hs+4−8 src/Graphics/Vty/Input/Classify.hs−3 src/Graphics/Vty/Input/Loop.hs−1 src/Graphics/Vty/Input/Terminfo.hs+5−9 src/Graphics/Vty/Input/Terminfo/ANSIVT.hs−5 src/Graphics/Vty/Output.hs−4 src/Graphics/Vty/Output/Interface.hs+1−5 src/Graphics/Vty/Output/TerminfoBased.hs+13−19 src/Graphics/Vty/Output/XTermColor.hs+1−1 src/Graphics/Vty/Picture.hs−7 src/Graphics/Vty/PictureToSpans.hs+4−16 src/Graphics/Vty/Span.hs−5
src/Data/Terminfo/Parse.hs−2
@@ -110,8 +110,6 @@ constructCapExpression capString buildResults =
110110 { capOps = outCapOps buildResults
111111 -- The cap bytes are the lower 8 bits of the input
112112 -- string's characters.
113− -- \todo Verify the input string actually contains an
114− -- 8bit byte per character.
115113 , capBytes = Vector.fromList $ map (toEnum.fromEnum) capString
116114 , sourceString = capString
117115 , paramCount = outParamCount buildResults
src/Graphics/Vty.hs−2
@@ -93,8 +93,6 @@ import Data.Monoid
9393-- This does not assure any thread safety. In theory, as long as an
9494-- update action is not executed when another update action is already
9595-- then it's safe to call this on multiple threads.
96−--
97−-- \todo Remove explicit `shutdown` requirement.
9896data Vty = Vty
9997 { -- | Outputs the given Picture. Equivalent to 'outputPicture'
10098 -- applied to a display context implicitly managed by Vty. The
src/Graphics/Vty/Attributes.hs−2
@@ -33,8 +33,6 @@
3333--
3434-- The value 'currentAttr' will keep the attributes of whatever was
3535-- output previously.
36−--
37−-- \todo This API is very verbose IMO. I'd like something more succinct.
3836module Graphics.Vty.Attributes
3937 ( module Graphics.Vty.Attributes
4038 , module Graphics.Vty.Attributes.Color
src/Graphics/Vty/Attributes/Color240.hs−1
@@ -8,7 +8,6 @@ import Text.Printf
88-- | RGB color to 240 color palette.
99--
1010-- generated from 256colres.pl which is forked from xterm 256colres.pl
11−-- todo: all values get clamped high.
1211rgbColor :: Integral i => i -> i -> i -> Color
1312rgbColor r g b
1413 | r < 0 && g < 0 && b < 0 = error "rgbColor with negative color component intensity"
src/Graphics/Vty/DisplayAttributes.hs−4
@@ -57,15 +57,11 @@ instance Monoid DisplayAttrDiff where
5757 in DisplayAttrDiff ds fcd bcd
5858
5959-- | Used in the computation of a final style attribute change.
60−--
61−-- TODO(corey): not really a simplify but a monoid instance.
6260simplifyStyleDiffs :: [StyleStateChange] -> [StyleStateChange] -> [StyleStateChange]
6361simplifyStyleDiffs cs0 cs1 = cs0 `mappend` cs1
6462
6563-- | Consider two display color attributes diffs. What display color
6664-- attribute diff are these equivalent to?
67−--
68−-- TODO(corey): not really a simplify but a monoid instance.
6965simplifyColorDiffs :: DisplayColorDiff -> DisplayColorDiff -> DisplayColorDiff
7066simplifyColorDiffs _cd ColorToDefault = ColorToDefault
7167simplifyColorDiffs cd NoColorChange = cd
src/Graphics/Vty/Image.hs−1
@@ -179,7 +179,6 @@ pad inL inT inR inB inImage
179179 | inL < 0 || inT < 0 || inR < 0 || inB < 0 = error "cannot pad by negative amount"
180180 | otherwise = go inL inT inR inB inImage
181181 where
182− -- TODO: uh.
183182 go 0 0 0 0 i = i
184183 go 0 0 0 b i = VertJoin i (BGFill w b) w h
185184 where w = imageWidth i
src/Graphics/Vty/Image/Internal.hs+1−15
@@ -23,18 +23,8 @@ import Data.Monoid
2323#endif
2424
2525-- | A display text is a Data.Text.Lazy
26−--
27−-- TODO(corey): hm. there is an explicit equation for each type which
28−-- goes to a lazy text. Each application probably uses a single type.
29−-- Perhaps parameterize the entire vty interface by the input text type?
30−-- TODO: Try using a builder instead of a TL.Text instance directly.
31−-- That might improve performance for the usual case of appending a
32−-- bunch of characters with the same attribute together.
3326type DisplayText = TL.Text
3427
35−-- TODO: store a skip list in HorizText(?)
36−-- TODO: represent display strings containing chars that are not 1
37−-- column chars as a separate display string value?
3828clipText :: DisplayText -> Int -> Int -> DisplayText
3929clipText txt leftSkip rightClip =
4030 -- CPS would clarify this I think
@@ -265,14 +255,12 @@ instance Monoid Image where
265255-- width. And the height will equal the largest height of the two
266256-- images. The area not defined in one image due to a height missmatch
267257-- will be filled with the background pattern.
268−--
269−-- TODO: the bg fill is biased towards top to bottom languages(?)
270258horizJoin :: Image -> Image -> Image
271259horizJoin EmptyImage i = i
272260horizJoin i EmptyImage = i
273261horizJoin i0@(HorizText a0 t0 w0 cw0) i1@(HorizText a1 t1 w1 cw1)
274262 | a0 == a1 = HorizText a0 (TL.append t0 t1) (w0 + w1) (cw0 + cw1)
275− -- TODO: assumes horiz text height is always 1
263+ -- assumes horiz text height is always 1
276264 | otherwise = HorizJoin i0 i1 (w0 + w1) 1
277265horizJoin i0 i1
278266 -- If the images are of the same height then no padding is required
@@ -298,8 +286,6 @@ horizJoin _ _ = error "horizJoin applied to undefined values."
298286-- of both images. The width will equal the largest width of the two
299287-- images. The area not defined in one image due to a width missmatch
300288-- will be filled with the background pattern.
301−--
302−-- TODO: the bg fill is biased towards right to left languages(?)
303289vertJoin :: Image -> Image -> Image
304290vertJoin EmptyImage i = i
305291vertJoin i EmptyImage = i
src/Graphics/Vty/Input.hs+4−8
@@ -189,20 +189,16 @@ import Data.Monoid ((<>))
189189-- "raw" mode is used for input.
190190--
191191-- * ISIG disabled
192−-- - enables keyboard combinations that result in signals. TODO:
193−-- should probably be a dynamic option.
192+-- - enables keyboard combinations that result in signals.
194193--
195194-- * ECHO disabled
196−-- - input is not echod to the output. TODO: should be a
197−-- dynamic option.
195+-- - input is not echoed to the output.
198196--
199197-- * ICANON disabled
200−-- - canonical mode (line mode) input is not used. TODO: should
201−-- be a dynamic option.
198+-- - canonical mode (line mode) input is not used.
202199--
203200-- * IEXTEN disabled
204−-- - extended functions are disabled. TODO: I don't know what
205−-- those are.
201+-- - extended functions are disabled.
206202--
207203inputForConfig :: Config -> IO Input
208204inputForConfig config@Config{ termName = Just termName
src/Graphics/Vty/Input/Classify.hs−3
@@ -2,8 +2,6 @@
22-- This makes a kind of tri. Has space efficiency issues with large
33-- input blocks. Likely building a parser and just applying that would
44-- be better.
5−-- TODO: The ClassifyMap interface requires this code to always assure
6−-- later entries override earlier.
75module Graphics.Vty.Input.Classify
86 ( classify
97 , KClass(..)
@@ -50,7 +48,6 @@ compile table = cl' where
5048 in case mapMaybe (\s -> (,) s `fmap` M.lookup s eventForInput) inputPrefixes of
5149 (s,e) : _ -> Valid e (drop (length s) inputBlock)
5250 -- neither a prefix or a full event.
53− -- TODO: debug log
5451 [] -> Invalid
5552
5653classify :: ClassifyMap -> [Char] -> KClass
src/Graphics/Vty/Input/Loop.hs−1
@@ -113,7 +113,6 @@ emit event = do
113113--
114114-- Precondition: Under the threaded runtime. Only current use is from a
115115-- forkOS thread. That case satisfies precondition.
116−-- TODO: When under the non-threaded runtime emulate VMIN and VTIME
117116readFromDevice :: InputM String
118117readFromDevice = do
119118 newConfig <- view configRef >>= liftIO . readIORef
src/Graphics/Vty/Input/Terminfo.hs+5−9
@@ -32,9 +32,6 @@ import System.Console.Terminfo
3232--
3333-- Precedence is currently implicit in the 'compile' algorithm. Which is
3434-- a bit odd.
35−--
36−-- \todo terminfo meta is not supported.
37−-- \todo no 8bit
3835classifyMapForTerm :: String -> Terminal -> ClassifyMap
3936classifyMapForTerm termName term =
4037 concat $ capsClassifyMap term keysFromCapsTable
@@ -43,7 +40,8 @@ classifyMapForTerm termName term =
4340
4441-- | key table applicable to all terminals.
4542--
46−-- TODO: some probably only applicable to ANSI/VT100 terminals.
43+-- Note that some of these entries are probably only applicable to
44+-- ANSI/VT100 terminals.
4745universalTable :: ClassifyMap
4846universalTable = concat [visibleChars, ctrlChars, ctrlMetaChars, specialSupportKeys]
4947
@@ -54,7 +52,8 @@ capsClassifyMap terminal table = [(x,y) | (Just x,y) <- map extractCap table]
5452-- | Tables specific to a given terminal that are not derivable from
5553-- terminfo.
5654--
57−-- TODO: Adds the ANSI/VT100/VT50 tables regardless of term identifier.
55+-- Note that this adds the ANSI/VT100/VT50 tables regardless of term
56+-- identifier.
5857termSpecificTables :: String -> [ClassifyMap]
5958termSpecificTables _termName = ANSIVT.classifyTable
6059
@@ -62,9 +61,6 @@ termSpecificTables _termName = ANSIVT.classifyTable
6261--
6362-- We limit to < 0xC1. The UTF8 sequence detector will catch all values
6463-- 0xC2 and above before this classify table is reached.
65−--
66−-- TODO: resolve
67−-- 1. start at ' '. The earlier characters are all 'ctrlChar'
6864visibleChars :: ClassifyMap
6965visibleChars = [ ([x], EvKey (KChar x) [])
7066 | x <- [' ' .. toEnum 0xC1]
@@ -73,7 +69,7 @@ visibleChars = [ ([x], EvKey (KChar x) [])
7369-- | Non visible characters in the ISO-8859-1 and UTF-8 common set
7470-- translated to ctrl + char.
7571--
76−-- \todo resolve CTRL-i is the same as tab
72+-- This treats CTRL-i the same as tab.
7773ctrlChars :: ClassifyMap
7874ctrlChars =
7975 [ ([toEnum x],EvKey (KChar y) [MCtrl])
src/Graphics/Vty/Input/Terminfo/ANSIVT.hs−5
@@ -10,9 +10,6 @@ module Graphics.Vty.Input.Terminfo.ANSIVT where
1010import Graphics.Vty.Input.Events
1111
1212-- | Encoding for navigation keys.
13−--
14−-- TODO: This is not the same as the input bytes pulled from teh caps
15−-- table.
1613navKeys0 :: ClassifyMap
1714navKeys0 =
1815 [ k "G" KCenter
@@ -67,8 +64,6 @@ functionKeys1 =
6764
6865-- | encoding for meta plus char
6966--
70−-- TODO: resolve -
71−--
7267-- 1. removed 'ESC' from second list due to duplication with
7368-- "special_support_keys".
7469-- 2. removed '[' from second list due to conflict with 7-bit encoding
src/Graphics/Vty/Output.hs−4
@@ -63,10 +63,6 @@ import Data.Monoid ((<>))
6363--
6464-- * If TERM contains "xterm" or "screen", use XTermColor.
6565-- * otherwise use the TerminfoBased driver.
66−--
67−-- \todo add an implementation for windows that does not depend on
68−-- terminfo. Should be installable with only what is provided in the
69−-- haskell platform. Use ansi-terminal
7066outputForConfig :: Config -> IO Output
7167outputForConfig Config{ outputFd = Just fd, termName = Just termName, .. } = do
7268 t <- if "xterm" `isPrefixOf` termName || "screen" `isPrefixOf` termName
src/Graphics/Vty/Output/Interface.hs+1−5
@@ -153,9 +153,6 @@ writeUtf8Text = writeByteString
153153-- 3. Serialized to the display.
154154--
155155-- 4. The cursor is then shown and positioned or kept hidden.
156−--
157−-- todo: specify possible IO exceptions.
158−-- abstract from IO monad to a MonadIO instance.
159156outputPicture :: MonadIO m => DisplayContext -> Picture -> m ()
160157outputPicture dc pic = liftIO $ do
161158 as <- readIORef (assumedStateRef $ contextDevice dc)
@@ -165,7 +162,6 @@ outputPicture dc pic = liftIO $ do
165162 initialAttr = FixedAttr defaultStyleMask Nothing Nothing
166163 -- Diff the previous output against the requested output.
167164 -- Differences are currently on a per-row basis.
168− -- \todo handle resizes that crop the dominate directions better.
169165 diffs :: [Bool] = case prevOutputOps as of
170166 Nothing -> replicate (fromEnum $ regionHeight $ effectedRegion ops) True
171167 Just previousOps -> if effectedRegion previousOps /= effectedRegion ops
@@ -288,7 +284,7 @@ limitAttrForDisplay t attr
288284 | contextColorCount t < 16 && v >= 8 = SetTo $ ISOColor (v - 8)
289285 | otherwise = SetTo $ ISOColor v
290286 clampColor' (Color240 v)
291− -- TODO: Choose closes ISO color?
287+ -- Should we choose closest ISO color?
292288 | contextColorCount t < 8 = Default
293289 | contextColorCount t < 16 = Default
294290 | contextColorCount t <= 256 = SetTo $ Color240 v
src/Graphics/Vty/Output/TerminfoBased.hs+13−19
@@ -99,19 +99,14 @@ sendCapToTerminal :: Output -> CapExpression -> [CapParam] -> IO ()
9999sendCapToTerminal t cap capParams = do
100100 outputByteBuffer t $ writeToByteString $ writeCapExpr cap capParams
101101
102−{- | Uses terminfo for all control codes. While this should provide the
103− - most compatible terminal terminfo does not support some features that
104− - would increase efficiency and improve compatibility:
105− -
106− - * determine the character encoding supported by the terminal. Should
107− - this be taken from the LANG environment variable?
108− -
109− - * Provide independent string capabilities for all display attributes.
110− -
111− - todo: Some display attributes like underline and bold have
112− - independent string capabilities that should be used instead of the
113− - generic "sgr" string capability.
114− -}
102+-- | Uses terminfo for all control codes. While this should provide the
103+-- most compatible terminal terminfo does not support some features that
104+-- would increase efficiency and improve compatibility:
105+--
106+-- * determine the character encoding supported by the terminal. Should
107+-- this be taken from the LANG environment variable?
108+--
109+-- * Provide independent string capabilities for all display attributes.
115110reserveTerminal :: ( Applicative m, MonadIO m ) => String -> Fd -> m Output
116111reserveTerminal termName outFd = liftIO $ do
117112 ti <- Terminfo.setupTerm termName
@@ -284,13 +279,12 @@ terminfoDisplayContext tActual terminfoCaps r = return dc
284279--
285280-- This equation implements the above logic.
286281--
287−-- \todo This assumes the removal of color changes in the display
288−-- attributes is done as expected with noColors == True. See
289−-- `limitAttrForDisplay`
282+-- Note that this assumes the removal of color changes in the
283+-- display attributes is done as expected with noColors == True. See
284+-- `limitAttrForDisplay`.
290285--
291−-- \todo This assumes that fewer state changes, followed by fewer
292−-- bytes, is what to optimize. I haven't measured this or even examined
293−-- terminal implementations. *shrug*
286+-- Note that this optimizes for fewer state changes followed by fewer
287+-- bytes.
294288terminfoWriteSetAttr :: DisplayContext -> TerminfoCaps -> FixedAttr -> Attr -> DisplayAttrDiff -> Write
295289terminfoWriteSetAttr dc terminfoCaps prevAttr reqAttr diffs = do
296290 case (foreColorDiff diffs == ColorToDefault) || (backColorDiff diffs == ColorToDefault) of
src/Graphics/Vty/Output/XTermColor.hs+1−1
@@ -102,7 +102,7 @@ disableBracketedPastes = "\ESC[?2004l"
102102
103103-- | These sequences set xterm based terminals to UTF-8 output.
104104--
105−-- \todo I don't know of a terminfo cap that is equivalent to this.
105+-- There is no known terminfo capability equivalent to this.
106106setUtf8CharSet, setDefaultCharSet :: String
107107setUtf8CharSet = "\ESC%G"
108108setDefaultCharSet = "\ESC%@"
src/Graphics/Vty/Picture.hs−7
@@ -79,10 +79,6 @@ picForLayers is = Picture
7979--
8080-- There is not a 1 to 1 map from character positions to a row and
8181-- column on the screen due to characters that take more than 1 column.
82−--
83−-- todo: The Cursor can be given a (character,row) offset outside of the
84−-- visible bounds of the output region. In this case the cursor will not
85−-- be shown.
8682data Cursor =
8783 -- | Hide the cursor
8884 NoCursor
@@ -101,9 +97,6 @@ instance NFData Cursor where
10197-- attribute. If the display attribute used previously should be used
10298-- for a background fill then use `currentAttr` for the background
10399-- attribute.
104−--
105−-- \todo The current attribute is always set to the default attributes
106−-- at the start of updating the screen to a picture.
107100data Background
108101 = Background
109102 { backgroundChar :: Char
src/Graphics/Vty/PictureToSpans.hs+4−16
@@ -91,9 +91,6 @@ displayOpsForImage :: Image -> DisplayOps
9191displayOpsForImage i = displayOpsForPic (picForImage i) (imageWidth i, imageHeight i)
9292
9393-- | Produces the span ops for each layer then combines them.
94−--
95−-- TODO: a fold over a builder function. start with span ops that are a
96−-- bg fill of the entire region.
9794combinedOpsForLayers :: Picture -> DisplayRegion -> ST s (MRowOps s)
9895combinedOpsForLayers pic r
9996 | regionWidth r == 0 || regionHeight r == 0 = MVector.new 0
@@ -118,7 +115,6 @@ substituteSkips ClearBackground ops = do
118115 -- but only by the insertion of a non skip. all this combines to
119116 -- mean we can check the last operation and remove it if it's a
120117 -- skip
121− -- todo: or does it?
122118 let rowOps' = case Vector.last rowOps of
123119 Skip w -> Vector.init rowOps `Vector.snoc` RowEnd w
124120 _ -> rowOps
@@ -197,17 +193,12 @@ swapSkipsForCharSpan w c a = Vector.map f
197193-- picture to the terminal.
198194--
199195-- Crops to the given display region.
200−--
201−-- \todo I'm pretty sure there is an algorithm that does not require a
202−-- mutable buffer.
203196buildSpans :: Image -> DisplayRegion -> ST s (MRowOps s)
204197buildSpans image outRegion = do
205198 -- First we create a mutable vector for each rows output operations.
206199 outOps <- MVector.replicate (regionHeight outRegion) Vector.empty
207− -- \todo I think building the span operations in display order
208− -- would provide better performance. However, I got stuck trying to
209− -- implement an algorithm that did this. This will be considered as
210− -- a possible future optimization.
200+ -- It's possible that building the span operations in display order
201+ -- would provide better performance.
211202 --
212203 -- A depth first traversal of the image is performed. ordered
213204 -- according to the column range defined by the image from least
@@ -255,12 +246,10 @@ isOutOfBounds i s
255246-- This is a very touchy algorithm. Too touchy. For instance, the
256247-- CropRight and CropBottom implementations are odd. They pass the
257248-- current tests but something seems terribly wrong about all this.
258−--
259−-- \todo prove this cannot be called in an out of bounds case.
260249addMaybeClipped :: forall s . Image -> BlitM s ()
261250addMaybeClipped EmptyImage = return ()
262251addMaybeClipped (HorizText a textStr ow _cw) = do
263− -- TODO: assumption that text spans are only 1 row high.
252+ -- This assumes that text spans are only 1 row high.
264253 s <- use skipRows
265254 when (s < 1) $ do
266255 leftClip <- use skipColumns
@@ -323,8 +312,7 @@ addMaybeClippedJoin name skip remaining offset i0Dim i0 i1 size = do
323312 state <- get
324313 when (state^.remaining <= 0) $ fail $ name ++ " with remaining <= 0"
325314 case state^.skip of
326− s -- TODO: check if clipped in other dim. if not use addUnclipped
327− | s > size -> put $ state & skip -~ size
315+ s | s > size -> put $ state & skip -~ size
328316 | s == 0 -> if state^.remaining > i0Dim
329317 then do
330318 addMaybeClipped i0
src/Graphics/Vty/Span.hs−5
@@ -10,9 +10,6 @@
1010--
1111-- A span op sequence will be defined for all rows and columns (and no
1212-- more) of the region provided with the picture to `spansForPic`.
13−--
14−-- todo: Partition attribute changes into multiple categories according
15−-- to the serialized representation of the various attributes.
1613module Graphics.Vty.Span where
1714
1815import Graphics.Vty.Attributes (Attr)
@@ -39,13 +36,11 @@ data SpanOp =
3936 -- | Skips the given number of columns
4037 -- A skip is transparent.... maybe? I am not sure how attribute
4138 -- changes interact.
42− -- todo: separate from this type.
4339 | Skip !Int
4440 -- | Marks the end of a row. specifies how many columns are
4541 -- remaining. These columns will not be explicitly overwritten with
4642 -- the span ops. The terminal is require to assure the remaining
4743 -- columns are clear.
48− -- todo: separate from this type.
4944 | RowEnd !Int
5045 deriving Eq
5146