Revert "internals: Support characters beyond the first unicode plane (WIP)"

This reverts commit d05c59f35b.
This commit is contained in:
Solomon Peachy 2025-08-20 16:09:49 -04:00
parent d05c59f35b
commit 84504c7471
44 changed files with 335 additions and 480 deletions

View file

@ -82,7 +82,7 @@ static void kdb_init(void)
sleep(HZ/10);
}
int kbd_input(char* text, int buflen, ucschar_t *kbd)
int kbd_input(char* text, int buflen, unsigned short *kbd)
{
(void)kbd;
JNIEnv e = *env_ptr;
@ -107,7 +107,7 @@ int kbd_input(char* text, int buflen, ucschar_t *kbd)
e->DeleteLocalRef(env_ptr, str);
e->DeleteLocalRef(env_ptr, ok_text);
e->DeleteLocalRef(env_ptr, cancel_text);
return !accepted; /* return 0 on success */
}

View file

@ -23,7 +23,7 @@
/* '*kbd', same format as https://www.rockbox.org/wiki/LoadableKeyboardLayouts */
int kbd_input(char* buffer, int buflen, ucschar_t *kbd);
int kbd_input(char* buffer, int buflen, unsigned short *kbd);
int load_kbd(unsigned char* filename);

View file

@ -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 274
#define PLUGIN_API_VERSION 273
/* 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
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);
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 );
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, ucschar_t char_code);
int (*font_get_width)(struct font* pf, unsigned short 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, ucschar_t *ucs);
const unsigned char* (*utf8decode)(const unsigned char *utf8, unsigned short *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, ucschar_t *kbd);
int (*kbd_input)(char* buffer, int buflen, unsigned short *kbd);
struct tm* (*get_time)(void);
struct tm * (*gmtime_r)(const time_t *timep, struct tm *tm);
#if CONFIG_RTC

View file

@ -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 ucschar_t kbd_buf[sizeof(keybd_layout)];
static unsigned short 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;
ucschar_t *kbd_p;
unsigned short* kbd_p;
int selection = rb->gui_synclist_get_sel_pos(this_list);

View file

@ -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];
ucschar_t key;
short 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;
ucschar_t key;
short key;
zchar zkey;
for(;;)

View file

@ -206,8 +206,8 @@ static int prompt_filename(char *buf, size_t bufsz)
{
#define KBD_LAYOUT "abcdefghijklmnop\nqrstuvwxyz |()[]\n1234567890 /._-+\n\n" \
"\nABCDEFGHIJKLMNOP\nQRSTUVWXYZ |()[]\n1234567890 /._-+"
ucschar_t kbd[sizeof(KBD_LAYOUT) + 10];
ucschar_t *kbd_p = kbd;
unsigned short kbd[sizeof(KBD_LAYOUT) + 10];
unsigned short *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();

View file

@ -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)
{
ucschar_t ch;
ucschar_t *ucs;
int ch;
unsigned short *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);

View file

@ -22,8 +22,8 @@
#include "kbd_helper.h"
/* USAGE:
ucschar_t kbd[64];
ucschar_t *kbd_p = kbd;
unsigned short kbd[64];
unsigned short *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, ucschar_t *buf, int bufsz)
int kbd_create_layout(const char *layout, unsigned short *buf, int bufsz)
{
ucschar_t *pbuf;
unsigned short *pbuf;
const unsigned char *p = layout;
int len = 0;
int total_len = 0;
pbuf = buf;
while (*p && (pbuf - buf + (ptrdiff_t) sizeof(ucschar_t)) < bufsz)
while (*p && (pbuf - buf + (ptrdiff_t) sizeof(unsigned short)) < bufsz)
{
p = rb->utf8decode(p, &pbuf[len+1]);
if (pbuf[len+1] == '\n')
@ -60,7 +60,7 @@ int kbd_create_layout(const char *layout, ucschar_t *buf, int bufsz)
*pbuf = len;
pbuf[len+1] = 0xFEFF; /* mark end of characters */
total_len += len + 1;
return total_len * sizeof(ucschar_t);
return total_len * sizeof(unsigned short);
}
return 0;

View file

@ -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, ucschar_t *buf, int bufsz);
int kbd_create_layout(const char *layout, unsigned short *buf, int bufsz);
#endif /* KBD_HELPER_H */

View file

