Date: 07/12-07/18
This week I started to read the vt source code (sys/dev/vt/)
Here are two useful functions I found:
vt_processkey(): process key sequences vt_mouse_paste(): paste text
vt_processkey is reponsible for processing keys sequence.
vt_mouse_paste() is called by vt_machine_kbdevent() when a user presses the PASTE key to paste text with mouse:
case SPCLKEY | PASTE: /* kbdmap(5) keyword `paste`. */ #ifndef SC_NO_CUTPASTE /* Insert text from cut-paste buffer. */ vt_mouse_paste(); #endif
And the function body:
static void
vt_mouse_paste()
{
term_char_t *buf;
int i, len;
len = VD_PASTEBUFLEN(main_vd);
buf = VD_PASTEBUF(main_vd);
len /= sizeof(term_char_t);
for (i = 0; i < len; i++) {
if (buf[i] == '\0')
continue;
terminal_input_char(main_vd->vd_curwindow->vw_terminal,
buf[i]);
}
}
It would call terminal_input_char to send characters into the current virtual terminal window.
librime, then opens a device/socket and listens for commands and events in user modevt_processkey such that a user presses a specific key combination to enable the IME modevt_mouse_paste()) to output these CJK chars if the modevt code, especially focuses on how to input/output characters