Mercurial > 510Connectbot
comparison src/com/five_ten_sg/connectbot/service/TerminalBridge.java @ 307:071eccdff8ea ganymed
fix java formatting
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Wed, 30 Jul 2014 14:16:58 -0700 |
parents | db26984b69f5 |
children | 651aff5a46c7 |
comparison
equal
deleted
inserted
replaced
305:d2b303406d63 | 307:071eccdff8ea |
---|---|
330 relayThread.start(); | 330 relayThread.start(); |
331 } | 331 } |
332 | 332 |
333 // get proper font size | 333 // get proper font size |
334 setMyFontSize(); | 334 setMyFontSize(); |
335 | |
336 // finally send any post-login string, if requested | 335 // finally send any post-login string, if requested |
337 injectString(host.getPostLogin()); | 336 injectString(host.getPostLogin()); |
338 } | 337 } |
339 | 338 |
340 private void setMyFontSize() { | 339 private void setMyFontSize() { |
443 * Request a different font size. Will make call to parentChanged() to make | 442 * Request a different font size. Will make call to parentChanged() to make |
444 * sure we resize PTY if needed. | 443 * sure we resize PTY if needed. |
445 */ | 444 */ |
446 final void setFontSize(float size) { | 445 final void setFontSize(float size) { |
447 if (size <= 0.0) size = 12.0f; | 446 if (size <= 0.0) size = 12.0f; |
447 | |
448 size = (float)(int)((size * 10.0f) + 0.5f) / 10.0f; | 448 size = (float)(int)((size * 10.0f) + 0.5f) / 10.0f; |
449 defaultPaint.setTextSize(size); | 449 defaultPaint.setTextSize(size); |
450 fontSize = size; | 450 fontSize = size; |
451 // read new metrics to get exact pixel dimensions | 451 // read new metrics to get exact pixel dimensions |
452 FontMetrics fm = defaultPaint.getFontMetrics(); | 452 FontMetrics fm = defaultPaint.getFontMetrics(); |
780 } | 780 } |
781 | 781 |
782 this.columns = cols; | 782 this.columns = cols; |
783 this.rows = rows; | 783 this.rows = rows; |
784 forcedSize = true; | 784 forcedSize = true; |
785 | |
785 if (fixed) setFontSize(host.getFontSize()); | 786 if (fixed) setFontSize(host.getFontSize()); |
786 else setFontSize(size); | 787 else setFontSize(size); |
787 } | 788 } |
788 | 789 |
789 private int fontSizeCompare(float size, int cols, int rows, int width, int height) { | 790 private int fontSizeCompare(float size, int cols, int rows, int width, int height) { |
1134 /** | 1135 /** |
1135 * Show arrows dialog | 1136 * Show arrows dialog |
1136 */ | 1137 */ |
1137 public boolean showArrowsDialog() { | 1138 public boolean showArrowsDialog() { |
1138 final String []pickerStrings = {"←", "→", "↑", "↓", "tab", "ins", "del", "ret"}; | 1139 final String []pickerStrings = {"←", "→", "↑", "↓", "tab", "ins", "del", "ret"}; |
1139 final HashMap<String,Integer> keymap = new HashMap<String,Integer>(); | 1140 final HashMap<String, Integer> keymap = new HashMap<String, Integer>(); |
1140 keymap.put("←", vt320.KEY_LEFT); | 1141 keymap.put("←", vt320.KEY_LEFT); |
1141 keymap.put("→", vt320.KEY_RIGHT); | 1142 keymap.put("→", vt320.KEY_RIGHT); |
1142 keymap.put("↑", vt320.KEY_UP); | 1143 keymap.put("↑", vt320.KEY_UP); |
1143 keymap.put("↓", vt320.KEY_DOWN); | 1144 keymap.put("↓", vt320.KEY_DOWN); |
1144 keymap.put("tab", vt320.KEY_TAB); | 1145 keymap.put("tab", vt320.KEY_TAB); |
1145 keymap.put("ins", vt320.KEY_INSERT); | 1146 keymap.put("ins", vt320.KEY_INSERT); |
1146 keymap.put("del", vt320.KEY_DELETE); | 1147 keymap.put("del", vt320.KEY_DELETE); |
1147 keymap.put("ret", vt320.KEY_ENTER); | 1148 keymap.put("ret", vt320.KEY_ENTER); |
1148 | |
1149 CharSequence str = ""; | 1149 CharSequence str = ""; |
1150 Editable content = Editable.Factory.getInstance().newEditable(str); | 1150 Editable content = Editable.Factory.getInstance().newEditable(str); |
1151 | 1151 |
1152 if (parent == null) return false; | 1152 if (parent == null) return false; |
1153 | 1153 |
1154 StringPickerDialog cpd = new StringPickerDialog(parent.getContext(), | 1154 StringPickerDialog cpd = new StringPickerDialog(parent.getContext(), |
1155 parent, content, | 1155 parent, content, |
1156 pickerStrings, true) { | 1156 pickerStrings, true) { |
1157 private void buttonPressed(String s) { | 1157 private void buttonPressed(String s) { |
1158 if (keymap.containsKey(s)) buffer.keyPressed(keymap.get(s), ' ', 0); | 1158 if (keymap.containsKey(s)) buffer.keyPressed(keymap.get(s), ' ', 0); |
1159 } | 1159 } |
1160 @Override | 1160 @Override |
1161 public void onItemClick(AdapterView p, View v, int pos, long id) { | 1161 public void onItemClick(AdapterView p, View v, int pos, long id) { |
1163 } | 1163 } |
1164 @Override | 1164 @Override |
1165 public void onClick(View v) { | 1165 public void onClick(View v) { |
1166 if (v instanceof Button) { | 1166 if (v instanceof Button) { |
1167 final String s = ((Button) v).getText().toString(); | 1167 final String s = ((Button) v).getText().toString(); |
1168 | |
1168 if (s.equals("")) dismiss(); | 1169 if (s.equals("")) dismiss(); |
1169 else buttonPressed(s); | 1170 else buttonPressed(s); |
1170 } | 1171 } |
1171 } | 1172 } |
1172 @Override | 1173 @Override |
1258 /** | 1259 /** |
1259 * Function keys dialog | 1260 * Function keys dialog |
1260 */ | 1261 */ |
1261 public boolean showFKeysDialog() { | 1262 public boolean showFKeysDialog() { |
1262 final String []pickerStrings = {"F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "F13", "F14", "F15", "F16", "F17", "F18", "F19", "F20", "F21", "F22", "F23", "F24", "←", "→", "↑", "↓", "tab", "ins", "del", "ret"}; | 1263 final String []pickerStrings = {"F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "F13", "F14", "F15", "F16", "F17", "F18", "F19", "F20", "F21", "F22", "F23", "F24", "←", "→", "↑", "↓", "tab", "ins", "del", "ret"}; |
1263 final HashMap<String,Integer> keymap = new HashMap<String,Integer>(); | 1264 final HashMap<String, Integer> keymap = new HashMap<String, Integer>(); |
1264 keymap.put("F1", vt320.KEY_F1); | 1265 keymap.put("F1", vt320.KEY_F1); |
1265 keymap.put("F2", vt320.KEY_F2); | 1266 keymap.put("F2", vt320.KEY_F2); |
1266 keymap.put("F3", vt320.KEY_F3); | 1267 keymap.put("F3", vt320.KEY_F3); |
1267 keymap.put("F4", vt320.KEY_F4); | 1268 keymap.put("F4", vt320.KEY_F4); |
1268 keymap.put("F5", vt320.KEY_F5); | 1269 keymap.put("F5", vt320.KEY_F5); |
1291 keymap.put("↓", vt320.KEY_DOWN); | 1292 keymap.put("↓", vt320.KEY_DOWN); |
1292 keymap.put("tab", vt320.KEY_TAB); | 1293 keymap.put("tab", vt320.KEY_TAB); |
1293 keymap.put("ins", vt320.KEY_INSERT); | 1294 keymap.put("ins", vt320.KEY_INSERT); |
1294 keymap.put("del", vt320.KEY_DELETE); | 1295 keymap.put("del", vt320.KEY_DELETE); |
1295 keymap.put("ret", vt320.KEY_ENTER); | 1296 keymap.put("ret", vt320.KEY_ENTER); |
1296 | |
1297 CharSequence str = ""; | 1297 CharSequence str = ""; |
1298 Editable content = Editable.Factory.getInstance().newEditable(str); | 1298 Editable content = Editable.Factory.getInstance().newEditable(str); |
1299 | 1299 |
1300 if (parent == null) return false; | 1300 if (parent == null) return false; |
1301 | 1301 |
1302 StringPickerDialog cpd = new StringPickerDialog(parent.getContext(), | 1302 StringPickerDialog cpd = new StringPickerDialog(parent.getContext(), |
1303 parent, content, | 1303 parent, content, |
1304 pickerStrings, true) { | 1304 pickerStrings, true) { |
1305 private void buttonPressed(String s) { | 1305 private void buttonPressed(String s) { |
1306 if (keymap.containsKey(s)) buffer.keyPressed(keymap.get(s), ' ', 0); | 1306 if (keymap.containsKey(s)) buffer.keyPressed(keymap.get(s), ' ', 0); |
1307 | |
1307 dismiss(); | 1308 dismiss(); |
1308 } | 1309 } |
1309 @Override | 1310 @Override |
1310 public void onItemClick(AdapterView p, View v, int pos, long id) { | 1311 public void onItemClick(AdapterView p, View v, int pos, long id) { |
1311 buttonPressed(pickerStrings[pos]); | 1312 buttonPressed(pickerStrings[pos]); |
1312 } | 1313 } |
1313 @Override | 1314 @Override |
1314 public void onClick(View v) { | 1315 public void onClick(View v) { |
1315 if (v instanceof Button) { | 1316 if (v instanceof Button) { |
1316 final String s = ((Button) v).getText().toString(); | 1317 final String s = ((Button) v).getText().toString(); |
1318 | |
1317 if (s.equals("")) dismiss(); | 1319 if (s.equals("")) dismiss(); |
1318 else buttonPressed(s); | 1320 else buttonPressed(s); |
1319 } | 1321 } |
1320 } | 1322 } |
1321 @Override | 1323 @Override |