コード例 #1
0
ファイル: tty.c プロジェクト: leasunhy/leanux
size_t tty_read(char *buf, size_t len) {
    enable_interrupt();
    size_t i = 0;
    while (i != len) {
        uint16_t scan_code;
        while (!cirqueue_serve(&kb_buf, &scan_code))
            /*nothing here*/;
        uint16_t key = KEYMAP[scan_code & 0xff];
        if ((scan_code & 0xFF) < 0xE0) {  /* it's a normal key */
            if (key == KB_ENTER) {
                tty_putchar('\n');
                break;
            } else if (key == KB_BACKSPACE) {
                if (i != 0) {
                    tty_putchar('\b');
                    i -= 1;
                }
            } else {
                buf[i] = key & 0xFF;
                tty_putchar(buf[i]);
                i += 1;
            }
        } else {  /* extended key */

        }
    }
    buf[i] = '\0';
    return i;
}
コード例 #2
0
ファイル: tty.c プロジェクト: leasunhy/leanux
void tty_putchar_ntimes(char c, uint8_t color, size_t n) {
    uint8_t ori_color = tty_color;
    tty_color = color;
    for (size_t i = 0; i < n; ++i)
        tty_putchar(c);
    tty_color = ori_color;
}
コード例 #3
0
ファイル: tty.c プロジェクト: liusongwei/mkernel
_START static void tty_clear_row(int row)
{
	int col = 0;

	for (col = 0; col < TTY_MAX_COL; col++)
		tty_putchar(row, col, ' ');
}
コード例 #4
0
ファイル: tty.c プロジェクト: liusongwei/mkernel
_START static void tty_copy_row(int src, int dst)
{
	int col = 0;

	for (col = 0; col < TTY_MAX_COL; col++)
	  tty_putchar(dst, col, tty_getchar(src, col));
}
コード例 #5
0
ファイル: tty.c プロジェクト: liusongwei/mkernel
_START void tty_init(void)
{
	int i = 0;
	int j = 0;

	for (i = 0; i < TTY_MAX_ROW; i++){
		for (j = 0; j < TTY_MAX_COL; j++){
			tty_setcolor(i, j, clWhite, clBlack);
			tty_putchar(i, j, ' ');
		}
	}
}
コード例 #6
0
ファイル: tty.c プロジェクト: leasunhy/leanux
void tty_write(const char *data, size_t size) {
    for (size_t i = 0; i < size; ++i)
        tty_putchar(data[i]);
}