public void onConnected(boolean doPostLogin) { disconnected = false; ((vt320) buffer).reset(); // We no longer need our local output. localOutput.clear(); // previously tried vt100 and xterm for emulation modes // "screen" works the best for color and escape codes ((vt320) buffer).setAnswerBack(emulation); if (HostDatabase.DELKEY_BACKSPACE.equals(host.getDelKey())) ((vt320) buffer).setBackspace(vt320.DELETE_IS_BACKSPACE); else ((vt320) buffer).setBackspace(vt320.DELETE_IS_DEL); // create thread to relay incoming connection data to buffer relay = new Relay(this, transport, (vt320) buffer, host.getEncoding()); Thread relayThread = new Thread(relay); relayThread.setDaemon(true); relayThread.setName("Relay"); relayThread.start(); // force font-size to make sure we resizePTY as needed setFontSize(fontSize); if (doPostLogin) { postLogin(); } }
/** * Resize terminal to fit [rows]x[cols] in screen of size [width]x[height] * * @param rows * @param cols * @param width * @param height */ public synchronized void resizeComputed(int cols, int rows, int width, int height) { float size = 8.0f; float step = 8.0f; float limit = 0.125f; int direction; while ((direction = fontSizeCompare(size, cols, rows, width, height)) < 0) size += step; if (direction == 0) { Log.d("fontsize", String.format("Found match at %f", size)); return; } step /= 2.0f; size -= step; while ((direction = fontSizeCompare(size, cols, rows, width, height)) != 0 && step >= limit) { step /= 2.0f; if (direction > 0) { size -= step; } else { size += step; } } if (direction > 0) size -= step; this.columns = cols; this.rows = rows; setFontSize(size); forcedSize = true; }
public void decreaseFontSize() { setFontSize(fontSize - FONT_SIZE_STEP); }
public void increaseFontSize() { setFontSize(fontSize + FONT_SIZE_STEP); }
/** * Create new terminal bridge with following parameters. We will immediately launch thread to * start SSH connection and handle any hostkey verification and password authentication. */ public TerminalBridge(final TerminalManager manager, final HostBean host) throws IOException { Typeface type; this.manager = manager; this.host = host; emulation = manager.getEmulation(); scrollback = manager.getScrollback(); // create prompt helper to relay password and hostkey requests up to gui promptHelper = new PromptHelper(this); // create our default paint defaultPaint = new Paint(); defaultPaint.setAntiAlias(true); type = Typeface.createFromAsset(this.manager.res.getAssets(), "UbuntuMono-R.ttf"); defaultPaint.setTypeface(type); defaultPaint.setFakeBoldText(true); // more readable? localOutput = new LinkedList<String>(); fontSizeChangedListeners = new LinkedList<FontSizeChangedListener>(); int hostFontSize = host.getFontSize(); if (hostFontSize <= 0) hostFontSize = DEFAULT_FONT_SIZE; setFontSize(hostFontSize); // create terminal buffer and handle outgoing data // this is probably status reply information buffer = new vt320() { @Override public void debug(String s) { Log.d(TAG, s); } @Override public void write(byte[] b) { try { if (b != null && transport != null) transport.write(b); } catch (IOException e) { Log.e(TAG, "Problem writing outgoing data in vt320() thread", e); } } @Override public void write(int b) { try { if (transport != null) transport.write(b); } catch (IOException e) { Log.e(TAG, "Problem writing outgoing data in vt320() thread", e); } } // We don't use telnet sequences. @Override public void sendTelnetCommand(byte cmd) {} // We don't want remote to resize our window. @Override public void setWindowSize(int c, int r) {} @Override public void beep() { if (parent.isShown()) manager.playBeep(); else manager.sendActivityNotification(host); } }; // Don't keep any scrollback if a session is not being opened. if (host.getWantSession()) buffer.setBufferSize(scrollback); else buffer.setBufferSize(0); resetColors(); buffer.setDisplay(this); selectionArea = new SelectionArea(); keyListener = new TerminalKeyListener(manager, this, buffer, host.getEncoding()); }