01: package gnu.jemacs.swing;
02:
03: import gnu.jemacs.buffer.*;
04: import gnu.mapping.*;
05: import java.io.*;
06: import gnu.lists.CharBuffer;
07:
08: public class MarkerReader extends InPort {
09: Marker marker;
10: CharBuffer content;
11:
12: public MarkerReader(Buffer buffer) {
13: this (buffer, buffer.pointMarker);
14: }
15:
16: public MarkerReader(Marker marker) {
17: this (marker.getBuffer(), marker);
18: }
19:
20: MarkerReader(Buffer buffer, Marker marker) {
21: super (gnu.text.NullReader.nullReader, buffer.getPath());
22: this .marker = marker;
23: content = ((gnu.jemacs.swing.SwingBuffer) buffer).content.buffer;
24: this .buffer = content.getArray();
25: }
26:
27: public int read() {
28: int offset = marker.getOffset();
29: buffer = content.getArray();
30: if (offset >= content.gapStart)
31: offset += content.gapEnd - content.gapStart;
32: int length = buffer.length;
33: pos = offset;
34: if (offset >= length) {
35: limit = offset;
36: return -1;
37: } else {
38: int ch = buffer[pos];
39: pos++;
40: limit = pos;
41: return ch;
42: }
43: }
44:
45: public int getLineNumber() {
46: throw new Error("MarkerReader. getLineNumber - not implemented");
47: }
48:
49: public int getColumnNumber() {
50: throw new Error(
51: "MarkerReader,getColumnNumber - not implemented");
52: }
53:
54: public void reset() throws IOException {
55: throw new Error("MarkerReader.reset - not implemented");
56: }
57:
58: }
|