Skip to content

Commit 56245b0

Browse files
committed
Added clear_shell feature
1 parent d285ecf commit 56245b0

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

lib/better_errors/templates/main.erb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,16 @@
579579
margin: 0;
580580
}
581581

582+
.console .clear_output {
583+
text-align: right;
584+
margin-right: 1em;
585+
}
586+
587+
.console .clear_output a {
588+
color: red;
589+
}
590+
591+
582592
/* Hint text */
583593
.hint {
584594
margin: 15px 0 20px 0;
@@ -812,12 +822,18 @@
812822
this.promptElement = this.container.querySelector(".prompt span");
813823
this.inputElement = this.container.querySelector("input");
814824
this.outputElement = this.container.querySelector("pre");
825+
this.outputClearElement = this.container.querySelector(".clear_output");
815826

816827
var self = this;
817828
this.inputElement.onkeydown = function(ev) {
818829
self.onKeyDown(ev);
819830
};
820831

832+
this.outputClearElement.onclick = function(ev) {
833+
ev.preventDefault();
834+
self.clearOutput();
835+
};
836+
821837
this.setPrompt(">>");
822838

823839
REPL.all[this.index] = this;
@@ -854,6 +870,11 @@
854870
this.writeRawOutput(escapeHTML(output));
855871
};
856872

873+
REPL.prototype.clearOutput = function() {
874+
this.outputElement.innerHTML = '';
875+
this.outputElement.scrollTop = this.outputElement.scrollHeight;
876+
};
877+
857878
REPL.prototype.sendInput = function(line) {
858879
var self = this;
859880
apiCall("eval", { "index": this.index, source: line }, function(response) {

lib/better_errors/templates/variable_info.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<div class="console">
1313
<pre></pre>
1414
<div class="prompt"><span>&gt;&gt;</span> <input/></div>
15+
<div class="clear_output"><a href='#'>Clear Shell</a></div>
1516
</div>
1617
</div>
1718
<% end %>

0 commit comments

Comments
 (0)