diff --git a/ghci.html b/ghci.html index aef9a10..01f55e3 100644 --- a/ghci.html +++ b/ghci.html @@ -18,6 +18,9 @@ + +

HIJi

+

Bringing you the power of GHCI to the interwebs

diff --git a/haskell.hiji.js b/haskell.hiji.js index 1296864..53eb622 100644 --- a/haskell.hiji.js +++ b/haskell.hiji.js @@ -13,17 +13,39 @@ }; var makeInput = function(modules){ - return "
  • " + makeModules(modules) + "
  • "; + return "
  • " + makeModules(modules) + "
  • "; }; var makeOutput = function(output) { console.log("%o", output); return $("
  • ").text(output.ast.toString()); }; + $.fn.startHiji = function() { var modules = new Array(); + var hist = new Array(); + + // history + var hiss = new historry; + modules[0] = "Prelude"; modules[1] = "Control.Monad"; this.html("
      " + makeInput(modules) + "
    "); + + + // pressing keyUP and keyDown + // history-related + document.onkeydown = function(e){ + var input = $('input', this); + var line = input.attr("value"); + // keyUp + if(e.keyCode=='38'){ + input.attr("value", hiss.older()); + } + if(e.keyCode=='40'){ + input.attr("value", hiss.newer()); + } + } + this.keypress(function(e){ if (e.keyCode=='13'){ var input = $('input', this); @@ -33,7 +55,38 @@ var output = makeOutput(evaluateHaskell(line,{})); $('.input', this).after(output).replaceWith(newLine); $("ol",this).append(makeInput(modules)); + + hiss.addHistory(line); } }); }; -})(jQuery); \ No newline at end of file +})(jQuery); + + +// historry-class with nice name +// !!!WARNING!!! NICE NAME +historry = function (){ + this.pointer = 0; + this.history_array = new Array(); + this.addHistory = function(input){ + this.history_array.unshift(input); + this.pointer = -1; + }; + + this.older = function(){ + this.pointer++; + if(this.pointer >= this.history_array.length){ + this.pointer = this.history_array.length-1 + } + return this.history_array[this.pointer]; + }; + + this.newer = function(){ + this.pointer--; + if(this.pointer < 0){ + this.pointer = 0 + return ""; + } + return this.history_array[this.pointer]; + }; +}; diff --git a/hiji.css b/hiji.css index a1328a8..b1ec22d 100644 --- a/hiji.css +++ b/hiji.css @@ -11,15 +11,21 @@ .ghci-look ol{ width:800px; height:400px; + background-color: #000; overflow-x:auto; overflow-y:scroll; list-style-type:none; + + color: #fff; } .ghci-look .input input { border:none; display:inline-block; margin-left:-1px; + background-color: #000; + + color: #fff; } .ghci-look .modules { @@ -38,4 +44,4 @@ .ghci-look .modules:after { content:">"; padding-right:0.5em; -} \ No newline at end of file +}