Examples of TerminalFactory


Examples of org.apache.karaf.shell.console.jline.TerminalFactory

                }
            }
        } else {

            // We are going into full blown interactive shell mode.
            TerminalFactory terminalFactory = new TerminalFactory();
            Terminal terminal = terminalFactory.getTerminal();
            Console console = createConsole(commandProcessor, in, out, err, terminal);
            CommandSession session = console.getSession();
            session.put("LINES", Integer.toString(terminal.getTerminalHeight()));
            session.put("COLUMNS", Integer.toString(terminal.getTerminalWidth()));
            session.put(".jline.terminal", terminal);
            session.put("USER", user);
            session.put("APPLICATION", application);
            session.put(NameScoping.MULTI_SCOPE_MODE_KEY, Boolean.toString(isMultiScopeMode()));

            console.run();
            terminalFactory.destroy();
        }
    }
View Full Code Here

Examples of org.apache.karaf.shell.console.jline.TerminalFactory

            ClientChannel channel;
      if (sb.length() > 0) {
                channel = session.createChannel("exec", sb.append("\n").toString());
                channel.setIn(new ByteArrayInputStream(new byte[0]));
      } else {
                terminal = new TerminalFactory().getTerminal();
         channel = session.createChannel("shell");
                ConsoleInputStream in = new ConsoleInputStream(terminal.wrapInIfNeeded(System.in));
                new Thread(in).start();
                channel.setIn(in);
                ((ChannelShell) channel).setupSensibleDefaultPty();
View Full Code Here

Examples of org.apache.karaf.shell.console.jline.TerminalFactory

            ClientChannel channel;
      if (sb.length() > 0) {
                channel = session.createChannel("exec", sb.append("\n").toString());
                channel.setIn(new ByteArrayInputStream(new byte[0]));
      } else {
                terminal = new TerminalFactory().getTerminal();
         channel = session.createChannel("shell");
                ConsoleInputStream in = new ConsoleInputStream(terminal.wrapInIfNeeded(System.in));
                new Thread(in).start();
                channel.setIn(in);
                ((ChannelShell) channel).setPtyColumns(terminal != null ? terminal.getWidth() : 80);
View Full Code Here

Examples of org.apache.karaf.shell.console.jline.TerminalFactory

            session.put(NameScoping.MULTI_SCOPE_MODE_KEY, Boolean.toString(isMultiScopeMode()));
            session.execute(sb);
        } else {
            // We are going into full blown interactive shell mode.

            final TerminalFactory terminalFactory = new TerminalFactory();
            final Terminal terminal = terminalFactory.getTerminal();
            Console console = createConsole(commandProcessor, in, out, err, terminal);
            CommandSession session = console.getSession();
            session.put("USER", user);
            session.put("APPLICATION", application);
            session.put(NameScoping.MULTI_SCOPE_MODE_KEY, Boolean.toString(isMultiScopeMode()));
            session.put("#LINES", new Function() {
                public Object execute(CommandSession session, List<Object> arguments) throws Exception {
                    return Integer.toString(terminal.getHeight());
                }
            });
            session.put("#COLUMNS", new Function() {
                public Object execute(CommandSession session, List<Object> arguments) throws Exception {
                    return Integer.toString(terminal.getWidth());
                }
            });
            session.put(".jline.terminal", terminal);

            console.run();

            terminalFactory.destroy();
        }

    }
View Full Code Here

Examples of org.apache.karaf.shell.impl.console.TerminalFactory

        run(sessionFactory, sb.toString(), in, out, err, cl);
    }

    private void run(final SessionFactory sessionFactory, String command, final InputStream in, final PrintStream out, final PrintStream err, ClassLoader cl) throws Exception {

        final TerminalFactory terminalFactory = new TerminalFactory();
        try {
            final Terminal terminal = new JLineTerminal(terminalFactory.getTerminal());
            Session session = createSession(sessionFactory, command.length() > 0 ? null : in, out, err, terminal);
            session.put("USER", user);
            session.put("APPLICATION", application);

            discoverCommands(session, cl, getDiscoveryResource());

            if (command.length() > 0) {
                // Shell is directly executing a sub/command, we don't setup a console
                // in this case, this avoids us reading from stdin un-necessarily.
                session.put(NameScoping.MULTI_SCOPE_MODE_KEY, Boolean.toString(isMultiScopeMode()));
                session.put(Session.PRINT_STACK_TRACES, "execution");
                try {
                    session.execute(command);
                } catch (Throwable t) {
                    ShellUtil.logException(session, t);
                }

            } else {
                // We are going into full blown interactive shell mode.
                session.run();
            }
        } finally {
            terminalFactory.destroy();
        }
    }
View Full Code Here

Examples of org.apache.karaf.shell.impl.console.TerminalFactory

        actionExtender = new CommandExtender(sessionFactory);
        actionExtender.start(context);

        if (Boolean.parseBoolean(context.getProperty(START_CONSOLE))) {
            terminalFactory = new TerminalFactory();
            localConsoleManager = new LocalConsoleManager(context, terminalFactory, sessionFactory);
            localConsoleManager.start();
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.