forked from xtermjs/xterm.js
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support to ANSI OSC52 sequence to manipulate selection and clipboard data. The sequence specs supports multiple selections but due to the browser limitations (Clipboard API), this PR only supports manipulating the clipboard selection. This adds a new event listener to the terminal `onClipboard` to allow other external implementations to hook into it. The browser uses a clipboard service that use the Clipboard API to read/write from and to the clipboard. Reference: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands Fixes: xtermjs#3260 Signed-off-by: Ayman Bagabas <ayman.bagabas@gmail.com>
- Loading branch information
1 parent
53f8d91
commit 3aac12c
Showing
13 changed files
with
293 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Copyright (c) 2022 The xterm.js authors. All rights reserved. | ||
* @license MIT | ||
*/ | ||
|
||
/** | ||
* Decode base64 encoded string to UTF-8 string. | ||
* @param data The base64 string to decode. | ||
* @returns The decoded base64 string. | ||
*/ | ||
export const decode = (data: string): string => { | ||
try { | ||
return typeof atob !== 'undefined' ? | ||
atob(data) : | ||
Buffer.from(data, 'base64').toString(); | ||
} catch { | ||
return ''; | ||
} | ||
}; | ||
|
||
/** | ||
* Encode UTF-8 string to base64 encoded string. | ||
* @param data The string to encode. | ||
* @returns The base64 encoded string. | ||
*/ | ||
export const encode = (data: string): string => { | ||
try { | ||
return typeof btoa !== 'undefined' ? | ||
btoa(data) : | ||
Buffer.from(data, 'binary').toString('base64'); | ||
} catch { | ||
return ''; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.