Home » Developing U++ » U++ Developers corner » How does UPP classify keys (key abstraction)
How does UPP classify keys [message #54579] |
Mon, 17 August 2020 07:28 |
chivstyle
Messages: 8 Registered: August 2020 Location: China
|
Promising Member |
|
|
Hi,
I'm developing our virtual terminal, but I'm confused about the key abstraction. I've read the manual book, still confused.
I tested these codes below, it worked well so far. Can anyone help me please ?
bool SerialConnVT::Key(dword key, int)
{
bool processed = false;
// split key and flags.
dword flags = K_CTRL | K_ALT | K_SHIFT;
dword d_key = key & ~(flags | K_KEYUP); // key with delta
flags = key & flags;
//
if (d_key & K_DELTA) { // can't capture RETURN
if (key & K_KEYUP) {
processed = ProcessKeyUp(d_key, flags);
} else {
processed = ProcessKeyDown(d_key, flags);
}
} else {
if (key < 0xffff) {
processed = ProcessChar(d_key);
ProcessKeyDown(d_key, flags);
} else if (key & K_KEYUP) {
// RETURN will reach here
ProcessKeyUp(d_key, flags);
}
}
if (processed) {
mScrollToEnd = true;
}
return processed;
}
|
|
|
Re: How does UPP classify keys [message #54580 is a reply to message #54579] |
Mon, 17 August 2020 09:51 |
Oblivion
Messages: 1092 Registered: August 2007
|
Senior Contributor |
|
|
Hello chivstyle,
In short, it is generally better to handle the control keys before stripping the delta on all platforms (MacOS uses "platform independent values" for those keys while windows and linux use ASCII codes, such as 0x0D for K_RETURN. Thus on MacOS, the K_RETURN value is shifted with delta flag, while on Windows and Linux (and others) it is simply ASCII code 0x0d).
P.s. Since you are developing a terminal emulator, there is already a high-end terminal emulator ctrl (widget) for Upp, that can speed up your development. Have you checked it?
Best regards,
Oblivion
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Mon, 17 August 2020 09:57] Report message to a moderator
|
|
|
|
Re: How does UPP classify keys [message #54584 is a reply to message #54582] |
Mon, 17 August 2020 11:06 |
Oblivion
Messages: 1092 Registered: August 2007
|
Senior Contributor |
|
|
Happy to help.
Thanks very much. I've read the VT102's mannual, it taked me lot of time. ECMA48, Xterm, oh, no!
Those documents are just the tip of the iceberg. First doc to read should be the DEC STD 070 document (a.k.a "the bible").
But I am afraid if you need a good and "modern" emulation you have to deal with 60 years of incompatible and "insane" cruft, which is a PITA.
By the way, to my knowledge our Terminal ctrl has very high xterm comaptibility with cross-platform support, and implements some of the "coolest" modern features. So it can save your time a lot. (even reading its code might be helpful. Plus, it has a sapearately available "lexical" ANSI/DEC sequence parser that you can use build your own emulator. Plus it comes with example code (SSH/PTY connections, tabbed, splitted interfaces, etc.) (Disclaimer: I am advertising it because I am its author: )
If you need any help or have questions on terminal emulation related stuff let me know.
Best regards,
Oblivion.
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Mon, 17 August 2020 11:15] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Fri Apr 26 08:53:02 CEST 2024
Total time taken to generate the page: 0.03887 seconds
|