use tabs to auto-indent particular lines (ala emacs) bug #22

This commit is contained in:
benfry
2005-12-15 23:44:30 +00:00
parent 19b2c8e436
commit 76a9b8ffe1
2 changed files with 32 additions and 12 deletions
+24 -6
View File
@@ -104,7 +104,6 @@ public class EditorListener {
switch ((int) c) {
case 9:
tabsExpand = false;
if (tabsExpand) { // expand tabs
textarea.setSelectedText(tabString);
event.consume();
@@ -119,21 +118,40 @@ public class EditorListener {
// now find the start of this line
int lineStart = calcLineStart(prevCharIndex, contents);
int indent = calcBraceIndent(lineStart, contents); //, 0);
int lineEnd = lineStart;
while ((lineEnd < contents.length - 1) &&
(contents[lineEnd] != 10)) {
lineEnd++;
}
// get the number of braces, to determine whether this is an indent
int braceBalance = 0;
int index = lineStart;
while ((index < contents.length) &&
(contents[index] != 10)) {
if (contents[index] == '{') {
braceBalance++;
} else if (contents[index] == '}') {
braceBalance--;
}
index++;
}
// if it's a starting indent, need to ignore it, so lineStart
// will be the counting point. but if there's a closing indent,
// then the lineEnd should be used.
int where = (braceBalance > 0) ? lineStart : lineEnd;
int indent = calcBraceIndent(where, contents);
if (indent == -1) {
// no braces to speak of, do nothing
//System.out.println("no indent");
indent = 0;
} else {
//System.out.println("indent found at " + indent);
indent += tabSize;
}
// and the number of spaces it has
int spaceCount = calcSpaceCount(prevCharIndex, contents);
System.out.println(indent + " " + lineStart + " " + spaceCount);
textarea.setSelectionStart(lineStart);
textarea.setSelectionEnd(lineStart + spaceCount);
textarea.setSelectedText(Editor.EMPTY.substring(0, indent));
+8 -6
View File
@@ -28,7 +28,15 @@ X mark temp build folder for deletion on exit
X properly remove console files on exit
X in previous releases this was filling up the temp dir with a lotta garbage
X bug where hiddenCount/codeCount weren't being set to zero on load()
tab handling
X indent/outdent with curly braces
X tab to just indent lines properly,
X rather than having it convert to spaces
X need a smarter handler (rather than the editor listener)
X could look at previous line for its indent
X and when hitting } do a proper outdent (if only spaces before it)
X http://dev.processing.org/bugs/show_bug.cgi?id=22
_ unchecking 'use external editor' sketch should not set modified
_ dangerous if a version that hasn't been re-loaded has possibility
@@ -273,12 +281,6 @@ PDE / Editor
_ when running with external editor, hide the editor text area
_ http://dev.processing.org/bugs/show_bug.cgi?id=20
_ tab to just indent lines properly,
_ rather than having it convert to spaces
_ need a smarter handler (rather than the editor listener)
_ could look at previous line for its indent
_ and when hitting } do a proper outdent (if only spaces before it)
_ http://dev.processing.org/bugs/show_bug.cgi?id=22
_ horizontal scroller gets weird sometimes
_ http://dev.processing.org/bugs/show_bug.cgi?id=23
_ mouse wheel broken in the text editor? (windows jdk 1.5?)