mirror of
https://github.com/gryf/wmaker.git
synced 2026-04-08 08:53:31 +02:00
WINGs: make UTF-8 functions global
This patch is moving the existing UTF-8 functions from wtextfield.c to WINGsP.h.in to be available to all modules.
This commit is contained in:
committed by
Carlos R. Mafra
parent
4babc0e422
commit
6dbc6c95ab
@@ -686,6 +686,37 @@ void W_BroadcastMessage(W_View *targetParent, XEvent *event);
|
|||||||
|
|
||||||
void W_DispatchMessage(W_View *target, XEvent *event);
|
void W_DispatchMessage(W_View *target, XEvent *event);
|
||||||
|
|
||||||
|
/* ---[ UTF-8 helpers ]--------------------------------------------------- */
|
||||||
|
|
||||||
|
static inline int oneUTF8CharBackward(const char *str, int len)
|
||||||
|
{
|
||||||
|
const unsigned char *ustr = (const unsigned char *)str;
|
||||||
|
int pos = 0;
|
||||||
|
|
||||||
|
while (len-- > 0 && ustr[--pos] >= 0x80 && ustr[pos] <= 0xbf) ;
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int oneUTF8CharForward(const char *str, int len)
|
||||||
|
{
|
||||||
|
const unsigned char *ustr = (const unsigned char *)str;
|
||||||
|
int pos = 0;
|
||||||
|
|
||||||
|
while (len-- > 0 && ustr[++pos] >= 0x80 && ustr[pos] <= 0xbf) ;
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
// find the beginning of the UTF8 char pointed by str
|
||||||
|
static inline int seekUTF8CharStart(const char *str, int len)
|
||||||
|
{
|
||||||
|
const unsigned char *ustr = (const unsigned char *)str;
|
||||||
|
int pos = 0;
|
||||||
|
|
||||||
|
while (len-- > 0 && ustr[pos] >= 0x80 && ustr[pos] <= 0xbf)
|
||||||
|
--pos;
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,35 +122,6 @@ static WMSelectionProcs selectionHandler = {
|
|||||||
#define TEXT_WIDTH2(tPtr, start, end) (WMWidthOfString((tPtr)->font, \
|
#define TEXT_WIDTH2(tPtr, start, end) (WMWidthOfString((tPtr)->font, \
|
||||||
&((tPtr)->text[(start)]), (end) - (start)))
|
&((tPtr)->text[(start)]), (end) - (start)))
|
||||||
|
|
||||||
static inline int oneUTF8CharBackward(const char *str, int len)
|
|
||||||
{
|
|
||||||
const unsigned char *ustr = (const unsigned char *)str;
|
|
||||||
int pos = 0;
|
|
||||||
|
|
||||||
while (len-- > 0 && ustr[--pos] >= 0x80 && ustr[pos] <= 0xbf) ;
|
|
||||||
return pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int oneUTF8CharForward(const char *str, int len)
|
|
||||||
{
|
|
||||||
const unsigned char *ustr = (const unsigned char *)str;
|
|
||||||
int pos = 0;
|
|
||||||
|
|
||||||
while (len-- > 0 && ustr[++pos] >= 0x80 && ustr[pos] <= 0xbf) ;
|
|
||||||
return pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
// find the beginning of the UTF8 char pointed by str
|
|
||||||
static inline int seekUTF8CharStart(const char *str, int len)
|
|
||||||
{
|
|
||||||
const unsigned char *ustr = (const unsigned char *)str;
|
|
||||||
int pos = 0;
|
|
||||||
|
|
||||||
while (len-- > 0 && ustr[pos] >= 0x80 && ustr[pos] <= 0xbf)
|
|
||||||
--pos;
|
|
||||||
return pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void normalizeRange(TextField * tPtr, WMRange * range)
|
static void normalizeRange(TextField * tPtr, WMRange * range)
|
||||||
{
|
{
|
||||||
if (range->position < 0 && range->count < 0)
|
if (range->position < 0 && range->count < 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user