Commit 16b9811b authored by John van Groningen's avatar John van Groningen

call defaultPrintSetup the first time the printer is used, and not when the

show profile application starts
parent a24c119d
......@@ -5,11 +5,13 @@ import StdPicture, StdPrint
:: ProgState a =
{ node_size_list::a
, node_size_sum::Int
, printingSetup :: PrintSetup
, printingSetup :: MaybePrintSetup
, application_name :: String
}
empty_progstate :: PrintSetup -> *ProgState [.a];
:: MaybePrintSetup = NoPrintSetup | PrintSetup !PrintSetup;
empty_progstate :: MaybePrintSetup -> *ProgState [.a];
:: SizeByNodeKindElem
......
......@@ -693,9 +693,9 @@ where
:: ProgState a = { node_size_list::a, node_size_sum::Int, printingSetup :: PrintSetup, application_name :: String};
:: ProgState a = { node_size_list::a, node_size_sum::Int, printingSetup :: MaybePrintSetup, application_name :: String};
empty_progstate :: PrintSetup -> *ProgState [.a];
empty_progstate :: MaybePrintSetup -> *ProgState [.a];
empty_progstate default_ps
= { ProgState |
node_size_list=[],
......@@ -762,7 +762,7 @@ p_open_file_function file_name ps
// [StaticText 0 (XY (MM 30.0) (MM 7.0))
// ("Reading "+++file_name_from_path file_name)]) io;
// Set-up a dummy ProgState which can be discarded in case of errors
# (defaultPS,ps) = defaultPrintSetup ps;
# defaultPS = NoPrintSetup;
# discardable_s = empty_progstate defaultPS;
# ((ok, discardable_s=:{node_size_list}, application_name), ps)
= accFiles (open_file file_name discardable_s) ps;
......@@ -991,8 +991,9 @@ open_file_function file_name s io
printTable :: Font .(ProgState [SizeByNodeKindElem]) *a -> *(.ProgState [SizeByNodeKindElem],*a) | PrintEnvironments a;
printTable printFont s=:{node_size_list,node_size_sum,printingSetup,application_name} env
# (PrintSetup printingSetup) = printingSetup;
# (usedPrintSetup,env) = print True True generate_pages printingSetup env;
= ({s & printingSetup=usedPrintSetup},env);
= ({s & printingSetup=PrintSetup usedPrintSetup},env);
where
generate_pages { printSetup, jobInfo={range=(first,last), copies }} picture
# {page=page=:{w=maxX,h=maxY},resolution=(horizontal_dpi,_)}
......
......@@ -121,7 +121,7 @@ info =
open_heap_file_from_command_line ps
# (commandline_arguments,ps) = initPlatformCommandLineArguments ps
| isEmpty commandline_arguments
# (dp,ps) = defaultPrintSetup ps
# dp=NoPrintSetup
= (empty_progstate dp,ps)
= open_file_function (hd commandline_arguments) ps
......@@ -151,7 +151,7 @@ openfun recId winId closeId printId pageId nextId prevId ps
= enable_disable nextId prevId pageId application_name ps
closefun recId winId closeId printId pageId nextId prevId ps
# (dp,ps) = defaultPrintSetup ps
# dp = NoPrintSetup
# ((err,_),ps) = syncSend2 recId (FW_SetContent (empty_progstate dp)) ps
| err <> SendOk
= ps
......@@ -175,6 +175,13 @@ printfun recId ps
FW_DummyOut
-> ps
(FW_ContentOut fw)
# (fw,ps) = case fw.printingSetup of
NoPrintSetup
# (printingSetup,ps) = defaultPrintSetup ps
# fw = {fw & printingSetup=PrintSetup printingSetup}
-> (fw,ps)
PrintSetup _
-> (fw,ps)
# (fw,ps) = printTable printFont fw ps
# (_,ps) = syncSend2 recId (FW_SetContent fw) ps
-> ps
......
......@@ -16,19 +16,22 @@ HelpFileName :== ApplicationName +++ "Help"
{ mode :: ViewMode
, mods :: [FormattedProfile]
, funs :: [FormattedProfile]
, pset :: PrintSetup
, pset :: MaybePrintSetup
, name :: String
}
:: MaybePrintSetup = NoPrintSetup | PrintSetup !PrintSetup;
:: ViewMode
= ViewByModule
| ViewByFunction
initialState pset =
initialState
=
{ mode = ViewByFunction
, mods = []
, funs = []
, pset = pset
, pset = NoPrintSetup
, name = ""
}
......@@ -44,12 +47,11 @@ Start world
["Profiling does not work on this computer,",
"because the Windows API function QueryPerformanceFrequency failed"
] world
# (dp,world) = defaultPrintSetup world
# (winId,world) = openId world
# (recId,world) = openR2Id world
# (closeId,world) = openId world
# (printId,world) = openId world
= startIO SDI (initialState dp) (init winId closeId printId recId) (atts winId closeId printId recId) world
= startIO SDI initialState (init winId closeId printId recId) (atts winId closeId printId recId) world
where
init winId closeId printId recId ps
# ((mods,funs,name),ps)
......@@ -215,7 +217,7 @@ closefun winId closeId printId recId ps
= ps
printfun recId ps
# ((printSetup),ps) = accPLoc (\vs=:{pset} -> (pset,vs)) ps
# (printSetup,ps) = getPrintSetup ps
# ((err,info),ps) = syncSend2 recId FW_GetContent ps
| err <> SendOk || isNothing info
= ps
......@@ -230,13 +232,20 @@ printfun recId ps
// | not ok
// = ps
# (printSetup,ps) = printTable printFont printSetup functionData sumData ps
# ps = appPLoc (\vs -> {vs & pset = printSetup}) ps
# ps = appPLoc (\vs -> {vs & pset = PrintSetup printSetup}) ps
= ps
where
printFont = PlatformDependant
{fName="Courier New",fStyles=[BoldStyle],fSize=8}
{fName="Monaco",fStyles=[],fSize=8}
getPrintSetup :: !*(PSt u:ProfileViewerState) -> *(!PrintSetup,!*(PSt u:ProfileViewerState))
getPrintSetup ps=:{ls={pset=PrintSetup printSetup}}
= (printSetup,ps)
getPrintSetup ps=:{ls={pset=NoPrintSetup}}
# (printSetup,ps) = defaultPrintSetup ps
= (printSetup,{ps & ls.pset=PrintSetup printSetup});
//-- Profile stuff...
open_file_function :: {#.Char} *a -> *((.[FormattedProfile],.[FormattedProfile],String),*a) | FileEnv a;
......
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