Skip to content

Commit 87c3912

Browse files
committed
Merge remote-tracking branch 'staabm/control-chars'
2 parents 6818fed + 35e1d6c commit 87c3912

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

Diff for: php-console.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,28 @@
7272
if (window.localStorage) {
7373
localStorage.setItem('phpCode', editor.getSession().getValue());
7474
}
75+
76+
var controlChars = {
77+
'NUL' : /\x00/g,
78+
'SOH' : /\x01/g,
79+
'STX' : /\x02/g,
80+
'ETX' : /\x03/g,
81+
'EOT' : /\x04/g,
82+
'ENQ' : /\x05/g,
83+
'ACK' : /\x06/g,
84+
'BEL' : /\x07/g,
85+
'BS' : /\x08/g,
86+
'SUB' : /\x1A/g,
87+
};
7588

7689
// eval server-side
7790
$.post('?js=1', { code: editor.getSession().getValue() }, function (res) {
7891
if (res.match(/#end-php-console-output#$/)) {
79-
$('div.output').html(res.substring(0, res.length - 24));
92+
var result = res.substring(0, res.length - 24);
93+
for (var k in controlChars) {
94+
result = result.replace(controlChars[k], '<span class="control-char">'+ k +'</span>');
95+
}
96+
$('div.output').html(result);
8097
} else {
8198
$('div.output').html(res + "<br /><br /><em>Script ended unexpectedly.</em>");
8299
}

Diff for: styles.css

+9
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,13 @@ a {
9494
}
9595
.footer a {
9696
color: #aaa;
97+
}
98+
99+
.krumo-root .control-char {
100+
background: #000;
101+
color: #fff;
102+
margin-left: 2px;
103+
margin-right: 2px;
104+
-webkit-border-radius: 5px;
105+
border-radius: 5px;
97106
}

0 commit comments

Comments
 (0)