當前位置: 首頁>>代碼示例>>Java>>正文


Java ConsoleReader.setBellEnabled方法代碼示例

本文整理匯總了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();
        }
    }
 
開發者ID:mintDS,項目名稱:mintds,代碼行數:39,代碼來源:MintDsTerminal.java

示例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;
    }
}
 
開發者ID:loadtestgo,項目名稱:pizzascript,代碼行數:52,代碼來源:PizzaScript.java

示例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;
}
 
開發者ID:HuaweiBigData,項目名稱:StreamCQL,代碼行數:45,代碼來源:CQLClient.java


注:本文中的jline.console.ConsoleReader.setBellEnabled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。