Fix #70
This commit is contained in:
parent
35f2b3254a
commit
29988c94fa
@ -10,6 +10,7 @@ import signal
|
||||
from threading import Thread
|
||||
|
||||
from .constants import terminfo_dir
|
||||
import kitty.fast_data_types as fast_data_types
|
||||
|
||||
|
||||
def remove_cloexec(fd):
|
||||
@ -33,6 +34,7 @@ class Child:
|
||||
self.forked = True
|
||||
master, slave = os.openpty() # Note that master and slave are in blocking mode
|
||||
remove_cloexec(slave)
|
||||
self.set_iutf8(fd=master)
|
||||
stdin, self.stdin = self.stdin, None
|
||||
if stdin is not None:
|
||||
stdin_read_fd, stdin_write_fd = os.pipe()
|
||||
@ -79,6 +81,16 @@ class Child:
|
||||
if self.child_fd is not None:
|
||||
fcntl.ioctl(self.child_fd, termios.TIOCSWINSZ, struct.pack('4H', h, w, ww, wh))
|
||||
|
||||
def set_iutf8(self, on=True, fd=None):
|
||||
fd = fd or self.child_fd
|
||||
if fd is not None and hasattr(fast_data_types, 'IUTF8'):
|
||||
attrs = termios.tcgetattr(fd)
|
||||
if on:
|
||||
attrs[0] |= fast_data_types.IUTF8
|
||||
else:
|
||||
attrs[0] &= ~fast_data_types.IUTF8
|
||||
termios.tcsetattr(fd, termios.TCSANOW, attrs)
|
||||
|
||||
def hangup(self):
|
||||
if self.pid is not None:
|
||||
pid, self.pid = self.pid, None
|
||||
|
||||
@ -56,6 +56,8 @@ static struct PyModuleDef module = {
|
||||
.m_methods = module_methods
|
||||
};
|
||||
|
||||
#include <termios.h>
|
||||
|
||||
PyMODINIT_FUNC
|
||||
PyInit_fast_data_types(void) {
|
||||
PyObject *m;
|
||||
@ -105,6 +107,9 @@ PyInit_fast_data_types(void) {
|
||||
PyModule_AddIntMacro(m, NORMAL_PROTOCOL);
|
||||
PyModule_AddIntMacro(m, URXVT_PROTOCOL);
|
||||
PyModule_AddIntMacro(m, UTF8_PROTOCOL);
|
||||
#ifdef IUTF8
|
||||
PyModule_AddIntMacro(m, IUTF8);
|
||||
#endif
|
||||
}
|
||||
|
||||
return m;
|
||||
|
||||
@ -860,6 +860,9 @@ void screen_erase_characters(Screen *self, unsigned int count) {
|
||||
void
|
||||
screen_use_latin1(Screen *self, bool on) {
|
||||
self->use_latin1 = on; self->utf8_state = 0; self->utf8_codepoint = 0;
|
||||
PyObject_CallMethod(self->callbacks, "use_utf8", "O", on ? Py_False : Py_True);
|
||||
if (PyErr_Occurred()) PyErr_Print();
|
||||
PyErr_Clear();
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@ -120,6 +120,9 @@ class Window:
|
||||
self.start_visual_bell_at = monotonic()
|
||||
glfw_post_empty_event()
|
||||
|
||||
def use_utf8(self, on):
|
||||
self.child.set_iutf8(on)
|
||||
|
||||
def update_screen(self):
|
||||
self.char_grid.update_cell_data()
|
||||
glfw_post_empty_event()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user