gpt4 book ai didi

scala - 是否可以通过编程方式更改Scala REPL的提示?

转载 作者:行者123 更新时间:2023-12-04 04:06:21 25 4
gpt4 key购买 nike

我想更改Scala REPL的提示。我发现我可以在电源模式下更改提示,如下所示。

scala> 

scala> :power
** Power User mode enabled - BEEP WHIR GYVE **
** :phase has been set to 'typer'. **
** scala.tools.nsc._ has been imported **
** global._, definitions._ also imported **
** Try :help, :vals, power.<tab> **

scala> repl.setPrompt("\ncool prompt!> ")

cool prompt!>

现在,我想在普通模式或sbt控制台的 initialCommands中执行此操作。有谁知道如何做到这一点?

最佳答案

斯卡拉2.10.0

$intp.asInstanceOf[scala.tools.nsc.interpreter.ILoop$ILoopInterpreter]
.getClass
.getDeclaredField("$outer").get($intp)
.asInstanceOf[scala.tools.nsc.interpreter.ILoop]
.setPrompt("\ncool prompt!> ")

关于scala - 是否可以通过编程方式更改Scala REPL的提示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15269324/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com