Mercurial > 510Connectbot
comparison src/com/five_ten_sg/connectbot/service/TerminalBridge.java @ 245:23119f3c0d28
add host preference for fixed screen size
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Mon, 14 Jul 2014 11:15:42 -0700 |
parents | 32737a428805 |
children | dfe5f44bbea1 |
comparison
equal
deleted
inserted
replaced
244:32737a428805 | 245:23119f3c0d28 |
---|---|
77 */ | 77 */ |
78 @SuppressWarnings("deprecation") // for ClipboardManager | 78 @SuppressWarnings("deprecation") // for ClipboardManager |
79 public class TerminalBridge implements VDUDisplay { | 79 public class TerminalBridge implements VDUDisplay { |
80 public final static String TAG = "ConnectBot.TerminalBridge"; | 80 public final static String TAG = "ConnectBot.TerminalBridge"; |
81 | 81 |
82 public final static float DEFAULT_FONT_SIZE = 10.0f; | |
83 private final static float FONT_SIZE_FACTOR = 1.1f; | 82 private final static float FONT_SIZE_FACTOR = 1.1f; |
84 | 83 |
85 public Integer[] color; | 84 public Integer[] color; |
86 | 85 |
87 public int defaultFg = HostDatabase.DEFAULT_FG_COLOR; | 86 public int defaultFg = HostDatabase.DEFAULT_FG_COLOR; |
187 defaultPaint.setAntiAlias(true); | 186 defaultPaint.setAntiAlias(true); |
188 defaultPaint.setTypeface(Typeface.MONOSPACE); | 187 defaultPaint.setTypeface(Typeface.MONOSPACE); |
189 defaultPaint.setFakeBoldText(true); // more readable? | 188 defaultPaint.setFakeBoldText(true); // more readable? |
190 localOutput = new LinkedList<String>(); | 189 localOutput = new LinkedList<String>(); |
191 fontSizeChangedListeners = new LinkedList<FontSizeChangedListener>(); | 190 fontSizeChangedListeners = new LinkedList<FontSizeChangedListener>(); |
192 setFontSize(host.getFontSize()); // not correct for fixed size screen | 191 setMyFontSize(); |
193 resetColors(); | 192 resetColors(); |
194 selectionArea = new SelectionArea(); | 193 selectionArea = new SelectionArea(); |
195 } | 194 } |
196 | 195 |
197 public PromptHelper getPromptHelper() { | 196 public PromptHelper getPromptHelper() { |
330 relayThread.setName("Relay"); | 329 relayThread.setName("Relay"); |
331 relayThread.start(); | 330 relayThread.start(); |
332 } | 331 } |
333 | 332 |
334 // get proper font size | 333 // get proper font size |
335 if (host.getFixedSize()) { | 334 setMyFontSize(); |
336 resizeComputed(host.getFixedWidth(), host.getFixedHeight(), w, h); | 335 |
336 // finally send any post-login string, if requested | |
337 injectString(host.getPostLogin()); | |
338 } | |
339 | |
340 private setMyFontSize() { | |
341 if ((parent != null) && (host.getFixedSize())) { | |
342 resizeComputed(host.getFixedWidth(), host.getFixedHeight(), parent.getWidth(), parent.getHeight()); | |
337 } | 343 } |
338 else { | 344 else { |
339 setFontSize(host.getFontSize()); | 345 setFontSize(host.getFontSize()); |
340 } | 346 } |
341 | |
342 // finally send any post-login string, if requested | |
343 injectString(host.getPostLogin()); | |
344 } | 347 } |
345 | 348 |
346 /** | 349 /** |
347 * @return whether a session is open or not | 350 * @return whether a session is open or not |
348 */ | 351 */ |
439 /** | 442 /** |
440 * Request a different font size. Will make call to parentChanged() to make | 443 * Request a different font size. Will make call to parentChanged() to make |
441 * sure we resize PTY if needed. | 444 * sure we resize PTY if needed. |
442 */ | 445 */ |
443 final void setFontSize(float size) { | 446 final void setFontSize(float size) { |
444 if (size <= 0.0) size = 12.0; | 447 if (size <= 0.0) size = 12.0f; |
445 size = (float)(int)((size * 10.0f) + 0.5f) / 10.0f; | 448 size = (float)(int)((size * 10.0f) + 0.5f) / 10.0f; |
446 defaultPaint.setTextSize(size); | 449 defaultPaint.setTextSize(size); |
447 fontSize = size; | 450 fontSize = size; |
448 // read new metrics to get exact pixel dimensions | 451 // read new metrics to get exact pixel dimensions |
449 FontMetrics fm = defaultPaint.getFontMetrics(); | 452 FontMetrics fm = defaultPaint.getFontMetrics(); |
997 /** | 1000 /** |
998 * Auto-size window back to default | 1001 * Auto-size window back to default |
999 */ | 1002 */ |
1000 public void resetSize(TerminalView parent) { | 1003 public void resetSize(TerminalView parent) { |
1001 this.forcedSize = false; | 1004 this.forcedSize = false; |
1002 float defaultFontSize = Float.parseFloat(manager.prefs.getString(PreferenceConstants.DEFAULT_FONT_SIZE, "-1")); | 1005 setMyFontSize(); |
1003 | |
1004 if (defaultFontSize > 0) | |
1005 setFontSize(defaultFontSize); | |
1006 else | |
1007 setFontSize(DEFAULT_FONT_SIZE); | |
1008 } | 1006 } |
1009 | 1007 |
1010 /** | 1008 /** |
1011 * Create a screenshot of the current view | 1009 * Create a screenshot of the current view |
1012 */ | 1010 */ |