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

@ -15,7 +15,7 @@ CONSTANTS = {
BaseCostFor1GBOfRamHacknetNode: 30000,
BaseCostForHacknetNode: 1000,
BaseCostForHacknetNodeCore: 1000000,
BaseCostForHacknetNodeCore: 250000,
/* Hacknet Node constants */
HacknetNodeMoneyGainPerLevel: 1,

@ -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;
}
}
}

@ -45,7 +45,7 @@ $(document).keydown(function(event) {
//Enter
if (event.keyCode == 13) {
event.preventDefault();
event.preventDefault(); //Prevent newline from being entered in Script Editor
var command = $('input[class=terminal-input]').val();
if (command.length > 0) {
post("> " + command);