mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 10:07:38 -04:00
internals: Support characters beyond the first unicode plane (WIP)
We used 16-bit variables to store the 'character code' everywhere but this won't let us represent anything beyond U+FFFF. This patch changes those variables to a custom type that can be 32 or 16 bits depending on the build, and adjusts numerous internal APIs and datastructures to match. This includes: * utf8decode() and friends * on-screen keyboard * font manipulation, caching, rendering, and generation * VFAT code parses and generates utf16 dirents * WIN32 simulator reads and writes utf16 filenames Note that this patch doesn't _enable_ >16bit unicode support; a followup patch will turn that on for appropriate targets. Known bugs: * Native players in 32-bit unicode mode generate mangled filename entries if they include UTF16 surrogate codepoints. Root cause is unclear, and may reside in core dircache code. Needs testing on: * windows simulator (16bit+32bit) Change-Id: I193a00fe2a11a4181ddc82df2d71be52bf00b6e6
This commit is contained in:
parent
94712b34d4
commit
d05c59f35b
44 changed files with 480 additions and 335 deletions
|
@ -82,7 +82,7 @@ static void kdb_init(void)
|
|||
sleep(HZ/10);
|
||||
}
|
||||
|
||||
int kbd_input(char* text, int buflen, unsigned short *kbd)
|
||||
int kbd_input(char* text, int buflen, ucschar_t *kbd)
|
||||
{
|
||||
(void)kbd;
|
||||
JNIEnv e = *env_ptr;
|
||||
|
@ -107,7 +107,7 @@ int kbd_input(char* text, int buflen, unsigned short *kbd)
|
|||
e->DeleteLocalRef(env_ptr, str);
|
||||
e->DeleteLocalRef(env_ptr, ok_text);
|
||||
e->DeleteLocalRef(env_ptr, cancel_text);
|
||||
|
||||
|
||||
return !accepted; /* return 0 on success */
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
/* '*kbd', same format as https://www.rockbox.org/wiki/LoadableKeyboardLayouts */
|
||||
|
||||
int kbd_input(char* buffer, int buflen, unsigned short *kbd);
|
||||
int kbd_input(char* buffer, int buflen, ucschar_t *kbd);
|
||||
|
||||
int load_kbd(unsigned char* filename);
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ int plugin_open(const char *plugin, const char *parameter);
|
|||
* when this happens please take the opportunity to sort in
|
||||
* any new functions "waiting" at the end of the list.
|
||||
*/
|
||||
#define PLUGIN_API_VERSION 273
|
||||
#define PLUGIN_API_VERSION 274
|
||||
|
||||
/* 239 Marks the removal of ARCHOS HWCODEC and CHARCELL */
|
||||
|
||||
|
@ -296,15 +296,15 @@ struct plugin_api {
|
|||
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
|
||||
void (*button_queue_post)(long id, intptr_t data);
|
||||
#endif
|
||||
unsigned short *(*bidi_l2v)( const unsigned char *str, int orientation );
|
||||
bool (*is_diacritic)(const unsigned short char_code, bool *is_rtl);
|
||||
const unsigned char *(*font_get_bits)( struct font *pf, unsigned short char_code );
|
||||
ucschar_t *(*bidi_l2v)(const unsigned char *str, int orientation);
|
||||
bool (*is_diacritic)(const ucschar_t char_code, bool *is_rtl);
|
||||
const unsigned char *(*font_get_bits)(struct font *pf, ucschar_t char_code);
|
||||
int (*font_load)(const char *path);
|
||||
void (*font_unload)(int font_id);
|
||||
struct font* (*font_get)(int font);
|
||||
int (*font_getstringsize)(const unsigned char *str, int *w, int *h,
|
||||
int fontnumber);
|
||||
int (*font_get_width)(struct font* pf, unsigned short char_code);
|
||||
int (*font_get_width)(struct font* pf, ucschar_t char_code);
|
||||
void (*screen_clear_area)(struct screen * display, int xstart, int ystart,
|
||||
int width, int height);
|
||||
void (*gui_scrollbar_draw)(struct screen * screen, int x, int y,
|
||||
|
@ -667,7 +667,7 @@ struct plugin_api {
|
|||
const unsigned char * const *units,
|
||||
unsigned int unit_count, bool binary_scale);
|
||||
/* unicode stuff */
|
||||
const unsigned char* (*utf8decode)(const unsigned char *utf8, unsigned short *ucs);
|
||||
const unsigned char* (*utf8decode)(const unsigned char *utf8, ucschar_t *ucs);
|
||||
unsigned char* (*iso_decode)(const unsigned char *iso, unsigned char *utf8, int cp, int count);
|
||||
unsigned char* (*utf16LEdecode)(const unsigned char *utf16, unsigned char *utf8, int count);
|
||||
unsigned char* (*utf16BEdecode)(const unsigned char *utf16, unsigned char *utf8, int count);
|
||||
|
@ -923,7 +923,7 @@ struct plugin_api {
|
|||
int (*rand)(void);
|
||||
void (*qsort)(void *base, size_t nmemb, size_t size,
|
||||
int(*compar)(const void *, const void *));
|
||||
int (*kbd_input)(char* buffer, int buflen, unsigned short *kbd);
|
||||
int (*kbd_input)(char* buffer, int buflen, ucschar_t *kbd);
|
||||
struct tm* (*get_time)(void);
|
||||
struct tm * (*gmtime_r)(const time_t *timep, struct tm *tm);
|
||||
#if CONFIG_RTC
|
||||
|
|
|
@ -70,7 +70,7 @@ static const char keybd_layout[] =
|
|||
* - \n does not create a key, but it also consumes one element
|
||||
* - the final null terminator is equivalent to \n
|
||||
* - since sizeof includes the null terminator we don't need +1 for that. */
|
||||
static unsigned short kbd_buf[sizeof(keybd_layout)];
|
||||
static ucschar_t kbd_buf[sizeof(keybd_layout)];
|
||||
|
||||
/****************** prototypes ******************/
|
||||
void print_scroll(char* string); /* implements a scrolling screen */
|
||||
|
@ -164,7 +164,7 @@ static void config_set_defaults(void)
|
|||
gAnnounce.announce_on = 0;
|
||||
gAnnounce.grouping = 0;
|
||||
gAnnounce.wps_fmt[0] = '\0';
|
||||
gAnnounce.show_prompt = true;
|
||||
gAnnounce.show_prompt = true;
|
||||
}
|
||||
|
||||
static void config_reset_voice(void)
|
||||
|
@ -250,7 +250,7 @@ static int announce_menu_cb(int action,
|
|||
struct gui_synclist *this_list)
|
||||
{
|
||||
(void)this_item;
|
||||
unsigned short* kbd_p;
|
||||
ucschar_t *kbd_p;
|
||||
|
||||
int selection = rb->gui_synclist_get_sel_pos(this_list);
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ void wait_for_key()
|
|||
case PLA_EXIT:
|
||||
hot_key_quit();
|
||||
break;
|
||||
|
||||
|
||||
case PLA_SELECT:
|
||||
return;
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ zchar do_input(int timeout, bool show_cursor)
|
|||
{
|
||||
case PLA_EXIT:
|
||||
return ZC_HKEY_QUIT;
|
||||
|
||||
|
||||
case PLA_CANCEL:
|
||||
menu_ret = menu();
|
||||
if (menu_ret != ZC_BAD)
|
||||
|
@ -174,7 +174,7 @@ zchar do_input(int timeout, bool show_cursor)
|
|||
return ZC_BAD;
|
||||
|
||||
default:
|
||||
if (timeout != TIMEOUT_BLOCK &&
|
||||
if (timeout != TIMEOUT_BLOCK &&
|
||||
!TIME_BEFORE(*rb->current_tick, timeout_at))
|
||||
return ZC_TIME_OUT;
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ zchar os_read_key(int timeout, bool show_cursor)
|
|||
{
|
||||
int r;
|
||||
char inputbuf[5];
|
||||
short key;
|
||||
ucschar_t key;
|
||||
zchar zkey;
|
||||
|
||||
for(;;)
|
||||
|
@ -214,7 +214,7 @@ zchar os_read_line(int max, zchar *buf, int timeout, int width, int continued)
|
|||
char inputbuf[256];
|
||||
const char *in;
|
||||
char *out;
|
||||
short key;
|
||||
ucschar_t key;
|
||||
zchar zkey;
|
||||
|
||||
for(;;)
|
||||
|
|
|
@ -206,8 +206,8 @@ static int prompt_filename(char *buf, size_t bufsz)
|
|||
{
|
||||
#define KBD_LAYOUT "abcdefghijklmnop\nqrstuvwxyz |()[]\n1234567890 /._-+\n\n" \
|
||||
"\nABCDEFGHIJKLMNOP\nQRSTUVWXYZ |()[]\n1234567890 /._-+"
|
||||
unsigned short kbd[sizeof(KBD_LAYOUT) + 10];
|
||||
unsigned short *kbd_p = kbd;
|
||||
ucschar_t kbd[sizeof(KBD_LAYOUT) + 10];
|
||||
ucschar_t *kbd_p = kbd;
|
||||
if (!kbd_create_layout(KBD_LAYOUT, kbd, sizeof(kbd)))
|
||||
kbd_p = NULL;
|
||||
|
||||
|
@ -1002,7 +1002,7 @@ next_line:
|
|||
{
|
||||
bufleft = bufsz - (pctx - filenamebuf);
|
||||
ctx = -1;
|
||||
int ctx_x_flag_count = (LAST_CONTEXT_PLACEHOLDER
|
||||
int ctx_x_flag_count = (LAST_CONTEXT_PLACEHOLDER
|
||||
* ARRAYLEN(context_flags));
|
||||
|
||||
for (int i=0;i < ctx_x_flag_count ;i++)
|
||||
|
@ -2058,7 +2058,7 @@ static void synclist_set(int id, int selected_item, int items, int sel_size)
|
|||
}
|
||||
else if (menu_id == MENU_ID(M_SETKEYS))
|
||||
{
|
||||
keyset.view_columns = printcell_set_columns(&lists, NULL,
|
||||
keyset.view_columns = printcell_set_columns(&lists, NULL,
|
||||
ACTVIEW_HEADER, Icon_Rockbox);
|
||||
printcell_enable(true);
|
||||
int curcol = printcell_get_column_selected();
|
||||
|
|
|
@ -199,8 +199,8 @@ void grey_hline(int x1, int x2, int y)
|
|||
/* nothing to draw? */
|
||||
if (y < _grey_info.clip_t || y >= _grey_info.clip_b ||
|
||||
x1 >= _grey_info.clip_r || x2 < _grey_info.clip_l)
|
||||
return;
|
||||
|
||||
return;
|
||||
|
||||
/* drawmode and optimisation */
|
||||
if (vp->drawmode & DRMODE_INVERSEVID)
|
||||
{
|
||||
|
@ -251,7 +251,7 @@ void grey_vline(int x, int y1, int y2)
|
|||
unsigned char *dst, *dst_end;
|
||||
void (*pfunc)(unsigned char *address);
|
||||
int dwidth;
|
||||
|
||||
|
||||
/* direction flip */
|
||||
if (y2 < y1)
|
||||
{
|
||||
|
@ -264,7 +264,7 @@ void grey_vline(int x, int y1, int y2)
|
|||
if (x < _grey_info.clip_l || x >= _grey_info.clip_r ||
|
||||
y1 >= _grey_info.clip_b || y2 < _grey_info.clip_t)
|
||||
return;
|
||||
|
||||
|
||||
/* clipping */
|
||||
if (y1 < _grey_info.clip_t)
|
||||
y1 = _grey_info.clip_t;
|
||||
|
@ -425,7 +425,7 @@ void grey_fillrect(int x, int y, int width, int height)
|
|||
|
||||
if (height <= 0)
|
||||
return;
|
||||
|
||||
|
||||
dwidth = _grey_info.cb_width;
|
||||
dst = &_grey_info.curbuffer[
|
||||
_GREY_MULUQ(dwidth, _grey_info.vp->y - _grey_info.cb_y + y) +
|
||||
|
@ -653,8 +653,8 @@ void grey_gray_bitmap(const unsigned char *src, int x, int y, int width,
|
|||
/* Put a string at a given pixel position, skipping first ofs pixel columns */
|
||||
void grey_putsxyofs(int x, int y, int ofs, const unsigned char *str)
|
||||
{
|
||||
int ch;
|
||||
unsigned short *ucs;
|
||||
ucschar_t ch;
|
||||
ucschar_t *ucs;
|
||||
struct font* pf;
|
||||
|
||||
if (_grey_info.clip_b <= _grey_info.clip_t)
|
||||
|
@ -680,7 +680,7 @@ void grey_putsxyofs(int x, int y, int ofs, const unsigned char *str)
|
|||
bits = rb->font_get_bits(pf, ch);
|
||||
|
||||
grey_mono_bitmap_part(bits, ofs, 0, width, x, y, width - ofs, pf->height);
|
||||
|
||||
|
||||
x += width - ofs;
|
||||
ofs = 0;
|
||||
}
|
||||
|
@ -709,7 +709,7 @@ void grey_ub_clear_display(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
/* Assembler optimised helper function for copying a single line to the
|
||||
/* Assembler optimised helper function for copying a single line to the
|
||||
* greyvalue buffer. */
|
||||
void _grey_line1(int width, unsigned char *dst, const unsigned char *src,
|
||||
const unsigned char *lut);
|
||||
|
@ -725,7 +725,7 @@ void grey_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
|
|||
if ((width <= 0) || (height <= 0) || (x >= _grey_info.width)
|
||||
|| (y >= _grey_info.height) || (x + width <= 0) || (y + height <= 0))
|
||||
return;
|
||||
|
||||
|
||||
/* clipping */
|
||||
if (x < 0)
|
||||
{
|
||||
|
@ -744,7 +744,7 @@ void grey_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
|
|||
if (y + height > _grey_info.height)
|
||||
height = _grey_info.height - y;
|
||||
|
||||
src += _GREY_MULUQ(stride, src_y) + src_x; /* move starting point */
|
||||
src += _GREY_MULUQ(stride, src_y) + src_x; /* move starting point */
|
||||
yc = y;
|
||||
ye = y + height;
|
||||
dst = _grey_info.values + (x << _GREY_BSHIFT);
|
||||
|
@ -773,7 +773,7 @@ void grey_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
|
|||
}
|
||||
while (src_row < src_end);
|
||||
#endif
|
||||
|
||||
|
||||
src += stride;
|
||||
}
|
||||
while (++yc < ye);
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
#include "kbd_helper.h"
|
||||
|
||||
/* USAGE:
|
||||
unsigned short kbd[64];
|
||||
unsigned short *kbd_p = kbd;
|
||||
ucschar_t kbd[64];
|
||||
ucschar_t *kbd_p = kbd;
|
||||
if (!kbd_create_layout("ABCD1234\n", kbd, sizeof(kbd)))
|
||||
kbd_p = NULL;
|
||||
|
||||
|
@ -34,14 +34,14 @@
|
|||
* success returns size of buffer used
|
||||
* failure returns 0
|
||||
*/
|
||||
int kbd_create_layout(const char *layout, unsigned short *buf, int bufsz)
|
||||
int kbd_create_layout(const char *layout, ucschar_t *buf, int bufsz)
|
||||
{
|
||||
unsigned short *pbuf;
|
||||
ucschar_t *pbuf;
|
||||
const unsigned char *p = layout;
|
||||
int len = 0;
|
||||
int total_len = 0;
|
||||
pbuf = buf;
|
||||
while (*p && (pbuf - buf + (ptrdiff_t) sizeof(unsigned short)) < bufsz)
|
||||
while (*p && (pbuf - buf + (ptrdiff_t) sizeof(ucschar_t)) < bufsz)
|
||||
{
|
||||
p = rb->utf8decode(p, &pbuf[len+1]);
|
||||
if (pbuf[len+1] == '\n')
|
||||
|
@ -60,7 +60,7 @@ int kbd_create_layout(const char *layout, unsigned short *buf, int bufsz)
|
|||
*pbuf = len;
|
||||
pbuf[len+1] = 0xFEFF; /* mark end of characters */
|
||||
total_len += len + 1;
|
||||
return total_len * sizeof(unsigned short);
|
||||
return total_len * sizeof(ucschar_t);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2020 William Wilgus
|
||||
|
@ -22,6 +22,6 @@
|
|||
#define KBD_HELPER_H
|
||||
|
||||
/* create a custom keyboard layout for kbd_input */
|
||||
int kbd_create_layout(const char *layout, unsigned short *buf, int bufsz);
|
||||
int kbd_create_layout(const char *layout, ucschar_t *buf, int bufsz);
|
||||
|
||||
#endif /* KBD_HELPER_H */
|
||||
|
|
|
@ -62,7 +62,7 @@ static const char* get_next_line(const char *text, struct view_info *info)
|
|||
total = 0;
|
||||
while(*ptr)
|
||||
{
|
||||
unsigned short ch;
|
||||
ucschar_t ch;
|
||||
n = ((intptr_t)rb->utf8decode(ptr, &ch) - (intptr_t)ptr);
|
||||
if (rb->is_diacritic(ch, NULL))
|
||||
w = 0;
|
||||
|
|
|
@ -422,7 +422,7 @@ static struct lrc_brpos *calc_brpos(struct lrc_line *lrc_line, int i)
|
|||
int nlrcbrpos = 0, max_lrcbrpos;
|
||||
uifont = rb->screens[0]->getuifont();
|
||||
struct font* pf = rb->font_get(uifont);
|
||||
unsigned short ch;
|
||||
ucschar_t ch;
|
||||
struct snap {
|
||||
int count, width;
|
||||
int nword;
|
||||
|
|
|
@ -141,6 +141,7 @@ RB_WRAP(touchscreen_mode)
|
|||
|
||||
#endif
|
||||
|
||||
// XXX this may be broken with 32-bit ucschar_t
|
||||
RB_WRAP(kbd_input)
|
||||
{
|
||||
/*kbd_input(text, layout)*
|
||||
|
@ -168,7 +169,7 @@ RB_WRAP(kbd_input)
|
|||
layout = NULL;
|
||||
}
|
||||
|
||||
if(!rb->kbd_input(buffer, LUAL_BUFFERSIZE, (unsigned short *)layout))
|
||||
if(!rb->kbd_input(buffer, LUAL_BUFFERSIZE, (ucschar_t *)layout))
|
||||
{
|
||||
luaL_addstring(&b, buffer);
|
||||
luaL_pushresult(&b);
|
||||
|
|
|
@ -1073,8 +1073,8 @@ static void draw_oriented_alpha_bitmap_part(const unsigned char *src,
|
|||
|
||||
static void draw_putsxy_oriented(int x, int y, const char *str)
|
||||
{
|
||||
unsigned short ch;
|
||||
unsigned short *ucs;
|
||||
ucschar_t ch;
|
||||
ucschar_t *ucs;
|
||||
int ofs = MIN(x, 0);
|
||||
struct font* pf = rb->font_get(osd.font);
|
||||
|
||||
|
|
|
@ -969,8 +969,8 @@ static void buffer_alpha_bitmap_part(
|
|||
static void buffer_putsxyofs( fb_data *buf, int buf_width, int buf_height,
|
||||
int x, int y, int ofs, const unsigned char *str )
|
||||
{
|
||||
unsigned short ch;
|
||||
unsigned short *ucs;
|
||||
ucschar_t ch;
|
||||
ucschar_t *ucs;
|
||||
|
||||
struct font *pf = rb->font_get( FONT_UI );
|
||||
if( !pf ) pf = rb->font_get( FONT_SYSFIXED );
|
||||
|
|
|
@ -135,10 +135,10 @@ static void sleep_yield(void)
|
|||
#define yield sleep_yield
|
||||
}
|
||||
|
||||
/* make sure tag can be displayed by font pf*/
|
||||
/* make sure tag can be displayed by font pf */
|
||||
static bool text_is_displayable(struct font *pf, unsigned char *src)
|
||||
{
|
||||
unsigned short code;
|
||||
ucschar_t code;
|
||||
const unsigned char *ptr = src;
|
||||
while(*ptr)
|
||||
{
|
||||
|
|
|
@ -41,7 +41,7 @@ static unsigned text_type = TV_TEXT_UNKNOWN;
|
|||
|
||||
static const unsigned char *end_ptr;
|
||||
|
||||
static unsigned short ucsbuf[TV_MAX_BLOCKS][TV_MAX_CHARS_PER_BLOCK];
|
||||
static ucschar_t ucsbuf[TV_MAX_BLOCKS][TV_MAX_CHARS_PER_BLOCK];
|
||||
static unsigned char utf8buf[TV_MAX_CHARS_PER_BLOCK * (2 * 3)];
|
||||
static unsigned char *outbuf;
|
||||
|
||||
|
@ -54,11 +54,11 @@ static bool expand_extra_line = false;
|
|||
/* when a line is divided, this value sets true. */
|
||||
static bool is_break_line = false;
|
||||
|
||||
static unsigned short break_chars[] =
|
||||
static unsigned short break_chars[] = // XXX promote to ucschar_t if we get a codepoint > 0xffff
|
||||
{
|
||||
0,
|
||||
/* halfwidth characters */
|
||||
'\t', '\n', 0x0b, 0x0c, ' ', '!', ',', '-', '.', ':', ';', '?', 0xb7,
|
||||
'\t', '\n', 0x0b, 0x0c, ' ', '!', ',', '-', '.', ':', ';', '?', 0xb7,
|
||||
/* fullwidth characters */
|
||||
0x2010, /* hyphen */
|
||||
0x3000, /* fullwidth space */
|
||||
|
@ -76,7 +76,7 @@ static unsigned short break_chars[] =
|
|||
};
|
||||
|
||||
/* the characters which is not judged as space with isspace() */
|
||||
static unsigned short extra_spaces[] = { 0, 0x3000 };
|
||||
static unsigned short extra_spaces[] = { 0, 0x3000 }; // XXX promote to ucschar_t if we get a codepoint > 0xffff
|
||||
|
||||
static int tv_glyph_width(int ch)
|
||||
{
|
||||
|
@ -93,7 +93,7 @@ static int tv_glyph_width(int ch)
|
|||
return rb->font_get_width(rb->font_get(preferences->font_id), ch);
|
||||
}
|
||||
|
||||
static unsigned char *tv_get_ucs(const unsigned char *str, unsigned short *ch)
|
||||
static unsigned char *tv_get_ucs(const unsigned char *str, ucschar_t *ch)
|
||||
{
|
||||
int count = 1;
|
||||
unsigned char utf8_tmp[3];
|
||||
|
@ -148,7 +148,7 @@ static unsigned char *tv_get_ucs(const unsigned char *str, unsigned short *ch)
|
|||
return (unsigned char *)str + count;
|
||||
}
|
||||
|
||||
static void tv_decode2utf8(const unsigned short *ucs, int count)
|
||||
static void tv_decode2utf8(const ucschar_t *ucs, int count)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -158,7 +158,7 @@ static void tv_decode2utf8(const unsigned short *ucs, int count)
|
|||
*outbuf = '\0';
|
||||
}
|
||||
|
||||
static bool tv_is_line_break_char(unsigned short ch)
|
||||
static bool tv_is_line_break_char(ucschar_t ch)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
|
@ -166,7 +166,7 @@ static bool tv_is_line_break_char(unsigned short ch)
|
|||
if (preferences->word_mode == WM_CHOP)
|
||||
return false;
|
||||
|
||||
for (i = 0; i < sizeof(break_chars)/sizeof(unsigned short); i++)
|
||||
for (i = 0; i < sizeof(break_chars)/sizeof(ucschar_t); i++)
|
||||
{
|
||||
if (break_chars[i] == ch)
|
||||
return true;
|
||||
|
@ -174,14 +174,14 @@ static bool tv_is_line_break_char(unsigned short ch)
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool tv_isspace(unsigned short ch)
|
||||
static bool tv_isspace(ucschar_t ch)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (ch < 128 && isspace(ch))
|
||||
return true;
|
||||
|
||||
for (i = 0; i < sizeof(extra_spaces)/sizeof(unsigned short); i++)
|
||||
for (i = 0; i < sizeof(extra_spaces)/sizeof(ucschar_t); i++)
|
||||
{
|
||||
if (extra_spaces[i] == ch)
|
||||
return true;
|
||||
|
@ -191,17 +191,17 @@ static bool tv_isspace(unsigned short ch)
|
|||
|
||||
static bool tv_is_break_line_join_mode(const unsigned char *next_str)
|
||||
{
|
||||
unsigned short ch;
|
||||
ucschar_t ch;
|
||||
|
||||
tv_get_ucs(next_str, &ch);
|
||||
return tv_isspace(ch);
|
||||
}
|
||||
|
||||
static int tv_form_reflow_line(unsigned short *ucs, int chars)
|
||||
static int tv_form_reflow_line(ucschar_t *ucs, int chars)
|
||||
{
|
||||
unsigned short new_ucs[TV_MAX_CHARS_PER_BLOCK];
|
||||
unsigned short *p = new_ucs;
|
||||
unsigned short ch;
|
||||
ucschar_t new_ucs[TV_MAX_CHARS_PER_BLOCK];
|
||||
ucschar_t *p = new_ucs;
|
||||
ucschar_t ch;
|
||||
int i;
|
||||
int k;
|
||||
int expand_spaces;
|
||||
|
@ -262,15 +262,15 @@ static int tv_form_reflow_line(unsigned short *ucs, int chars)
|
|||
}
|
||||
}
|
||||
|
||||
rb->memcpy(ucs, new_ucs, sizeof(unsigned short) * TV_MAX_CHARS_PER_BLOCK);
|
||||
rb->memcpy(ucs, new_ucs, sizeof(ucschar_t) * TV_MAX_CHARS_PER_BLOCK);
|
||||
return indent_chars + nonspace_chars + expand_spaces;
|
||||
}
|
||||
|
||||
static void tv_align_right(int *block_chars)
|
||||
{
|
||||
unsigned short *cur_text;
|
||||
unsigned short *prev_text;
|
||||
unsigned short ch;
|
||||
ucschar_t *cur_text;
|
||||
ucschar_t *prev_text;
|
||||
ucschar_t ch;
|
||||
int cur_block = block_count - 1;
|
||||
int prev_block;
|
||||
int cur_chars;
|
||||
|
@ -335,9 +335,9 @@ static void tv_align_right(int *block_chars)
|
|||
if (break_pos < prev_chars)
|
||||
{
|
||||
rb->memmove(cur_text + prev_chars - break_pos,
|
||||
cur_text, block_chars[cur_block] * sizeof(unsigned short));
|
||||
cur_text, block_chars[cur_block] * sizeof(ucschar_t));
|
||||
rb->memcpy(cur_text, prev_text + break_pos,
|
||||
(prev_chars - break_pos) * sizeof(unsigned short));
|
||||
(prev_chars - break_pos) * sizeof(ucschar_t));
|
||||
|
||||
block_chars[prev_block] = break_pos;
|
||||
block_chars[cur_block ] += prev_chars - break_pos;
|
||||
|
@ -347,15 +347,15 @@ static void tv_align_right(int *block_chars)
|
|||
}
|
||||
}
|
||||
|
||||
static int tv_parse_text(const unsigned char *src, unsigned short *ucs,
|
||||
static int tv_parse_text(const unsigned char *src, ucschar_t *ucs,
|
||||
int *ucs_chars, bool is_indent)
|
||||
{
|
||||
const unsigned char *cur = src;
|
||||
const unsigned char *next = src;
|
||||
const unsigned char *line_break_ptr = NULL;
|
||||
const unsigned char *line_end_ptr = NULL;
|
||||
unsigned short ch = 0;
|
||||
unsigned short prev_ch;
|
||||
ucschar_t ch = 0;
|
||||
ucschar_t prev_ch;
|
||||
int chars = 0;
|
||||
int gw;
|
||||
int line_break_width = 0;
|
||||
|
@ -480,7 +480,7 @@ static int tv_parse_text(const unsigned char *src, unsigned short *ucs,
|
|||
int tv_create_formed_text(const unsigned char *src, ssize_t bufsize,
|
||||
int block, bool is_multi, const unsigned char **dst)
|
||||
{
|
||||
unsigned short ch;
|
||||
ucschar_t ch;
|
||||
int chars[block_count];
|
||||
int i;
|
||||
int size = 0;
|
||||
|
|
|
@ -326,7 +326,7 @@
|
|||
struct keyboard_parameters {
|
||||
const unsigned char* default_kbd;
|
||||
int DEFAULT_LINES;
|
||||
unsigned short kbd_buf[KBD_BUF_SIZE];
|
||||
ucschar_t kbd_buf[KBD_BUF_SIZE];
|
||||
int nchars;
|
||||
int font_w;
|
||||
int font_h;
|
||||
|
@ -358,7 +358,7 @@ int zx_kbd_input(char* text/*, int buflen*/)
|
|||
int editpos, len_utf8;
|
||||
#endif
|
||||
/* int statusbar_size = global_settings.statusbar ? STATUSBAR_HEIGHT : 0;*/
|
||||
unsigned short ch/*, tmp, hlead = 0, hvowel = 0, htail = 0*/;
|
||||
ucschar_t ch/*, tmp, hlead = 0, hvowel = 0, htail = 0*/;
|
||||
/*bool hangul = false;*/
|
||||
unsigned char *utf8;
|
||||
const unsigned char *p;
|
||||
|
|
|
@ -90,15 +90,15 @@ enum ekbd_viewports
|
|||
struct keyboard_parameters
|
||||
{
|
||||
struct viewport *kbd_viewports;
|
||||
unsigned short kbd_buf[KBD_BUF_SIZE];
|
||||
unsigned short *kbd_buf_ptr;
|
||||
ucschar_t kbd_buf[KBD_BUF_SIZE];
|
||||
ucschar_t *kbd_buf_ptr;
|
||||
unsigned short max_line_len;
|
||||
int default_lines;
|
||||
int last_k;
|
||||
int last_i;
|
||||
int font_w;
|
||||
int font_h;
|
||||
int text_w;
|
||||
unsigned int last_k;
|
||||
unsigned int last_i;
|
||||
unsigned short font_w;
|
||||
unsigned short font_h;
|
||||
unsigned int text_w;
|
||||
int curfont;
|
||||
int main_y;
|
||||
#ifdef HAVE_MORSE_INPUT
|
||||
|
@ -128,7 +128,7 @@ struct edit_state
|
|||
int editpos; /* Edit position on all screens */
|
||||
bool cur_blink; /* Cursor on/off flag */
|
||||
bool hangul;
|
||||
unsigned short hlead, hvowel, htail;
|
||||
ucschar_t hlead, hvowel, htail;
|
||||
#ifdef HAVE_MORSE_INPUT
|
||||
bool morse_mode;
|
||||
bool morse_reading;
|
||||
|
@ -158,13 +158,13 @@ static void keyboard_layout(struct viewport *kbd_vp,
|
|||
{
|
||||
/*Note: viewports are initialized to vp_default by kbd_create_viewports */
|
||||
|
||||
int sc_w = sc->getwidth();
|
||||
int sc_h = sc->getheight();
|
||||
unsigned short sc_w = sc->getwidth();
|
||||
unsigned short sc_h = sc->getheight();
|
||||
|
||||
/* TEXT */
|
||||
struct viewport *vp = &kbd_vp[eKBD_VP_TEXT];
|
||||
/* make sure height is even for the text box */
|
||||
int text_height = (MAX(pm->font_h, get_icon_height(sc->screen_type)) & ~1) + 2;
|
||||
unsigned short text_height = (MAX(pm->font_h, (unsigned int)get_icon_height(sc->screen_type)) & ~1) + 2;
|
||||
vp->x = 0; /* LEFT */
|
||||
vp->y = 0; /* TOP */
|
||||
vp->width = sc_w;
|
||||
|
@ -224,7 +224,7 @@ int load_kbd(unsigned char* filename)
|
|||
int fd;
|
||||
int i, line_len, max_line_len;
|
||||
unsigned char buf[4];
|
||||
unsigned short *pbuf;
|
||||
ucschar_t *pbuf;
|
||||
|
||||
if (filename == NULL)
|
||||
{
|
||||
|
@ -245,7 +245,7 @@ int load_kbd(unsigned char* filename)
|
|||
/* check how many bytes to read for this character */
|
||||
static const unsigned char sizes[4] = { 0x80, 0xe0, 0xf0, 0xf5 };
|
||||
size_t count;
|
||||
unsigned short ch;
|
||||
ucschar_t ch;
|
||||
|
||||
for (count = 0; count < ARRAYLEN(sizes); count++)
|
||||
{
|
||||
|
@ -297,7 +297,7 @@ int load_kbd(unsigned char* filename)
|
|||
struct keyboard_parameters *pm = &kbd_param[l];
|
||||
#if NB_SCREENS > 1
|
||||
if (l > 0)
|
||||
memcpy(pm->kbd_buf, kbd_param[0].kbd_buf, i*sizeof(unsigned short));
|
||||
memcpy(pm->kbd_buf, kbd_param[0].kbd_buf, i*sizeof(ucschar_t));
|
||||
#endif
|
||||
/* initialize parameters */
|
||||
pm->x = pm->y = pm->page = 0;
|
||||
|
@ -309,7 +309,7 @@ int load_kbd(unsigned char* filename)
|
|||
}
|
||||
|
||||
/* helper function to spell a char */
|
||||
static void kbd_spellchar(unsigned short c)
|
||||
static void kbd_spellchar(ucschar_t c)
|
||||
{
|
||||
unsigned char tmp[5];
|
||||
/* store char to pass to talk_spell */
|
||||
|
@ -322,7 +322,7 @@ static void kbd_spellchar(unsigned short c)
|
|||
talk_spell(tmp, false);
|
||||
}
|
||||
|
||||
static void kbd_inschar(struct edit_state *state, unsigned short ch)
|
||||
static void kbd_inschar(struct edit_state *state, ucschar_t ch)
|
||||
{
|
||||
int i, j, len;
|
||||
unsigned char tmp[4];
|
||||
|
@ -361,10 +361,10 @@ static void kbd_delchar(struct edit_state *state)
|
|||
}
|
||||
|
||||
/* Lookup k value based on state of param (pm) */
|
||||
static unsigned short get_kbd_ch(struct keyboard_parameters *pm, int x, int y)
|
||||
static ucschar_t get_kbd_ch(struct keyboard_parameters *pm, int x, int y)
|
||||
{
|
||||
int i = 0, k = pm->page*pm->lines + y, n;
|
||||
unsigned short *pbuf;
|
||||
unsigned int n, i = 0, k = pm->page*pm->lines + y;
|
||||
ucschar_t *pbuf;
|
||||
if (k >= pm->last_k)
|
||||
{
|
||||
i = pm->last_i;
|
||||
|
@ -406,12 +406,12 @@ static void kbd_move_picker_horizontal(struct keyboard_parameters *pm,
|
|||
static void kbd_move_picker_vertical(struct keyboard_parameters *pm,
|
||||
struct edit_state *state, int dir);
|
||||
|
||||
int kbd_input(char* text, int buflen, unsigned short *kbd)
|
||||
int kbd_input(char* text, int buflen, ucschar_t *kbd)
|
||||
{
|
||||
bool done = false;
|
||||
struct keyboard_parameters * const param = kbd_param;
|
||||
struct edit_state state;
|
||||
unsigned short ch;
|
||||
ucschar_t ch;
|
||||
int ret = 0; /* assume success */
|
||||
FOR_NB_SCREENS(l)
|
||||
{
|
||||
|
@ -449,7 +449,7 @@ int kbd_input(char* text, int buflen, unsigned short *kbd)
|
|||
FOR_NB_SCREENS(l)
|
||||
{
|
||||
struct keyboard_parameters *pm = ¶m[l];
|
||||
unsigned short *pbuf;
|
||||
ucschar_t *pbuf;
|
||||
const unsigned char *p;
|
||||
int len = 0;
|
||||
|
||||
|
@ -800,8 +800,8 @@ static void kbd_calc_pm_params(struct keyboard_parameters *pm,
|
|||
{
|
||||
struct font* font;
|
||||
const unsigned char *p;
|
||||
unsigned short ch, *pbuf;
|
||||
int i, w;
|
||||
ucschar_t ch, *pbuf;
|
||||
unsigned int i, w;
|
||||
#ifdef HAVE_TOUCHSCREEN
|
||||
pm->show_buttons = (sc->screen_type == SCREEN_MAIN &&
|
||||
(touchscreen_get_mode() == TOUCHSCREEN_POINT));
|
||||
|
@ -812,7 +812,7 @@ static void kbd_calc_pm_params(struct keyboard_parameters *pm,
|
|||
pm->font_h = font->height;
|
||||
|
||||
/* check if FONT_UI fits the screen */
|
||||
if (2*pm->font_h + 3 > sc->getheight())
|
||||
if (pm->font_h*2 + 3 > sc->getheight())
|
||||
{
|
||||
pm->curfont = FONT_SYSFIXED;
|
||||
font = font_get(FONT_SYSFIXED);
|
||||
|
@ -858,9 +858,9 @@ static void kbd_calc_vp_params(struct keyboard_parameters *pm,
|
|||
{
|
||||
(void) state;
|
||||
struct viewport *vp = &pm->kbd_viewports[eKBD_VP_PICKER];
|
||||
int icon_w, sc_w, sc_h;
|
||||
unsigned int icon_w, sc_w, sc_h;
|
||||
int i, total_lines;
|
||||
unsigned short *pbuf;
|
||||
ucschar_t *pbuf;
|
||||
/* calculate how many characters to put in a row. */
|
||||
icon_w = get_icon_width(sc->screen_type);
|
||||
|
||||
|
@ -970,7 +970,7 @@ static void kbd_draw_picker(struct keyboard_parameters *pm,
|
|||
x = 0;
|
||||
y = 0;
|
||||
outline[1] = '\0';
|
||||
|
||||
|
||||
/* Draw morse code table with code descriptions. */
|
||||
for (i = 0; morse_alphabets[i] != '\0'; i++) {
|
||||
int morse_code;
|
||||
|
@ -1024,7 +1024,7 @@ static void kbd_draw_picker(struct keyboard_parameters *pm,
|
|||
/* draw page */
|
||||
int i, j;
|
||||
int w, h;
|
||||
unsigned short ch;
|
||||
ucschar_t ch;
|
||||
unsigned char *utf8;
|
||||
|
||||
sc->setfont(pm->curfont);
|
||||
|
@ -1071,7 +1071,7 @@ static void kbd_draw_edit_line(struct keyboard_parameters *pm,
|
|||
int sc_w = vp->width;
|
||||
int y = (vp->height - pm->font_h) / 2;
|
||||
|
||||
|
||||
|
||||
int text_margin = (sc_w - pm->text_w * pm->max_chars_text) / 2;
|
||||
|
||||
#if 0
|
||||
|
@ -1265,12 +1265,12 @@ static void kbd_insert_selected(struct keyboard_parameters *pm,
|
|||
struct edit_state *state)
|
||||
{
|
||||
/* find input char */
|
||||
unsigned short ch = get_kbd_ch(pm, pm->x, pm->y);
|
||||
ucschar_t ch = get_kbd_ch(pm, pm->x, pm->y);
|
||||
|
||||
/* check for hangul input */
|
||||
if (ch >= 0x3131 && ch <= 0x3163)
|
||||
{
|
||||
unsigned short tmp;
|
||||
ucschar_t tmp;
|
||||
|
||||
if (!state->hangul)
|
||||
{
|
||||
|
@ -1335,7 +1335,7 @@ static void kbd_insert_selected(struct keyboard_parameters *pm,
|
|||
|
||||
static void kbd_backspace(struct edit_state *state)
|
||||
{
|
||||
unsigned short ch;
|
||||
ucschar_t ch;
|
||||
if (state->hangul)
|
||||
{
|
||||
if (state->htail)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue