* @param cursor the new cursor position
*/
public void setCursor(final int cursor) {
- lines.get(lineNumber).setCursor(cursor);
+ if (cursor >= lines.get(lineNumber).getDisplayLength()) {
+ lines.get(lineNumber).end();
+ } else {
+ lines.get(lineNumber).setCursor(cursor);
+ }
}
/**
if (lineNumber < lines.size() - 1) {
int x = lines.get(lineNumber).getCursor();
lineNumber++;
- if (x > lines.get(lineNumber).getDisplayLength()) {
+ if (x >= lines.get(lineNumber).getDisplayLength()) {
lines.get(lineNumber).end();
} else {
lines.get(lineNumber).setCursor(x);
if (lineNumber > lines.size() - 1) {
lineNumber = lines.size() - 1;
}
- if (x > lines.get(lineNumber).getDisplayLength()) {
+ if (x >= lines.get(lineNumber).getDisplayLength()) {
lines.get(lineNumber).end();
} else {
lines.get(lineNumber).setCursor(x);
if (lineNumber > 0) {
int x = lines.get(lineNumber).getCursor();
lineNumber--;
- if (x > lines.get(lineNumber).getDisplayLength()) {
+ if (x >= lines.get(lineNumber).getDisplayLength()) {
lines.get(lineNumber).end();
} else {
lines.get(lineNumber).setCursor(x);
if (lineNumber < 0) {
lineNumber = 0;
}
- if (x > lines.get(lineNumber).getDisplayLength()) {
+ if (x >= lines.get(lineNumber).getDisplayLength()) {
lines.get(lineNumber).end();
} else {
lines.get(lineNumber).setCursor(x);