*
* The MIT License (MIT)
*
- * Copyright (C) 2016 Kevin Lamonte
+ * Copyright (C) 2017 Kevin Lamonte
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
}
/**
- * Update the cursor position.
+ * Update the visible cursor position to match the location of position
+ * and windowStart.
*/
protected void updateCursor() {
if ((position > getWidth()) && fixed) {
}
}
+ /**
+ * Normalize windowStart such that most of the field data if visible.
+ */
+ protected void normalizeWindowStart() {
+ if (fixed) {
+ // windowStart had better be zero, there is nothing to do here.
+ assert (windowStart == 0);
+ return;
+ }
+ windowStart = position - (getWidth() - 1);
+ if (windowStart < 0) {
+ windowStart = 0;
+ }
+
+ updateCursor();
+ }
+
/**
* Handle mouse button presses.
*
windowStart--;
}
}
+ normalizeWindowStart();
return;
}
text = text.substring(0, position)
+ text.substring(position + 1);
}
+ dispatch(false);
return;
}
}
}
dispatch(false);
+ normalizeWindowStart();
return;
}