Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backspace in raw mode #57

Open
Piervit opened this issue Jan 18, 2018 · 3 comments
Open

Backspace in raw mode #57

Piervit opened this issue Jan 18, 2018 · 3 comments

Comments

@Piervit
Copy link

Piervit commented Jan 18, 2018

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
Copy link
Author

Piervit commented Jan 18, 2018

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.

@ghost
Copy link

ghost commented Jan 18, 2018

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

@Piervit
Copy link
Author

Piervit commented Mar 24, 2018

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 pushed a commit to Piervit/gufo that referenced this issue Mar 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant