import Generics.gCons
-from iTasks.UI.Editor.Common import emptyEditor
+import iTasks.UI.Editor.Common
+import iTasks.UI.Editor
import GenEq, StdMisc, StdArray, GenBimap
import GenPrint
instance toByteCode BCValue where toByteCode (BCValue v) = toByteCode v
instance fromByteCode Bool where fromByteCode s = fromByteCode s == 1
-instance fromByteCode Int where fromByteCode s = (toInt s.[0])*256 + toInt s.[1]
+instance fromByteCode Int where fromByteCode s = (toInt s.[1])*256 + toInt s.[2]
instance fromByteCode Long where fromByteCode s = L $ fromByteCode s
instance fromByteCode Char where fromByteCode s = fromInt $ fromByteCode s
instance fromByteCode String where fromByteCode s = abort $ "Undef on fromBytecode String" +++ s
consNum{|BCValue|} _ = 1
gPrint{|BCValue|} v ps = gPrint{|*|} (readable $ BCPush v) ps
-gEditor{|BCValue|} = emptyEditor
+gEditor{|BCValue|} = {Editor|genUI=genUI`,onEdit=onEdit`,onRefresh=onRefresh`}
+ where
+ genUI` dp (BCValue a) vst = (castEditor a).Editor.genUI dp a vst
+ onEdit` dp jsn (BCValue a) em vst = appSnd3 BCValue $ (castEditor a).Editor.onEdit dp jsn a em vst
+ onRefresh` dp (BCValue a) (BCValue a`) em vst = appSnd3 BCValue $ (castEditor a).Editor.onRefresh dp a (fromByteCode $ toByteCode a`) em vst
+
+ castEditor :: a -> (Editor a) | mTaskType a
+ castEditor _ = gEditor{|*|}
+
gText{|BCValue|} fm Nothing = []
gText{|BCValue|} fm (Just (BCValue e)) = gText{|*|} fm (Just e)
JSONEncode{|BCValue|} b (BCValue e) = JSONEncode{|*|} b (toByteCode e)