Package org.jnode.driver.console

Examples of org.jnode.driver.console.TextConsole


        }
    }

    private static TextConsole createConsoleWithShell(final ConsoleManager conMgr, PrintWriter out)
        throws ShellException {
        final TextConsole console = (TextConsole) conMgr.createConsole(null,
                ConsoleManager.CreateOptions.TEXT | ConsoleManager.CreateOptions.SCROLLABLE);
        CommandShell commandShell = new CommandShell(console);
        new Thread(commandShell, "command-shell").start();

        out.println("New console created with name: " + console.getConsoleName());

        // FIXME we shouldn't be setting the invoker (and interpreter) via the System Properties
        // object because it is "global" in some operation modes, and we want to be able to
        // control the invoker / interpreter on a per-console basis.
        String invokerName = System.getProperty(CommandShell.INVOKER_PROPERTY_NAME, "");
        // FIXME this is a temporary hack until we decide what to do about these invokers
        if ("thread".equals(invokerName) || "default".equals(invokerName)) {
            PrintWriter err = new PrintWriter(console.getErr());
            err.println(
                    "Warning: any commands run in this console via their main(String[]) will " +
                    "have the 'wrong' System.out and System.err.");
            err.println("The 'proclet' invoker should give better results.");
            err.println("To use it, type 'exit', run 'set jnode.invoker proclet' " +
View Full Code Here


        public static void main(String[] args) {
            try {
                final ShellManager sm = InitialNaming.lookup(ShellManager.NAME);
                final ConsoleManager conMgr = sm.getCurrentShell().getConsole().getManager();
                final PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
                TextConsole console = createConsoleWithShell(conMgr, out);
                System.setIn(new ReaderInputStream(console.getIn()));
                System.setOut(new PrintStream(new WriterOutputStream(console.getOut(), false), true));
                System.setErr(new PrintStream(new WriterOutputStream(console.getErr(), false), true));
            } catch (Exception ex) {
                // FIXME
                System.out.println("Problem creating the isolated console");
                ex.printStackTrace(System.err);
            }
View Full Code Here

    }
   
    @Override
    public void execute() throws Exception {
        final Shell shell = ShellUtils.getCurrentShell();
        TextConsole tc = (TextConsole) shell.getConsole();
        tc.clear();
        tc.setCursor(0, 0);
    }
View Full Code Here

            } 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();
        }
    }
View Full Code Here

    private static Toolkit createInstance() {
        try {
            final ShellManager sm = InitialNaming.lookup(ShellManager.NAME);
            final ConsoleManager conMgr = sm.getCurrentShell().getConsole().getManager();
            final TextConsole console = (TextConsole) conMgr.createConsole(
                "charva",
                ConsoleManager.CreateOptions.TEXT |
                            ConsoleManager.CreateOptions.STACKED |
                            ConsoleManager.CreateOptions.NO_LINE_EDITTING);
            console.addKeyboardListener(new KeyboardAdapter() {
                public void keyPressed(KeyboardEvent event) {
                    if (event.isControlDown() && event.getKeyChar() == 'z') {
                        System.err.println("got ctrl-z, unregistering Toolkit.");
                        //maybe this will help to debug the finite-sized text
                        // area bug.
View Full Code Here

    protected void startPlugin() throws PluginException {
        final Logger root = Logger.getRootLogger();
        try {
            // Create the appenders
            final ConsoleManager conMgr = InitialNaming.lookup(ConsoleManager.NAME);
            final TextConsole console =
                (TextConsole) conMgr.createConsole(
                    "Log4j",
                    (ConsoleManager.CreateOptions.TEXT |
                        ConsoleManager.CreateOptions.SCROLLABLE |
                        ConsoleManager.CreateOptions.NO_SYSTEM_OUT_ERR |
                        ConsoleManager.CreateOptions.NO_LINE_EDITTING));
            conMgr.registerConsole(console);

            console.setAcceleratorKeyCode(KeyEvent.VK_F7);
            final VirtualConsoleAppender debugApp =
                new VirtualConsoleAppender(new PatternLayout(LAYOUT), console, false);
            debugApp.setThreshold(Level.DEBUG);
            BootLogInstance.get().setDebugOut(new PrintStream(new WriterOutputStream(console.getOut(), false), true));

            TextConsole atc = new ActiveTextConsole(conMgr);
            final VirtualConsoleAppender infoApp = new VirtualConsoleAppender(
                    new PatternLayout(LAYOUT), atc, false);
            infoApp.setThreshold(Level.INFO);

            // Add the new appenders
View Full Code Here

     *       otherwise to it's 'out' stream.
     */
    public VirtualConsoleAppender(Layout layout, String name, boolean toErr) {
        super();
        this.layout = layout;
        TextConsole console = getNamedConsole(name);
        this.writer = toErr ? console.getErr() : console.getOut();
        super.setWriter(this.writer);
    }
View Full Code Here

            } catch (NameNotFoundException ex) {
                return null;
            }
        }
        try {
            TextConsole res = (TextConsole) mgr.getConsole(name);
            if (res == null) {
                throw new IllegalArgumentException("Unknown console: '" + name + '\'');
            }
            return res;
        } catch (ClassCastException ex) {
View Full Code Here

        err = getError().getPrintWriter();
        Console console = ShellUtils.getCurrentShell().getConsole();
        if (!(console instanceof TextConsole)) {
            err.println(err_not_text);
        }
        TextConsole textConsole = (TextConsole) console;
        if (argReset.isSet()) {
            resetBindings(textConsole);
        } else if (argAdd.isSet()) {
            addBindings(textConsole);
        } else if (argRemove.isSet()) {
View Full Code Here

        try {
            mgr = new TextScreenConsoleManager();
            InitialNaming.bind(ConsoleManager.NAME, mgr);

            // Create the first console
            final TextConsole first = (TextConsole) mgr.createConsole(
                null,
                (ConsoleManager.CreateOptions.TEXT |
                    ConsoleManager.CreateOptions.SCROLLABLE));
            first.setAcceleratorKeyCode(KeyEvent.VK_F1);
            mgr.focus(first);
            System.setOut(new PrintStream(new WriterOutputStream(first.getOut(), false), true));
            System.setErr(new PrintStream(new WriterOutputStream(first.getErr(), false), true));
            System.out.println(VmSystem.getBootLog());
        } catch (ConsoleException ex) {
            throw new PluginException(ex);
        } catch (NamingException ex) {
            throw new PluginException(ex);
View Full Code Here

TOP

Related Classes of org.jnode.driver.console.TextConsole

Copyright © 2018 www.massapicom. 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.