Skip to content

Commit 34869df

Browse files
committed
In “Try CoffeeScript,” if you press the tab key it should type a tab character. Closes jashkenas#3342.
1 parent e3aa8e0 commit 34869df

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

docs/v1/css/docs.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,10 @@ div.code {
304304
outline: none;
305305
margin: 5px 0 20px;
306306
color: #def;
307+
-webkit-tab-size: 2;
308+
-moz-tab-size: 2;
309+
-o-tab-size: 2;
310+
tab-size: 2;
307311
}
308312
#repl_results, #repl_source_wrap {
309313
width: auto; height: auto;

docs/v1/index.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3892,6 +3892,16 @@ <h2>
38923892
# Listen for keypresses and recompile.
38933893
$('#repl_source').keyup -> compileSource()
38943894

3895+
# Use tab key to insert tabs
3896+
$('#repl_source').keydown (e) ->
3897+
if e.keyCode is 9
3898+
e.preventDefault()
3899+
textbox = e.target
3900+
# Insert tab character at caret or in selection
3901+
textbox.value = textbox.value[0...textbox.selectionStart] + "\t" + textbox.value[textbox.selectionEnd...]
3902+
# Put caret in correct position
3903+
textbox.selectionEnd = ++textbox.selectionStart
3904+
38953905
# Eval the compiled js.
38963906
evalJS = ->
38973907
try

documentation/index.html.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2317,6 +2317,16 @@ six = -&gt;
23172317
# Listen for keypresses and recompile.
23182318
$('#repl_source').keyup -> compileSource()
23192319

2320+
# Use tab key to insert tabs
2321+
$('#repl_source').keydown (e) ->
2322+
if e.keyCode is 9
2323+
e.preventDefault()
2324+
textbox = e.target
2325+
# Insert tab character at caret or in selection
2326+
textbox.value = textbox.value[0...textbox.selectionStart] + "\t" + textbox.value[textbox.selectionEnd...]
2327+
# Put caret in correct position
2328+
textbox.selectionEnd = ++textbox.selectionStart
2329+
23202330
# Eval the compiled js.
23212331
evalJS = ->
23222332
try

0 commit comments

Comments
 (0)