コード例 #1
0
ファイル: ConsoleCommand.java プロジェクト: neoedmund/jnode
  @Override
  public void execute() throws NameNotFoundException, IsolateStartupException, ShellException {
    final PrintWriter out = getOutput().getPrintWriter();
    final ShellManager sm = InitialNaming.lookup(ShellManager.NAME);
    final ConsoleManager conMgr = sm.getCurrentShell().getConsole().getManager();

    boolean listConsoles = FLAG_LIST.isSet();
    boolean newConsole = FLAG_NEW.isSet();
    boolean isolateNewConsole = FLAG_ISOLATED.isSet();
    boolean test = FLAG_TEST.isSet();

    if (listConsoles) {
      conMgr.printConsoles(out);
    } else if (newConsole) {
      if (isolateNewConsole) {
        try {
          Isolate newIsolate =
              new Isolate(ConsoleCommand.IsolatedConsole.class.getName(), new String[0]);
          newIsolate.start();
          out.println("Started new isolated console");
        } catch (IsolateStartupException ex) {
          out.println("Failed to start new isolated console");
          throw ex;
        }
      } else {
        createConsoleWithShell(conMgr, out);
      }
    } else if (test) {
      out.println("test RawTextConsole");
      final TextConsole console =
          (TextConsole)
              conMgr.createConsole(
                  null,
                  ConsoleManager.CreateOptions.TEXT
                      | ConsoleManager.CreateOptions.NO_LINE_EDITTING);
      conMgr.registerConsole(console);
      conMgr.focus(console);
      console.clear();
    }
  }
コード例 #2
0
ファイル: PageCommand.java プロジェクト: flesire/jnode.mirror
  /**
   * Do the paging, reading commands from our private console input pipe to figure out what to do
   * next.
   *
   * @param r the source of data to be paged.
   * @throws IOException
   */
  private void pager() throws IOException {
    // Output first page.
    console.clear();
    bottomLineNo = -1;
    boolean exit = false;
    nextPage();

    // Process commands until we reach the EOF on the data source or
    // the command pipe.
    while (!exit) {
      prompt();
      int ch = pr.read();
      erasePrompt();
      switch (ch) {
        case -1:
          exit = true;
          break;
        case ' ':
        case 'f':
          if (lineStore.isLastLineNo(bottomLineNo)) {
            exit = true;
          } else {
            nextPage();
          }
          break;
        case 'b':
          prevPage();
          break;
        case 'k':
        case 'y':
          prevLine();
          break;
        case '\n':
          if (lineStore.isLastLineNo(bottomLineNo)) {
            exit = true;
          } else {
            nextLine();
          }
          break;
        case 'u':
          prevScreenLine();
          break;
        case 'd':
          nextScreenLine();
          break;
        case '<':
          gotoPage(0);
          break;
        case '>':
          gotoLastPage();
          break;
        case '/':
          searchForwards();
          break;
        case '?':
          searchBackwards();
          break;
        case '\004': // ^D
        case 'q':
          exit = true;
          break;
        case 'h':
          help();
        default:
          // ignore
      }
    }
  }