-
-
Notifications
You must be signed in to change notification settings - Fork 140
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
Add far2l terminal extensions support #74
Comments
Hi @cyd01 , This functionality seems interesting. Can you check it? |
There is also competing clipboard access method for terminals, it is used in linux port of Far Manager (https://github.com/elfmz/far2l), so called "far2l terminal extensions", but those are completely undocumented and not very popular outside far2l (only one external supporting client is known for now, https://github.com/unxed/putty4far2l). Those extensions provide not only clipboard but also full keyboard support (keyup/keydown, all modifiers, etc). Still I (as the author of putty4far2l) can try to document them if someone is interested. |
Would be nice to be able to interact with the clipboard from the terminal. I expect there is a little chance the requested documentation for "far2l terminal extensions" will surface. The OSC-52 code from the kovidgoyal/kitty seem to be available here: |
Protocol is very simple, but to explain it, I need to digg into the code I wrote a half a year ago. Will try to find some time for it. Maybe it is reasonable to start right now and add some little pieces from time to time, so let's go :) First of all. Far2l extensions use APC (Application Program Command) escape sequences, so all of them starts with "\x1b_". Next goes sequence header (string "far2l0" or "far2l1" or "far2l:" for server->client sequences, "far2l" or "f2l" for client->server sequences - shorter "f2l" version is used for input events to save traffic). After it goes actual payload that is stack-like structure [VARIABLE1][VARIABLE2][VARIABLE3] etc, encoded in base64 format (exceptions for server->client communication are "far2l0" and "far2l1" that have no payload at all, client->server "far2lok" has no payload also). Each sequence is finished with "\x07". When far2l is launched on the server side, it tries to turn on special "far2l extensions" mode on client (in this mode keyboard keys and mouse events should be sent as far2l sequences and not in common way) by sending "\x1b_far2l1\x07". Client should reply with "\x1b_far2lok\x07", this means far2l mode is supported and turned on. If client receives "\x1b_far2l0\x07", that means it should turn extensions mode off and send keyboard and mouse events as usual. All other server-to-client sequences starts with "\x1b_far2l:", and there are several types of them (event type is always last variable in payload stack for such sequences): "n" - show desktop notification, "w" - get largest console window size, "c" - clipboard interaction, etc. Will explain each of those sequence types and also client-to-server sequences in further comments. Please remind several days later! Also @elfmz, far2l author, is welcomed to help with documenting this :) UPD: Original implementation, terminal part: |
Trying to document far2l terminal extensions, part II Virtual terminal -> console application (client -> server) events:
KeyDown event's message payload consists of the following variables: RepeatCount: 2 bytes, pressed key repeat count as defined in KEY_EVENT_RECORD struct There is special case with keys VK_TAB, VK_BACK, VK_ESCAPE, VK_DELETE. Example 1, "t" key down. RepeatCount = 1 base64-encoded message: AQBUABQAAAAAAHQAAABL Example 2, Ctrl+ArrowUp keys down. RepeatCount = 1 base64-encoded message: AQAmAEgACAAAAAAAAABL Example of how to construct corresponding message in windows WM_KEYUP/WM_KEYDOWN handler can be found here:
Just the same as KeyDown, but MessageType is "k" instead of "K". |
Has there been any progress or interest in supporting OSC 52 clipboard access? Its long overdue as a feature. If I understand the commands correctly, they are basically:
From a quick browse of the source, I see three issues;
I'm happy to put in a little time to implement this if it seems worthwhile. I'm not 100% comfortable it will be all that usable with a 1533(ish) character limit, and unicode may pose challenges. It may require making EDIT: detail |
Now we have far2l terminal extensions protocol somewhat explained here: |
That's great! I just need some time to make comments little more informative and remove commented out debug stuff. |
PR will be from https://github.com/mihmig/KiTTY as adoption of my putty patch for KiTTY was done by @mihmig |
Let's split issues now. This will stay about far2l extensions support. OSC 52 is different feature, so it should be discussed in a separate issue, #356 |
Created PR: |
PR was merged with some minor problems preventing far2l extensions from actually working. This new PR fixes them: #363 |
This issue was originally dedicated to OSC 52 support, but it is about implementing far2l terminal extensions support now. For OSC 52 support see #356
For example,
should send "hello" to clipboard. More detailed explanations:
mintty/mintty#258 (comment)
https://bugs.kde.org/show_bug.cgi?id=372116
https://gitlab.gnome.org/GNOME/vte/-/issues/125
microsoft/terminal#2946
The text was updated successfully, but these errors were encountered: