I have the same issue, it would be awesome if we could get that implemented.
if you're interested, I made a small demo that shows how it 'could' be done, my javascript skills aren't top, just saying.
http://jsfiddle.net/e5PK5/11/
But if you're too lazy to click the link, here's the code:
HTML::>
<textarea style="width:100%;" rows="25" id="Content">
........
</textarea>
JS::>
/*********************************/
// Fellow Game-Devs, here ya go! //
/*********************************/
$(document).ready(function () {
// Remember, is shift down?
var bShiftDown = false;
$(document).delegate('#Content', 'keyup', function (e) {
// Shift Up
if ((e.keyCode || e.which) == 16) bShiftDown = false;
});
$(document).delegate('#Content', 'keydown', function (e) {
// Store it
var keyCode = e.keyCode || e.which;
// Shift Down
if (keyCode == 16) bShiftDown = true;
// Tab Down
if (keyCode == 9) {
e.preventDefault();
// Get the positions
var start = $(this).get(0).selectionStart;
var end = $(this).get(0).selectionEnd;
// What type of command is this? Indent, or Dedent? ( If that's even a word )
if (!bShiftDown) {
// Get array of lines and add \t
var code = $(this).val().substring(start, end).match(/[^\r\n]+/g);
if (!code) return;
for (var i = 0; i < code.length; i++) {
code[i] = '\t' + code[i];
}
// Fill it in
$(this).val($(this).val().substring(0, start) + code.join('\n') + $(this).val().substring(end));
// Remember to put the cursor somewhere!
$(this).get(0).selectionStart = $(this).get(0).selectionEnd = start + 1;
} else {
// Get array of lines and remove one \t
// SUGGESTION: maybe remove some spaces if no t found...
var code = $(this).val().substring(start, end).match(/[^\r\n]+/g);
if (!code) return;
for (var i = 0; i < code.length; i++) {
code[i] = code[i].replace("\t", '');
}
// Fill it in
$(this).val($(this).val().substring(0, start) + code.join('\n') + $(this).val().substring(end));
// Remember to put the cursor there!
$(this).get(0).selectionStart = $(this).get(0).selectionEnd = start;
}
}
});
});
And you reached the bottom!
-MIGI0027