summaryrefslogtreecommitdiff
path: root/src/entry_backend
diff options
context:
space:
mode:
authorPhil Jones <philj56@gmail.com>2022-10-23 13:24:48 +0100
committerPhil Jones <philj56@gmail.com>2022-10-23 13:24:59 +0100
commit3bbd8ff839354a6f488c8481d5e6336a3f637cee (patch)
treef793acfea9c8115d30bd00d1a7dde5fc9fc079d7 /src/entry_backend
parentdd3a4a84d6676b51025e8feeb7af662a07b1e73c (diff)
Replace wchar and friends with Unicode handling.
All text handling should now be explicitly UTF-8 or UTF-32, removing the ambiguity around wchar_t and related functions.
Diffstat (limited to 'src/entry_backend')
-rw-r--r--src/entry_backend/harfbuzz.c20
-rw-r--r--src/entry_backend/pango.c20
2 files changed, 20 insertions, 20 deletions
diff --git a/src/entry_backend/harfbuzz.c b/src/entry_backend/harfbuzz.c
index 734d305..5d9ba99 100644
--- a/src/entry_backend/harfbuzz.c
+++ b/src/entry_backend/harfbuzz.c
@@ -5,7 +5,7 @@
#include "../entry.h"
#include "../log.h"
#include "../nelem.h"
-#include "../utf8.h"
+#include "../unicode.h"
#include "../xmalloc.h"
/*
@@ -232,12 +232,12 @@ void entry_backend_harfbuzz_update(struct entry *entry)
hb_buffer_clear_contents(buffer);
setup_hb_buffer(buffer);
if (entry->hide_input) {
- size_t char_len = N_ELEM(entry->hidden_character_mb);
- for (size_t i = 0; i < entry->input_length; i++) {
- hb_buffer_add_utf8(buffer, entry->hidden_character_mb, char_len, 0, char_len);
+ size_t char_len = N_ELEM(entry->hidden_character_utf8);
+ for (size_t i = 0; i < entry->input_utf32_length; i++) {
+ hb_buffer_add_utf8(buffer, entry->hidden_character_utf8, char_len, 0, char_len);
}
} else {
- hb_buffer_add_utf8(buffer, entry->input_mb, -1, 0, -1);
+ hb_buffer_add_utf8(buffer, entry->input_utf8, -1, 0, -1);
}
hb_shape(entry->harfbuzz.hb_font, buffer, NULL, 0);
extents = render_hb_buffer(cr, buffer);
@@ -368,17 +368,17 @@ void entry_backend_harfbuzz_update(struct entry *entry)
char *match = NULL;
char *postmatch = NULL;
cairo_text_extents_t subextents;
- if (entry->input_mb_length > 0 && entry->selection_highlight_color.a != 0) {
- char *match_pos = utf8_strcasestr(prematch, entry->input_mb);
+ if (entry->input_utf8_length > 0 && entry->selection_highlight_color.a != 0) {
+ char *match_pos = utf8_strcasestr(prematch, entry->input_utf8);
if (match_pos != NULL) {
match = xstrdup(result);
prematch_len = (match_pos - prematch);
prematch[prematch_len] = '\0';
- postmatch_len = strlen(result) - prematch_len - entry->input_mb_length;
+ postmatch_len = strlen(result) - prematch_len - entry->input_utf8_length;
if (postmatch_len > 0) {
postmatch = xstrdup(result);
}
- match[entry->input_mb_length + prematch_len] = '\0';
+ match[entry->input_utf8_length + prematch_len] = '\0';
}
}
@@ -438,7 +438,7 @@ void entry_backend_harfbuzz_update(struct entry *entry)
cairo_set_source_rgba(cr, color.r, color.g, color.b, color.a);
hb_buffer_clear_contents(buffer);
setup_hb_buffer(buffer);
- hb_buffer_add_utf8(buffer, &postmatch[entry->input_mb_length + prematch_len], -1, 0, -1);
+ hb_buffer_add_utf8(buffer, &postmatch[entry->input_utf8_length + prematch_len], -1, 0, -1);
hb_shape(entry->harfbuzz.hb_font, buffer, NULL, 0);
subextents = render_hb_buffer(cr, buffer);
diff --git a/src/entry_backend/pango.c b/src/entry_backend/pango.c
index 1cc7628..d533742 100644
--- a/src/entry_backend/pango.c
+++ b/src/entry_backend/pango.c
@@ -4,7 +4,7 @@
#include "../entry.h"
#include "../log.h"
#include "../nelem.h"
-#include "../utf8.h"
+#include "../unicode.h"
#include "../xmalloc.h"
#undef MAX
@@ -91,16 +91,16 @@ void entry_backend_pango_update(struct entry *entry)
* Pango needs to be passed the whole text at once, so we need
* to manually replicate the replacement character in a buffer.
*/
- static char buf[sizeof(entry->input_mb)];
- uint32_t char_len = entry->hidden_character_mb_length;
- for (size_t i = 0; i < entry->input_length; i++) {
+ static char buf[sizeof(entry->input_utf8)];
+ uint32_t char_len = entry->hidden_character_utf8_length;
+ for (size_t i = 0; i < entry->input_utf32_length; i++) {
for (size_t j = 0; j < char_len; j++) {
- buf[i * char_len + j] = entry->hidden_character_mb[j];
+ buf[i * char_len + j] = entry->hidden_character_utf8[j];
}
}
- pango_layout_set_text(layout, buf, char_len * entry->input_length);
+ pango_layout_set_text(layout, buf, char_len * entry->input_utf32_length);
} else {
- pango_layout_set_text(layout, entry->input_mb, -1);
+ pango_layout_set_text(layout, entry->input_utf8, -1);
}
pango_cairo_update_layout(cr, layout);
pango_cairo_show_layout(cr, layout);
@@ -178,11 +178,11 @@ void entry_backend_pango_update(struct entry *entry)
} else {
ssize_t prematch_len = -1;
ssize_t postmatch_len = -1;
- size_t match_len = entry->input_mb_length;
+ size_t match_len = entry->input_utf8_length;
PangoRectangle ink_subrect;
PangoRectangle logical_subrect;
- if (entry->input_mb_length > 0 && entry->selection_highlight_color.a != 0) {
- char *match_pos = utf8_strcasestr(str, entry->input_mb);
+ if (entry->input_utf8_length > 0 && entry->selection_highlight_color.a != 0) {
+ char *match_pos = utf8_strcasestr(str, entry->input_utf8);
if (match_pos != NULL) {
prematch_len = (match_pos - str);
postmatch_len = strlen(str) - prematch_len - match_len;