Move is_combining_char() to core utf8 module

Relocate is_combining_char() from gui-entry.c to src/core/utf8.c
as suggested in code review. This better organizes the codebase by
placing UTF-8 character classification logic with other UTF-8
utilities in the core module.

The function now uses is_utf8() instead of checking term_type
directly, which is the appropriate method for core layer code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
kofany 2025-10-06 20:39:46 +02:00
commit 20fbea0e2d
3 changed files with 18 additions and 14 deletions

View file

@ -399,6 +399,20 @@ int unichar_array_find_cluster_start(const unichar *text, int text_len, int pos)
#endif #endif
} }
int is_combining_char(unichar c)
{
if (!is_utf8())
return 0;
#ifdef HAVE_LIBUTF8PROC
/* Use utf8proc for precise combining character detection */
return unichar_isprint(c) && utf8proc_charwidth(c) == 0;
#else
/* Fallback to unichar_width for compatibility */
return unichar_isprint(c) && unichar_width(c) == 0;
#endif
}
void utf8_init(void) void utf8_init(void)
{ {
/* no-op */ /* no-op */

View file

@ -72,6 +72,10 @@ int unichar_array_move_cluster_backward(const unichar *text, int text_len, int *
* Returns the codepoint index of the cluster start. */ * Returns the codepoint index of the cluster start. */
int unichar_array_find_cluster_start(const unichar *text, int text_len, int pos); int unichar_array_find_cluster_start(const unichar *text, int text_len, int pos);
/* Check if a unichar is a combining character (width 0).
* Returns 1 if the character is combining, 0 otherwise. */
int is_combining_char(unichar c);
/* Initialize UTF-8 debugging system */ /* Initialize UTF-8 debugging system */
void utf8_init(void); void utf8_init(void);

View file

@ -54,20 +54,6 @@ static unichar i_tolower(unichar c)
return c <= 255 ? tolower(c) : c; return c <= 255 ? tolower(c) : c;
} }
static int is_combining_char(unichar c)
{
if (term_type != TERM_TYPE_UTF8)
return 0;
#ifdef HAVE_LIBUTF8PROC
/* Use utf8proc for precise combining character detection */
return unichar_isprint(c) && utf8proc_charwidth(c) == 0;
#else
/* Fallback to unichar_width for compatibility */
return unichar_isprint(c) && unichar_width(c) == 0;
#endif
}
static int i_isalnum(unichar c) static int i_isalnum(unichar c)
{ {
if (term_type == TERM_TYPE_UTF8) if (term_type == TERM_TYPE_UTF8)