diff --git a/lovebird.lua b/lovebird.lua
index a7ac4a0..aa6eac6 100644
--- a/lovebird.lua
+++ b/lovebird.lua
@@ -159,7 +159,9 @@ end
-
@@ -206,10 +208,34 @@ end
var req = new XMLHttpRequest();
req.open("POST", "/", true);
req.send("input=" + encodeURIComponent(b.value));
+ /* Do input history */
+ if (b.value && inputHistory[0] != b.value) {
+ inputHistory.unshift(b.value);
+ }
+ inputHistory.index = -1;
+ /* Reset */
b.value = "";
refreshOutput();
}
+ /* Input box history */
+ var inputHistory = [];
+ inputHistory.index = 0;
+ var onInputKeyDown = function(e) {
+ var key = e.which || e.keyCode;
+ var b = document.getElementById("inputbox");
+ if (key == 38 && inputHistory.index < inputHistory.length - 1) {
+ /* Up key */
+ inputHistory.index++;
+ b.value = inputHistory[inputHistory.index];
+ }
+ if (key == 40 && inputHistory.index >= 0) {
+ /* Down key */
+ inputHistory.index--;
+ b.value = inputHistory[inputHistory.index] || "";
+ }
+ }
+
/* Output buffer and status */
var refreshOutput = function() {
geturl("/buffer", function(text) {