47
47
48
48
public class EspExceptionDecoder implements Tool , DocumentListener {
49
49
Editor editor ;
50
- JTextArea outputArea ;
50
+ JLabel outputArea ;
51
51
JTextArea inputArea ;
52
52
JFrame frame ;
53
53
File tool ;
@@ -70,8 +70,18 @@ public void run() {
70
70
try {
71
71
InputStreamReader reader = new InputStreamReader (p .getInputStream ());
72
72
int c ;
73
- while ((c = reader .read ()) != -1 )
74
- outputArea .append ("" +((char ) c ));
73
+ String line = "" ;
74
+ while ((c = reader .read ()) != -1 ){
75
+ if ((char )c == '\r' )
76
+ continue ;
77
+ if ((char )c == '\n' ){
78
+ printLine (line );
79
+ line = "" ;
80
+ } else {
81
+ line += (char )c ;
82
+ }
83
+ }
84
+ printLine (line );
75
85
reader .close ();
76
86
77
87
reader = new InputStreamReader (p .getErrorStream ());
@@ -198,16 +208,48 @@ private void createAndUpload(){
198
208
inputArea .getDocument ().addDocumentListener (this );
199
209
frame .getContentPane ().add (new JScrollPane (inputArea ), BorderLayout .PAGE_START );
200
210
201
- outputArea = new JTextArea (16 , 60 );
202
- outputArea .setLineWrap (true );
203
- outputArea .setWrapStyleWord (true );
204
- outputArea .setEditable (false );
205
- frame .getContentPane ().add (new JScrollPane (outputArea ), BorderLayout .CENTER );
206
-
211
+ outputArea = new JLabel ();
212
+ JScrollPane outputScrollPane = new JScrollPane (outputArea );
213
+ outputScrollPane .setVerticalScrollBarPolicy (JScrollPane .VERTICAL_SCROLLBAR_ALWAYS );
214
+ outputScrollPane .setPreferredSize (new Dimension (640 , 200 ));
215
+ outputScrollPane .setMinimumSize (new Dimension (10 , 10 ));
216
+ frame .getContentPane ().add (outputScrollPane , BorderLayout .CENTER );
217
+
207
218
frame .pack ();
208
219
frame .setVisible (true );
209
220
}
210
221
222
+ private void printLine (String line ){
223
+ String address = "" , method = "" , file = "" ;
224
+ if (line .startsWith ("0x" )){
225
+ address = line .substring (0 , line .indexOf (':' ));
226
+ line = line .substring (line .indexOf (':' ) + 2 );
227
+ } else if (line .startsWith ("(inlined by)" )){
228
+ line = line .substring (13 );
229
+ address = "inlined by" ;
230
+ }
231
+ int atIndex = line .indexOf (" at " );
232
+ if (atIndex == -1 )
233
+ return ;
234
+ method = line .substring (0 , atIndex );
235
+ line = line .substring (atIndex + 4 );
236
+ file = line .substring (0 , line .lastIndexOf (':' ));
237
+ if (file .length () > 0 ){
238
+ int lastfs = file .lastIndexOf ('/' );
239
+ int lastbs = file .lastIndexOf ('\\' );
240
+ int slash = (lastfs > lastbs )?lastfs :lastbs ;
241
+ if (slash != -1 ){
242
+ String filename = file .substring (slash +1 );
243
+ file = file .substring (0 ,slash +1 ) + "<b>" + filename + "</b>" ;
244
+ }
245
+ }
246
+ line = line .substring (line .lastIndexOf (':' ) + 1 );
247
+ String html = "" +
248
+ "<font color=green>" + address + ": </font>" +
249
+ "<b><font color=blue>" + method + "</font></b> at " + file + " line <b>" + line + "</b>" ;
250
+ outputArea .setText (outputArea .getText () + html +"<br>" );
251
+ }
252
+
211
253
public void run () {
212
254
createAndUpload ();
213
255
}
@@ -233,7 +275,7 @@ private void parseText(){
233
275
while (m .find ()) {
234
276
command [i ++] = content .substring (m .start (), m .end ());
235
277
}
236
- outputArea .setText ("Decoding " +count +" results\n " );
278
+ outputArea .setText ("<html><i> Decoding " +count +" results</i><br> " );
237
279
sysExec (command );
238
280
}
239
281
0 commit comments