Reviewed by Tim H.
authorthatcher <thatcher@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Oct 2006 18:37:48 +0000 (18:37 +0000)
committerthatcher <thatcher@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Oct 2006 18:37:48 +0000 (18:37 +0000)
        Added a bash-style command history.

        * Drosera/console.js:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16781 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKitTools/ChangeLog
WebKitTools/Drosera/console.js

index 19d8ec0a1f3a605f121460279fc8578979b15a5d..495041253583788667c5612901f2dc5a6ea8b532 100644 (file)
@@ -1,3 +1,11 @@
+2006-10-04  David Smith  <catfish.man@gmail.com>
+
+        Reviewed by Tim H.
+
+        Added a bash-style command history.
+
+        * Drosera/console.js:
+
 2006-10-03  Anders Carlsson  <acarlsson@apple.com>
 
         Reviewed by Adam and Brady.
index 89a7458d3b708fd354b15b73113232ff2947d9c5..f1707690d5d4639e682e99946aae3f5cfee2eb23 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2006 David Smith (catfish.man@gmail.com)
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -28,6 +29,8 @@
 
 var inputElement = null;
 var mainWindow = window.opener;
+var historyIndex = -1;
+var storedInput = null;
 
 function loaded()
 {
@@ -46,6 +49,29 @@ function inputKeyDown(event)
         } else
             alert("The debugger needs to be paused.\tIn order to evaluate your script input you need to pause the debugger in the context of another script.");
         event.preventDefault();
+    } else if (event.keyCode == 38 && !event.altKey) {
+        var history = document.getElementById("history");
+        if(historyIndex == -1)
+            storedInput = inputElement.innerText;
+        var historyArray = history.childNodes;
+        var historySize = historyArray.length - 1;
+        if(historyIndex < historySize) {
+            historyIndex++;
+            inputElement.innerText = historyArray[historySize - historyIndex].childNodes[0].innerText;
+        }
+        event.preventDefault();
+    } else if (event.keyCode == 40 && !event.altKey) {
+        if(historyIndex >= 0) {
+            var history = document.getElementById("history");
+            historyIndex--;
+            if (historyIndex == -1)
+                inputElement.innerText = storedInput;
+            else {
+                var historyArray = history.childNodes;
+                inputElement.innerText = historyArray[(historyArray.length - 1) - historyIndex].childNodes[0].innerText;
+            }
+        }
+        event.preventDefault();
     }
 }