From 894ed485745c00ed1dd9274c047c00c6758b4a3d Mon Sep 17 00:00:00 2001 From: Imanol-Mikel Barba Sabariego Date: Fri, 15 Nov 2013 18:48:32 +0000 Subject: [PATCH] git-svn-id: svn://imanolbarba.net/PAD@18 c2ee353e-ed0d-4329-bf56-03aec153487f --- JChat/.classpath | 6 ++++++ JChat/.project | 17 +++++++++++++++++ JChat/.settings/org.eclipse.jdt.core.prefs | 11 +++++++++++ JChat/bin/pad/prac2/MyServerSocket.class | Bin 0 -> 287 bytes JChat/bin/pad/prac2/MySocket.class | Bin 0 -> 269 bytes JChat/src/pad/prac2/MyServerSocket.java | 5 +++++ JChat/src/pad/prac2/MySocket.java | 6 ++++++ readline/bin/pad/prac1/Command.class | Bin 771 -> 0 bytes readline/bin/pad/prac1/Console.class | Bin 3482 -> 0 bytes readline/bin/pad/prac1/Coordinate.class | Bin 688 -> 0 bytes readline/bin/pad/prac1/EditableBufferedReader.class | Bin 4151 -> 0 bytes readline/bin/pad/prac1/Line.class | Bin 2991 -> 0 bytes readline/src/pad/prac1/Console.java | 5 +---- readline/src/pad/prac1/EditableBufferedReader.java | 3 ++- readline/src/pad/prac1/Line.java | 6 +++++- readline/src/pad/prac1/MainClass.java | 12 +++++++++++- 16 files changed, 64 insertions(+), 7 deletions(-) create mode 100644 JChat/.classpath create mode 100644 JChat/.project create mode 100644 JChat/.settings/org.eclipse.jdt.core.prefs create mode 100644 JChat/bin/pad/prac2/MyServerSocket.class create mode 100644 JChat/bin/pad/prac2/MySocket.class create mode 100644 JChat/src/pad/prac2/MyServerSocket.java create mode 100644 JChat/src/pad/prac2/MySocket.java diff --git a/JChat/.classpath b/JChat/.classpath new file mode 100644 index 0000000..18d70f0 --- /dev/null +++ b/JChat/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/JChat/.project b/JChat/.project new file mode 100644 index 0000000..f3795fe --- /dev/null +++ b/JChat/.project @@ -0,0 +1,17 @@ + + + JChat + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/JChat/.settings/org.eclipse.jdt.core.prefs b/JChat/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8000cd6 --- /dev/null +++ b/JChat/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/JChat/bin/pad/prac2/MyServerSocket.class b/JChat/bin/pad/prac2/MyServerSocket.class new file mode 100644 index 0000000..ea4047a Binary files /dev/null and b/JChat/bin/pad/prac2/MyServerSocket.class differ diff --git a/JChat/bin/pad/prac2/MySocket.class b/JChat/bin/pad/prac2/MySocket.class new file mode 100644 index 0000000..efe075a Binary files /dev/null and b/JChat/bin/pad/prac2/MySocket.class differ diff --git a/JChat/src/pad/prac2/MyServerSocket.java b/JChat/src/pad/prac2/MyServerSocket.java new file mode 100644 index 0000000..0f6a2fe --- /dev/null +++ b/JChat/src/pad/prac2/MyServerSocket.java @@ -0,0 +1,5 @@ +package pad.prac2; + +public class MyServerSocket { + +} diff --git a/JChat/src/pad/prac2/MySocket.java b/JChat/src/pad/prac2/MySocket.java new file mode 100644 index 0000000..920a8f2 --- /dev/null +++ b/JChat/src/pad/prac2/MySocket.java @@ -0,0 +1,6 @@ +package pad.prac2; + +public class MySocket +{ + +} diff --git a/readline/bin/pad/prac1/Command.class b/readline/bin/pad/prac1/Command.class index 5e6a22b..5c8b189 100644 Binary files a/readline/bin/pad/prac1/Command.class and b/readline/bin/pad/prac1/Command.class differ diff --git a/readline/bin/pad/prac1/Console.class b/readline/bin/pad/prac1/Console.class index 0fd5a29..1877ab4 100644 Binary files a/readline/bin/pad/prac1/Console.class and b/readline/bin/pad/prac1/Console.class differ diff --git a/readline/bin/pad/prac1/Coordinate.class b/readline/bin/pad/prac1/Coordinate.class index 21285e1..2cf1281 100644 Binary files a/readline/bin/pad/prac1/Coordinate.class and b/readline/bin/pad/prac1/Coordinate.class differ diff --git a/readline/bin/pad/prac1/EditableBufferedReader.class b/readline/bin/pad/prac1/EditableBufferedReader.class index 1ecdac0..9ad8ed1 100644 Binary files a/readline/bin/pad/prac1/EditableBufferedReader.class and b/readline/bin/pad/prac1/EditableBufferedReader.class differ diff --git a/readline/bin/pad/prac1/Line.class b/readline/bin/pad/prac1/Line.class index 3de6175..58b6231 100644 Binary files a/readline/bin/pad/prac1/Line.class and b/readline/bin/pad/prac1/Line.class differ diff --git a/readline/src/pad/prac1/Console.java b/readline/src/pad/prac1/Console.java index feec07f..fd91168 100644 --- a/readline/src/pad/prac1/Console.java +++ b/readline/src/pad/prac1/Console.java @@ -22,7 +22,7 @@ public class Console implements Observer updateCurrentPos(); if(pos > currentPos) { - while((pos-currentPos) >= numCols) + while((currentXY.x()+(pos-currentPos)) > numCols) { currentPos += numCols - currentXY.x()+1; System.out.print((char)EditableBufferedReader.ESC); @@ -45,9 +45,6 @@ public class Console implements Observer } else if(pos < currentPos) { - System.err.println(currentPos); - System.err.println(pos); - System.err.println(currentXY); while((currentPos-pos) >= currentXY.x()) { currentPos -= currentXY.x(); diff --git a/readline/src/pad/prac1/EditableBufferedReader.java b/readline/src/pad/prac1/EditableBufferedReader.java index 3fcfe08..2d57b1e 100644 --- a/readline/src/pad/prac1/EditableBufferedReader.java +++ b/readline/src/pad/prac1/EditableBufferedReader.java @@ -140,9 +140,10 @@ public class EditableBufferedReader extends BufferedReader break; case EOF: - case RETURN_KEY: endOfFile = true; break; + + case RETURN_KEY: default: line.addChar((char)character); break; diff --git a/readline/src/pad/prac1/Line.java b/readline/src/pad/prac1/Line.java index 797baa8..e58f9d9 100644 --- a/readline/src/pad/prac1/Line.java +++ b/readline/src/pad/prac1/Line.java @@ -86,9 +86,13 @@ public class Line extends Observable public void addChar(char c) { - if(c == EditableBufferedReader.LINE_FEED) + if(c == EditableBufferedReader.RETURN_KEY) { + insertCharAt((char)EditableBufferedReader.LINE_FEED,cursorPosition-1); + sendCommand(Command.INSERT_CHAR,EditableBufferedReader.LINE_FEED); sendCommand(Command.INSERT_CHAR,EditableBufferedReader.RETURN_KEY); + cursorPosition++; + return; } switch(writeMode) { diff --git a/readline/src/pad/prac1/MainClass.java b/readline/src/pad/prac1/MainClass.java index 09ec8d6..73e4530 100644 --- a/readline/src/pad/prac1/MainClass.java +++ b/readline/src/pad/prac1/MainClass.java @@ -12,5 +12,15 @@ public class MainClass System.out.println("\nLine read: \n" + editable.readLine()); editable.close(); } - } + +/* + * TODO + * DETECT LINE LENGTH BEFORE PASSING ARGS TO LINE.SETCURSOR + * UP/DOWN cursor + * PGUP/PGDN + * INSERT NEWLINE IN A STRING (SPLITTING STRINGS) + * MOUSE SUPPORT + * FORM SUPPORT + */ + -- libgit2 0.22.2