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

User input #64

Open
joshuafocht opened this issue Nov 27, 2024 · 9 comments
Open

User input #64

joshuafocht opened this issue Nov 27, 2024 · 9 comments

Comments

@joshuafocht
Copy link

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

@lpil
Copy link
Member

lpil commented Nov 28, 2024

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?

@joshuafocht
Copy link
Author

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

@joshuafocht
Copy link
Author

joshuafocht commented Dec 3, 2024

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

@lpil
Copy link
Member

lpil commented Dec 4, 2024

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

@joshuafocht
Copy link
Author

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.

@lpil
Copy link
Member

lpil commented Dec 6, 2024

Could you try in Erlang after running these please

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

@joshuafocht
Copy link
Author

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

@lpil
Copy link
Member

lpil commented Dec 9, 2024

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

@joshuafocht
Copy link
Author

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

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

2 participants