Commit 85e55b8a authored by Mart Lubbers's avatar Mart Lubbers

Add traceLayout for debugging purposes

parent 1fd727ce
definition module iTasks.UI.Layout.Debug
from iTasks.UI.Layout import :: Layout
/*
* Print the layout on stderr. The given string will be the prefix
*/
traceLayout :: String -> Layout
implementation module iTasks.UI.Layout.Debug
import iTasks
import StdDebug
import StdMisc
from Data.Map import toList, toAscList, foldrWithKey
from Text import class Text(join), instance Text String
import GenPrint
derive gPrint UIType, JSONNode, (,), Map
traceLayout :: String -> Layout
traceLayout m =
{ apply = \ui->trace_n (m +++ "- (apply) : " +++ printUI 0 ui) (NoChange, LSNone)
, adjust = \x ->trace_n (m +++ "- (adjust) : ") x
, restore= \c ->trace_n (m +++ "- (restore): ") NoChange
}
where
printUI ident (UI type attr children)
= toString (take (ident*4) (repeat ' '))
+++ printToString type +++ " {" +++ join "," (map printAttr (toList attr)) +++ "} :\n"
+++ foldr (+++) "" (map (printUI (ident+1)) children)
printAttr (t, json) = toString t +++ ": " +++ printToString json
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment