本文整理汇总了Java中jline.console.ConsoleReader.setBellEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java ConsoleReader.setBellEnabled方法的具体用法?Java ConsoleReader.setBellEnabled怎么用?Java ConsoleReader.setBellEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jline.console.ConsoleReader
的用法示例。
在下文中一共展示了ConsoleReader.setBellEnabled方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import jline.console.ConsoleReader; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
final Optional<String> host = args.length > 0 ? Optional.of(args[0]) : Optional.empty();
final Optional<Integer> port = args.length > 1 ? Optional.of(Integer.valueOf(args[1])) : Optional.empty();
try {
ConsoleReader console = new ConsoleReader(null, System.in, System.out, null);
console.setPrompt("\nmintDS> ");
console.setBellEnabled(false);
MintDsClient client = new MintDsClient.Builder()
.host(host.orElse(DEFAULT_HOST))
.port(port.orElse(DEFAULT_PORT))
.numberOfThreads(1)
.numberOfConnections(1)
.build();
for (; ;) {
String line = console.readLine();
if (line == null || "bye".equals(line.toLowerCase())) {
break;
}
if (line.trim().isEmpty()) {
continue;
}
// Waits for the response
CompletableFuture<Response> future = client.send(DefaultRequest.fromString(line));
System.out.println(future.get());
}
client.close();
} finally {
TerminalFactory.get().restore();
}
}
示例2: interactiveMode
import jline.console.ConsoleReader; //导入方法依赖的package包/类
private static boolean interactiveMode(JavaScriptEngine engine) {
try {
ConsoleReader reader = new ConsoleReader();
reader.setPrompt(PromptNewLine);
reader.addCompleter(new JavaScriptCompleter(engine));
reader.setBellEnabled(false);
reader.setHistoryEnabled(true);
int lineNo = 1;
int startLine = lineNo;
String line;
String source = "";
PrintWriter out = new PrintWriter(reader.getOutput());
boolean bContinueReading = false;
while (!bExiting && (line = reader.readLine()) != null ) {
source = source + line + "\n";
lineNo++;
bContinueReading = !engine.stringIsCompilableUnit(source);
if (!bContinueReading) {
try {
Object result = engine.runPartialScript(source, startLine);
if (result != null) {
out.println(engine.valueToString(result));
}
} catch (ScriptException se) {
out.println(se.getMessage());
}
startLine = lineNo;
source = "";
}
String prompt;
if (bContinueReading) {
prompt = PromptContinueLine;
} else {
prompt = PromptNewLine;
}
reader.setPrompt(prompt);
}
return true;
} catch (IOException e) {
System.err.println(e.getMessage());
return false;
}
}
示例3: readConconsole
import jline.console.ConsoleReader; //导入方法依赖的package包/类
private int readConconsole()
throws IOException
{
ConsoleReader reader = new ConsoleReader();
reader.setBellEnabled(false);
//这样就可以支持'!='这样的输入了。
reader.setExpandEvents(false);
reader.setCopyPasteDetection(true);
String line;
int ret = 0;
StringBuilder prefix = new StringBuilder();
printHelp();
String tip = DEFAULT_CLI_TIP;
while ((line = reader.readLine(tip)) != null)
{
tip = WAITING_INPUT_TIP;
if (!prefix.toString().equals(""))
{
prefix.append("\n");
}
if (line.trim().startsWith("--"))
{
continue;
}
if (line.trim().endsWith(";") && !line.trim().endsWith("\\;"))
{
line = prefix.toString() + line;
ret = processLine(line);
prefix.delete(0, prefix.length());
tip = DEFAULT_CLI_TIP;
}
else
{
prefix.append(line);
continue;
}
}
return ret;
}