本文整理汇总了Scala中jline.console.ConsoleReader类的典型用法代码示例。如果您正苦于以下问题:Scala ConsoleReader类的具体用法?Scala ConsoleReader怎么用?Scala ConsoleReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConsoleReader类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: checkStop
//设置package包名称以及导入依赖的类
package es.weso.utils
import jline.console.ConsoleReader
import com.typesafe.scalalogging._
import jline.console.ConsoleReader
var stopAfterShow: Boolean = false
private def checkStop(forceStop: Boolean, action: => Unit): Unit = {
if (forceStop) {
stopAfterShow = true
}
if (stopAfterShow) {
consoleReader.println("\nAction? (n = next, r = resume, q = quit):")
val next = readFn()
next.toUpperCase match {
case "N" => return
case "R" => {
stopAfterShow = false
return
}
case "Q" => System.exit(0)
case c => {
info(s"\nUnknown char: $c");
action
}
}
}
}
def debugStep(msg: String, forceStop: Boolean = false) {
if (showDebug || stopAfterShow) {
debug(msg)
checkStop(forceStop, debugStep(msg))
}
}
def infoStep(msg: String, forceStop: Boolean = false) {
if (showInfo || forceStop) {
info(msg)
checkStop(forceStop, infoStep(msg))
}
}
}
示例2: Terminal
//设置package包名称以及导入依赖的类
package escli
import jline.console.ConsoleReader
import jline.TerminalFactory
class Terminal(val prompt: String) {
val reader = new ConsoleReader()
reader.setExpandEvents(false)
reader.setBellEnabled(false)
reader.setPrompt(prompt)
def scan(): Iterator[String] =
Iterator
.continually(reader.readLine())
.takeWhile(_ != null)
}
object Terminal {
def apply(prompt: String) = new Terminal(prompt)
def shutdown() = {
TerminalFactory.get().restore()
}
}