Skip to content

Commit

Permalink
rename DelegatingStyleRange into StyleImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
koentsje committed Mar 25, 2014
1 parent af4c64b commit 9d72e46
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
public class DelegatingDocument implements org.jboss.tools.aesh.core.document.Document {

private Document delegate;
private DelegatingStyleRange currentStyle;
private StyleImpl currentStyle;
private int savedCursor = 0;
private int cursorOffset = 0;
private Set<CursorListener> cursorListeners = new HashSet<CursorListener>();

public DelegatingDocument() {
this.delegate = new Document();
this.currentStyle = DelegatingStyleRange.getDefault();
this.currentStyle = StyleImpl.getDefault();
}

@Override
Expand Down Expand Up @@ -122,17 +122,17 @@ public void saveCursor() {

@Override
public Style newStyleFromCurrent() {
StyleRange oldStyleRange = currentStyle.getDelegate();
StyleRange oldStyleRange = currentStyle.getStyleRange();
StyleRange newStyleRange = new StyleRange(oldStyleRange);
newStyleRange.start = oldStyleRange.start + oldStyleRange.length;
newStyleRange.length = 0;
return new DelegatingStyleRange(newStyleRange);
return new StyleImpl(newStyleRange);
}

@Override
public void setCurrentStyle(Style styleRangeProxy) {
if (styleRangeProxy instanceof DelegatingStyleRange) {
currentStyle = (DelegatingStyleRange)styleRangeProxy;
if (styleRangeProxy instanceof StyleImpl) {
currentStyle = (StyleImpl)styleRangeProxy;
}
}

Expand All @@ -143,7 +143,7 @@ public Style getCurrentStyle() {

@Override
public void setDefaultStyle() {
DelegatingStyleRange defaultStyle = DelegatingStyleRange.getDefault();
StyleImpl defaultStyle = StyleImpl.getDefault();
StyleRange styleRange = defaultStyle.getStyleRange();
styleRange.start = delegate.getLength();
styleRange.length = 0;
Expand All @@ -154,7 +154,7 @@ public Document getDelegate() {
return delegate;
}

public DelegatingStyleRange getCurrentStyleRange() {
public StyleImpl getCurrentStyleRange() {
return currentStyle;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
import org.jboss.tools.aesh.ui.internal.util.ColorConstants;
import org.jboss.tools.aesh.ui.internal.util.FontManager;

public class DelegatingStyleRange implements Style {
public class StyleImpl implements Style {

private StyleRange styleRange;

public DelegatingStyleRange(StyleRange styleRange) {
public StyleImpl(StyleRange styleRange) {
this.styleRange = styleRange;
}

StyleRange getStyleRange() {
public StyleRange getStyleRange() {
return styleRange;
}

Expand Down Expand Up @@ -216,17 +216,13 @@ private void reverseVideo() {
styleRange.foreground = background;
}

public static DelegatingStyleRange getDefault() {
public static StyleImpl getDefault() {
Font font = FontManager.INSTANCE.getDefault();
Color foreground = ColorConstants.BLACK;
Color background = ColorConstants.WHITE;
TextStyle textStyle = new TextStyle(font, foreground, background);
StyleRange styleRange = new StyleRange(textStyle);
return new DelegatingStyleRange(styleRange);
}

public StyleRange getDelegate() {
return styleRange;
return new StyleImpl(styleRange);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.jboss.tools.aesh.core.console.Console;
import org.jboss.tools.aesh.ui.internal.document.CursorListener;
import org.jboss.tools.aesh.ui.internal.document.DelegatingDocument;
import org.jboss.tools.aesh.ui.internal.document.DelegatingStyleRange;
import org.jboss.tools.aesh.ui.internal.document.StyleImpl;
import org.jboss.tools.aesh.ui.internal.util.CharacterConstants;
import org.jboss.tools.aesh.ui.internal.util.FontManager;

Expand Down Expand Up @@ -44,8 +44,8 @@ public void documentChanged(final DocumentEvent event) {
if (textWidget != null && !textWidget.isDisposed()) {
int lineCount = textWidget.getLineCount();
textWidget.setTopIndex(lineCount - 1);
DelegatingStyleRange style = aeshDocument.getCurrentStyleRange();
StyleRange styleRange = style.getDelegate();
StyleImpl style = aeshDocument.getCurrentStyleRange();
StyleRange styleRange = style.getStyleRange();
if (styleRange != null &&
event.getLength() == 0 &&
styleRange.start <= getDocument().getLength() &&
Expand Down

0 comments on commit 9d72e46

Please sign in to comment.