@ -62,7 +62,7 @@ static const char* get_next_line(const char *text, struct view_info *info)
total = 0;
while(*ptr)
{
ucschar_t ch;
unsigned short ch;
n = ((intptr_t)rb->utf8decode(ptr, &ch) - (intptr_t)ptr);
if (rb->is_diacritic(ch, NULL))
w = 0;

View file

@ -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);
ucschar_t ch;
unsigned short ch;
struct snap {
int count, width;
int nword;

View file

@ -141,7 +141,6 @@ RB_WRAP(touchscreen_mode)
#endif
// XXX this may be broken with 32-bit ucschar_t
RB_WRAP(kbd_input)
{
/*kbd_input(text, layout)*
@ -169,7 +168,7 @@ RB_WRAP(kbd_input)
layout = NULL;
}
if(!rb->kbd_input(buffer, LUAL_BUFFERSIZE, (ucschar_t *)layout))
if(!rb->kbd_input(buffer, LUAL_BUFFERSIZE, (unsigned short *)layout))
{
luaL_addstring(&b, buffer);
luaL_pushresult(&b);

View file

@ -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)
{
ucschar_t ch;
ucschar_t *ucs;
unsigned short ch;
unsigned short *ucs;
int ofs = MIN(x, 0);
struct font* pf = rb->font_get(osd.font);

View file

@ -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 )
{
ucschar_t ch;
ucschar_t *ucs;
unsigned short ch;
unsigned short *ucs;
struct font *pf = rb->font_get( FONT_UI );
if( !pf ) pf = rb->font_get( FONT_SYSFIXED );

View file

@ -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)
{
ucschar_t code;
unsigned short code;
const unsigned char *ptr = src;
while(*ptr)
{

View file

@ -41,7 +41,7 @@ static unsigned text_type = TV_TEXT_UNKNOWN;
static const unsigned char *end_ptr;
static ucschar_t ucsbuf[TV_MAX_BLOCKS][TV_MAX_CHARS_PER_BLOCK];
static unsigned short 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[] = // XXX promote to ucschar_t if we get a codepoint > 0xffff
static unsigned short break_chars[] =
{
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[] = // XXX promote to ucschar_t if we get a co
};
/* the characters which is not judged as space with isspace() */
static unsigned short extra_spaces[] = { 0, 0x3000 }; // XXX promote to ucschar_t if we get a codepoint > 0xffff
static unsigned short extra_spaces[] = { 0, 0x3000 };
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, ucschar_t *ch)
static unsigned char *tv_get_ucs(const unsigned char *str, unsigned short *ch)
{
int count = 1;
unsigned char utf8_tmp[3];
@ -148,7 +148,7 @@ static unsigned char *tv_get_ucs(const unsigned char *str, ucschar_t *ch)
return (unsigned char *)str + count;
}
static void tv_decode2utf8(const ucschar_t *ucs, int count)
static void tv_decode2utf8(const unsigned short *ucs, int count)
{
int i;
@ -158,7 +158,7 @@ static void tv_decode2utf8(const ucschar_t *ucs, int count)
*outbuf = '\0';
}
static bool tv_is_line_break_char(ucschar_t ch)
static bool tv_is_line_break_char(unsigned short ch)
{
size_t i;
@ -166,7 +166,7 @@ static bool tv_is_line_break_char(ucschar_t ch)
if (preferences->word_mode == WM_CHOP)
return false;
for (i = 0; i < sizeof(break_chars)/sizeof(ucschar_t); i++)
for (i = 0; i < sizeof(break_chars)/sizeof(unsigned short); i++)
{
if (break_chars[i] == ch)
return true;
@ -174,14 +174,14 @@ static bool tv_is_line_break_char(ucschar_t ch)
return false;
}
static bool tv_isspace(ucschar_t ch)
static bool tv_isspace(unsigned short ch)
{
size_t i;
if (ch < 128 && isspace(ch))
return true;
for (i = 0; i < sizeof(extra_spaces)/sizeof(ucschar_t); i++)
for (i = 0; i < sizeof(extra_spaces)/sizeof(unsigned short); i++)
{
if (extra_spaces[i] == ch)
return true;
@ -191,17 +191,17 @@ static bool tv_isspace(ucschar_t ch)
static bool tv_is_break_line_join_mode(const unsigned char *next_str)
{
ucschar_t ch;
unsigned short ch;
tv_get_ucs(next_str, &ch);
return tv_isspace(ch);
}
static int tv_form_reflow_line(ucschar_t *ucs, int chars)
static int tv_form_reflow_line(unsigned short *ucs, int chars)
{
ucschar_t new_ucs[TV_MAX_CHARS_PER_BLOCK];
ucschar_t *p = new_ucs;
ucschar_t ch;
unsigned short new_ucs[TV_MAX_CHARS_PER_BLOCK];
unsigned short *p = new_ucs;
unsigned short ch;
int i;
int k;
int expand_spaces;
@ -262,15 +262,15 @@ static int tv_form_reflow_line(ucschar_t *ucs, int chars)
}
}
rb->memcpy(ucs, new_ucs, sizeof(ucschar_t) * TV_MAX_CHARS_PER_BLOCK);
rb->memcpy(ucs, new_ucs, sizeof(unsigned short) * TV_MAX_CHARS_PER_BLOCK);
return indent_chars + nonspace_chars + expand_spaces;
}
static void tv_align_right(int *block_chars)
{
ucschar_t *cur_text;
ucschar_t *prev_text;
ucschar_t ch;
unsigned short *cur_text;
unsigned short *prev_text;
unsigned short 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(ucschar_t));
cur_text, block_chars[cur_block] * sizeof(unsigned short));
rb->memcpy(cur_text, prev_text + break_pos,
(prev_chars - break_pos) * sizeof(ucschar_t));
(prev_chars - break_pos) * sizeof(unsigned short));
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, ucschar_t *ucs,
static int tv_parse_text(const unsigned char *src, unsigned short *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;
ucschar_t ch = 0;
ucschar_t prev_ch;
unsigned short ch = 0;
unsigned short 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, ucschar_t *ucs,
int tv_create_formed_text(const unsigned char *src, ssize_t bufsize,
int block, bool is_multi, const unsigned char **dst)
{
ucschar_t ch;
unsigned short ch;
int chars[block_count];
int i;
int size = 0;

View file

@ -326,7 +326,7 @@
struct keyboard_parameters {
const unsigned char* default_kbd;
int DEFAULT_LINES;
ucschar_t kbd_buf[KBD_BUF_SIZE];
unsigned short 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;*/
ucschar_t ch/*, tmp, hlead = 0, hvowel = 0, htail = 0*/;
unsigned short ch/*, tmp, hlead = 0, hvowel = 0, htail = 0*/;
/*bool hangul = false;*/
unsigned char *utf8;
const unsigned char *p;

View file

@ -90,15 +90,15 @@ enum ekbd_viewports
struct keyboard_parameters
{
struct viewport *kbd_viewports;
ucschar_t kbd_buf[KBD_BUF_SIZE];
ucschar_t *kbd_buf_ptr;
unsigned short kbd_buf[KBD_BUF_SIZE];
unsigned short *kbd_buf_ptr;
unsigned short max_line_len;
int default_lines;
unsigned int last_k;
unsigned int last_i;
unsigned short font_w;
unsigned short font_h;
unsigned int text_w;
int last_k;
int last_i;
int font_w;
int font_h;
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;
ucschar_t hlead, hvowel, htail;
unsigned short 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 */
unsigned short sc_w = sc->getwidth();
unsigned short sc_h = sc->getheight();
int sc_w = sc->getwidth();
int sc_h = sc->getheight();
/* TEXT */
struct viewport *vp = &kbd_vp[eKBD_VP_TEXT];
/* make sure height is even for the text box */
unsigned short text_height = (MAX(pm->font_h, (unsigned int)get_icon_height(sc->screen_type)) & ~1) + 2;
int text_height = (MAX(pm->font_h, 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];
ucschar_t *pbuf;
unsigned short *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;
ucschar_t ch;
unsigned short 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(ucschar_t));
memcpy(pm->kbd_buf, kbd_param[0].kbd_buf, i*sizeof(unsigned short));
#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(ucschar_t c)
static void kbd_spellchar(unsigned short c)
{
unsigned char tmp[5];
/* store char to pass to talk_spell */
@ -322,7 +322,7 @@ static void kbd_spellchar(ucschar_t c)
talk_spell(tmp, false);
}
static void kbd_inschar(struct edit_state *state, ucschar_t ch)
static void kbd_inschar(struct edit_state *state, unsigned short 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 ucschar_t get_kbd_ch(struct keyboard_parameters *pm, int x, int y)
static unsigned short get_kbd_ch(struct keyboard_parameters *pm, int x, int y)
{
unsigned int n, i = 0, k = pm->page*pm->lines + y;
ucschar_t *pbuf;
int i = 0, k = pm->page*pm->lines + y, n;
unsigned short *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, ucschar_t *kbd)
int kbd_input(char* text, int buflen, unsigned short *kbd)
{
bool done = false;
struct keyboard_parameters * const param = kbd_param;
struct edit_state state;
ucschar_t ch;
unsigned short ch;
int ret = 0; /* assume success */
FOR_NB_SCREENS(l)
{
@ -449,7 +449,7 @@ int kbd_input(char* text, int buflen, ucschar_t *kbd)
FOR_NB_SCREENS(l)
{
struct keyboard_parameters *pm = &param[l];
ucschar_t *pbuf;
unsigned short *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;
ucschar_t ch, *pbuf;
unsigned int i, w;
unsigned short ch, *pbuf;
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 (pm->font_h*2 + 3 > sc->getheight())
if (2*pm->font_h + 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];
unsigned int icon_w, sc_w, sc_h;
int icon_w, sc_w, sc_h;
int i, total_lines;
ucschar_t *pbuf;
unsigned short *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;
ucschar_t ch;
unsigned short 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 */
ucschar_t ch = get_kbd_ch(pm, pm->x, pm->y);
unsigned short ch = get_kbd_ch(pm, pm->x, pm->y);
/* check for hangul input */
if (ch >= 0x3131 && ch <= 0x3163)
{
ucschar_t tmp;
unsigned short 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)
{
ucschar_t ch;
unsigned short ch;
if (state->hangul)
{
if (state->htail)