Commit dd75b5eeccccbedc8b18bc4a472c51fb5dca55b3

Authored by Imanol-Mikel Barba Sabariego
1 parent 75718947

git-svn-id: svn://imanolbarba.net/PAD@15 c2ee353e-ed0d-4329-bf56-03aec153487f

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,7 +27,7 @@ public class Console implements Observer
27 scanner.findWithinHorizon(pattern,0); 27 scanner.findWithinHorizon(pattern,0);
28 numCols = Integer.parseInt(scanner.match().group(2)); 28 numCols = Integer.parseInt(scanner.match().group(2));
29 numRows = Integer.parseInt(scanner.match().group(1)); 29 numRows = Integer.parseInt(scanner.match().group(1));
30 - scanner.close(); 30 + System.err.println("TERMSIZE:" + numCols + " " + numRows);
31 } 31 }
32 32
33 public Coordinate getCurrentPos() 33 public Coordinate getCurrentPos()
@@ -40,7 +40,7 @@ public class Console implements Observer @@ -40,7 +40,7 @@ public class Console implements Observer
40 scanner.findWithinHorizon(pattern,0); 40 scanner.findWithinHorizon(pattern,0);
41 int x = Integer.parseInt(scanner.match().group(2)); 41 int x = Integer.parseInt(scanner.match().group(2));
42 int y = Integer.parseInt(scanner.match().group(1)); 42 int y = Integer.parseInt(scanner.match().group(1));
43 - scanner.close(); 43 + System.err.println("POS:" + x + " " + y);
44 return new Coordinate(x,y); 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,7 +108,6 @@ public class EditableBufferedReader extends BufferedReader
108 line.toggleMode(); 108 line.toggleMode();
109 break; 109 break;
110 } 110 }
111 - scanner.close();  
112 return; 111 return;
113 } 112 }
114 else if(scanner.findWithinHorizon("O?", 0).length() > 0) 113 else if(scanner.findWithinHorizon("O?", 0).length() > 0)
@@ -125,10 +124,8 @@ public class EditableBufferedReader extends BufferedReader @@ -125,10 +124,8 @@ public class EditableBufferedReader extends BufferedReader
125 line.setCursorTo(line.length()+1); 124 line.setCursorTo(line.length()+1);
126 break; 125 break;
127 } 126 }
128 - scanner.close();  
129 return; 127 return;
130 } 128 }
131 - scanner.close();  
132 } 129 }
133 else 130 else
134 { 131 {
@@ -150,7 +147,6 @@ public class EditableBufferedReader extends BufferedReader @@ -150,7 +147,6 @@ public class EditableBufferedReader extends BufferedReader
150 line.addChar((char)character); 147 line.addChar((char)character);
151 break; 148 break;
152 } 149 }
153 - scanner.close();  
154 return; 150 return;
155 } 151 }
156 } 152 }
@@ -180,6 +176,7 @@ public class EditableBufferedReader extends BufferedReader @@ -180,6 +176,7 @@ public class EditableBufferedReader extends BufferedReader
180 } 176 }
181 catch(Exception e) 177 catch(Exception e)
182 { 178 {
  179 + e.printStackTrace();
183 System.out.println("Error reading line"); 180 System.out.println("Error reading line");
184 return ""; 181 return "";
185 } 182 }
readline/src/pad/prac1/Line.java
@@ -106,6 +106,7 @@ public class Line extends Observable @@ -106,6 +106,7 @@ public class Line extends Observable
106 if(cursorPosition != line.length()+1) 106 if(cursorPosition != line.length()+1)
107 { 107 {
108 removeCharAt(cursorPosition-1); 108 removeCharAt(cursorPosition-1);
  109 + sendCommand(Command.DELETE_CHAR);
109 } 110 }
110 sendCommand(Command.INSERT_CHAR,(int)c); 111 sendCommand(Command.INSERT_CHAR,(int)c);
111 insertCharAt(c, cursorPosition-1); 112 insertCharAt(c, cursorPosition-1);
readline/src/pad/prac1/MainClass.java
@@ -21,4 +21,5 @@ public class MainClass @@ -21,4 +21,5 @@ public class MainClass
21 * 21 *
22 * TO-FIX 22 * TO-FIX
23 * Cursor keys, Home and end keys when new line, reset line length 23 * Cursor keys, Home and end keys when new line, reset line length
  24 + * SPEED
24 */ 25 */
25 \ No newline at end of file 26 \ No newline at end of file