From a2aa3db78480fcc7891c1b3ed40240c7b4e3618e Mon Sep 17 00:00:00 2001 From: benfry Date: Fri, 10 Nov 2006 14:05:52 +0000 Subject: [PATCH] improve editor indent mechanism, remove extraneous indents --- app/EditorListener.java | 49 ++++++++++++++++++++++++++++++----------- core/todo.txt | 39 ++++++++++++++++---------------- todo.txt | 7 ++++++ 3 files changed, 63 insertions(+), 32 deletions(-) diff --git a/app/EditorListener.java b/app/EditorListener.java index f583ffc4c..57ab1ca9a 100644 --- a/app/EditorListener.java +++ b/app/EditorListener.java @@ -286,12 +286,30 @@ public class EditorListener { origIndex += offset; // ARGH!#(* WINDOWS#@($* */ + // calculate the amount of indent on the previous line int spaceCount = calcSpaceCount(origIndex, contents); - //int origCount = spaceCount; + + // If the last character was a left curly brace, then indent. + // For 0122, walk backwards a bit to make sure that the there + // isn't a curly brace several spaces (or lines) back. Also + // moved this before calculating extraCount, since it'll affect + // that as well. + int index2 = origIndex; + while ((index2 >= 0) && + Character.isWhitespace(contents[index2])) { + index2--; + } + if (index2 != -1) { + // still won't catch a case where prev stuff is a comment + if (contents[index2] == '{') { + spaceCount += tabSize; + } + } + //System.out.println("spaceCount should be " + spaceCount); // now before inserting this many spaces, walk forward from - // the caret position, so that the number of spaces aren't - // just being duplicated again + // the caret position and count the number of spaces, + // so that the number of spaces aren't duplicated again int index = origIndex + 1; int extraCount = 0; while ((index < contents.length) && @@ -302,22 +320,27 @@ public class EditorListener { } // hitting return on a line with spaces *after* the caret - // can cause trouble. for simplicity's sake, just ignore this case. - //if (spaceCount < 0) spaceCount = origCount; + // can cause trouble. for 0099, was ignoring the case, but this is + // annoying, so in 0122 we're trying to fix that. + /* if (spaceCount - extraCount > 0) { spaceCount -= extraCount; } + */ + spaceCount -= extraCount; + //if (spaceCount < 0) spaceCount = 0; + //System.out.println("extraCount is " + extraCount); - // if the last character was a left curly brace, then indent - if (origIndex != -1) { - if (contents[origIndex] == '{') { - spaceCount += tabSize; - } + if (spaceCount < 0) { + // for rev 0122, actually delete extra space + //textarea.setSelectionStart(origIndex + 1); + textarea.setSelectionEnd(textarea.getSelectionEnd() - spaceCount); + textarea.setSelectedText("\n"); + } else { + String insertion = "\n" + Editor.EMPTY.substring(0, spaceCount); + textarea.setSelectedText(insertion); } - String insertion = "\n" + Editor.EMPTY.substring(0, spaceCount); - textarea.setSelectedText(insertion); - // mark this event as already handled event.consume(); return true; diff --git a/core/todo.txt b/core/todo.txt index 025c9e01c..8f5018292 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -1,6 +1,26 @@ 0122 core X noiseSeed() only works once, before the arrays are created X http://processing.org/discourse/yabb_beta/YaBB.cgi?board=SoftwareBugs;action=display;num=1162856262 +X make lerpColor honor the current color mode +X lerpColor(c1, c2, amt, RGB/HSB/???) +_ test this out for a bit +_ though that's awkward b/c colors always RGB +_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Suggestions;action=display;num=1160096087 + +_ http://dev.processing.org/bugs/show_bug.cgi?id=428 +_ related to the fill bugs: when fill is identical, no fill applied +_ actually tint() should take over for fill as per-vertex color +_ when textured images are being used +_ http://dev.processing.org/bugs/show_bug.cgi?id=169 +_ tint() should set texture color, fill() is ignored with textures +_ fix tint() for PGraphics3 (what could be wrong?) +_ tint() honoring alpha but not colored tint +_ maybe not setting fill color when drawing textures +_ guessing it's an implementation issue in sami's renderer +_ check with the a_Displaying example and tint(255, 0, 0, 100); +_ http://dev.processing.org/bugs/show_bug.cgi?id=90 +_ is fill() not coloring textures properly? +_ don't need to apply tint() to textures, supposed to use fill color _ gradient-painted lines and fills _ java2d will do both line and fill, illusfarter only does fills @@ -18,25 +38,6 @@ g2.setPaint(gradient); //g2.draw(gp); g2.fill(gp); -_ make lerpColor honor the current color mode -_ though that's awkward b/c colors always RGB -_ lerpColor(c1, c2, amt, RGB/HSB/???) -_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Suggestions;action=display;num=1160096087 - -_ related to the fill bugs: when fill is identical, no fill applied -_ actually tint() should take over for fill as per-vertex color -_ when textured images are being used -_ http://dev.processing.org/bugs/show_bug.cgi?id=169 -_ tint() should set texture color, fill() is ignored with textures -_ fix tint() for PGraphics3 (what could be wrong?) -_ tint() honoring alpha but not colored tint -_ maybe not setting fill color when drawing textures -_ guessing it's an implementation issue in sami's renderer -_ check with the a_Displaying example and tint(255, 0, 0, 100); -_ http://dev.processing.org/bugs/show_bug.cgi?id=90 -_ is fill() not coloring textures properly? -_ don't need to apply tint() to textures, supposed to use fill color - add to reference _ also parseInt and parseFloat, how they can return another number or NaN _ background() with an image ignores the tint.. it's basically like set() diff --git a/todo.txt b/todo.txt index 260cb446c..5ccda5edd 100644 --- a/todo.txt +++ b/todo.txt @@ -1,4 +1,11 @@ 0122 pde +X improve editor listener to not add so many extraneous indents + +libraries +_ add control for dependencies (i.e. svg needs xml), needed for export +_ add "pretty menu name" to the export.txt file +_ more export.txt to xml? (nah, it's only flat information) +_ need better platform designation setup for libs _ slow save/new because of large sketchbook _ this is a total cluster, the rebuild is being called incessantly