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


Java ConsoleReader.clearScreen方法代碼示例

本文整理匯總了Java中jline.console.ConsoleReader.clearScreen方法的典型用法代碼示例。如果您正苦於以下問題:Java ConsoleReader.clearScreen方法的具體用法?Java ConsoleReader.clearScreen怎麽用?Java ConsoleReader.clearScreen使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在jline.console.ConsoleReader的用法示例。


在下文中一共展示了ConsoleReader.clearScreen方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: run

import jline.console.ConsoleReader; //導入方法依賴的package包/類
@Override
public void run(String line, ConsoleReader reader) {
    try {
        reader.clearScreen();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
開發者ID:metadave,項目名稱:eql,代碼行數:9,代碼來源:EQLConsole.java

示例2: main

import jline.console.ConsoleReader; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException {
    RunnerConfigure.getInstance();

    Logger.info("starting bootscope runner...");

    Runtime.getRuntime().addShutdownHook(new Thread()
    {
        @Override
        public void run()
        {
            System.out.println("Shutdown progressing...");
            BytescopeContext.close();
        }
    });

    AnsiPrint.enable = (!SystemUtils.IS_OS_WINDOWS);

    if (ArrayUtils.contains(args, "-ansi"))
        AnsiPrint.enable = true;
    else if (ArrayUtils.contains(args, "-noansi"))
        AnsiPrint.enable = false;

    ConsoleReader console = BytescopeConsole.getConsole();
    console.setPrompt(AnsiPrint.green("bytescope> "));

    //console.addCompleter(new AggregateCompleter(new ArgumentCompleter()));

    String line;

    Logger.info("bootscope runner started.");
    while (true) {
        line = console.readLine().trim();
        if($.isEmpty(line)) continue;
        if (line.equalsIgnoreCase("quit") || line.equalsIgnoreCase("exit") || line.equalsIgnoreCase("bye")) {
            Logger.info("Shutdown progressing...");
            return;
        } else if (line.equalsIgnoreCase("cls")) {
            console.clearScreen();
            continue;
        }

        try {
            CommandResult result = CommandChainExecutor.getInstance().execute(line);
            if(result.getResult() < 0) {
                BytescopeConsole.getWriter().write(AnsiPrint.red("[error] ") + result.getMessage() + "\n");
            } else {
                if($.isNotBlank(result.getMessage())) {
                    BytescopeConsole.getWriter().write(result.getMessage() + "\n");
                }
            }
        } catch(Throwable t) {
            t.printStackTrace();
        }
    }
}
 
開發者ID:scouter-project,項目名稱:bytescope,代碼行數:56,代碼來源:RunnerMain.java

示例3: run

import jline.console.ConsoleReader; //導入方法依賴的package包/類
@Override
public void run() throws IOException {
           this.setup();
	if (this.getScriptFile() != null && this.getScriptFile().length() > 0) {
		try {
			String[] script = FileIO.read(this.getScriptFile()).split("\n");
                               logger.info(this.getMessages().get("executing_script", new Object[]{new File(this.getScriptFile()).getAbsolutePath()}));
			for (String scriptEntry: script) {
                                   processTask(scriptEntry, this.getLanguageCode());
			}
			logger.info(this.getMessages().get("executed_script", new Object[]{new File(this.getScriptFile()).getAbsolutePath()}));
		}
		catch (Exception e) {
			logger.error(this.getMessages().get("script_error", new Object[]{this.getScriptFile()}));
			logger.error(StackTrace.asString(e));
		}
	}
	String result = "";
       ConsoleReader reader = new ConsoleReader();
       reader.setPrompt(System.getProperty("user.name")+"@"+Host.name()+"> ");
       Collection<String> commands = new LinkedList<String>();
       commands.add("clear");
       commands.add("help");
       Set<String> keySet = this.getVocabulary().getVocabularyProperties().keySet();
	for (Object key: keySet.toArray()) {
		String value = this.getVocabulary().getVocabularyProperties().get(key.toString());
		if (value.split("\\|")[0].equals(this.getLanguageCode())) {
			commands.add(key.toString());
		}
	}
       List<Completer> completors = new LinkedList<Completer>();
       StringsCompleter stringsCompleter = new StringsCompleter(commands);
       completors.add(stringsCompleter);
       for (Completer c : completors) {
           reader.addCompleter(c);
       }
       this.getConsole().writer().write(this.getMessages().get("console_welcome", new Object[]{}));
       this.getConsole().flush();
       while (!(result.equals("exit"))) {
		result = reader.readLine(reader.getPrompt()).toLowerCase().trim();
		 if (result.equals("clear")) {
                reader.clearScreen();
            }
		 else {
			 processTask(result, this.getLanguageCode());
		 }
	}
}
 
開發者ID:rovemonteux,項目名稱:automation_engine,代碼行數:49,代碼來源:Console.java

示例4: main

import jline.console.ConsoleReader; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException {
	try {
		Character mask = null;
		String trigger = null;
		boolean color = false;

		ConsoleReader reader = new ConsoleReader();

		reader.setPrompt("prompt> ");

		if ((args == null) || (args.length == 0)) {
			usage();

			return;
		}

		List<Completer> completors = new LinkedList<Completer>();

		if (args.length > 0) {
			if (args[0].equals("none")) {
			} else if (args[0].equals("files")) {
				completors.add(new FileNameCompleter());
			} else if (args[0].equals("simple")) {
				completors.add(new StringsCompleter("foo", "bar", "baz"));
			} else if (args[0].equals("color")) {
				color = true;
				reader.setPrompt("\u001B[1mfoo\u001B[[email protected]\u001B[[email protected]\u001B[0m> ");
			} else {
				usage();

				return;
			}
		}

		if (args.length == 3) {
			mask = args[2].charAt(0);
			trigger = args[1];
		}

		for (Completer c : completors) {
			reader.addCompleter(c);
		}

		String line;
		PrintWriter out = new PrintWriter(reader.getOutput());

		while ((line = reader.readLine()) != null) {
			if (color) {
				out.println("\u001B[33m======>\u001B[0m\"" + line + "\"");

			} else {
				out.println("======>\"" + line + "\"");
			}
			out.flush();

			// If we input the special word then we will mask
			// the next line.
			if ((trigger != null) && (line.compareTo(trigger) == 0)) {
				line = reader.readLine("password> ", mask);
			}
			if (line.equalsIgnoreCase("quit")
					|| line.equalsIgnoreCase("exit")) {
				break;
			}
			if (line.equalsIgnoreCase("cls")) {
				reader.clearScreen();
			}
		}
	} catch (Throwable t) {
		t.printStackTrace();
	}
}
 
開發者ID:mixaceh,項目名稱:openyu-commons,代碼行數:73,代碼來源:JLineExample.java

示例5: execute

import jline.console.ConsoleReader; //導入方法依賴的package包/類
@Override public boolean execute(@NonNull final JCommander commander, @NonNull final ConsoleReader reader,
                                 @NonNull final PrintWriter printWriter) throws IOException {
	log.debug("Clearing the screen.");
	reader.clearScreen();
	return true;
}
 
開發者ID:Kelleth,項目名稱:age3-nanorobots,代碼行數:7,代碼來源:ClearScreenCommand.java


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