From 9927436cc355eb09675bcd6dd026a984c6ba9309 Mon Sep 17 00:00:00 2001 From: Jacob McDonnell Date: Thu, 13 Jan 2022 18:39:09 -0500 Subject: Added previous, next, and last line commands --- src/jed.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/jed.java') diff --git a/src/jed.java b/src/jed.java index 3aae502..3f2056c 100644 --- a/src/jed.java +++ b/src/jed.java @@ -18,7 +18,9 @@ public class jed { file = new filebuffer(fileName, hasName); + /* Main command prompt */ while (true) { + System.out.print("> "); String line = kbIn.nextLine(); int err = parser(line); if (err == 1) @@ -32,7 +34,6 @@ public class jed { int err = 0; if (isNum(cmd)) { file.changeCurrentLine(Integer.parseInt(cmd) - 1); - System.out.printf("%d %s\n", file.getCurrentLine() + 1, file.getLine(file.getCurrentLine())); } else { char c = cmd.charAt(0); switch (c) { @@ -89,6 +90,21 @@ public class jed { case 'h': // help command help(); break; + case '^': case '-': // previous line command + if ((file.getCurrentLine() - 1) > -1) + file.changeCurrentLine((file.getCurrentLine() - 1)); + else + System.out.println("?"); + break; + case '+': // Next line command + if ((file.getCurrentLine() + 1) <= file.getFileSize()) + file.changeCurrentLine((file.getCurrentLine() + 1)); + else + System.out.println("?"); + break; + case '$': // Last line command + file.changeCurrentLine(file.getFileSize() - 1); + break; default: System.out.println("?"); break; -- cgit v1.2.3