-
Notifications
You must be signed in to change notification settings - Fork 213
Description
Feature Request: Bracket Paste Mode Support
Overview
We would like to use bracket paste mode support in terminal-kit to handle large multi-line paste operations efficiently. Bracket paste mode is a standard terminal feature where pasted content is wrapped in escape sequences:
- Start:
\x1b[200~ - Content: (pasted text)
- End:
\x1b[201~
Proposed Implementation
We considered the following keymap entry:
term.keymap.PASTE = {
starter: '\x1b[200~',
ender: '\x1b[201~',
accumulate: true,
handler: (name, content) => ({
eaten: 0,
name: 'PASTE',
data: { content }
}),
event: 'key'
}Problem
The current pattern-matching implementation in Terminal.js (lines 1207-1217) uses a hardcoded character class that only matches ASCII printable characters:
regexp = '^' +
string.escape.regExp( keymap.starter ) +
'([ -~]*?)' + // [ -~] match only all ASCII non-control character
string.escape.regExp( keymap.ender ) ;The pattern [ -~]*? matches characters from space (0x20) to tilde (0x7E), which excludes:
- Newlines (
\n, 0x0A) - Carriage returns (
\r, 0x0D) - Tabs (
\t, 0x09) - Other control characters
- Unicode characters outside ASCII range
This prevents bracket paste mode from working with multi-line content or content containing tabs and other
control characters.
Question
@cronvel What would be an appropriate pattern to match content between starter/ender delimiters that includes:
- Newlines and carriage returns
- Tab characters
- Control characters
- Unicode content
- Any character except the ender sequence itself
Would something like (.*?) be acceptable, or is there a reason the current implementation restricts to printable ASCII?
Thank you for maintaining this excellent library.
-Eric