Get rid of safe_wcwidth
Since wcwidth is now in our control, we dont need to wrap it.
This commit is contained in:
parent
fbe4d036d8
commit
ebe97bf492
@ -255,7 +255,6 @@ bool set_iutf8(int, bool);
|
|||||||
color_type colorprofile_to_color(ColorProfile *self, color_type entry, color_type defval);
|
color_type colorprofile_to_color(ColorProfile *self, color_type entry, color_type defval);
|
||||||
void copy_color_table_to_buffer(ColorProfile *self, color_type *address, int offset, size_t stride);
|
void copy_color_table_to_buffer(ColorProfile *self, color_type *address, int offset, size_t stride);
|
||||||
|
|
||||||
unsigned int safe_wcwidth(uint32_t ch);
|
|
||||||
void set_mouse_cursor(MouseShape);
|
void set_mouse_cursor(MouseShape);
|
||||||
void mouse_event(int, int);
|
void mouse_event(int, int);
|
||||||
void focus_in_event();
|
void focus_in_event();
|
||||||
|
|||||||
@ -274,13 +274,6 @@ screen_designate_charset(Screen *self, uint32_t which, uint32_t as) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
|
||||||
safe_wcwidth(uint32_t ch) {
|
|
||||||
int ans = wcwidth_std(ch);
|
|
||||||
if (ans < 0) ans = 1;
|
|
||||||
return ans;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
draw_combining_char(Screen *self, char_type ch) {
|
draw_combining_char(Screen *self, char_type ch) {
|
||||||
bool has_prev_char = false;
|
bool has_prev_char = false;
|
||||||
@ -312,9 +305,12 @@ screen_draw(Screen *self, uint32_t och) {
|
|||||||
draw_combining_char(self, ch);
|
draw_combining_char(self, ch);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
unsigned int char_width = safe_wcwidth(ch);
|
int char_width = wcwidth_std(ch);
|
||||||
if (UNLIKELY(char_width < 1)) return;
|
if (UNLIKELY(char_width < 1)) {
|
||||||
if (UNLIKELY(self->columns - self->cursor->x < char_width)) {
|
if (char_width == 0) return;
|
||||||
|
char_width = 1;
|
||||||
|
}
|
||||||
|
if (UNLIKELY(self->columns - self->cursor->x < (unsigned int)char_width)) {
|
||||||
if (self->modes.mDECAWM) {
|
if (self->modes.mDECAWM) {
|
||||||
screen_carriage_return(self);
|
screen_carriage_return(self);
|
||||||
screen_linefeed(self);
|
screen_linefeed(self);
|
||||||
@ -1445,7 +1441,9 @@ screen_wcswidth(Screen UNUSED *self, PyObject *str) {
|
|||||||
unsigned long ans = 0;
|
unsigned long ans = 0;
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
char_type ch = PyUnicode_READ(kind, data, i);
|
char_type ch = PyUnicode_READ(kind, data, i);
|
||||||
ans += safe_wcwidth(ch);
|
int cw = wcwidth_std(ch);
|
||||||
|
if (cw < 1) cw = 1;
|
||||||
|
ans += cw;
|
||||||
}
|
}
|
||||||
return PyLong_FromUnsignedLong(ans);
|
return PyLong_FromUnsignedLong(ans);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user