comparison src/com/five_ten_sg/connectbot/service/TerminalBridge.java @ 244:32737a428805

add host preference for fixed screen size
author Carl Byington <carl@five-ten-sg.com>
date Mon, 14 Jul 2014 11:07:11 -0700
parents 502ba7668993
children 23119f3c0d28
comparison
equal deleted inserted replaced
243:918dfcb862ed 244:32737a428805
187 defaultPaint.setAntiAlias(true); 187 defaultPaint.setAntiAlias(true);
188 defaultPaint.setTypeface(Typeface.MONOSPACE); 188 defaultPaint.setTypeface(Typeface.MONOSPACE);
189 defaultPaint.setFakeBoldText(true); // more readable? 189 defaultPaint.setFakeBoldText(true); // more readable?
190 localOutput = new LinkedList<String>(); 190 localOutput = new LinkedList<String>();
191 fontSizeChangedListeners = new LinkedList<FontSizeChangedListener>(); 191 fontSizeChangedListeners = new LinkedList<FontSizeChangedListener>();
192 float defaultFontSize = Float.parseFloat(manager.prefs.getString(PreferenceConstants.DEFAULT_FONT_SIZE, "-1")); 192 setFontSize(host.getFontSize()); // not correct for fixed size screen
193 Log.i(TAG, "fontSize: " + this.fontSize + ", defaultFontSize: " + defaultFontSize);
194
195 float hostFontSize;
196 if (fontSize <= 0) {
197 if ((defaultFontSize > 0) && (host.getFontSize() <= 0))
198 hostFontSize = defaultFontSize;
199 else
200 hostFontSize = host.getFontSize();
201 }
202 else
203 hostFontSize = fontSize;
204
205 if (hostFontSize <= 0) hostFontSize = DEFAULT_FONT_SIZE;
206
207 setFontSize(hostFontSize);
208 resetColors(); 193 resetColors();
209 selectionArea = new SelectionArea(); 194 selectionArea = new SelectionArea();
210 } 195 }
211 196
212 public PromptHelper getPromptHelper() { 197 public PromptHelper getPromptHelper() {
344 relayThread.setDaemon(true); 329 relayThread.setDaemon(true);
345 relayThread.setName("Relay"); 330 relayThread.setName("Relay");
346 relayThread.start(); 331 relayThread.start();
347 } 332 }
348 333
349 // force font-size to make sure we resizePTY as needed 334 // get proper font size
350 setFontSize(fontSize); 335 if (host.getFixedSize()) {
336 resizeComputed(host.getFixedWidth(), host.getFixedHeight(), w, h);
337 }
338 else {
339 setFontSize(host.getFontSize());
340 }
341
351 // finally send any post-login string, if requested 342 // finally send any post-login string, if requested
352 injectString(host.getPostLogin()); 343 injectString(host.getPostLogin());
353 } 344 }
354 345
355 /** 346 /**
448 /** 439 /**
449 * Request a different font size. Will make call to parentChanged() to make 440 * Request a different font size. Will make call to parentChanged() to make
450 * sure we resize PTY if needed. 441 * sure we resize PTY if needed.
451 */ 442 */
452 final void setFontSize(float size) { 443 final void setFontSize(float size) {
453 if (size <= 0.0) return; 444 if (size <= 0.0) size = 12.0;
454 size = (float)(int)((size * 10.0f) + 0.5f) / 10.0f; 445 size = (float)(int)((size * 10.0f) + 0.5f) / 10.0f;
455 defaultPaint.setTextSize(size); 446 defaultPaint.setTextSize(size);
456 fontSize = size; 447 fontSize = size;
457 // read new metrics to get exact pixel dimensions 448 // read new metrics to get exact pixel dimensions
458 FontMetrics fm = defaultPaint.getFontMetrics(); 449 FontMetrics fm = defaultPaint.getFontMetrics();