public static void main(String[] args) throws Exception { final String devId = (args.length > 0) ? args[0] : "" /*"fb0"*/; Surface g = null; try { Device dev = null; if ("".equals(devId)) { final Collection<Device> devs = DeviceUtils.getDevicesByAPI(FrameBufferAPI.class); int dev_count = devs.size(); if (dev_count > 0) { Device[] dev_a = devs.toArray(new Device[dev_count]); dev = dev_a[0]; } } if (dev == null) { final DeviceManager dm = InitialNaming.lookup(DeviceManager.NAME); dev = dm.getDevice(devId); } final FrameBufferAPI api = dev.getAPI(FrameBufferAPI.class); final FrameBufferConfiguration conf = api.getConfigurations()[0]; g = api.open(conf); TextScreenConsoleManager mgr = new TextScreenConsoleManager(); ScrollableTextScreen ts = new FBConsole.FBPcTextScreen(g).createCompatibleScrollableBufferScreen(500); ScrollableTextScreenConsole first = new ScrollableTextScreenConsole( mgr, "console", ts, ConsoleManager.CreateOptions.TEXT | ConsoleManager.CreateOptions.SCROLLABLE); mgr.registerConsole(first); mgr.focus(first); new CommandShell(first).run(); Thread.sleep(60 * 1000); } catch (Throwable ex) { log.error("Error in FBConsole", ex); } finally { if (g != null) { log.info("Close graphics"); g.close(); } } }
/** Set up the pager's console and command pipe. */ private void setup() throws NameNotFoundException, IOException { ShellManager sm = InitialNaming.lookup(ShellManager.NAME); manager = (TextScreenConsoleManager) sm.getCurrentShell().getConsole().getManager(); console = manager.createConsole( "page", (ConsoleManager.CreateOptions.TEXT | ConsoleManager.CreateOptions.STACKED | ConsoleManager.CreateOptions.NO_LINE_EDITTING | ConsoleManager.CreateOptions.NO_SYSTEM_OUT_ERR)); manager.focus(console); pageHeight = console.getDeviceHeight() - 1; pageWidth = console.getDeviceWidth(); pageSize = pageHeight * pageWidth; tabSize = console.getTabSize(); pw = new PipedWriter(); pr = new PipedReader(); pr.connect(pw); console.addKeyboardListener(this); }