erlang icon indicating copy to clipboard operation
erlang copied to clipboard

User input

Open joshuafocht opened this issue 1 year ago • 9 comments

When using erlang.get_line() and you press backspace it deletes the last word not the last character. Here is my code:

import gleam/io
import gleam/string
import gleam/erlang

pub fn main() {
  case erlang.get_line("What is you name? ") {
    Ok(name) -> io.println("Hello, " <> string.trim(name) <> "!")
    Error(_) -> io.println("Something went wrong")
  }
}

And here is a screen recording: https://github.com/user-attachments/assets/b2f273e7-fa27-49a3-8c04-e7881583d519

joshuafocht avatar Nov 27 '24 19:11 joshuafocht

This library does not implement that function, it is part of Erlang, so we may not be able to help. The Erlang forums may be the place to ask. https://erlangforums.com/

Does it happen if you call it from the Erlang shell or an Erlang program?

lpil avatar Nov 28 '24 11:11 lpil

Sorry that I didn't see your comment till now. It does not happen when calling from erlang or the erlang shell.

joshuafocht avatar Dec 03 '24 18:12 joshuafocht

Another thing I forgot to mention, it only happens on windows, so it might have something to do with CRLF.

joshuafocht avatar Dec 03 '24 18:12 joshuafocht

Does it only happen when using get_line? Does it happen when using gleam export erlang-shipment?

lpil avatar Dec 04 '24 13:12 lpil

Does it only happen when using get_line?

I have only tried get_line. Is there an alternative?

Does it happen when using gleam export erlang-shipment?

I just tried that, and it still happens.

joshuafocht avatar Dec 05 '24 19:12 joshuafocht

Could you try in Erlang after running these please

    io:setopts(standard_io, [binary, {encoding, utf8}]),
    io:setopts(standard_error, [{encoding, utf8}]).

lpil avatar Dec 06 '24 00:12 lpil

I have just tried that, and it still works in erlang.

joshuafocht avatar Dec 09 '24 21:12 joshuafocht

I'm confused as I can't think of anything that differs between the working erl scenario and the not working shipment scenario.

lpil avatar Dec 09 '24 22:12 lpil

I think it has something to do with windows because it only happens there.

joshuafocht avatar Dec 17 '24 16:12 joshuafocht