private void broadcast() { if (interrupted) { term.close(); return; int width = term.width(); int height = term.height(); Image temp = capture.getScaledInstance(width, height, Image.SCALE_SMOOTH); BufferedImage scaled = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); term.write(sb.toString()); vertx.setTimer(100, v -> broadcast());
public void handle() { if (term.width() > 0 && term.height() > 0) { broadcast(); } else { term.resizehandler(v -> { broadcast(); }); } }
public ScreenCaster(Vertx vertx, Robot robot, Term term) { this.vertx = vertx; this.robot = robot; this.term = term; term.stdinHandler(keys -> { // Ctrl-C or Ctrl-D if (keys.contains("\u0003") || keys.contains("\u0004")) { interrupted = true; } }); }
@Test public void testDifferentCharset(TestContext context) throws Exception { CompletableFuture<Void> closeLatch = new CompletableFuture<Void>(); startTelnet(context, new TelnetTermOptions().setCharset("ISO_8859_1"), term -> { term.write("\u20AC"); closeLatch.thenAccept(v -> { term.close(); }); }); client.connect("localhost", server.actualPort()); InputStream in = client.getInputStream(); int b = in.read(); context.assertEquals(63, b); closeLatch.complete(null); }
public ShellImpl init() { term.interruptHandler(key -> jobController().foregroundJob().interrupt()); term.suspendHandler(key -> { term.echo(Helper.fromCodePoints(new int[]{key, '\n'})); Job job = jobController.foregroundJob(); term.echo(statusLine(job, ExecStatus.STOPPED) + "\n"); job.suspend(); return true; }); term.closeHandler(v -> jobController.close(ar -> closedFuture.complete() ) ); if (welcome != null && welcome.length() > 0) { term.write(welcome); } return this; }
public io.vertx.rxjava.ext.shell.term.Term write(String data) { delegate.write(data); return this; }
term.readline(prompt, line -> { term.close(); return; case "exit": case "logout": term.close(); return; case "jobs": jobController.jobs().forEach(job -> { String statusLine = statusLine(job, job.status()) + "\n"; term.write(statusLine); }); readline(); Job job = findJob(); if (job == null) { term.write("no such job\n"); readline(); } else { Job job = findJob(); if (job == null) { term.write("no such job\n"); readline(); } else { if (job.status() == ExecStatus.STOPPED) { job.resume(false);
/** * Close the connection to terminal. */ public void close() { delegate.close(); }
/** * Set a handler that will be called when the terminal is closed. * @param handler the handler * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.shell.term.Term closeHandler(Handler<Void> handler) { delegate.closeHandler(handler); return this; }
public io.vertx.rxjava.ext.shell.term.Term resizehandler(Handler<Void> handler) { delegate.resizehandler(handler); return this; }
/** * Prompt the user a line of text. * @param prompt the displayed prompt * @param lineHandler the line handler called with the line */ public void readline(String prompt, Handler<String> lineHandler) { delegate.readline(prompt, lineHandler); }
private void testSize(TestContext context, String uri, int expectedCols, int expectedRows) { Async async = context.async(); server = createServer(context, new HttpTermOptions().setPort(8080));; server.termHandler(term -> { context.assertEquals(expectedCols, term.width()); context.assertEquals(expectedRows, term.height()); async.complete(); }); server.listen(context.asyncAssertSuccess(server -> { HttpClient client = vertx.createHttpClient(); client.websocket(8080, "localhost", uri, ws -> { }, context::fail); })); }
/** * @return the last time this term received input */ public long lastAccessedTime() { long ret = delegate.lastAccessedTime(); return ret; }
/** * Set an interrupt signal handler on the term. * @param handler the interrupt handler * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.shell.term.Term interruptHandler(io.vertx.rxjava.ext.shell.term.SignalHandler handler) { delegate.interruptHandler(handler.getDelegate()); return this; }
/** * Echo some text in the terminal, escaped if necessary.<p/> * @param text the text to echo * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.shell.term.Term echo(String text) { delegate.echo(text); return this; }
@Test public void testDifferentCharset(TestContext context) throws Exception { termHandler = term -> { term.write("\u20AC"); term.close(); }; startShell(new SSHTermOptions().setDefaultCharset("ISO_8859_1").setPort(5000).setHost("localhost").setKeyPairOptions( new JksOptions().setPath("src/test/resources/server-keystore.jks").setPassword("wibble")). setAuthOptions(new ShiroAuthOptions().setType(ShiroAuthRealmType.PROPERTIES).setConfig( new JsonObject().put("properties_path", "classpath:test-auth.properties")))); Session session = createSession("paulo", "secret", false); session.connect(); Channel channel = session.openChannel("shell"); channel.connect(); InputStream in = channel.getInputStream(); int b = in.read(); context.assertEquals(63, b); }
public io.vertx.rxjava.ext.shell.term.Term write(String data) { delegate.write(data); return this; }
/** * Close the connection to terminal. */ public void close() { delegate.close(); }
/** * Set a handler that will be called when the terminal is closed. * @param handler the handler * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.shell.term.Term closeHandler(Handler<Void> handler) { delegate.closeHandler(handler); return this; }
public io.vertx.rxjava.ext.shell.term.Term resizehandler(Handler<Void> handler) { delegate.resizehandler(handler); return this; }