Mercurial > 510Connectbot
comparison src/com/five_ten_sg/connectbot/transport/TN5250.java @ 112:77ac18bc1b2f
cleanup java formatting
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Wed, 18 Jun 2014 13:03:01 -0700 |
parents | 171e0a977544 |
children | 477cca1e0c15 |
comparison
equal
deleted
inserted
replaced
111:6a0ad4d384ea | 112:77ac18bc1b2f |
---|---|
72 class vt320x5250 extends vt320 { | 72 class vt320x5250 extends vt320 { |
73 private HashMap<Integer, Integer> controls; | 73 private HashMap<Integer, Integer> controls; |
74 private HashMap<Integer, String> mnemonics; | 74 private HashMap<Integer, String> mnemonics; |
75 | 75 |
76 public vt320x5250() { | 76 public vt320x5250() { |
77 this(80,24); | 77 this(80, 24); |
78 } | 78 } |
79 | 79 |
80 public vt320x5250(int width, int height) { | 80 public vt320x5250(int width, int height) { |
81 super(width, height); | 81 super(width, height); |
82 controls = new HashMap<Integer, Integer>(); | 82 controls = new HashMap<Integer, Integer>(); |
83 controls.put(0x08, KEY_BACK_SPACE); | 83 controls.put(0x08, KEY_BACK_SPACE); |
84 controls.put(0x09, KEY_TAB); | 84 controls.put(0x09, KEY_TAB); |
85 controls.put(0x0d, KEY_ENTER); | 85 controls.put(0x0d, KEY_ENTER); |
86 controls.put(0x1b, KEY_ESCAPE); | 86 controls.put(0x1b, KEY_ESCAPE); |
87 | |
88 mnemonics = new HashMap<Integer, String>(); | 87 mnemonics = new HashMap<Integer, String>(); |
89 mnemonics.put(KEY_PAUSE , "[attn]"); | 88 mnemonics.put(KEY_PAUSE , "[attn]"); |
90 mnemonics.put(KEY_F1 , "[pf1]"); | 89 mnemonics.put(KEY_F1 , "[pf1]"); |
91 mnemonics.put(KEY_F2 , "[pf2]"); | 90 mnemonics.put(KEY_F2 , "[pf2]"); |
92 mnemonics.put(KEY_F3 , "[pf3]"); | 91 mnemonics.put(KEY_F3 , "[pf3]"); |
145 | 144 |
146 // terminal key listener sending to local screen | 145 // terminal key listener sending to local screen |
147 @Override | 146 @Override |
148 public void write(byte[] b) { | 147 public void write(byte[] b) { |
149 if (bridge.monitor != null) bridge.monitor.hostData(b); | 148 if (bridge.monitor != null) bridge.monitor.hostData(b); |
149 | |
150 screen52.sendKeys(new String(b)); | 150 screen52.sendKeys(new String(b)); |
151 } | 151 } |
152 @Override | 152 @Override |
153 public void write(int b) { | 153 public void write(int b) { |
154 if (controls.containsKey(b)) { | 154 if (controls.containsKey(b)) { |
155 keyPressed(controls.get(b), ' ', 0); | 155 keyPressed(controls.get(b), ' ', 0); |
156 } | 156 } |
157 else { | 157 else { |
158 if (bridge.monitor != null) bridge.monitor.hostData(b); | 158 if (bridge.monitor != null) bridge.monitor.hostData(b); |
159 | |
159 screen52.sendKeys(new String(new byte[] {(byte)b})); | 160 screen52.sendKeys(new String(new byte[] {(byte)b})); |
160 } | 161 } |
161 } | 162 } |
162 @Override | 163 @Override |
163 public void keyPressed(int keyCode, char keyChar, int modifiers) { | 164 public void keyPressed(int keyCode, char keyChar, int modifiers) { |
164 if (mnemonics.containsKey(keyCode)) { | 165 if (mnemonics.containsKey(keyCode)) { |
165 String s = mnemonics.get(keyCode); | 166 String s = mnemonics.get(keyCode); |
167 | |
166 if (s != "") { | 168 if (s != "") { |
167 if (bridge.monitor != null) bridge.monitor.hostData(s.getBytes()); | 169 if (bridge.monitor != null) bridge.monitor.hostData(s.getBytes()); |
170 | |
168 screen52.sendKeys(s); | 171 screen52.sendKeys(s); |
169 } | 172 } |
170 } | 173 } |
171 } | 174 } |
172 // 5250 writing to the screen | 175 // 5250 writing to the screen |
176 if (bridge.monitor != null) bridge.monitor.testChanged(); | 179 if (bridge.monitor != null) bridge.monitor.testChanged(); |
177 } | 180 } |
178 @Override | 181 @Override |
179 public void putChar(int c, int l, char ch, int attributes) { | 182 public void putChar(int c, int l, char ch, int attributes) { |
180 if (bridge.monitor != null) bridge.monitor.screenChanged(l, c); | 183 if (bridge.monitor != null) bridge.monitor.screenChanged(l, c); |
184 | |
181 super.putChar(c, l, ch, attributes); | 185 super.putChar(c, l, ch, attributes); |
182 } | 186 } |
183 @Override | 187 @Override |
184 public void setCursorPosition(int c, int l) { | 188 public void setCursorPosition(int c, int l) { |
185 if (bridge.monitor != null) bridge.monitor.cursorMove(l, c); | 189 if (bridge.monitor != null) bridge.monitor.cursorMove(l, c); |
190 | |
186 super.setCursorPosition(c, l); | 191 super.setCursorPosition(c, l); |
187 redraw(); | 192 redraw(); |
188 } | 193 } |
189 }; | 194 }; |
190 | 195 |
191 | 196 |
192 public TN5250() { | 197 public TN5250() { |
193 super(); | 198 super(); |
194 } | 199 } |
195 | 200 |
196 | 201 |
197 /** | 202 /** |
198 * @return protocol part of the URI | 203 * @return protocol part of the URI |
199 */ | 204 */ |
200 public static String getProtocolName() { | 205 public static String getProtocolName() { |
201 return PROTOCOL; | 206 return PROTOCOL; |
202 } | 207 } |
203 | 208 |
204 | 209 |
205 /** | 210 /** |
206 * Encode the current transport into a URI that can be passed via intent calls. | 211 * Encode the current transport into a URI that can be passed via intent calls. |
207 * @return URI to host | 212 * @return URI to host |
208 */ | 213 */ |
209 public Uri getUri(String input) { | 214 public Uri getUri(String input) { |
210 Matcher matcher = hostmask.matcher(input); | 215 Matcher matcher = hostmask.matcher(input); |
211 | 216 |
212 if (!matcher.matches()) | 217 if (!matcher.matches()) |
213 return null; | 218 return null; |
214 | 219 |
239 | 244 |
240 sb.append("/#") | 245 sb.append("/#") |
241 .append(Uri.encode(input)); | 246 .append(Uri.encode(input)); |
242 Uri uri = Uri.parse(sb.toString()); | 247 Uri uri = Uri.parse(sb.toString()); |
243 return uri; | 248 return uri; |
244 } | 249 } |
245 | 250 |
246 | 251 |
247 /** | 252 /** |
248 * Causes transport to connect to the target host. After connecting but before a | 253 * Causes transport to connect to the target host. After connecting but before a |
249 * session is started, must call back to {@link TerminalBridge#onConnected()}. | 254 * session is started, must call back to {@link TerminalBridge#onConnected()}. |
250 * After that call a session may be opened. | 255 * After that call a session may be opened. |
251 */ | 256 */ |
252 @Override | 257 @Override |
253 public void connect() { | 258 public void connect() { |
254 screen52 = new Screen5250(); | 259 screen52 = new Screen5250(); |
255 handler = new tnvt(screen52, true, false, bridge, manager); | 260 handler = new tnvt(screen52, true, false, bridge, manager); |
256 String encryption = host.getEncryption5250(); | 261 String encryption = host.getEncryption5250(); |
262 | |
257 if ((encryption == null) || (encryption.length() == 0)) encryption = "NONE"; | 263 if ((encryption == null) || (encryption.length() == 0)) encryption = "NONE"; |
264 | |
258 screen52.setVT(handler); | 265 screen52.setVT(handler); |
259 screen52.setBuffer(buffer); | 266 screen52.setBuffer(buffer); |
260 connected = handler.connect(host.getHostname(), host.getPort(), encryption, homeDirectory, buffer); | 267 connected = handler.connect(host.getHostname(), host.getPort(), encryption, homeDirectory, buffer); |
268 | |
261 if (connected) bridge.onConnected(); | 269 if (connected) bridge.onConnected(); |
262 } | 270 } |
263 | 271 |
264 | 272 |
265 /** | 273 /** |