====== Input method in FreeBSD virtual terminal (Week8) ====== Date: 07/26-08/01 ===== Progress ===== During this week, I was struggling with the kernel socket apis and CJK characters input/output . For the socket part, I first took a look at ''%%socket(9)%%'', but I found there were a lot of terms I had never seen before. As a result, I decided to focus on those functions I would probably use: ''%%soconnect%%'', ''%%sosend%%'', ''%%sorecieve%%'' and ''%%soclose%%''. The parameters of ''%%soconnect%%'' and ''%%soclose%%'' are quite straightforward, OK. However, the other two functions, ''%%sosend%%'' and ''%%sorecieve%%'', made me confused since I had no idea what is ''%%uio%%'' and ''%%mbuf%%''. After reading numerous materials, I finally figured them out and learned that both of them can transfer memory between kernel space and user space. Finally, I chose ''%%uio%%'' over ''%%mbuf%%'', and the only reason was that ''%%uio%%'' seems to be less complicated than ''%%mbuf%%''. For the CJK input/output part, I set my console font to ''%%b16.hex%%'' in [[https://github.com/emaste/fontstuff|fontstuff]] repo, now the terminal can display CJK characters correctly! Next I stole the functions ''%%teken_input_byte()%%'' and ''%%teken_input()%%'' from ''%%libteken%%'' for converting utf-8 sequences to ''%%term_char_t%%'' string, whose type is a 32-bit integer, and inserting them onto the screen. Now the vt console can handle user inputs, send them to the ime server, and output them onto the screen! Our goal was almost completed! The next issue we need to deal with is to display the IME status properly. (At present I used ''%%printf()%%'' to display the status, but it would mess with the existing text on the screen.) ===== Todo ===== * Find a better way to display the status bar. * Understand the socket stuff more deeply.