Skip to content

Backspace in raw mode #57

Open
Open
@Piervit

Description

Hello,

I am playing with lambda-term(thanks) : version: 1.12.0 .
I have created a test program, I have a problem with the Backspace keyboard in raw mode: it appears it is not mapped to the correct key.

Running a LTerm_key.to_string show me the following result when I press the backspace key:

{ control = true; meta = false; shift = false; code = Char 0x68 }

For the other keys, it works well.
I use a "PC generic 105 keys", I got the bug with both a french or US international keyboard binding.

Thank you for lambda-term.

Here is the test program:

open Lwt
open Printf
open LTerm_key

exception ExitTerm of (LTerm.t * LTerm.mode)

let rec loop term history tmod =
  Lwt.catch (fun () -> (LTerm.read_event term)
    >>= fun event -> 
      match event with 
        | Key akey ->
            (** A key has been pressed. *)
                  (match akey.LTerm_key.code with
                    | Escape -> Lwt.fail (ExitTerm (term,tmod))
                    | _ -> 
                        LTerm.fprints term (LTerm_text.eval [S (sprintf "%s\n" (LTerm_key.to_string akey))]) >>= 
                        (fun () -> loop term history tmod )
                  )
        | _ -> 
                loop term history tmod 
  )
    (function
      | exn -> Lwt.fail exn)
 

let main () =
  LTerm_inputrc.load ()
  >>= fun () ->
  (Lwt.catch
    (fun () ->
       Lazy.force LTerm.stdout
       >>= fun term ->
       LTerm.enter_raw_mode term >>=
         (fun tmod -> loop term (LTerm_history.create []) tmod )
    )
    (function
      | ExitTerm (term, tmod) -> LTerm.leave_raw_mode term tmod 
      | exn -> Lwt.fail exn)
  )

let () = Lwt_main.run (main ())


Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions