anchor.diff:                  Term: string
               }
   
  +        open ColoredString
  +
           type private LineEditorState =
               {
                   /// The text being edited.
  
positive.code:                         slot <- history.Length+slot;
                      if slot >= history.Length then
                          slot <- 0
                      if (history.Lines.[slot] <> null && history.Lines.[slot].IndexOf (term) <> -1) then
                          newCursor <- slot;
                          found <- true
  
  
negative.code:                         st
                      | Some(previousTerm) -> 
                          { st with SearchState = Some { search with Term = previousTerm } }
                              |> setSearchPrompt previousTerm
                              |> reverseSearch 
                  else
                      st |> reverseSearch
  
          let private cmdRefresh st =
              Console.Clear ()
              { st with MaxRendered = 0 }
                  |> render
                  |> forceCursor st.Cursor
  
          let private handlers =
              [|
                  new Handler (Command.Done, ConsoleKey.Enter,      cmdDone)
                  new Handler (Command.Home,ConsoleKey.Home,       cmdHome)
                  new Handler (Command.End,ConsoleKey.End,        cmdEnd)
                  new Handler (Command.Left,ConsoleKey.LeftArrow,  cmdLeft)
                  new Handler (Command.Right,ConsoleKey.RightArrow, cmdRight)
                  new Handler (Command.HistoryPrev,ConsoleKey.UpArrow,    cmdHistoryPrev)
                  new Handler (Command.HistoryNext,ConsoleKey.DownArrow,  cmdHistoryNext)
                  new Handler (Command.Backspace,ConsoleKey.Backspace,  cmdBackspace)
                  new Handler (Command.DeleteChar,ConsoleKey.Delete,     cmdDeleteChar)
                  new Handler (Command.TabOrComplete,ConsoleKey.Tab,        cmdTabOrComplete)
                  
                  // Emacs keys
                  Handler.Control Command.Home 'A' (cmdHome)
                  Handler.Control Command.End 'E' (cmdEnd)
                  Handler.Control Command.Left 'B' (cmdLeft)
                  Handler.Control Command.Right 'F' (cmdRight)
                  Handler.Control Command.HistoryPrev 'P' (cmdHistoryPrev)
                  Handler.Control Command.HistoryNext 'N' (cmdHistoryNext)
                  Handler.Control Command.CmdKillToEOF 'K' (cmdKillToEOF)
                  Handler.Control Command.Yank 'Y' (cmdYank)
                  Handler.Control Command.DeleteChar 'D' (cmdDeleteChar)
                  Handler.Control Command.Refresh 'L' (cmdRefresh)
                  Handler.Control Command.ReverseSearch 'R' (cmdReverseSearch)
                          
                  Handler.Alt Command.BackwardWord 'B' ConsoleKey.B (cmdBackwardWord)
                  Handler.Alt Command.ForwardWord 'F' ConsoleKey.F (cmdForwardWord)
                  
                  Handler.Alt Command.DeleteWord 'D' ConsoleKey.D (cmdDeleteWord)
                  Handler.Alt Command.DeleteBackword ((char)8) ConsoleKey.Backspace (cmdDeleteBackword)
                  
                  // DEBUG
                  //Handler.Control ('T', CmdDebug),
  
                  // quote
                  Handler.Control Command.Quote 'Q' (fun st -> st |> handleChar ((Console.ReadKey (true)).KeyChar))
              |]
  
          let private interruptEdit (thread:Thread) (sender:obj) (a:ConsoleCancelEventArgs) =
  