From cef7be6c25891b0d40a208486c3c3db9b7587a47 Mon Sep 17 00:00:00 2001 From: Mike Cifelli Date: Sun, 19 Mar 2017 17:32:44 -0400 Subject: [PATCH] Add comments to broken code --- src/terminal/LispTerminal.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/terminal/LispTerminal.java b/src/terminal/LispTerminal.java index 4667be8..a952254 100644 --- a/src/terminal/LispTerminal.java +++ b/src/terminal/LispTerminal.java @@ -26,6 +26,7 @@ public class LispTerminal { private boolean isFinished; public LispTerminal(IOSafeTerminal terminal, PipedOutputStream inputWriter, PipedInputStream outputReader) { + // FIXME - add resize handler this.terminal = terminal; this.inputWriter = inputWriter; this.outputReader = outputReader; @@ -136,11 +137,9 @@ public class LispTerminal { if (isAtStartOfRow(cursorPosition)) newPosition = cursorPosition.withColumn(terminal.getTerminalSize().getColumns()).withRelativeRow(-1); - + terminal.setCursorPosition(newPosition); - if (distanceFromOrigin(newPosition) == inputLine.length()) - leadingEdge = terminal.getCursorPosition(); } private boolean isAtStartOfRow(TerminalPosition cursorPosition) { @@ -163,9 +162,10 @@ public class LispTerminal { moveCursorToNextRow(cursorPosition); else terminal.setCursorPosition(cursorPosition.withRelativeColumn(1)); - + TerminalPosition newPosition = terminal.getCursorPosition(); + // FIXME - use distance from origin to set leading edge if (distanceFromOrigin(newPosition) == inputLine.length()) leadingEdge = terminal.getCursorPosition(); } @@ -225,6 +225,10 @@ public class LispTerminal { terminal.putCharacter(' '); retractCursor(cursorPosition); + + // FIXME - use distance from origin to set leading edge + if (distanceFromOrigin(leadingEdge) > inputLine.length()) + leadingEdge = terminal.getCursorPosition(); } } @@ -240,6 +244,10 @@ public class LispTerminal { terminal.putCharacter(' '); terminal.setCursorPosition(cursorPosition); + + // FIXME - use distance from origin to set leading edge + if (distanceFromOrigin(leadingEdge) > inputLine.length()) + leadingEdge = terminal.getCursorPosition(); } } @@ -251,6 +259,8 @@ public class LispTerminal { + inputLine.substring(distanceFromOrigin(cursorPosition), inputLine.length()); inputLine = inputLine.substring(0, distanceFromOrigin(cursorPosition)) + remaining; + // FIXME - must have a way to push remainder on to a new line at the end of the buffer + for (char c : remaining.toCharArray()) terminal.putCharacter(c);