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

Inconsistent number of newlines produced by \n in key_sequence #239

Open
ChaiTRex opened this issue Oct 27, 2023 · 1 comment
Open

Inconsistent number of newlines produced by \n in key_sequence #239

ChaiTRex opened this issue Oct 27, 2023 · 1 comment

Comments

@ChaiTRex
Copy link

ChaiTRex commented Oct 27, 2023

Describe the bug
On X11, the number of newlines produced by the code below differs between GNOME Terminal 3.44.0 and gedit 41.0.

To Reproduce
The following code produces four newlines on GNOME Terminal and zero newlines on gedit:

Enigo::new().key_sequence("test\n\n\n\n");

The following code produces two newlines on GNOME Terminal and one newline on gedit:

Enigo::new().key_sequence("test\r\n");

Expected behavior
An \n in key_sequence should produce exactly one newline, regardless of application.

Environment (please complete the following information):

  • OS: Linux (Pop!_OS 22.04)
  • Rust: rustc 1.73.0 (cc66ad468 2023-10-03) and rustc 1.75.0-nightly (1c05d50c8 2023-10-21)
  • Library: enigo 0.1.3
  • X11: X.Org version: 1.21.1.4
@acrinklaw
Copy link

acrinklaw commented Jan 13, 2024

I did some debugging with xev and noticed that Enigo is using 0x0a for newline, while other libraries (like PyAutoGUI for example) use 0x0d for carriage return to simulate the newline when you call for it.

So it seems like an application specific interpretation of 0x0a, which seems to be the right behavior. But if you really wanted it to work as expected you'd have to force it to use 0x0d. VSCode / terminal are totally cool with 0x0a but Gedit/Kate/Libreoffice won't produce anything.

If you printf '\x0a' into a text file and open it with Gedit the newline doesn't appear but if you open it in vscode or with cat you see the new line. Not sure why this application specific interpretation is the way it is

@pentamassiv pentamassiv added the Linux Linux spedific label Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants