Changed tabbing i script editor so that it uses four spaces rather than the tab char"

This commit is contained in:
Daniel Xie
2017-05-15 23:37:14 -05:00
parent c0f5f9da9e
commit b8ccddf256
3 changed files with 11 additions and 5 deletions
+9 -3
View File
@@ -17,9 +17,15 @@ function scriptEditorInit() {
textareas[i].onkeydown = function(e){
if(e.keyCode==9 || e.which==9){
e.preventDefault();
var s = this.selectionStart;
this.value = this.value.substring(0,this.selectionStart) + "\t" + this.value.substring(this.selectionEnd);
this.selectionEnd = s+1;
var start = this.selectionStart;
var end = this.selectionEnd;
// set textarea value to: text before caret + tab + text after caret
spaces = " ";
this.value = this.value.substring(0, start) + spaces + this.value.substring(end);
// put caret at right position again
this.selectionStart = this.selectionEnd = start + spaces.length;
}
}
}