Skip to content

Commit

Permalink
In “Try CoffeeScript,” if you press the tab key it should type a tab …
Browse files Browse the repository at this point in the history
…character. Closes jashkenas#3342.
  • Loading branch information
GeoffreyBooth committed Nov 19, 2016
1 parent e3aa8e0 commit 34869df
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/v1/css/docs.css
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ div.code {
outline: none;
margin: 5px 0 20px;
color: #def;
-webkit-tab-size: 2;
-moz-tab-size: 2;
-o-tab-size: 2;
tab-size: 2;
}
#repl_results, #repl_source_wrap {
width: auto; height: auto;
Expand Down
10 changes: 10 additions & 0 deletions docs/v1/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3892,6 +3892,16 @@ <h2>
# Listen for keypresses and recompile.
$('#repl_source').keyup -> compileSource()

# Use tab key to insert tabs
$('#repl_source').keydown (e) ->
if e.keyCode is 9
e.preventDefault()
textbox = e.target
# Insert tab character at caret or in selection
textbox.value = textbox.value[0...textbox.selectionStart] + "\t" + textbox.value[textbox.selectionEnd...]
# Put caret in correct position
textbox.selectionEnd = ++textbox.selectionStart

# Eval the compiled js.
evalJS = ->
try
Expand Down
10 changes: 10 additions & 0 deletions documentation/index.html.js
Original file line number Diff line number Diff line change
Expand Up @@ -2317,6 +2317,16 @@ six = -&gt;
# Listen for keypresses and recompile.
$('#repl_source').keyup -> compileSource()

# Use tab key to insert tabs
$('#repl_source').keydown (e) ->
if e.keyCode is 9
e.preventDefault()
textbox = e.target
# Insert tab character at caret or in selection
textbox.value = textbox.value[0...textbox.selectionStart] + "\t" + textbox.value[textbox.selectionEnd...]
# Put caret in correct position
textbox.selectionEnd = ++textbox.selectionStart

# Eval the compiled js.
evalJS = ->
try
Expand Down

0 comments on commit 34869df

Please sign in to comment.