Mercurial > projects > dwt-addons
diff dwtx/jface/viewers/StyledString.d @ 104:04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
These new wrappers now use the tango.util.containers instead of the tango.util.collections.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 07 Aug 2008 15:01:33 +0200 |
parents | 5df4896124c7 |
children |
line wrap: on
line diff
--- a/dwtx/jface/viewers/StyledString.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/viewers/StyledString.d Thu Aug 07 15:01:33 2008 +0200 @@ -19,8 +19,8 @@ import dwtx.jface.resource.JFaceResources; import dwt.dwthelper.utils; +import dwtx.dwtxhelper.Collection; import tango.text.convert.Format; -import tango.util.collection.ArraySeq; import tango.core.Exception; @@ -224,8 +224,8 @@ int offset = fBuffer.length(); fBuffer.append(string.toString()); - auto otherRuns = string.fStyleRuns; - if (otherRuns !is null && !otherRuns.drained()) { + List otherRuns = string.fStyleRuns; + if (otherRuns !is null && !otherRuns.isEmpty()) { for (int i = 0; i < otherRuns.size(); i++) { StyleRun curr = cast(StyleRun) otherRuns.get(i); if (i is 0 && curr.offset !is 0) { @@ -345,7 +345,7 @@ Styler prevStyle = endRun > 0 ? fStyleRuns.getRun(endRun - 1).style : null; fStyleRuns - .addAt(endRun, new StyleRun(offset + length, prevStyle)); + .add(endRun, new StyleRun(offset + length, prevStyle)); } } @@ -361,7 +361,7 @@ : null; if (isDifferentStyle(prevStyle, styler) || (startRun is 0 && styler !is null)) { - fStyleRuns.addAt(startRun, new StyleRun(offset, styler)); + fStyleRuns.add(startRun, new StyleRun(offset, styler)); endRun++; // endrun is moved one back } else { startRun--; // we use the previous @@ -381,25 +381,25 @@ */ public StyleRange[] getStyleRanges() { if (hasRuns()) { - StyleRange[] res; + ArrayList res = new ArrayList(); - auto styleRuns = getStyleRuns(); + List styleRuns = getStyleRuns(); int offset = 0; Styler style = null; for (int i = 0; i < styleRuns.size(); i++) { StyleRun curr = cast(StyleRun) styleRuns.get(i); if (isDifferentStyle(curr.style, style)) { if (curr.offset > offset && style !is null) { - res ~= createStyleRange(offset, curr.offset, style); + res.add(createStyleRange(offset, curr.offset, style)); } offset = curr.offset; style = curr.style; } } if (fBuffer.length() > offset && style !is null) { - res ~= createStyleRange(offset, fBuffer.length(), style); + res.add(createStyleRange(offset, fBuffer.length(), style)); } - return res; + return arraycast!(StyleRange)(res.toArray()); } return EMPTY; } @@ -431,7 +431,7 @@ } private bool hasRuns() { - return fStyleRuns !is null && !fStyleRuns.drained(); + return fStyleRuns !is null && !fStyleRuns.isEmpty(); } private void appendStyleRun(Styler style, int offset) { @@ -443,7 +443,7 @@ if (lastRun is null && style !is null || lastRun !is null && isDifferentStyle(style, lastRun.style)) { - getStyleRuns().append(new StyleRun(offset, style)); + getStyleRuns().add(new StyleRun(offset, style)); } } @@ -455,13 +455,13 @@ } private StyleRun getLastRun() { - if (fStyleRuns is null || fStyleRuns.drained()) { + if (fStyleRuns is null || fStyleRuns.isEmpty()) { return null; } return fStyleRuns.getRun(fStyleRuns.size() - 1); } - private StyleRunList getStyleRuns() { + private List getStyleRuns() { if (fStyleRuns is null) fStyleRuns = new StyleRunList(); return fStyleRuns; @@ -481,21 +481,20 @@ } } - private static class StyleRunList : ArraySeq!(Object) { + private static class StyleRunList : ArrayList { private static final long serialVersionUID = 123L; public this() { - super(); - capacity(3); + super(3); } public StyleRun getRun(int index) { return cast(StyleRun) get(index); } - //public void removeRange(int fromIndex, int toIndex) { - // super.removeRange(fromIndex, toIndex); - //} + public void removeRange(int fromIndex, int toIndex) { + super.removeRange(fromIndex, toIndex); + } } private static class DefaultStyler : Styler {