Revision: 6923
Author: victormote
Date: 2006-03-09 16:58:50 -0800 (Thu, 09 Mar 2006)
ViewCVS: http://svn.sourceforge.net/foray/?rev=6923&view=rev
Log Message:
-----------
More improvements to line writing.
Modified Paths:
--------------
trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java
Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java
===================================================================
--- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-10 00:15:01 UTC (rev 6922)
+++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-10 00:58:50 UTC (rev 6923)
@@ -715,22 +715,13 @@
return;
}
- int activeBreak;
- int previousBreak;
for (int i = 0; i < this.breaksChosen.size(); i++) {
- activeBreak = this.getBreakChosen(i);
- if (i == 0) {
- previousBreak = 0;
- } else {
- previousBreak = this.getBreakChosen(i - 1);
- }
- this.writeChunk(previousBreak, activeBreak);
+ this.writeChunk(i);
write(newLine());
}
/* Write the last chunk. Don't write a new-line after it. That will
* be controlled at a higher level. */
- activeBreak = this.getBreakChosen(this.breaksChosen.size() - 1);
- this.writeChunk(activeBreak, Integer.MAX_VALUE);
+ this.writeChunk(Integer.MAX_VALUE);
}
private int getBreakChosen(int index) {
@@ -841,7 +832,20 @@
return count;
}
- private void writeChunk(int startOpportunity, int endOpportunity) {
+ private void writeChunk(int breakSelected) {
+ int startOpportunity;
+ int endOpportunity;
+ if (breakSelected == 0) {
+ startOpportunity = Integer.MIN_VALUE;
+ endOpportunity = this.getBreakChosen(breakSelected);
+ } else if (breakSelected > this.breaksChosen.size() - 1) {
+ startOpportunity = this.getLastBreakChosen();
+ endOpportunity = Integer.MAX_VALUE;
+ } else {
+ startOpportunity = this.getBreakChosen(breakSelected - 1);
+ endOpportunity = this.getBreakChosen(breakSelected);
+ }
+
int startItem;
int startItemIndex;
int endItem;
@@ -866,17 +870,21 @@
int startIndex = 0;
if (i == startItem) {
startIndex = startItemIndex;
+ /* If the first character on a line is a space, don't write
+ * it. */
+ if (string.charAt(startIndex) == ' '
+ && lastColumnWritten == 0) {
+ startIndex ++;
+ }
}
int endIndex = string.length() - 1;
if (i == endItem) {
endIndex = endItemIndex;
+ if (string.charAt(endIndex) == ' ') {
+ endIndex --;
+ }
}
- if (startIndex == 0
- && endIndex == string.length() - 1) {
- write(string);
- } else {
- write(string.substring(startIndex, endIndex + 1));
- }
+ write(string.substring(startIndex, endIndex + 1));
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|