From 66a03632cc4e83da129e7043bcbf27fae8a9d887 Mon Sep 17 00:00:00 2001 From: cc-wr <47033353+cc-wr@users.noreply.github.com> Date: Thu, 16 Jan 2020 06:28:16 -0500 Subject: [PATCH] Add TODO comment --- .../Resources/EvaluationUtilities.wl | 59 ++++++++++--------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/WolframLanguageForJupyter/Resources/EvaluationUtilities.wl b/WolframLanguageForJupyter/Resources/EvaluationUtilities.wl index 91eebe0..afd5ddf 100644 --- a/WolframLanguageForJupyter/Resources/EvaluationUtilities.wl +++ b/WolframLanguageForJupyter/Resources/EvaluationUtilities.wl @@ -66,6 +66,36 @@ If[ uninteract[expr_] := UsingFrontEnd[applyHook[$Pre, expr]]; SetAttributes[uninteract, HoldAll]; +(************************************ + version of Print that + sends output to Jupyter +*************************************) + + (* redirect Print calls into a message to Jupyter, in order to print in Jupyter *) + (* TODO: review other methods: through EvaluationData or WSTP so we don't redefine Print *) + (* TODO: remove this and just permanently set $Output to {..., loopState["WolframLanguageForJupyter-stdout"], ...} *) + Unprotect[Print]; + Print[ourArgs___, opts:OptionsPattern[]] := + Block[ + { + $inPrint = True, + $Output + }, + If[ + loopState["printFunction"] =!= False, + $Output = {OpenWrite[FormatType -> OutputForm]}; + If[ + !FailureQ[First[$Output]], + Print[ourArgs, opts]; + loopState["printFunction"][ + Import[$Output[[1,1]], "String"] + ]; + Close[First[$Output]]; + ]; + ]; + ] /; !TrueQ[$inPrint]; + Protect[Print]; + (************************************ version of Write that sends output to Jupyter @@ -136,35 +166,6 @@ If[ ] /; !TrueQ[$inWriteString]; Protect[WriteString]; -(************************************ - version of Print that - sends output to Jupyter -*************************************) - - (* redirect Print calls into a message to Jupyter, in order to print in Jupyter *) - (* TODO: review other methods: through EvaluationData or WSTP so we don't redefine Print *) - Unprotect[Print]; - Print[ourArgs___, opts:OptionsPattern[]] := - Block[ - { - $inPrint = True, - $Output - }, - If[ - loopState["printFunction"] =!= False, - $Output = {OpenWrite[FormatType -> OutputForm]}; - If[ - !FailureQ[First[$Output]], - Print[ourArgs, opts]; - loopState["printFunction"][ - Import[$Output[[1,1]], "String"] - ]; - Close[First[$Output]]; - ]; - ]; - ] /; !TrueQ[$inPrint]; - Protect[Print]; - (************************************ versions of Quit and Exit that ask the Jupyter console