A few more places to remove wcwidth from
This commit is contained in:
parent
fc7ec1d3f7
commit
3f24e5b571
@ -70,11 +70,6 @@ static inline double monotonic_() {
|
||||
|
||||
double monotonic() { return monotonic_(); }
|
||||
|
||||
static PyObject*
|
||||
wcwidth_wrap(PyObject UNUSED *self, PyObject *chr) {
|
||||
return PyLong_FromUnsignedLong(safe_wcwidth(PyLong_AsLong(chr)));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
redirect_std_streams(PyObject UNUSED *self, PyObject *args) {
|
||||
char *devnull = NULL;
|
||||
@ -140,7 +135,6 @@ static PyMethodDef module_methods[] = {
|
||||
{"parse_bytes", (PyCFunction)parse_bytes, METH_VARARGS, ""},
|
||||
{"parse_bytes_dump", (PyCFunction)parse_bytes_dump, METH_VARARGS, ""},
|
||||
{"redirect_std_streams", (PyCFunction)redirect_std_streams, METH_VARARGS, ""},
|
||||
{"wcwidth", (PyCFunction)wcwidth_wrap, METH_O, ""},
|
||||
{"install_sigchld_handler", (PyCFunction)install_sigchld_handler, METH_NOARGS, ""},
|
||||
#ifdef __APPLE__
|
||||
METHODB(user_cache_dir, METH_NOARGS),
|
||||
|
||||
@ -5,7 +5,10 @@
|
||||
* Distributed under terms of the GPL3 license.
|
||||
*/
|
||||
|
||||
#define EXTRA_INIT PyModule_AddIntMacro(module, SCROLL_LINE); PyModule_AddIntMacro(module, SCROLL_PAGE); PyModule_AddIntMacro(module, SCROLL_FULL);
|
||||
#define EXTRA_INIT { \
|
||||
PyModule_AddIntMacro(module, SCROLL_LINE); PyModule_AddIntMacro(module, SCROLL_PAGE); PyModule_AddIntMacro(module, SCROLL_FULL); \
|
||||
if (PyModule_AddFunctions(module, module_methods) != 0) return false; \
|
||||
}
|
||||
|
||||
#include "state.h"
|
||||
#include "fonts.h"
|
||||
@ -1756,8 +1759,6 @@ static PyMethodDef methods[] = {
|
||||
MND(cursor_down, METH_VARARGS)
|
||||
MND(cursor_down1, METH_VARARGS)
|
||||
MND(cursor_forward, METH_VARARGS)
|
||||
{"wcwidth", (PyCFunction)wcwidth_wrap, METH_O, ""},
|
||||
{"wcswidth", (PyCFunction)screen_wcswidth, METH_O, ""},
|
||||
{"index", (PyCFunction)xxx_index, METH_VARARGS, ""},
|
||||
MND(refresh_sprite_positions, METH_NOARGS)
|
||||
MND(tab, METH_NOARGS)
|
||||
@ -1831,5 +1832,11 @@ PyTypeObject Screen_Type = {
|
||||
.tp_getset = getsetters,
|
||||
};
|
||||
|
||||
static PyMethodDef module_methods[] = {
|
||||
{"wcwidth", (PyCFunction)wcwidth_wrap, METH_O, ""},
|
||||
{"wcswidth", (PyCFunction)screen_wcswidth, METH_O, ""},
|
||||
{NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
INIT_TYPE(Screen)
|
||||
// }}}
|
||||
|
||||
@ -15,12 +15,11 @@ import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
from contextlib import contextmanager
|
||||
from functools import lru_cache
|
||||
from time import monotonic
|
||||
|
||||
from .constants import appname, is_macos, is_wayland
|
||||
from .fast_data_types import (
|
||||
GLSL_VERSION, redirect_std_streams, wcwidth as wcwidth_impl, x11_display,
|
||||
GLSL_VERSION, redirect_std_streams, x11_display,
|
||||
x11_window_id
|
||||
)
|
||||
from .rgb import Color, to_color
|
||||
@ -45,14 +44,6 @@ def ceil_int(x):
|
||||
return int(math.ceil(x))
|
||||
|
||||
|
||||
@lru_cache(maxsize=2**13)
|
||||
def wcwidth(c: str) -> int:
|
||||
try:
|
||||
return wcwidth_impl(ord(c))
|
||||
except TypeError:
|
||||
return wcwidth_impl(ord(c[0]))
|
||||
|
||||
|
||||
@contextmanager
|
||||
def timeit(name, do_timing=False):
|
||||
if do_timing:
|
||||
|
||||
@ -4,10 +4,10 @@
|
||||
|
||||
from kitty.config import build_ansi_color_table, defaults
|
||||
from kitty.fast_data_types import (
|
||||
REVERSE, ColorProfile, Cursor as C, HistoryBuf, LineBuf
|
||||
REVERSE, ColorProfile, Cursor as C, HistoryBuf, LineBuf, wcwidth
|
||||
)
|
||||
from kitty.utils import sanitize_title, wcwidth
|
||||
from kitty.rgb import to_color
|
||||
from kitty.utils import sanitize_title
|
||||
|
||||
from . import BaseTest, filled_cursor, filled_history_buf, filled_line_buf
|
||||
|
||||
@ -332,7 +332,9 @@ class TestDataTypes(BaseTest):
|
||||
self.assertContinued(lb2, False, True, True, True)
|
||||
|
||||
def test_utils(self):
|
||||
self.ae(tuple(map(wcwidth, 'a1\0コニチ ')), (1, 1, 0, 2, 2, 2, 1))
|
||||
def w(x):
|
||||
return wcwidth(ord(x))
|
||||
self.ae(tuple(map(w, 'a1\0コニチ ')), (1, 1, 0, 2, 2, 2, 1))
|
||||
self.assertEqual(sanitize_title('a\0\01 \t\n\f\rb'), 'a b')
|
||||
|
||||
def test_color_profile(self):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user