mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
Use my_wcwidth()+my_wcswidth() instead of system’s wcwdith()+wcswidth()
But not that these functions map to the system’s versions if foot was configured with ‘-Dsystem-wcwidth’.
This commit is contained in:
parent
c758949145
commit
97ade97d38
4 changed files with 15 additions and 11 deletions
3
csi.c
3
csi.c
|
|
@ -24,6 +24,7 @@
|
|||
#include "vt.h"
|
||||
#include "xmalloc.h"
|
||||
#include "xsnprintf.h"
|
||||
#include "my-wcwidth.h"
|
||||
|
||||
#define UNHANDLED() LOG_DBG("unhandled: %s", csi_as_string(term, final, -1))
|
||||
#define UNHANDLED_SGR(idx) LOG_DBG("unhandled: %s", csi_as_string(term, 'm', idx))
|
||||
|
|
@ -742,7 +743,7 @@ csi_dispatch(struct terminal *term, uint8_t final)
|
|||
int count = vt_param_get(term, 0, 1);
|
||||
LOG_DBG("REP: '%lc' %d times", (wint_t)term->vt.last_printed, count);
|
||||
|
||||
const int width = wcwidth(term->vt.last_printed);
|
||||
const int width = my_wcwidth(term->vt.last_printed);
|
||||
if (width > 0) {
|
||||
for (int i = 0; i < count; i++)
|
||||
term_print(term, term->vt.last_printed, width);
|
||||
|
|
|
|||
3
ime.c
3
ime.c
|
|
@ -15,6 +15,7 @@
|
|||
#include "util.h"
|
||||
#include "wayland.h"
|
||||
#include "xmalloc.h"
|
||||
#include "my-wcwidth.h"
|
||||
|
||||
static void
|
||||
enter(void *data, struct zwp_text_input_v3 *zwp_text_input_v3,
|
||||
|
|
@ -178,7 +179,7 @@ done(void *data, struct zwp_text_input_v3 *zwp_text_input_v3,
|
|||
size_t widths[wchars + 1];
|
||||
|
||||
for (size_t i = 0; i < wchars; i++) {
|
||||
int width = max(wcwidth(seat->ime.preedit.text[i]), 1);
|
||||
int width = max(my_wcwidth(seat->ime.preedit.text[i]), 1);
|
||||
widths[i] = width;
|
||||
cell_count += width;
|
||||
}
|
||||
|
|
|
|||
13
render.c
13
render.c
|
|
@ -40,6 +40,7 @@
|
|||
#include "url-mode.h"
|
||||
#include "util.h"
|
||||
#include "xmalloc.h"
|
||||
#include "my-wcwidth.h"
|
||||
|
||||
#define TIME_SCROLL_DAMAGE 0
|
||||
|
||||
|
|
@ -627,7 +628,7 @@ render_cell(struct terminal *term, pixman_image_t *pix,
|
|||
if (single != NULL) {
|
||||
glyph_count = 1;
|
||||
glyphs = &single;
|
||||
cell_cols = single->cols;
|
||||
cell_cols = my_wcwidth(base);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -661,7 +662,7 @@ render_cell(struct terminal *term, pixman_image_t *pix,
|
|||
} else {
|
||||
glyph_count = 1;
|
||||
glyphs = &single;
|
||||
cell_cols = single->cols;
|
||||
cell_cols = my_wcwidth(base);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1414,7 +1415,7 @@ render_ime_preedit_for_seat(struct terminal *term, struct seat *seat,
|
|||
if (cell->wc >= CELL_SPACER)
|
||||
continue;
|
||||
|
||||
int width = max(1, wcwidth(cell->wc));
|
||||
int width = max(1, my_wcwidth(cell->wc));
|
||||
if (col_idx + i + width > term->cols)
|
||||
break;
|
||||
|
||||
|
|
@ -2854,10 +2855,10 @@ render_search_box(struct terminal *term)
|
|||
/* Calculate the width of each character */
|
||||
int widths[text_len + 1];
|
||||
for (size_t i = 0; i < text_len; i++)
|
||||
widths[i] = max(0, wcwidth(text[i]));
|
||||
widths[i] = max(0, my_wcwidth(text[i]));
|
||||
widths[text_len] = 0;
|
||||
|
||||
const size_t total_cells = wcswidth(text, text_len);
|
||||
const size_t total_cells = my_wcswidth(text, text_len);
|
||||
const size_t wanted_visible_cells = max(20, total_cells);
|
||||
|
||||
xassert(term->scale >= 1);
|
||||
|
|
@ -3288,7 +3289,7 @@ render_urls(struct terminal *term)
|
|||
int cols = 0;
|
||||
|
||||
for (size_t i = 0; i <= wcslen(label); i++) {
|
||||
int _cols = wcswidth(label, i);
|
||||
int _cols = my_wcswidth(label, i);
|
||||
|
||||
if (_cols == (size_t)-1)
|
||||
continue;
|
||||
|
|
|
|||
7
vt.c
7
vt.c
|
|
@ -19,6 +19,7 @@
|
|||
#include "osc.h"
|
||||
#include "util.h"
|
||||
#include "xmalloc.h"
|
||||
#include "my-wcwidth.h"
|
||||
|
||||
#define UNHANDLED() LOG_DBG("unhandled: %s", esc_as_string(term, final))
|
||||
|
||||
|
|
@ -619,7 +620,7 @@ chain_key(uint32_t old_key, uint32_t new_wc)
|
|||
static void
|
||||
action_utf8_print(struct terminal *term, wchar_t wc)
|
||||
{
|
||||
int width = wcwidth(wc);
|
||||
int width = my_wcwidth(wc);
|
||||
const bool grapheme_clustering = term->conf->tweak.grapheme_shaping;
|
||||
|
||||
#if !defined(FOOT_GRAPHEME_CLUSTERING)
|
||||
|
|
@ -672,7 +673,7 @@ action_utf8_print(struct terminal *term, wchar_t wc)
|
|||
}
|
||||
#endif
|
||||
|
||||
int base_width = wcwidth(base);
|
||||
int base_width = my_wcwidth(base);
|
||||
if (base_width > 0) {
|
||||
term->grid->cursor.point.col = col;
|
||||
term->grid->cursor.lcf = false;
|
||||
|
|
@ -686,7 +687,7 @@ action_utf8_print(struct terminal *term, wchar_t wc)
|
|||
term->fonts[0], base, wc, &base_from_primary,
|
||||
&comb_from_primary, &pre_from_primary);
|
||||
|
||||
int precomposed_width = wcwidth(precomposed);
|
||||
int precomposed_width = my_wcwidth(precomposed);
|
||||
|
||||
/*
|
||||
* Only use the pre-composed character if:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue