Skip to content
Snippets Groups Projects
Commit 2ae76299 authored by Ludovic Apvrille's avatar Ludovic Apvrille
Browse files

Test on DEL

parent 59749730
No related branches found
No related tags found
No related merge requests found
...@@ -212,7 +212,7 @@ public class Terminal { ...@@ -212,7 +212,7 @@ public class Terminal {
//BACKSPACE //BACKSPACE
if ((val == BACKSPACE) || (val == DEL)) { if ((val == BACKSPACE) || (val == DEL)) {
currentBuf = del(currentBuf); currentBuf = del(currentBuf);
//TAB //TAB
} else if (val == TAB) { } else if (val == TAB) {
...@@ -232,8 +232,13 @@ public class Terminal { ...@@ -232,8 +232,13 @@ public class Terminal {
currentBuf += x; currentBuf += x;
} else { } else {
//System.out.println("Tricky cursor position"); //System.out.println("Tricky cursor position");
int sep = currentBuf.length()- cursorPosition;
currentBuf = currentBuf.substring(0,cursorPosition-1) + x + currentBuf.substring(cursorPosition, currentBuf.length()); currentBuf = currentBuf.substring(0,cursorPosition-1) + x + currentBuf.substring(cursorPosition, currentBuf.length());
myPrint("" + x + currentBuf.substring(cursorPosition, currentBuf.length())); myPrint("" + x + currentBuf.substring(cursorPosition, currentBuf.length()));
// Must move cursor to previous psition + 1
for(int i=0; i<sep; i++) {
backwardCode();
}
} }
cursorPosition ++; cursorPosition ++;
...@@ -308,10 +313,14 @@ public class Terminal { ...@@ -308,10 +313,14 @@ public class Terminal {
if (cursorPosition == 0) { if (cursorPosition == 0) {
return; return;
} }
System.out.print("\033[1D"); backwardCode();
cursorPosition --; cursorPosition --;
} }
private void backwardCode() {
System.out.print("\033[1D");
}
private void forward(String currentBuf) { private void forward(String currentBuf) {
if (cursorPosition == currentBuf.length()) { if (cursorPosition == currentBuf.length()) {
return ; return ;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment