Skip to content

Commit

Permalink
rename DocumentProxy to AeshDocument
Browse files Browse the repository at this point in the history
  • Loading branch information
koentsje committed Feb 25, 2014
1 parent 727f0d7 commit 7aa34c5
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.jboss.tools.aesh.core.ansi;

import org.jboss.tools.aesh.core.document.DocumentProxy;
import org.jboss.tools.aesh.core.document.AeshDocument;

public abstract class ControlSequence {

public abstract ControlSequenceType getType();

public void handle(DocumentProxy document) {
public void handle(AeshDocument document) {
throw new RuntimeException("not implemented!");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.jboss.tools.aesh.core.ansi;

import org.jboss.tools.aesh.core.document.DocumentProxy;
import org.jboss.tools.aesh.core.document.AeshDocument;


public class CursorBack extends ControlSequence {
Expand All @@ -17,7 +17,7 @@ public ControlSequenceType getType() {
}

@Override
public void handle(DocumentProxy document) {
public void handle(AeshDocument document) {
document.moveCursorTo(document.getCursorOffset() - amount);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.jboss.tools.aesh.core.ansi;

import org.jboss.tools.aesh.core.document.DocumentProxy;
import org.jboss.tools.aesh.core.document.AeshDocument;


public class CursorForward extends ControlSequence {
Expand All @@ -17,7 +17,7 @@ public ControlSequenceType getType() {
}

@Override
public void handle(DocumentProxy document) {
public void handle(AeshDocument document) {
document.moveCursorTo(document.getCursorOffset() + amount);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.jboss.tools.aesh.core.ansi;

import org.jboss.tools.aesh.core.document.DocumentProxy;
import org.jboss.tools.aesh.core.document.AeshDocument;


public class CursorHorizontalAbsolute extends ControlSequence {
Expand All @@ -17,7 +17,7 @@ public ControlSequenceType getType() {
}

@Override
public void handle(DocumentProxy document) {
public void handle(AeshDocument document) {
int lineStart = document.getLineOffset(document.getLineOfOffset(document.getCursorOffset()));
document.moveCursorTo(lineStart + column);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.jboss.tools.aesh.core.ansi;

import org.jboss.tools.aesh.core.document.DocumentProxy;
import org.jboss.tools.aesh.core.document.AeshDocument;


public class CursorPosition extends ControlSequence {
Expand All @@ -23,7 +23,7 @@ public ControlSequenceType getType() {
}

@Override
public void handle(DocumentProxy document) {
public void handle(AeshDocument document) {
int offset = document.getLineOffset(line);
int maxColumn = document.getLineLength(line);
offset += Math.min(maxColumn, column);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.jboss.tools.aesh.core.ansi;

import org.jboss.tools.aesh.core.document.DocumentProxy;
import org.jboss.tools.aesh.core.document.AeshDocument;


public class EraseData extends ControlSequence {
Expand All @@ -17,7 +17,7 @@ public ControlSequenceType getType() {
}

@Override
public void handle(DocumentProxy document) {
public void handle(AeshDocument document) {
if ("2".equals(arguments)) {
document.reset();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.jboss.tools.aesh.core.ansi;

import org.jboss.tools.aesh.core.document.DocumentProxy;
import org.jboss.tools.aesh.core.document.AeshDocument;


public class EraseInLine extends ControlSequence {
Expand All @@ -13,7 +13,7 @@ public ControlSequenceType getType() {
}

@Override
public void handle(DocumentProxy document) {
public void handle(AeshDocument document) {
document.replace(
document.getCursorOffset(),
document.getLength() - document.getCursorOffset(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.jboss.tools.aesh.core.ansi;

import org.jboss.tools.aesh.core.document.DocumentProxy;
import org.jboss.tools.aesh.core.document.AeshDocument;


public class RestoreCursorPosition extends ControlSequence {
Expand All @@ -13,7 +13,7 @@ public ControlSequenceType getType() {
}

@Override
public void handle(DocumentProxy document) {
public void handle(AeshDocument document) {
document.restoreCursor();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.jboss.tools.aesh.core.ansi;

import org.jboss.tools.aesh.core.document.DocumentProxy;
import org.jboss.tools.aesh.core.document.AeshDocument;


public class SaveCursorPosition extends ControlSequence {
Expand All @@ -13,7 +13,7 @@ public ControlSequenceType getType() {
}

@Override
public void handle(DocumentProxy document) {
public void handle(AeshDocument document) {
document.saveCursor();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.StringTokenizer;

import org.jboss.tools.aesh.core.document.DocumentProxy;
import org.jboss.tools.aesh.core.document.AeshDocument;
import org.jboss.tools.aesh.core.document.StyleRangeProxy;
import org.jboss.tools.aesh.core.internal.AeshCorePlugin;

Expand All @@ -21,7 +21,7 @@ public ControlSequenceType getType() {
}

@Override
public void handle(DocumentProxy document) {
public void handle(AeshDocument document) {
StyleRangeProxy styleRange = document.newStyleRangeFromCurrent();
StringTokenizer tokenizer = new StringTokenizer(arguments, ";");
while (tokenizer.hasMoreTokens()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.jboss.tools.aesh.core.document;

public interface DocumentProxy {
public interface AeshDocument {

int getCursorOffset();
int getLineOfOffset(int offset);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
import org.jboss.tools.aesh.core.ansi.ControlSequence;
import org.jboss.tools.aesh.core.ansi.ControlSequenceFilter;
import org.jboss.tools.aesh.core.console.AeshConsole;
import org.jboss.tools.aesh.core.document.DocumentProxy;
import org.jboss.tools.aesh.core.io.StreamListener;
import org.jboss.tools.aesh.ui.fonts.FontManager;

public class AeshDocument extends Document {
public class DelegateDocument extends Document {

public interface CursorListener {
void cursorMoved();
Expand All @@ -29,12 +28,12 @@ public interface CursorListener {
private AeshConsole console;
private Set<CursorListener> cursorListeners = new HashSet<CursorListener>();
private StyleRange currentStyleRange;
private DocumentProxy proxy;
private DelegatingDocument proxy;

private int savedCursor = 0;

public AeshDocument() {
proxy = new AeshDocumentProxy(this);
public DelegateDocument() {
proxy = new DelegatingDocument(this);
currentStyleRange = getDefaultStyleRange();
stdOutListener = new StreamListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import org.eclipse.jface.text.BadLocationException;
import org.eclipse.swt.custom.StyleRange;
import org.jboss.tools.aesh.core.document.DocumentProxy;
import org.jboss.tools.aesh.core.document.AeshDocument;
import org.jboss.tools.aesh.core.document.StyleRangeProxy;
import org.jboss.tools.aesh.ui.AeshUIPlugin;

public class AeshDocumentProxy implements DocumentProxy {
public class DelegatingDocument implements AeshDocument {

private AeshDocument document;
private DelegateDocument document;

public AeshDocumentProxy(AeshDocument document) {
public DelegatingDocument(DelegateDocument document) {
this.document = document;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import org.eclipse.swt.widgets.Composite;
import org.jboss.tools.aesh.core.console.AeshConsole;
import org.jboss.tools.aesh.ui.AeshUIConstants;
import org.jboss.tools.aesh.ui.document.AeshDocument;
import org.jboss.tools.aesh.ui.document.AeshDocument.CursorListener;;
import org.jboss.tools.aesh.ui.document.DelegateDocument;
import org.jboss.tools.aesh.ui.document.DelegateDocument.CursorListener;;

public class AeshTextViewer extends TextViewer {

Expand All @@ -30,7 +30,7 @@ public class AeshTextViewer extends TextViewer {
private static String DELETE_NEXT_CHAR = new String(new char[] {(char)27,(char)91,(char)51,(char)126});

protected AeshConsole aeshConsole;
protected AeshDocument aeshDocument;
protected DelegateDocument aeshDocument;

protected CursorListener cursorListener = new CursorListener() {
@Override
Expand Down Expand Up @@ -70,7 +70,7 @@ protected void initializeConsole() {
}

protected void initializeDocument() {
aeshDocument = new AeshDocument();
aeshDocument = new DelegateDocument();
aeshDocument.connect(aeshConsole);
aeshDocument.addCursorListener(cursorListener);
aeshDocument.addDocumentListener(documentListener);
Expand Down Expand Up @@ -150,8 +150,8 @@ protected void handleVerifyEvent(VerifyEvent e) {
e.doit = false;
}

public AeshDocument getDocument() {
return (AeshDocument)super.getDocument();
public DelegateDocument getDocument() {
return (DelegateDocument)super.getDocument();
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.jboss.tools.aesh.ui.document.AeshDocument;
import org.jboss.tools.aesh.ui.document.DelegateDocument;
import org.jboss.tools.aesh.ui.view.AeshTextViewer;

public class F2TextViewer extends AeshTextViewer {
Expand All @@ -12,7 +12,7 @@ public F2TextViewer(Composite parent) {
}

protected void initializeDocument() {
aeshDocument = new AeshDocument();
aeshDocument = new DelegateDocument();
aeshDocument.addCursorListener(cursorListener);
aeshDocument.addDocumentListener(documentListener);
}
Expand Down

0 comments on commit 7aa34c5

Please sign in to comment.