Commit dd75b5eeccccbedc8b18bc4a472c51fb5dca55b3
1 parent
75718947
git-svn-id: svn://imanolbarba.net/PAD@15 c2ee353e-ed0d-4329-bf56-03aec153487f
Showing
7 changed files
with
5 additions
and
6 deletions
readline/bin/pad/prac1/Console.class
No preview for this file type
readline/bin/pad/prac1/EditableBufferedReader.class
No preview for this file type
readline/bin/pad/prac1/Line.class
No preview for this file type
readline/src/pad/prac1/Console.java
... | ... | @@ -27,7 +27,7 @@ public class Console implements Observer |
27 | 27 | scanner.findWithinHorizon(pattern,0); |
28 | 28 | numCols = Integer.parseInt(scanner.match().group(2)); |
29 | 29 | numRows = Integer.parseInt(scanner.match().group(1)); |
30 | - scanner.close(); | |
30 | + System.err.println("TERMSIZE:" + numCols + " " + numRows); | |
31 | 31 | } |
32 | 32 | |
33 | 33 | public Coordinate getCurrentPos() |
... | ... | @@ -40,7 +40,7 @@ public class Console implements Observer |
40 | 40 | scanner.findWithinHorizon(pattern,0); |
41 | 41 | int x = Integer.parseInt(scanner.match().group(2)); |
42 | 42 | int y = Integer.parseInt(scanner.match().group(1)); |
43 | - scanner.close(); | |
43 | + System.err.println("POS:" + x + " " + y); | |
44 | 44 | return new Coordinate(x,y); |
45 | 45 | } |
46 | 46 | ... | ... |
readline/src/pad/prac1/EditableBufferedReader.java
... | ... | @@ -108,7 +108,6 @@ public class EditableBufferedReader extends BufferedReader |
108 | 108 | line.toggleMode(); |
109 | 109 | break; |
110 | 110 | } |
111 | - scanner.close(); | |
112 | 111 | return; |
113 | 112 | } |
114 | 113 | else if(scanner.findWithinHorizon("O?", 0).length() > 0) |
... | ... | @@ -125,10 +124,8 @@ public class EditableBufferedReader extends BufferedReader |
125 | 124 | line.setCursorTo(line.length()+1); |
126 | 125 | break; |
127 | 126 | } |
128 | - scanner.close(); | |
129 | 127 | return; |
130 | 128 | } |
131 | - scanner.close(); | |
132 | 129 | } |
133 | 130 | else |
134 | 131 | { |
... | ... | @@ -150,7 +147,6 @@ public class EditableBufferedReader extends BufferedReader |
150 | 147 | line.addChar((char)character); |
151 | 148 | break; |
152 | 149 | } |
153 | - scanner.close(); | |
154 | 150 | return; |
155 | 151 | } |
156 | 152 | } |
... | ... | @@ -180,6 +176,7 @@ public class EditableBufferedReader extends BufferedReader |
180 | 176 | } |
181 | 177 | catch(Exception e) |
182 | 178 | { |
179 | + e.printStackTrace(); | |
183 | 180 | System.out.println("Error reading line"); |
184 | 181 | return ""; |
185 | 182 | } | ... | ... |
readline/src/pad/prac1/Line.java
... | ... | @@ -106,6 +106,7 @@ public class Line extends Observable |
106 | 106 | if(cursorPosition != line.length()+1) |
107 | 107 | { |
108 | 108 | removeCharAt(cursorPosition-1); |
109 | + sendCommand(Command.DELETE_CHAR); | |
109 | 110 | } |
110 | 111 | sendCommand(Command.INSERT_CHAR,(int)c); |
111 | 112 | insertCharAt(c, cursorPosition-1); | ... | ... |