summaryrefslogtreecommitdiff
path: root/javax/swing/text/GapContent.java
diff options
context:
space:
mode:
Diffstat (limited to 'javax/swing/text/GapContent.java')
-rw-r--r--javax/swing/text/GapContent.java67
1 files changed, 67 insertions, 0 deletions
diff --git a/javax/swing/text/GapContent.java b/javax/swing/text/GapContent.java
new file mode 100644
index 000000000..a0d6e3d2b
--- /dev/null
+++ b/javax/swing/text/GapContent.java
@@ -0,0 +1,67 @@
+package javax.swing.text;
+
+// too lazy to make a real gapcontent.
+// lets just use a stringbuffer instead.
+
+import javax.swing.undo.*;
+
+
+public class GapContent implements AbstractDocument.Content
+{
+ StringBuffer buf = new StringBuffer();
+
+ GapContent()
+ {
+ this(10);
+ }
+
+ GapContent(int size)
+ {
+ }
+
+ public Position createPosition(final int offset) throws BadLocationException
+ {
+ return new Position()
+ {
+ int off = offset;
+ public int getOffset()
+ {
+ return off;
+ }
+ };
+ }
+
+ public int length()
+ {
+ return buf.length();
+ }
+
+ public UndoableEdit insertString(int where, String str) throws BadLocationException
+ {
+ buf.insert(where, str);
+ return null;
+ }
+
+ public UndoableEdit remove(int where, int nitems) throws BadLocationException
+ {
+ buf.delete(where, where + nitems);
+ return null;
+ }
+
+ public String getString(int where, int len) throws BadLocationException
+ {
+ return buf.toString();
+ }
+
+ public void getChars(int where, int len, Segment txt) throws BadLocationException
+ {
+ txt.array = new char[len];
+
+ System.arraycopy(buf.getValue(), where,
+ txt.array, 0,
+ len);
+
+ txt.count = len;
+ txt.offset = 0;
+ }
+}