Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/subr_terminal.c
Show First 20 Lines • Show All 311 Lines • ▼ Show 20 Lines | terminal_input_char(struct terminal *tm, term_char_t c) | ||||
* Strip off any attributes. Also ignore input of second part of | * Strip off any attributes. Also ignore input of second part of | ||||
* CJK fullwidth characters, as we don't want to return these | * CJK fullwidth characters, as we don't want to return these | ||||
* characters twice. | * characters twice. | ||||
*/ | */ | ||||
if (TCHAR_FORMAT(c) & TF_CJK_RIGHT) | if (TCHAR_FORMAT(c) & TF_CJK_RIGHT) | ||||
return; | return; | ||||
c = TCHAR_CHARACTER(c); | c = TCHAR_CHARACTER(c); | ||||
tty_lock(tp); | ttydisc_lock(tp); | ||||
/* | /* | ||||
* Conversion to UTF-8. | * Conversion to UTF-8. | ||||
*/ | */ | ||||
if (c < 0x80) { | if (c < 0x80) { | ||||
ttydisc_rint(tp, c, 0); | ttydisc_rint(tp, c, 0); | ||||
} else if (c < 0x800) { | } else if (c < 0x800) { | ||||
char str[2] = { | char str[2] = { | ||||
0xc0 | (c >> 6), | 0xc0 | (c >> 6), | ||||
Show All 15 Lines | char str[4] = { | ||||
0x80 | ((c >> 12) & 0x3f), | 0x80 | ((c >> 12) & 0x3f), | ||||
0x80 | ((c >> 6) & 0x3f), | 0x80 | ((c >> 6) & 0x3f), | ||||
0x80 | (c & 0x3f) | 0x80 | (c & 0x3f) | ||||
}; | }; | ||||
ttydisc_rint_simple(tp, str, sizeof str); | ttydisc_rint_simple(tp, str, sizeof str); | ||||
} | } | ||||
ttydisc_rint_done(tp); | ttydisc_rint_done(tp); | ||||
tty_unlock(tp); | ttydisc_unlock(tp); | ||||
} | } | ||||
void | void | ||||
terminal_input_raw(struct terminal *tm, char c) | terminal_input_raw(struct terminal *tm, char c) | ||||
{ | { | ||||
struct tty *tp; | struct tty *tp; | ||||
tp = tm->tm_tty; | tp = tm->tm_tty; | ||||
if (tp == NULL) | if (tp == NULL) | ||||
return; | return; | ||||
tty_lock(tp); | ttydisc_lock(tp); | ||||
ttydisc_rint(tp, c, 0); | ttydisc_rint(tp, c, 0); | ||||
ttydisc_rint_done(tp); | ttydisc_rint_done(tp); | ||||
tty_unlock(tp); | ttydisc_unlock(tp); | ||||
} | } | ||||
void | void | ||||
terminal_input_special(struct terminal *tm, unsigned int k) | terminal_input_special(struct terminal *tm, unsigned int k) | ||||
{ | { | ||||
struct tty *tp; | struct tty *tp; | ||||
const char *str; | const char *str; | ||||
tp = tm->tm_tty; | tp = tm->tm_tty; | ||||
if (tp == NULL) | if (tp == NULL) | ||||
return; | return; | ||||
str = teken_get_sequence(&tm->tm_emulator, k); | str = teken_get_sequence(&tm->tm_emulator, k); | ||||
if (str == NULL) | if (str == NULL) | ||||
return; | return; | ||||
tty_lock(tp); | ttydisc_lock(tp); | ||||
ttydisc_rint_simple(tp, str, strlen(str)); | ttydisc_rint_simple(tp, str, strlen(str)); | ||||
ttydisc_rint_done(tp); | ttydisc_rint_done(tp); | ||||
tty_unlock(tp); | ttydisc_unlock(tp); | ||||
} | } | ||||
/* | /* | ||||
* Binding with the TTY layer. | * Binding with the TTY layer. | ||||
*/ | */ | ||||
static int | static int | ||||
termtty_open(struct tty *tp) | termtty_open(struct tty *tp) | ||||
Show All 15 Lines | |||||
static void | static void | ||||
termtty_outwakeup(struct tty *tp) | termtty_outwakeup(struct tty *tp) | ||||
{ | { | ||||
struct terminal *tm = tty_softc(tp); | struct terminal *tm = tty_softc(tp); | ||||
char obuf[128]; | char obuf[128]; | ||||
size_t olen; | size_t olen; | ||||
unsigned int flags = 0; | unsigned int flags = 0; | ||||
ttydisc_assert_locked(tp); | |||||
while ((olen = ttydisc_getc(tp, obuf, sizeof obuf)) > 0) { | while ((olen = ttydisc_getc(tp, obuf, sizeof obuf)) > 0) { | ||||
TERMINAL_LOCK_TTY(tm); | TERMINAL_LOCK_TTY(tm); | ||||
if (!(tm->tm_flags & TF_MUTE)) { | if (!(tm->tm_flags & TF_MUTE)) { | ||||
tm->tm_flags &= ~TF_BELL; | tm->tm_flags &= ~TF_BELL; | ||||
teken_input(&tm->tm_emulator, obuf, olen); | teken_input(&tm->tm_emulator, obuf, olen); | ||||
flags |= tm->tm_flags; | flags |= tm->tm_flags; | ||||
} | } | ||||
TERMINAL_UNLOCK_TTY(tm); | TERMINAL_UNLOCK_TTY(tm); | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | termtty_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td) | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* Unlike various other drivers, this driver will never | * Unlike various other drivers, this driver will never | ||||
* deallocate TTYs. This means it's safe to temporarily unlock | * deallocate TTYs. This means it's safe to temporarily unlock | ||||
* the TTY when handling ioctls. | * the TTY when handling ioctls. | ||||
*/ | */ | ||||
ttydisc_unlock(tp); | |||||
tty_unlock(tp); | tty_unlock(tp); | ||||
error = tm->tm_class->tc_ioctl(tm, cmd, data, td); | error = tm->tm_class->tc_ioctl(tm, cmd, data, td); | ||||
tty_lock(tp); | tty_lock(tp); | ||||
ttydisc_lock(tp); | |||||
if ((error == 0) && (cmd == CONS_CLRHIST)) { | if ((error == 0) && (cmd == CONS_CLRHIST)) { | ||||
/* | /* | ||||
* Scrollback history has been successfully cleared, | * Scrollback history has been successfully cleared, | ||||
* so reset the cursor position to the top left of the screen. | * so reset the cursor position to the top left of the screen. | ||||
*/ | */ | ||||
teken_pos_t p; | teken_pos_t p; | ||||
p.tp_row = 0; | p.tp_row = 0; | ||||
p.tp_col = 0; | p.tp_col = 0; | ||||
▲ Show 20 Lines • Show All 224 Lines • Show Last 20 Lines |