Skip to content

Commit

Permalink
Set a beautiful command prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
paradoxxxzero committed Mar 18, 2016
1 parent 0be8d94 commit 3c08597
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 32 deletions.
4 changes: 0 additions & 4 deletions server/coffees/_console.coffee

This file was deleted.

4 changes: 2 additions & 2 deletions server/coffees/_history.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class History extends Log
super
@index = -1
@current = ''
@currentPos = null
@currentPos = CodeMirror.Pos(0, 0)

try
@history = JSON.parse(localStorage['history'] or '[]')
Expand Down Expand Up @@ -40,4 +40,4 @@ class History extends Log
reset: ->
@index = -1
@current = ''
@currentPos = null
@currentPos = CodeMirror.Pos(0, 0)
4 changes: 3 additions & 1 deletion server/coffees/wdb.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,9 @@ specify a module like `logging.config`.
$group = $('<div>', class: 'echoed scroll-line')
@$scrollback.append($group)
@code($group, data.for, ['for prompted'])
@code($group, data.val or '', ['val'], true, null, data.mode)
$result = $('<div>', class: 'result')
$group.append($result)
@code($result, data.val or '', ['val'], true, null, data.mode)
@done()

rawhtml: (data) ->
Expand Down
31 changes: 21 additions & 10 deletions server/sass/material.sass
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@
.source-editor .CodeMirror
height: calc(50vh - 64px)

.prompt .CodeMirror
height: auto
border-bottom: 1px solid rgba(0, 0, 0, .1)
&.CodeMirror-focused
border-bottom: 1px solid rgba(0, 0, 0, .2)

.interpreter
position: relative
height: calc(50vh - 40px)
overflow: auto
outline: 0
Expand All @@ -31,6 +26,26 @@
text-decoration: none
border-bottom: 1px solid rgba(0, 0, 0, .05)

.prompt, .for
margin-left: 26px

&::before
content: '>>>'
position: absolute
left: 0

.prompt
&:before
margin-top: 4px
font-family: "Roboto Mono"

.CodeMirror
height: auto
border-bottom: 1px solid rgba(0, 0, 0, .1)

&.CodeMirror-focused
border-bottom: 1px solid rgba(0, 0, 0, .2)

.title
white-space: pre

Expand All @@ -53,10 +68,6 @@ table
tbody.closed
display: none

.prompt
width: 100%
padding: 0

.duration
float: right

Expand Down
12 changes: 8 additions & 4 deletions server/wdb_server/static/javascripts/wdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ History = (function(superClass) {
History.__super__.constructor.apply(this, arguments);
this.index = -1;
this.current = '';
this.currentPos = null;
this.currentPos = CodeMirror.Pos(0, 0);
try {
this.history = JSON.parse(localStorage['history'] || '[]');
} catch (error) {
Expand Down Expand Up @@ -402,7 +402,7 @@ History = (function(superClass) {
History.prototype.reset = function() {
this.index = -1;
this.current = '';
return this.currentPos = null;
return this.currentPos = CodeMirror.Pos(0, 0);
};

return History;
Expand Down Expand Up @@ -1045,13 +1045,17 @@ Wdb = (function(superClass) {
};

Wdb.prototype.echo = function(data) {
var $group;
var $group, $result;
$group = $('<div>', {
"class": 'echoed scroll-line'
});
this.$scrollback.append($group);
this.code($group, data["for"], ['for prompted']);
this.code($group, data.val || '', ['val'], true, null, data.mode);
$result = $('<div>', {
"class": 'result'
});
$group.append($result);
this.code($result, data.val || '', ['val'], true, null, data.mode);
return this.done();
};

Expand Down
2 changes: 1 addition & 1 deletion server/wdb_server/static/javascripts/wdb/wdb.min.js

Large diffs are not rendered by default.

25 changes: 15 additions & 10 deletions server/wdb_server/static/stylesheets/material.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@
.source-editor .CodeMirror {
height: calc(50vh - 64px); }

.prompt .CodeMirror {
height: auto;
border-bottom: 1px solid rgba(0, 0, 0, 0.1); }
.prompt .CodeMirror.CodeMirror-focused {
border-bottom: 1px solid rgba(0, 0, 0, 0.2); }

.interpreter {
position: relative;
height: calc(50vh - 40px);
overflow: auto;
outline: 0; }
Expand All @@ -24,6 +19,20 @@
display: inline-block;
text-decoration: none;
border-bottom: 1px solid rgba(0, 0, 0, 0.05); }
.interpreter .prompt, .interpreter .for {
margin-left: 26px; }
.interpreter .prompt::before, .interpreter .for::before {
content: '>>>';
position: absolute;
left: 0; }
.interpreter .prompt:before {
margin-top: 4px;
font-family: "Roboto Mono"; }
.interpreter .prompt .CodeMirror {
height: auto;
border-bottom: 1px solid rgba(0, 0, 0, 0.1); }
.interpreter .prompt .CodeMirror.CodeMirror-focused {
border-bottom: 1px solid rgba(0, 0, 0, 0.2); }

.title {
white-space: pre; }
Expand All @@ -44,10 +53,6 @@ table {
table tbody.closed {
display: none; }

.prompt {
width: 100%;
padding: 0; }

.duration {
float: right; }

Expand Down

0 comments on commit 3c08597

Please sign in to comment.