[Bug]: Toolbar text input Enter (send) uses session.write() instead of emulator.paste() bypassing DECSET 2004
Problem description
I'm not sure whether the use of session.write() here is intentional or a bug.
When entering text through the toolbar text input and send ( Enter), the text is sent to the terminal using session.write()
The toolbar text input is intended as an alternative input method for Android's IME composed text. For this composed text, especially long text, it seems more appropriate to use paste semantics rather than treating the entire contents as raw keyboard input.
Using session.write() bypasses TerminalEmulator.paste(), and therefore does not honor Bracketed Paste Mode (DECSET 2004).
Other Termux paste entry points, like long press paste, route the text through TerminalEmulator.paste()
Toolbar text input text is delivered as raw input without the bracketed paste sequences:
\033[200~ ...text... \033[201~
Applications that process input and redraw on each character can therefore receive and process the text "character by character".
There is input delay due to streaming of letters, particularly in some reactive or component based TUIs.
Lighter TUI applications like lazygit may show the same behavior without an obvious performance impact but heavier ones like Antigravity CLI have noticable delay/wait time.
I don't see an obvious benefit (if any, then please let me know) to treating the entire contents of the toolbar text box as raw keyboard input instead of pasted text. The empty input case can still be handled separately so that pressing send with no text retains normal "Enter" semantics.
Proposed Fix:
Use session.getEmulator().paste() for non empty toolbar text while retaining session.write("\r") for an empty submission:
In app/src/main/java/com/termux/app/terminal/io/TerminalToolbarViewPager.java
if (textToSend.length() == 0) {
session.write("\r");
} else {
session.getEmulator().paste(textToSend);
}
Steps to reproduce the behavior.
Run a terminal application that enables Bracketed Paste Mode (DECSET 2004).
Open the Termux toolbar text input by swiping left on the bottom toolbar.
Enter a long text.
Send (Enter)
Compare the result with entering the same text using long press paste.
What is the expected behavior?
Non empty text submitted from the toolbar text input field should have the same semantics as other paste operations:
session.getEmulator().paste(textToSend)
When DECSET 2004 is enabled, the text should be delivered as a bracketed paste, rather than as individual keyboard input.
When bracketed paste mode is disabled, behavior remain unchanged.
For an empty text field, pressing send (Enter) should continue to send a raw carriage return:
session.write("\r")
System information
- Termux application version: 0.118.3
Source: termux/termux-app