Input method in FreeBSD virtual terminal (Week6)
Date: 07/12-07/18
vt
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()
vt_processkey is reponsible for processing keys sequence.
vt_mouse_paste()
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.
Final Phase Plan
Write a IME library with librime, then opens a device/socket and listens for commands and events in user mode
Modify vt_processkey such that a user presses a specific key combination to enable the IME mode
- After the user has enabled the IME mode, all key input will be processed with the IME library to output CJK chars
Write a send_chars function (can refer to vt_mouse_paste()) to output these CJK chars if the mode
- Additionally, show candidates during typing
This week's plans
Do some experiments on vt code, especially focuses on how to input/output characters
- Research how to display text to show candidates