lambda-term icon indicating copy to clipboard operation
lambda-term copied to clipboard

Backspace in raw mode

Open Piervit opened this issue 7 years ago • 3 comments

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 ())


Piervit avatar Jan 18 '18 06:01 Piervit

Hum, I have confess that running from a non graphic terminal, the backspace is matched. So it is only in my GUI (xfce) but still, backspace works for other programs.

Piervit avatar Jan 18 '18 07:01 Piervit

Hi, I admit that I'm not working much on lambda term these days. notty looks more active, have you tried it?

ghost avatar Jan 18 '18 12:01 ghost

Ok, I add some times to look back at the issue: well I remarked that on some GUI terminals it was working while on others not. Then I have seen that xfce terminal had different compatibility mode for backspace (quickly translated from french):

  • automatic detection
  • escape sequence
  • CTRL-H
  • Escape TTY

So there is no trivial bugs in lambda-term, some terms just map backspace to CTRL-H... I am not sure lambda-term should do something for this, because when you are stuck in it... It is a big loss of time.

Piervit avatar Mar 24 '18 09:03 Piervit