}
}
Operation operation = currentOperation.getOperation();
Action workingMode = currentOperation.getWorkingMode();
//if ctrl-d is pressed on an empty line we update the eofCounter
// if eofCounter > ignoreEof we send EXIT operation, else NO_ACTION
//if buffer is not empty, we send a NEW_LINE
if(operation == Operation.EOF) {
if(buffer.isEmpty()) {
checkEof();
eofCounter++;
if(eofCounter > ignoreEof)
return operation;
else
return Operation.IGNOREEOF;
}
else
return Operation.NEW_LINE;
}
if(operation == Operation.NEW_LINE) {
mode = Action.EDIT; //set to edit after a newline
return Operation.NEW_LINE;
}
else if(operation == Operation.REPLACE && !isInEditMode()) {
mode = Action.REPLACE;
return Operation.NO_ACTION;
}
else if(operation == Operation.DELETE_PREV_CHAR && workingMode == Action.NO_ACTION) {
if(isInEditMode())
return Operation.DELETE_PREV_CHAR;
else
return Operation.MOVE_PREV_CHAR;
}
else if(operation == Operation.DELETE_NEXT_CHAR && workingMode == Action.COMMAND) {
if(isInEditMode())
return Operation.NO_ACTION;
else
return saveAction(Operation.DELETE_NEXT_CHAR);
}
else if(operation == Operation.COMPLETE) {
if(isInEditMode())
return Operation.COMPLETE;
else
return Operation.NO_ACTION;
}
else if(operation == Operation.ESCAPE) {
if(isInEditMode()) {
mode = Action.MOVE;
return Operation.MOVE_PREV_CHAR;
}
else {
mode = Action.MOVE;
return Operation.NO_ACTION;
}
}
else if (operation == Operation.SEARCH_PREV) {
mode = Action.SEARCH;
return Operation.SEARCH_PREV;
}
else if(operation == Operation.CLEAR)
return Operation.CLEAR;
//make sure that this only works for working more == Action.EDIT
else if(operation == Operation.MOVE_PREV_CHAR && workingMode.equals(Action.EDIT))
return Operation.MOVE_PREV_CHAR;
else if(operation == Operation.MOVE_NEXT_CHAR && workingMode.equals(Action.EDIT))
return Operation.MOVE_NEXT_CHAR;
else if(operation == Operation.HISTORY_PREV && workingMode.equals(Action.EDIT))
return operation;
else if(operation == Operation.HISTORY_NEXT && workingMode.equals(Action.EDIT))
return operation;
else if(operation == Operation.MOVE_BEGINNING && workingMode.equals(Action.EDIT)) //home
return operation;
else if(operation == Operation.MOVE_END && workingMode.equals(Action.EDIT)) //end
return operation;
//pgup / pgdown
else if(operation == Operation.PGDOWN || operation == Operation.PGUP)
return Operation.NO_ACTION;