public void processOperation() throws IOException {
boolean attach = true;
try {
while(attach) {
CommandOperation operation = commandInvocation.getInput();
if(operation.getInputKey() == Key.q) {
attach = false;
}
else if( operation.getInputKey() == Key.ENTER) {
topVisibleRow = topVisibleRow + getNumber();
if(topVisibleRow > (page.size()-rows)) {
topVisibleRow = page.size()-rows;
if(topVisibleRow < 0)
topVisibleRow = 0;
display(Background.INVERSE);
attach = false;
}
else
display(Background.INVERSE);
clearNumber();
}
// ctrl-f || space
else if(operation.getInputKey() == Key.CTRL_F ||
operation.getInputKey() == Key.SPACE) {
topVisibleRow = topVisibleRow + rows*getNumber();
if(topVisibleRow > (page.size()-rows)) {
topVisibleRow = page.size()-rows;
if(topVisibleRow < 0)
topVisibleRow = 0;
display(Background.INVERSE);
attach = false;
}
else
display(Background.INVERSE);
clearNumber();
}
else if(operation.getInputKey() == Key.CTRL_B) { // ctrl-b
topVisibleRow = topVisibleRow - rows*getNumber();
if(topVisibleRow < 0)
topVisibleRow = 0;
display(Background.INVERSE);
clearNumber();
}
else if(Character.isDigit(operation.getInput()[0])) {
number.append(Character.getNumericValue(operation.getInput()[0]));
}
}
}
catch (InterruptedException ie) {
}