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

Bracketed paste mode support #452

Closed
2 tasks done
exquo opened this issue Jan 13, 2021 · 1 comment
Closed
2 tasks done

Bracketed paste mode support #452

exquo opened this issue Jan 13, 2021 · 1 comment

Comments

@exquo
Copy link
Contributor

exquo commented Jan 13, 2021

Description:

When pasting multi-line clipboard contents into urwid, the newline symbols (\n) get reported as enter key presses.

Most terminal emulators now support the bracketed paste mode, which should allow urwid to distinguish between the Enter key presses and newlines in pasted text.

Affected versions
  • master branch (4c739b6be21b0c98324e7b7780d8e712f3ad6db3)
  • Latest stable version from pypi (2.1.2)
Steps to reproduce
import urwid
def unhandled_input(key):
    txt.set_text(' '.join([txt.text, repr(key)]))
txt = urwid.Text('pressed keys:')
fill = urwid.Filler(txt)
loop = urwid.MainLoop(fill, unhandled_input=unhandled_input)
loop.run()

(same idea: can use the Global Input example in urwid tutorial, or run input_test.py from examples)

Pasting (with e.g. Shift + Insert) into the terminal window where urwid is running a multi-line clipboard contents:

Ab
Cd

The output is

pressed keys: 'A' 'b' 'enter' 'C' 'd' 'enter'
Expected/actual outcome

Expected: pasted newline symbols are interpreted as \n "keys".
Actual: pasted newline symbols are interpreted as enter keys.

Related

Support bracketed paste mode escape sequences #119

@exquo
Copy link
Contributor Author

exquo commented Jan 13, 2021

An example of the kind of behavior that is expected: pasting the above multi-line contents into bash (with set enable-bracketed-paste on in ~/.inputrc) keeps the newline:

$ Ab
Cd

In sh (dash) the newline gets interpreted as Enter (same as in urwid currently):

$ Ab
Cd
sh: 49: Ab: not found
$ sh: 50: Cd: not found
$

@exquo exquo changed the title Pasting clipboard, newlines are interpreted as Enter key presses Bracketed paste mode support Jan 13, 2021
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