anchor.diff:  type internal Anchor =
       {top:int; left:int}
       static member Current(inset) = {top=Console.CursorTop;left= max inset Console.CursorLeft}
  -
  +    static member Top(inset) = {top = 0; left = inset}
       member p.PlaceAt(inset, index) =
           //printf "p.top = %d, p.left = %d, inset = %d, index = %d\n" p.top p.left inset index
           let left = inset + (( (p.left - inset) + index) % (Console.BufferWidth - inset))
           let top = p.top + ( (p.left - inset) + index) / (Console.BufferWidth - inset)
           Cursor.ResetTo(top,left)
  +
  +
   
   type internal ReadLineConsole() =
       let history = new History()
  
positive.code:                 setInput String.Empty
                  change()
              | ConsoleKey.Home ->
                  current <- 0
                  anchor.PlaceAt(x.Inset,0)
                  change()
              | ConsoleKey.End ->
                  current <- input.Length
                  anchor.PlaceAt(x.Inset,rendered)
                  change()
              | _ ->
              match (key.Modifiers, key.KeyChar) with
              // Control-A
              | (ConsoleModifiers.Control, '\001') ->
                  current <- 0
                  anchor.PlaceAt(x.Inset,0)
                  change ()
              // Control-E
              | (ConsoleModifiers.Control, '\005') ->
                  current <-input.Length
                  anchor.PlaceAt(x.Inset,rendered)
                  change ()
              // Control-B
              | (ConsoleModifiers.Control, '\002') ->
                  moveLeft()
                  change ()
              // Control-f
              | (ConsoleModifiers.Control, '\006') ->
                  moveRight()
                  change ()
              // Control-k delete to end of line
              | (ConsoleModifiers.Control, '\011') ->
                  deleteToEndOfLine()
                  change()
              // Control-P
              | (ConsoleModifiers.Control, '\016') ->
                  setInput(history.Previous())
                  change()
              // Control-n
              | (ConsoleModifiers.Control, '\014') ->
                  setInput(history.Next())
                  change()
              // Control-d
              | (ConsoleModifiers.Control, '\004') ->
                  if (input.Length = 0) then
                      exit 0 //quit
                  else
                      delete()
                      change()
              | _ ->
                  // Note: If KeyChar=0, the not a proper char, e.g. it could be part of a multi key-press character,
                  //       e.g. e-acute is ' and e with the French (Belgium) IME and US Intl KB.
  
negative.code:             let c = if (key.Key = ConsoleKey.F6) then '\x1A' else key.KeyChar
              let c = ConsoleOptions.readKeyFixup c
              insertChar(c)
              
          let backspace() =
              if (input.Length > 0 && current > 0) then
                  input.Remove(current - 1, 1) |> ignore
                  current <- current - 1
                  render()
          let enter() = 
              Console.Write("\n")
              let line = input.ToString()
              if (line = "\x1A") then null
              else 
                  if (line.Length > 0) then 
                      history.AddLast(line)
                  line
          let clear() = 
              current <- input.Length
              let setPrompt prompt = 
                  if prompt then // We only allow clearing if prompt is ">"
                      Console.Clear()
                      Console.Write (x.Prompt)
                      Console.Write(input.ToString())
                      anchor <- Anchor.Top(x.Inset)   
              let previous = history.Previous()
              history.Next() |> ignore
              if previous = "" then
                  setPrompt true
              else
                  setPrompt (previous.EndsWith(";;"))
  
              
          let home() =
              current <- 0
              anchor.PlaceAt(x.Inset,0)
          let rec read() = 
              let key = Console.ReadKey true
  
              match key.Key with
  