diff options
author | Daniel Burrows <dburrows@debian.org> | 2009-03-21 10:38:01 -0700 |
---|---|---|
committer | Daniel Burrows <dburrows@debian.org> | 2009-03-21 10:38:01 -0700 |
commit | 50c5d11cb044dc9ae952a85882334c5dbd95eb6a (patch) | |
tree | 953ebb4807a951d52641f4da73ed5209c88d5231 /tools | |
parent | 7d71965b413a6fdbc0aa0da3233a5ee7ff97db13 (diff) | |
download | aptitude-50c5d11cb044dc9ae952a85882334c5dbd95eb6a.tar.gz |
Nicely pretty-print choices in the list display.
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/resolver-visualize/Main.hs | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/tools/resolver-visualize/Main.hs b/tools/resolver-visualize/Main.hs index d6edcfa7..07f80597 100755 --- a/tools/resolver-visualize/Main.hs +++ b/tools/resolver-visualize/Main.hs @@ -5,7 +5,8 @@ module Main where import Control.Monad.Reader import qualified Control.Monad.State as State import Control.Monad.Trans(liftIO) -import Data.ByteString.Char8 as ByteString(ByteString, empty, readFile, unpack) +import Data.ByteString.Char8 as ByteString(ByteString, empty, readFile, pack, unpack) +import Data.List(intersperse) import Graphics.UI.Gtk import Graphics.UI.Gtk.Glade import Graphics.UI.Gtk.SourceView @@ -162,8 +163,23 @@ logFileToTree log = case processingSteps log of return $ catMaybes (first:rest') makeOrphanedTree root = Step root Unknown +class PP a where + ppS :: a -> ShowS + +instance PP Version where + ppS (Version pkg verName) = ppS pkg . (' ':) . (unpack verName++) + +instance PP Package where + ppS (Package pkgName) = (unpack pkgName++) + +instance PP Dep where + ppS (Dep src solvers) = ppS src . (" -> {"++) . (\x -> foldr (++) x $ intersperse ", " $ map pp solvers) . ('}':) + +pp x = ppS x "" + choiceText :: LinkChoice -> String -choiceText (LinkChoice choice) = show choice -- TODO: custom choice rendering +choiceText (LinkChoice (InstallVersion ver _ _)) = "Install " ++ pp ver +choiceText (LinkChoice (BreakSoftDep d)) = "Break " ++ pp d choiceText Unknown = "(...)" -- Column definitions for tree view entries. |