Skip to content

Commit

Permalink
Fix colors handling (#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexarchambault authored Aug 19, 2020
1 parent 0211846 commit 7ac35e0
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 5 deletions.
77 changes: 77 additions & 0 deletions examples/colors.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\u001b[36mres0\u001b[39m: \u001b[32mInt\u001b[39m = \u001b[32m2\u001b[39m"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"2"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"interp.colors() = ammonite.util.Colors.BlackWhite"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"res2: Int = 3"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"3"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Scala (sources)",
"language": "scala",
"name": "scala-debug"
},
"language_info": {
"codemirror_mode": "text/x-scala",
"file_extension": ".sc",
"mimetype": "text/x-scala",
"name": "scala",
"nbconvert_exporter": "script",
"version": "2.12.12"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ object AmmInterpreter {
printer = execute0.printer,
storage = storage,
wd = ammonite.ops.pwd,
colors = Ref(Colors.Default),
colors = replApi.colors,
verboseOutput = true, // ???
getFrame = () => frames0().head,
createFrame = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ object UpdatableFuture {
replApi: ReplAPI,
jupyterApi: JupyterApi,
ec: ExecutionContext
): Unit =
replApi.pprinter() = {
import jupyterApi.updatableResults._
val p = replApi.pprinter()
): Unit = {
import jupyterApi.updatableResults._
val previous = replApi.pprinter.live()
replApi.pprinter.bind {
val p = previous()
p.copy(
additionalHandlers = p.additionalHandlers.orElse {
case f: Future[_] =>
Expand All @@ -36,5 +37,6 @@ object UpdatableFuture {
}
)
}
}

}

0 comments on commit 7ac35e0

Please sign in to comment.