forked from len0rd/rockbox
keyboard: a bit of rework in keyboard.
* remove hangul thing from struct keyboard_parameters. * add new structure to hold state of edting and to be passed to functions. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24411 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
d3e82060c4
commit
e2359ac73b
1 changed files with 296 additions and 287 deletions
|
|
@ -20,7 +20,6 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "version.h"
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
#include "screens.h"
|
#include "screens.h"
|
||||||
|
|
@ -39,7 +38,6 @@
|
||||||
#include "viewport.h"
|
#include "viewport.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "splash.h"
|
#include "splash.h"
|
||||||
#include "appevents.h"
|
|
||||||
|
|
||||||
#ifndef O_BINARY
|
#ifndef O_BINARY
|
||||||
#define O_BINARY 0
|
#define O_BINARY 0
|
||||||
|
|
@ -94,17 +92,17 @@
|
||||||
|
|
||||||
struct keyboard_parameters
|
struct keyboard_parameters
|
||||||
{
|
{
|
||||||
const unsigned char* default_kbd;
|
|
||||||
int DEFAULT_LINES;
|
|
||||||
unsigned short kbd_buf[KBD_BUF_SIZE];
|
unsigned short kbd_buf[KBD_BUF_SIZE];
|
||||||
|
int default_lines;
|
||||||
int nchars;
|
int nchars;
|
||||||
int font_w;
|
int font_w;
|
||||||
int font_h;
|
int font_h;
|
||||||
int text_w;
|
int text_w;
|
||||||
struct font* font;
|
|
||||||
int curfont;
|
int curfont;
|
||||||
int main_y;
|
int main_y;
|
||||||
|
#ifdef HAVE_MORSE_INPUT
|
||||||
int old_main_y;
|
int old_main_y;
|
||||||
|
#endif
|
||||||
int max_chars;
|
int max_chars;
|
||||||
int max_chars_text;
|
int max_chars_text;
|
||||||
int lines;
|
int lines;
|
||||||
|
|
@ -118,8 +116,23 @@ struct keyboard_parameters
|
||||||
#ifdef KBD_MODES
|
#ifdef KBD_MODES
|
||||||
bool line_edit;
|
bool line_edit;
|
||||||
#endif
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
struct edit_state
|
||||||
|
{
|
||||||
|
char* text;
|
||||||
|
int buflen;
|
||||||
|
int len_utf8;
|
||||||
|
int editpos; /* Edit position on all screens */
|
||||||
|
bool cur_blink; /* Cursor on/off flag */
|
||||||
bool hangul;
|
bool hangul;
|
||||||
unsigned short hlead, hvowel, htail;
|
unsigned short hlead, hvowel, htail;
|
||||||
|
#ifdef HAVE_MORSE_INPUT
|
||||||
|
bool morse_mode;
|
||||||
|
bool morse_reading;
|
||||||
|
unsigned char morse_code;
|
||||||
|
int morse_tick;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct keyboard_parameters kbd_param[NB_SCREENS];
|
static struct keyboard_parameters kbd_param[NB_SCREENS];
|
||||||
|
|
@ -147,8 +160,10 @@ int load_kbd(unsigned char* filename)
|
||||||
|
|
||||||
FOR_NB_SCREENS(l)
|
FOR_NB_SCREENS(l)
|
||||||
{
|
{
|
||||||
|
/* initialize parameters */
|
||||||
struct keyboard_parameters *pm = &kbd_param[l];
|
struct keyboard_parameters *pm = &kbd_param[l];
|
||||||
pm->x = pm->y = pm->page = 0;
|
pm->x = pm->y = pm->page = 0;
|
||||||
|
pm->default_lines = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filename == NULL)
|
if (filename == NULL)
|
||||||
|
|
@ -185,12 +200,13 @@ int load_kbd(unsigned char* filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
utf8decode(buf, &ch);
|
utf8decode(buf, &ch);
|
||||||
|
if (ch != 0xFEFF && ch != '\r') /* skip BOM & carriage returns */
|
||||||
|
{
|
||||||
FOR_NB_SCREENS(l)
|
FOR_NB_SCREENS(l)
|
||||||
kbd_param[l].kbd_buf[i] = ch;
|
kbd_param[l].kbd_buf[i] = ch;
|
||||||
|
|
||||||
if (ch != 0xFEFF && ch != '\r') /*skip BOM & carriage returns */
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
kbd_loaded = true;
|
kbd_loaded = true;
|
||||||
|
|
@ -211,7 +227,7 @@ static void kbd_spellchar(unsigned short c)
|
||||||
unsigned char* utf8 = utf8encode(c, tmp);
|
unsigned char* utf8 = utf8encode(c, tmp);
|
||||||
*utf8 = 0;
|
*utf8 = 0;
|
||||||
|
|
||||||
if(c == ' ')
|
if (c == ' ')
|
||||||
talk_id(VOICE_BLANK, false);
|
talk_id(VOICE_BLANK, false);
|
||||||
else
|
else
|
||||||
talk_spell(tmp, false);
|
talk_spell(tmp, false);
|
||||||
|
|
@ -221,43 +237,42 @@ static void kbd_spellchar(unsigned short c)
|
||||||
#ifdef KBD_MODES
|
#ifdef KBD_MODES
|
||||||
static void say_edit(void)
|
static void say_edit(void)
|
||||||
{
|
{
|
||||||
if(global_settings.talk_menu)
|
if (global_settings.talk_menu)
|
||||||
talk_id(VOICE_EDIT, false);
|
talk_id(VOICE_EDIT, false);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void kbd_inschar(unsigned char* text, int buflen,
|
static void kbd_inschar(struct edit_state *state, unsigned short ch)
|
||||||
int* editpos, unsigned short ch)
|
|
||||||
{
|
{
|
||||||
int i, j, len;
|
int i, j, len;
|
||||||
unsigned char tmp[4];
|
unsigned char tmp[4];
|
||||||
unsigned char* utf8;
|
unsigned char* utf8;
|
||||||
|
|
||||||
len = strlen(text);
|
len = strlen(state->text);
|
||||||
utf8 = utf8encode(ch, tmp);
|
utf8 = utf8encode(ch, tmp);
|
||||||
j = (long)utf8 - (long)tmp;
|
j = (long)utf8 - (long)tmp;
|
||||||
|
|
||||||
if (len + j < buflen)
|
if (len + j < state->buflen)
|
||||||
{
|
{
|
||||||
i = utf8seek(text, *editpos);
|
i = utf8seek(state->text, state->editpos);
|
||||||
utf8 = text + i;
|
utf8 = state->text + i;
|
||||||
memmove(utf8 + j, utf8, len - i + 1);
|
memmove(utf8 + j, utf8, len - i + 1);
|
||||||
memcpy(utf8, tmp, j);
|
memcpy(utf8, tmp, j);
|
||||||
(*editpos)++;
|
state->editpos++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void kbd_delchar(unsigned char* text, int* editpos)
|
static void kbd_delchar(struct edit_state *state)
|
||||||
{
|
{
|
||||||
int i, j, len;
|
int i, j, len;
|
||||||
unsigned char* utf8;
|
unsigned char* utf8;
|
||||||
|
|
||||||
if (*editpos > 0)
|
if (state->editpos > 0)
|
||||||
{
|
{
|
||||||
(*editpos)--;
|
state->editpos--;
|
||||||
len = strlen(text);
|
len = strlen(state->text);
|
||||||
i = utf8seek(text, *editpos);
|
i = utf8seek(state->text, state->editpos);
|
||||||
utf8 = text + i;
|
utf8 = state->text + i;
|
||||||
j = utf8seek(utf8, 1);
|
j = utf8seek(utf8, 1);
|
||||||
memmove(utf8, utf8 + j, len - i - j + 1);
|
memmove(utf8, utf8 + j, len - i - j + 1);
|
||||||
}
|
}
|
||||||
|
|
@ -279,29 +294,53 @@ int kbd_input(char* text, int buflen)
|
||||||
#else
|
#else
|
||||||
struct keyboard_parameters * const param = kbd_param;
|
struct keyboard_parameters * const param = kbd_param;
|
||||||
#endif
|
#endif
|
||||||
|
struct edit_state state;
|
||||||
int l; /* screen loop variable */
|
int l; /* screen loop variable */
|
||||||
int editpos; /* Edit position on all screens */
|
|
||||||
unsigned short ch;
|
unsigned short ch;
|
||||||
unsigned char *utf8;
|
|
||||||
bool cur_blink = true; /* Cursor on/off flag */
|
|
||||||
int ret = 0; /* assume success */
|
int ret = 0; /* assume success */
|
||||||
#ifdef HAVE_MORSE_INPUT
|
FOR_NB_SCREENS(l)
|
||||||
bool morse_mode = global_settings.morse_input;
|
{
|
||||||
bool morse_reading = false;
|
viewportmanager_theme_enable(l, false, NULL);
|
||||||
unsigned char morse_code = 0;
|
}
|
||||||
int morse_tick = 0;
|
|
||||||
|
char outline[8];
|
||||||
|
#ifdef HAVE_BUTTONBAR
|
||||||
|
struct gui_buttonbar buttonbar;
|
||||||
|
bool buttonbar_config = global_settings.buttonbar;
|
||||||
|
|
||||||
|
global_settings.buttonbar = true;
|
||||||
|
gui_buttonbar_init(&buttonbar);
|
||||||
|
gui_buttonbar_set_display(&buttonbar, &screens[SCREEN_MAIN]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* initialize state */
|
||||||
|
state.text = text;
|
||||||
|
state.buflen = buflen;
|
||||||
|
state.cur_blink = true;
|
||||||
|
#ifdef HAVE_MORSE_INPUT
|
||||||
|
state.morse_mode = global_settings.morse_input;
|
||||||
|
state.morse_reading = false;
|
||||||
|
#endif
|
||||||
|
state.hangul = false;
|
||||||
|
|
||||||
|
if (!kbd_loaded)
|
||||||
|
{
|
||||||
|
/* Copy default keyboard to buffer */
|
||||||
FOR_NB_SCREENS(l)
|
FOR_NB_SCREENS(l)
|
||||||
{
|
{
|
||||||
struct keyboard_parameters *pm = ¶m[l];
|
struct keyboard_parameters *pm = ¶m[l];
|
||||||
viewportmanager_theme_enable(l, false, NULL);
|
const unsigned char *p;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
/* initialize parameters */
|
||||||
|
pm->x = pm->y = pm->page = 0;
|
||||||
|
|
||||||
#if LCD_WIDTH >= 160 && LCD_HEIGHT >= 96
|
#if LCD_WIDTH >= 160 && LCD_HEIGHT >= 96
|
||||||
struct screen *sc = &screens[l];
|
struct screen *sc = &screens[l];
|
||||||
|
|
||||||
if (sc->getwidth() >= 160 && sc->getheight() >= 96)
|
if (sc->getwidth() >= 160 && sc->getheight() >= 96)
|
||||||
{
|
{
|
||||||
pm->default_kbd =
|
p = "ABCDEFG abcdefg !?\" @#$%+'\n"
|
||||||
"ABCDEFG abcdefg !?\" @#$%+'\n"
|
|
||||||
"HIJKLMN hijklmn 789 &_()-`\n"
|
"HIJKLMN hijklmn 789 &_()-`\n"
|
||||||
"OPQRSTU opqrstu 456 §|{}/<\n"
|
"OPQRSTU opqrstu 456 §|{}/<\n"
|
||||||
"VWXYZ., vwxyz.,0123 ~=[]*>\n"
|
"VWXYZ., vwxyz.,0123 ~=[]*>\n"
|
||||||
|
|
@ -310,13 +349,12 @@ int kbd_input(char* text, int buflen)
|
||||||
"ÓÒÔÕÖØ ÇÐÞÝß ÙÚÛÜ ¯±×÷¡¿µ·\n"
|
"ÓÒÔÕÖØ ÇÐÞÝß ÙÚÛÜ ¯±×÷¡¿µ·\n"
|
||||||
"òóôõöø çðþýÿ ùúûü ¼½¾¬¶¨:;";
|
"òóôõöø çðþýÿ ùúûü ¼½¾¬¶¨:;";
|
||||||
|
|
||||||
pm->DEFAULT_LINES = 8;
|
pm->default_lines = 8;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* LCD_WIDTH >= 160 && LCD_HEIGHT >= 96 */
|
#endif /* LCD_WIDTH >= 160 && LCD_HEIGHT >= 96 */
|
||||||
{
|
{
|
||||||
pm->default_kbd =
|
p = "ABCDEFG !?\" @#$%+'\n"
|
||||||
"ABCDEFG !?\" @#$%+'\n"
|
|
||||||
"HIJKLMN 789 &_()-`\n"
|
"HIJKLMN 789 &_()-`\n"
|
||||||
"OPQRSTU 456 §|{}/<\n"
|
"OPQRSTU 456 §|{}/<\n"
|
||||||
"VWXYZ.,0123 ~=[]*>\n"
|
"VWXYZ.,0123 ~=[]*>\n"
|
||||||
|
|
@ -331,85 +369,77 @@ int kbd_input(char* text, int buflen)
|
||||||
"ÓÒÔÕÖØ ÇÐÞÝß ÙÚÛÜ\n"
|
"ÓÒÔÕÖØ ÇÐÞÝß ÙÚÛÜ\n"
|
||||||
"òóôõöø çðþýÿ ùúûü";
|
"òóôõöø çðþýÿ ùúûü";
|
||||||
|
|
||||||
pm->DEFAULT_LINES = 4;
|
pm->default_lines = 4;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char outline[256];
|
while (*p)
|
||||||
#ifdef HAVE_BUTTONBAR
|
|
||||||
struct gui_buttonbar buttonbar;
|
|
||||||
bool buttonbar_config = global_settings.buttonbar;
|
|
||||||
|
|
||||||
global_settings.buttonbar = true;
|
|
||||||
gui_buttonbar_init(&buttonbar);
|
|
||||||
|
|
||||||
FOR_NB_SCREENS(l)
|
|
||||||
gui_buttonbar_set_display(&buttonbar, &screens[l]);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
FOR_NB_SCREENS(l)
|
|
||||||
{
|
|
||||||
struct keyboard_parameters *pm = ¶m[l];
|
|
||||||
|
|
||||||
if ( !kbd_loaded )
|
|
||||||
{
|
|
||||||
/* Copy default keyboard to buffer */
|
|
||||||
const unsigned char *p = pm->default_kbd;
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
pm->curfont = FONT_SYSFIXED;
|
|
||||||
|
|
||||||
while (*p != 0)
|
|
||||||
p = utf8decode(p, &pm->kbd_buf[i++]);
|
p = utf8decode(p, &pm->kbd_buf[i++]);
|
||||||
|
|
||||||
pm->nchars = i;
|
pm->nchars = i;
|
||||||
}
|
}
|
||||||
else
|
kbd_loaded = true;
|
||||||
{
|
|
||||||
pm->curfont = FONT_UI;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FOR_NB_SCREENS(l)
|
FOR_NB_SCREENS(l)
|
||||||
{
|
{
|
||||||
struct keyboard_parameters *pm = ¶m[l];
|
struct keyboard_parameters *pm = ¶m[l];
|
||||||
struct screen *sc = &screens[l];
|
struct screen *sc = &screens[l];
|
||||||
|
struct font* font;
|
||||||
|
const unsigned char *p;
|
||||||
|
int icon_w, sc_w;
|
||||||
int i, w;
|
int i, w;
|
||||||
|
|
||||||
pm->font = font_get(pm->curfont);
|
pm->curfont = pm->default_lines ? FONT_SYSFIXED : FONT_UI;
|
||||||
pm->font_h = pm->font->height;
|
font = font_get(pm->curfont);
|
||||||
|
pm->font_h = font->height;
|
||||||
|
|
||||||
/* check if FONT_UI fits the screen */
|
/* check if FONT_UI fits the screen */
|
||||||
if (2*pm->font_h + 3 + BUTTONBAR_HEIGHT > sc->getheight())
|
if (2*pm->font_h + 3 + BUTTONBAR_HEIGHT > sc->getheight())
|
||||||
{
|
{
|
||||||
pm->font = font_get(FONT_SYSFIXED);
|
|
||||||
pm->font_h = pm->font->height;
|
|
||||||
pm->curfont = FONT_SYSFIXED;
|
pm->curfont = FONT_SYSFIXED;
|
||||||
|
font = font_get(FONT_SYSFIXED);
|
||||||
|
pm->font_h = font->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* find max width of keyboard glyphs.
|
/* find max width of keyboard glyphs.
|
||||||
* since we're going to be adding spaces,
|
* since we're going to be adding spaces,
|
||||||
* max width is at least their width */
|
* max width is at least their width */
|
||||||
pm->font_w = font_get_width(pm->font, ' ');
|
pm->font_w = font_get_width(font, ' ');
|
||||||
for (i = 0; i < pm->nchars; i++)
|
for (i = 0; i < pm->nchars; i++)
|
||||||
{
|
{
|
||||||
if (pm->kbd_buf[i] != '\n')
|
if (pm->kbd_buf[i] != '\n')
|
||||||
{
|
{
|
||||||
w = font_get_width(pm->font, pm->kbd_buf[i]);
|
w = font_get_width(font, pm->kbd_buf[i]);
|
||||||
if (w > pm->font_w)
|
if (pm->font_w < w)
|
||||||
pm->font_w = w;
|
pm->font_w = w;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Find max width for text string */
|
||||||
|
pm->text_w = pm->font_w;
|
||||||
|
p = state.text;
|
||||||
|
while (*p)
|
||||||
|
{
|
||||||
|
p = utf8decode(p, &ch);
|
||||||
|
w = font_get_width(font, ch);
|
||||||
|
if (pm->text_w < w)
|
||||||
|
pm->text_w = w;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* calculate how many characters to put in a row. */
|
||||||
|
icon_w = get_icon_width(l);
|
||||||
|
sc_w = sc->getwidth();
|
||||||
|
pm->max_chars = sc_w / pm->font_w;
|
||||||
|
pm->max_chars_text = (sc_w - icon_w * 2 - 2) / pm->text_w;
|
||||||
|
if (pm->max_chars_text < 3 && icon_w > pm->text_w)
|
||||||
|
pm->max_chars_text = sc_w / pm->text_w - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
FOR_NB_SCREENS(l)
|
FOR_NB_SCREENS(l)
|
||||||
{
|
{
|
||||||
struct keyboard_parameters *pm = ¶m[l];
|
struct keyboard_parameters *pm = ¶m[l];
|
||||||
struct screen *sc = &screens[l];
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
pm->max_chars = sc->getwidth() / pm->font_w;
|
|
||||||
|
|
||||||
/* Pad lines with spaces */
|
/* Pad lines with spaces */
|
||||||
while (i < pm->nchars)
|
while (i < pm->nchars)
|
||||||
{
|
{
|
||||||
|
|
@ -455,36 +485,18 @@ int kbd_input(char* text, int buflen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find max width for text string */
|
/* calculate pm->pages and pm->lines */
|
||||||
FOR_NB_SCREENS(l)
|
FOR_NB_SCREENS(l)
|
||||||
{
|
{
|
||||||
struct keyboard_parameters *pm = ¶m[l];
|
struct keyboard_parameters *pm = ¶m[l];
|
||||||
struct screen *sc = &screens[l];
|
struct screen *sc = &screens[l];
|
||||||
int icon_w, sc_w, sc_h;
|
int sc_h, total_lines;
|
||||||
|
|
||||||
pm->text_w = pm->font_w;
|
|
||||||
|
|
||||||
utf8 = text;
|
|
||||||
while (*utf8)
|
|
||||||
{
|
|
||||||
int w;
|
|
||||||
utf8 = (unsigned char*)utf8decode(utf8, &ch);
|
|
||||||
w = font_get_width(pm->font, ch);
|
|
||||||
if (w > pm->text_w)
|
|
||||||
pm->text_w = w;
|
|
||||||
}
|
|
||||||
|
|
||||||
icon_w = get_icon_width(l);
|
|
||||||
sc_w = sc->getwidth();
|
|
||||||
sc_h = sc->getheight();
|
sc_h = sc->getheight();
|
||||||
pm->max_chars_text = (sc_w - icon_w * 2 - 2) / pm->text_w;
|
|
||||||
if(pm->max_chars_text < 3 && icon_w > pm->text_w)
|
|
||||||
pm->max_chars_text = sc_w / pm->text_w - 2;
|
|
||||||
|
|
||||||
pm->lines = (sc_h - BUTTONBAR_HEIGHT) / pm->font_h - 1;
|
pm->lines = (sc_h - BUTTONBAR_HEIGHT) / pm->font_h - 1;
|
||||||
|
|
||||||
if (!kbd_loaded && pm->lines > pm->DEFAULT_LINES)
|
if (pm->default_lines && pm->lines > pm->default_lines)
|
||||||
pm->lines = pm->DEFAULT_LINES;
|
pm->lines = pm->default_lines;
|
||||||
|
|
||||||
pm->keyboard_margin = sc_h - BUTTONBAR_HEIGHT
|
pm->keyboard_margin = sc_h - BUTTONBAR_HEIGHT
|
||||||
- (pm->lines+1)*pm->font_h;
|
- (pm->lines+1)*pm->font_h;
|
||||||
|
|
@ -498,27 +510,29 @@ int kbd_input(char* text, int buflen)
|
||||||
if (pm->keyboard_margin > DEFAULT_MARGIN)
|
if (pm->keyboard_margin > DEFAULT_MARGIN)
|
||||||
pm->keyboard_margin = DEFAULT_MARGIN;
|
pm->keyboard_margin = DEFAULT_MARGIN;
|
||||||
|
|
||||||
pm->pages = (pm->nchars + (pm->lines*pm->max_chars-1))
|
total_lines = (pm->nchars + pm->max_chars - 1) / pm->max_chars;
|
||||||
/ (pm->lines*pm->max_chars);
|
pm->pages = (total_lines + pm->lines - 1) / pm->lines;
|
||||||
|
pm->lines = (total_lines + pm->pages - 1) / pm->pages;
|
||||||
if (pm->pages == 1)
|
|
||||||
pm->lines = (pm->nchars + pm->max_chars - 1) / pm->max_chars;
|
|
||||||
|
|
||||||
pm->main_y = pm->font_h*pm->lines + pm->keyboard_margin;
|
pm->main_y = pm->font_h*pm->lines + pm->keyboard_margin;
|
||||||
pm->keyboard_margin -= pm->keyboard_margin/2;
|
pm->keyboard_margin -= pm->keyboard_margin/2;
|
||||||
|
|
||||||
#ifdef HAVE_MORSE_INPUT
|
#ifdef HAVE_MORSE_INPUT
|
||||||
pm->old_main_y = pm->main_y;
|
pm->old_main_y = sc_h - pm->font_h - BUTTONBAR_HEIGHT;
|
||||||
if (morse_mode)
|
if (state.morse_mode)
|
||||||
pm->main_y = sc_h - pm->font_h - BUTTONBAR_HEIGHT;
|
{
|
||||||
|
int y = pm->main_y;
|
||||||
|
pm->main_y = pm->old_main_y;
|
||||||
|
pm->old_main_y = y;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initial edit position is after last character */
|
/* Initial edit position is after last character */
|
||||||
editpos = utf8length(text);
|
state.editpos = utf8length(state.text);
|
||||||
|
|
||||||
if (global_settings.talk_menu) /* voice UI? */
|
if (global_settings.talk_menu) /* voice UI? */
|
||||||
talk_spell(text, true); /* spell initial text */
|
talk_spell(state.text, true); /* spell initial text */
|
||||||
|
|
||||||
while (!done)
|
while (!done)
|
||||||
{
|
{
|
||||||
|
|
@ -534,21 +548,23 @@ int kbd_input(char* text, int buflen)
|
||||||
struct keyboard_parameters *pm;
|
struct keyboard_parameters *pm;
|
||||||
struct screen *sc;
|
struct screen *sc;
|
||||||
|
|
||||||
int len_utf8 = utf8length(text);
|
state.len_utf8 = utf8length(state.text);
|
||||||
|
|
||||||
FOR_NB_SCREENS(l)
|
FOR_NB_SCREENS(l)
|
||||||
screens[l].clear_display();
|
screens[l].clear_display();
|
||||||
|
|
||||||
#ifdef HAVE_MORSE_INPUT
|
|
||||||
if (morse_mode)
|
|
||||||
{
|
|
||||||
FOR_NB_SCREENS(l)
|
FOR_NB_SCREENS(l)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_MORSE_INPUT
|
||||||
|
if (state.morse_mode)
|
||||||
|
{
|
||||||
/* declare scoped pointers inside screen loops - hide the
|
/* declare scoped pointers inside screen loops - hide the
|
||||||
declarations from previous block level */
|
declarations from previous block level */
|
||||||
const int w = 6; /* sysfixed font width */
|
const int w = 6, h = 8; /* sysfixed font width, height */
|
||||||
|
struct keyboard_parameters *pm = ¶m[l];
|
||||||
struct screen *sc = &screens[l];
|
struct screen *sc = &screens[l];
|
||||||
int i, x, y;
|
int i, x, y;
|
||||||
|
int sc_w = sc->getwidth(), sc_h = pm->main_y - pm->keyboard_margin - 1;
|
||||||
|
|
||||||
/* Draw morse code screen with sysfont */
|
/* Draw morse code screen with sysfont */
|
||||||
sc->setfont(FONT_SYSFIXED);
|
sc->setfont(FONT_SYSFIXED);
|
||||||
|
|
@ -559,30 +575,33 @@ int kbd_input(char* text, int buflen)
|
||||||
/* Draw morse code table with code descriptions. */
|
/* Draw morse code table with code descriptions. */
|
||||||
for (i = 0; morse_alphabets[i] != '\0'; i++)
|
for (i = 0; morse_alphabets[i] != '\0'; i++)
|
||||||
{
|
{
|
||||||
int morse_len;
|
int morse_code, j;
|
||||||
int j;
|
|
||||||
|
|
||||||
outline[0] = morse_alphabets[i];
|
outline[0] = morse_alphabets[i];
|
||||||
sc->putsxy(x, y, outline);
|
sc->putsxy(x, y, outline);
|
||||||
|
|
||||||
for (j = 0; (morse_codes[i] >> j) > 0x01; j++) ;
|
morse_code = morse_codes[i];
|
||||||
morse_len = j;
|
for (j = 0; morse_code > 0x01; morse_code >>= 1)
|
||||||
|
j++;
|
||||||
|
|
||||||
x += w + 3;
|
x += w + 3 + j*4;
|
||||||
for (j = 0; j < morse_len; j++)
|
morse_code = morse_codes[i];
|
||||||
|
for (; morse_code > 0x01; morse_code >>= 1)
|
||||||
{
|
{
|
||||||
if ((morse_codes[i] >> (morse_len-j-1)) & 0x01)
|
x -= 4;
|
||||||
sc->fillrect(x + j*4, y + 2, 3, 4);
|
if (morse_code & 0x01)
|
||||||
|
sc->fillrect(x, y + 2, 3, 4);
|
||||||
else
|
else
|
||||||
sc->fillrect(x + j*4, y + 3, 1, 2);
|
sc->fillrect(x, y + 3, 1, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
x += w*5 - 3;
|
x += w*5 - 3;
|
||||||
if (x + w*6 >= sc->getwidth())
|
if (x + w*6 >= sc_w)
|
||||||
{
|
{
|
||||||
x = 0;
|
x = 0;
|
||||||
y += 8; /* sysfixed font height */
|
y += h;
|
||||||
}
|
if (y + h >= sc_h)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -590,8 +609,6 @@ int kbd_input(char* text, int buflen)
|
||||||
#endif /* HAVE_MORSE_INPUT */
|
#endif /* HAVE_MORSE_INPUT */
|
||||||
{
|
{
|
||||||
/* draw page */
|
/* draw page */
|
||||||
FOR_NB_SCREENS(l)
|
|
||||||
{
|
|
||||||
struct keyboard_parameters *pm = ¶m[l];
|
struct keyboard_parameters *pm = ¶m[l];
|
||||||
struct screen *sc = &screens[l];
|
struct screen *sc = &screens[l];
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
|
|
@ -600,9 +617,10 @@ int kbd_input(char* text, int buflen)
|
||||||
|
|
||||||
k = pm->page*pm->max_chars*pm->lines;
|
k = pm->page*pm->max_chars*pm->lines;
|
||||||
|
|
||||||
for (i = j = 0; j < pm->lines && k < pm->nchars; k++)
|
for (i = j = 0; k < pm->nchars; k++)
|
||||||
{
|
{
|
||||||
int w;
|
int w;
|
||||||
|
unsigned char *utf8;
|
||||||
utf8 = utf8encode(pm->kbd_buf[k], outline);
|
utf8 = utf8encode(pm->kbd_buf[k], outline);
|
||||||
*utf8 = 0;
|
*utf8 = 0;
|
||||||
|
|
||||||
|
|
@ -613,9 +631,21 @@ int kbd_input(char* text, int buflen)
|
||||||
if (++i >= pm->max_chars)
|
if (++i >= pm->max_chars)
|
||||||
{
|
{
|
||||||
i = 0;
|
i = 0;
|
||||||
j++;
|
if (++j >= pm->lines)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef KBD_MODES
|
||||||
|
if (!pm->line_edit)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
/* highlight the key that has focus */
|
||||||
|
sc->set_drawmode(DRMODE_COMPLEMENT);
|
||||||
|
sc->fillrect(pm->font_w*pm->x, pm->font_h*pm->y,
|
||||||
|
pm->font_w, pm->font_h);
|
||||||
|
sc->set_drawmode(DRMODE_SOLID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -623,43 +653,37 @@ int kbd_input(char* text, int buflen)
|
||||||
{
|
{
|
||||||
struct keyboard_parameters *pm = ¶m[l];
|
struct keyboard_parameters *pm = ¶m[l];
|
||||||
struct screen *sc = &screens[l];
|
struct screen *sc = &screens[l];
|
||||||
|
unsigned char *utf8;
|
||||||
int i = 0, j = 0, icon_w;
|
int i = 0, j = 0, icon_w;
|
||||||
int text_w = pm->text_w;
|
int text_w = pm->text_w;
|
||||||
int sc_w = sc->getwidth();
|
int sc_w = sc->getwidth();
|
||||||
|
int y = pm->main_y - pm->keyboard_margin, w;
|
||||||
int text_margin = (sc_w - text_w * pm->max_chars_text) / 2;
|
int text_margin = (sc_w - text_w * pm->max_chars_text) / 2;
|
||||||
|
|
||||||
/* Clear text area one pixel above separator line so any overdraw
|
/* Clear text area one pixel above separator line so any overdraw
|
||||||
doesn't collide */
|
doesn't collide */
|
||||||
sc->set_drawmode(DRMODE_SOLID | DRMODE_INVERSEVID);
|
screen_clear_area(sc, 0, y - 1, sc_w, pm->font_h + 4);
|
||||||
sc->fillrect(0, pm->main_y - pm->keyboard_margin - 1,
|
|
||||||
sc_w, pm->font_h + 4);
|
|
||||||
sc->set_drawmode(DRMODE_SOLID);
|
|
||||||
|
|
||||||
sc->hline(0, sc_w - 1, pm->main_y - pm->keyboard_margin);
|
sc->hline(0, sc_w - 1, y);
|
||||||
|
|
||||||
/* write out the text */
|
/* write out the text */
|
||||||
sc->setfont(pm->curfont);
|
sc->setfont(pm->curfont);
|
||||||
|
|
||||||
pm->curpos = MIN(editpos, pm->max_chars_text
|
pm->curpos = MIN(state.editpos, pm->max_chars_text
|
||||||
- MIN(len_utf8 - editpos, 2));
|
- MIN(state.len_utf8 - state.editpos, 2));
|
||||||
pm->leftpos = editpos - pm->curpos;
|
pm->leftpos = state.editpos - pm->curpos;
|
||||||
utf8 = text + utf8seek(text, pm->leftpos);
|
utf8 = state.text + utf8seek(state.text, pm->leftpos);
|
||||||
|
|
||||||
while (*utf8 && i < pm->max_chars_text)
|
while (*utf8 && i < pm->max_chars_text)
|
||||||
{
|
{
|
||||||
outline[j++] = *utf8++;
|
j = utf8seek(utf8, 1);
|
||||||
|
strlcpy(outline, utf8, j+1);
|
||||||
if ((*utf8 & MASK) != COMP)
|
|
||||||
{
|
|
||||||
int w;
|
|
||||||
outline[j] = 0;
|
|
||||||
j = 0;
|
|
||||||
sc->getstringsize(outline, &w, NULL);
|
sc->getstringsize(outline, &w, NULL);
|
||||||
sc->putsxy(text_margin + i*text_w + (text_w-w)/2,
|
sc->putsxy(text_margin + i*text_w + (text_w-w)/2,
|
||||||
pm->main_y, outline);
|
pm->main_y, outline);
|
||||||
|
utf8 += j;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
icon_w = get_icon_width(l);
|
icon_w = get_icon_width(l);
|
||||||
if (pm->leftpos > 0)
|
if (pm->leftpos > 0)
|
||||||
|
|
@ -673,13 +697,12 @@ int kbd_input(char* text, int buflen)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int w;
|
|
||||||
sc->getstringsize("<", &w, NULL);
|
sc->getstringsize("<", &w, NULL);
|
||||||
sc->putsxy(text_margin - w, pm->main_y, "<");
|
sc->putsxy(text_margin - w, pm->main_y, "<");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len_utf8 - pm->leftpos > pm->max_chars_text)
|
if (state.len_utf8 - pm->leftpos > pm->max_chars_text)
|
||||||
{
|
{
|
||||||
/* Draw nicer bitmap arrow if room, else settle for ">". */
|
/* Draw nicer bitmap arrow if room, else settle for ">". */
|
||||||
if (text_margin >= icon_w)
|
if (text_margin >= icon_w)
|
||||||
|
|
@ -697,14 +720,23 @@ int kbd_input(char* text, int buflen)
|
||||||
/* cursor */
|
/* cursor */
|
||||||
i = text_margin + pm->curpos * text_w;
|
i = text_margin + pm->curpos * text_w;
|
||||||
|
|
||||||
if (cur_blink)
|
if (state.cur_blink)
|
||||||
sc->vline(i, pm->main_y, pm->main_y + pm->font_h - 1);
|
sc->vline(i, pm->main_y, pm->main_y + pm->font_h - 1);
|
||||||
|
|
||||||
if (pm->hangul) /* draw underbar */
|
if (state.hangul) /* draw underbar */
|
||||||
sc->hline(i - text_w, i, pm->main_y + pm->font_h - 1);
|
sc->hline(i - text_w, i, pm->main_y + pm->font_h - 1);
|
||||||
|
|
||||||
|
#ifdef KBD_MODES
|
||||||
|
if (pm->line_edit)
|
||||||
|
{
|
||||||
|
sc->set_drawmode(DRMODE_COMPLEMENT);
|
||||||
|
sc->fillrect(0, y + 2, sc_w, pm->font_h + 2);
|
||||||
|
sc->set_drawmode(DRMODE_SOLID);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_blink = !cur_blink;
|
state.cur_blink = !state.cur_blink;
|
||||||
|
|
||||||
#ifdef HAVE_BUTTONBAR
|
#ifdef HAVE_BUTTONBAR
|
||||||
/* draw the button bar */
|
/* draw the button bar */
|
||||||
|
|
@ -712,32 +744,12 @@ int kbd_input(char* text, int buflen)
|
||||||
gui_buttonbar_draw(&buttonbar);
|
gui_buttonbar_draw(&buttonbar);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FOR_NB_SCREENS(l)
|
|
||||||
{
|
|
||||||
struct keyboard_parameters *pm = ¶m[l];
|
|
||||||
struct screen *sc = &screens[l];
|
|
||||||
|
|
||||||
sc->set_drawmode(DRMODE_COMPLEMENT);
|
|
||||||
#ifdef KBD_MODES
|
|
||||||
if (pm->line_edit)
|
|
||||||
sc->fillrect(0, pm->main_y - pm->keyboard_margin + 2,
|
|
||||||
sc->getwidth(), pm->font_h + 2);
|
|
||||||
else /* highlight the key that has focus */
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_MORSE_INPUT
|
|
||||||
if(!morse_mode)
|
|
||||||
#endif
|
|
||||||
sc->fillrect(pm->font_w*pm->x, pm->font_h*pm->y,
|
|
||||||
pm->font_w, pm->font_h);
|
|
||||||
sc->set_drawmode(DRMODE_SOLID);
|
|
||||||
}
|
|
||||||
|
|
||||||
FOR_NB_SCREENS(l)
|
FOR_NB_SCREENS(l)
|
||||||
screens[l].update();
|
screens[l].update();
|
||||||
|
|
||||||
button = get_action(
|
button = get_action(
|
||||||
#ifdef HAVE_MORSE_INPUT
|
#ifdef HAVE_MORSE_INPUT
|
||||||
morse_mode? CONTEXT_MORSE_INPUT:
|
state.morse_mode? CONTEXT_MORSE_INPUT:
|
||||||
#endif
|
#endif
|
||||||
CONTEXT_KEYBOARD, HZ/2);
|
CONTEXT_KEYBOARD, HZ/2);
|
||||||
#if NB_SCREENS > 1
|
#if NB_SCREENS > 1
|
||||||
|
|
@ -750,11 +762,11 @@ int kbd_input(char* text, int buflen)
|
||||||
/* Remap some buttons to allow to move
|
/* Remap some buttons to allow to move
|
||||||
* cursor in line edit mode and morse mode. */
|
* cursor in line edit mode and morse mode. */
|
||||||
#if defined(KBD_MODES) && defined(HAVE_MORSE_INPUT)
|
#if defined(KBD_MODES) && defined(HAVE_MORSE_INPUT)
|
||||||
if (pm->line_edit || morse_mode)
|
if (pm->line_edit || state.morse_mode)
|
||||||
#elif defined(KBD_MODES)
|
#elif defined(KBD_MODES)
|
||||||
if (pm->line_edit)
|
if (pm->line_edit)
|
||||||
#else /* defined(HAVE_MORSE_INPUT) */
|
#else /* defined(HAVE_MORSE_INPUT) */
|
||||||
if (morse_mode)
|
if (state.morse_mode)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (button == ACTION_KBD_LEFT)
|
if (button == ACTION_KBD_LEFT)
|
||||||
|
|
@ -784,7 +796,7 @@ int kbd_input(char* text, int buflen)
|
||||||
|
|
||||||
case ACTION_KBD_PAGE_FLIP:
|
case ACTION_KBD_PAGE_FLIP:
|
||||||
#ifdef HAVE_MORSE_INPUT
|
#ifdef HAVE_MORSE_INPUT
|
||||||
if (morse_mode)
|
if (state.morse_mode)
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
if (++pm->page >= pm->pages)
|
if (++pm->page >= pm->pages)
|
||||||
|
|
@ -796,17 +808,14 @@ int kbd_input(char* text, int buflen)
|
||||||
|
|
||||||
#if defined(HAVE_MORSE_INPUT) && defined(KBD_TOGGLE_INPUT)
|
#if defined(HAVE_MORSE_INPUT) && defined(KBD_TOGGLE_INPUT)
|
||||||
case ACTION_KBD_MORSE_INPUT:
|
case ACTION_KBD_MORSE_INPUT:
|
||||||
morse_mode = !morse_mode;
|
state.morse_mode = !state.morse_mode;
|
||||||
|
|
||||||
FOR_NB_SCREENS(l)
|
FOR_NB_SCREENS(l)
|
||||||
{
|
{
|
||||||
struct keyboard_parameters *pm = ¶m[l];
|
struct keyboard_parameters *pm = ¶m[l];
|
||||||
struct screen *sc = &screens[l];
|
int y = pm->main_y;
|
||||||
|
|
||||||
if (morse_mode)
|
|
||||||
pm->main_y = sc->getheight() - pm->font_h - BUTTONBAR_HEIGHT;
|
|
||||||
else
|
|
||||||
pm->main_y = pm->old_main_y;
|
pm->main_y = pm->old_main_y;
|
||||||
|
pm->old_main_y = y;
|
||||||
}
|
}
|
||||||
/* FIXME: We should talk something like Morse mode.. */
|
/* FIXME: We should talk something like Morse mode.. */
|
||||||
break;
|
break;
|
||||||
|
|
@ -844,11 +853,11 @@ int kbd_input(char* text, int buflen)
|
||||||
|
|
||||||
case ACTION_KBD_DOWN:
|
case ACTION_KBD_DOWN:
|
||||||
#ifdef HAVE_MORSE_INPUT
|
#ifdef HAVE_MORSE_INPUT
|
||||||
if (morse_mode)
|
if (state.morse_mode)
|
||||||
{
|
{
|
||||||
#ifdef KBD_MODES
|
#ifdef KBD_MODES
|
||||||
pm->line_edit = !pm->line_edit;
|
pm->line_edit = !pm->line_edit;
|
||||||
if(pm->line_edit)
|
if (pm->line_edit)
|
||||||
say_edit();
|
say_edit();
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
@ -880,11 +889,11 @@ int kbd_input(char* text, int buflen)
|
||||||
|
|
||||||
case ACTION_KBD_UP:
|
case ACTION_KBD_UP:
|
||||||
#ifdef HAVE_MORSE_INPUT
|
#ifdef HAVE_MORSE_INPUT
|
||||||
if (morse_mode)
|
if (state.morse_mode)
|
||||||
{
|
{
|
||||||
#ifdef KBD_MODES
|
#ifdef KBD_MODES
|
||||||
pm->line_edit = !pm->line_edit;
|
pm->line_edit = !pm->line_edit;
|
||||||
if(pm->line_edit)
|
if (pm->line_edit)
|
||||||
say_edit();
|
say_edit();
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
@ -916,25 +925,25 @@ int kbd_input(char* text, int buflen)
|
||||||
|
|
||||||
#ifdef HAVE_MORSE_INPUT
|
#ifdef HAVE_MORSE_INPUT
|
||||||
case ACTION_KBD_MORSE_SELECT:
|
case ACTION_KBD_MORSE_SELECT:
|
||||||
if (morse_mode && morse_reading)
|
if (state.morse_mode && state.morse_reading)
|
||||||
{
|
{
|
||||||
morse_code <<= 1;
|
state.morse_code <<= 1;
|
||||||
if ((current_tick - morse_tick) > HZ/5)
|
if ((current_tick - state.morse_tick) > HZ/5)
|
||||||
morse_code |= 0x01;
|
state.morse_code |= 0x01;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif /* HAVE_MORSE_INPUT */
|
#endif /* HAVE_MORSE_INPUT */
|
||||||
|
|
||||||
case ACTION_KBD_SELECT:
|
case ACTION_KBD_SELECT:
|
||||||
#ifdef HAVE_MORSE_INPUT
|
#ifdef HAVE_MORSE_INPUT
|
||||||
if (morse_mode)
|
if (state.morse_mode)
|
||||||
{
|
{
|
||||||
morse_tick = current_tick;
|
state.morse_tick = current_tick;
|
||||||
|
|
||||||
if (!morse_reading)
|
if (!state.morse_reading)
|
||||||
{
|
{
|
||||||
morse_reading = true;
|
state.morse_reading = true;
|
||||||
morse_code = 1;
|
state.morse_code = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -949,103 +958,104 @@ int kbd_input(char* text, int buflen)
|
||||||
{
|
{
|
||||||
unsigned short tmp;
|
unsigned short tmp;
|
||||||
|
|
||||||
if (!pm->hangul)
|
if (!state.hangul)
|
||||||
{
|
{
|
||||||
pm->hlead = pm->hvowel = pm->htail = 0;
|
state.hlead = state.hvowel = state.htail = 0;
|
||||||
pm->hangul = true;
|
state.hangul = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pm->hvowel)
|
if (!state.hvowel)
|
||||||
{
|
{
|
||||||
pm->hvowel = ch;
|
state.hvowel = ch;
|
||||||
}
|
}
|
||||||
else if (!pm->htail)
|
else if (!state.htail)
|
||||||
{
|
{
|
||||||
pm->htail = ch;
|
state.htail = ch;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* previous hangul complete */
|
{
|
||||||
|
/* previous hangul complete */
|
||||||
/* check whether tail is actually lead of next char */
|
/* check whether tail is actually lead of next char */
|
||||||
tmp = hangul_join(pm->htail, ch, 0);
|
tmp = hangul_join(state.htail, ch, 0);
|
||||||
|
|
||||||
if (tmp != 0xfffd)
|
if (tmp != 0xfffd)
|
||||||
{
|
{
|
||||||
tmp = hangul_join(pm->hlead, pm->hvowel, 0);
|
tmp = hangul_join(state.hlead, state.hvowel, 0);
|
||||||
kbd_delchar(text, &editpos);
|
kbd_delchar(&state);
|
||||||
kbd_inschar(text, buflen, &editpos, tmp);
|
kbd_inschar(&state, tmp);
|
||||||
/* insert dummy char */
|
/* insert dummy char */
|
||||||
kbd_inschar(text, buflen, &editpos, ' ');
|
kbd_inschar(&state, ' ');
|
||||||
pm->hlead = pm->htail;
|
state.hlead = state.htail;
|
||||||
pm->hvowel = ch;
|
state.hvowel = ch;
|
||||||
pm->htail = 0;
|
state.htail = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pm->hvowel = pm->htail = 0;
|
state.hvowel = state.htail = 0;
|
||||||
pm->hlead = ch;
|
state.hlead = ch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* combine into hangul */
|
/* combine into hangul */
|
||||||
tmp = hangul_join(pm->hlead, pm->hvowel, pm->htail);
|
tmp = hangul_join(state.hlead, state.hvowel, state.htail);
|
||||||
|
|
||||||
if (tmp != 0xfffd)
|
if (tmp != 0xfffd)
|
||||||
{
|
{
|
||||||
kbd_delchar(text, &editpos);
|
kbd_delchar(&state);
|
||||||
ch = tmp;
|
ch = tmp;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pm->hvowel = pm->htail = 0;
|
state.hvowel = state.htail = 0;
|
||||||
pm->hlead = ch;
|
state.hlead = ch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pm->hangul = false;
|
state.hangul = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* insert char */
|
/* insert char */
|
||||||
kbd_inschar(text, buflen, &editpos, ch);
|
kbd_inschar(&state, ch);
|
||||||
|
|
||||||
if (global_settings.talk_menu) /* voice UI? */
|
if (global_settings.talk_menu) /* voice UI? */
|
||||||
talk_spell(text, false); /* speak revised text */
|
talk_spell(state.text, false); /* speak revised text */
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ACTION_KBD_BACKSPACE:
|
case ACTION_KBD_BACKSPACE:
|
||||||
if (pm->hangul)
|
if (state.hangul)
|
||||||
{
|
{
|
||||||
if (pm->htail)
|
if (state.htail)
|
||||||
pm->htail = 0;
|
state.htail = 0;
|
||||||
else if (pm->hvowel)
|
else if (state.hvowel)
|
||||||
pm->hvowel = 0;
|
state.hvowel = 0;
|
||||||
else
|
else
|
||||||
pm->hangul = false;
|
state.hangul = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
kbd_delchar(text, &editpos);
|
kbd_delchar(&state);
|
||||||
|
|
||||||
if (pm->hangul)
|
if (state.hangul)
|
||||||
{
|
{
|
||||||
if (pm->hvowel)
|
if (state.hvowel)
|
||||||
ch = hangul_join(pm->hlead, pm->hvowel, pm->htail);
|
ch = hangul_join(state.hlead, state.hvowel, state.htail);
|
||||||
else
|
else
|
||||||
ch = pm->hlead;
|
ch = state.hlead;
|
||||||
kbd_inschar(text, buflen, &editpos, ch);
|
kbd_inschar(&state, ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (global_settings.talk_menu) /* voice UI? */
|
if (global_settings.talk_menu) /* voice UI? */
|
||||||
talk_spell(text, false); /* speak revised text */
|
talk_spell(state.text, false); /* speak revised text */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ACTION_KBD_CURSOR_RIGHT:
|
case ACTION_KBD_CURSOR_RIGHT:
|
||||||
pm->hangul = false;
|
state.hangul = false;
|
||||||
|
|
||||||
if (editpos < len_utf8)
|
if (state.editpos < state.len_utf8)
|
||||||
{
|
{
|
||||||
int c = utf8seek(text, ++editpos);
|
int c = utf8seek(state.text, ++state.editpos);
|
||||||
kbd_spellchar(text[c]);
|
kbd_spellchar(state.text[c]);
|
||||||
}
|
}
|
||||||
#if CONFIG_CODEC == SWCODEC
|
#if CONFIG_CODEC == SWCODEC
|
||||||
else if (global_settings.talk_menu)
|
else if (global_settings.talk_menu)
|
||||||
|
|
@ -1054,12 +1064,12 @@ int kbd_input(char* text, int buflen)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ACTION_KBD_CURSOR_LEFT:
|
case ACTION_KBD_CURSOR_LEFT:
|
||||||
pm->hangul = false;
|
state.hangul = false;
|
||||||
|
|
||||||
if (editpos > 0)
|
if (state.editpos > 0)
|
||||||
{
|
{
|
||||||
int c = utf8seek(text, --editpos);
|
int c = utf8seek(state.text, --state.editpos);
|
||||||
kbd_spellchar(text[c]);
|
kbd_spellchar(state.text[c]);
|
||||||
}
|
}
|
||||||
#if CONFIG_CODEC == SWCODEC
|
#if CONFIG_CODEC == SWCODEC
|
||||||
else if (global_settings.talk_menu)
|
else if (global_settings.talk_menu)
|
||||||
|
|
@ -1067,17 +1077,17 @@ int kbd_input(char* text, int buflen)
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BUTTON_NONE:
|
case ACTION_NONE:
|
||||||
#ifdef HAVE_MORSE_INPUT
|
#ifdef HAVE_MORSE_INPUT
|
||||||
if (morse_reading)
|
if (state.morse_reading)
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
logf("Morse: 0x%02x", morse_code);
|
logf("Morse: 0x%02x", state.morse_code);
|
||||||
morse_reading = false;
|
state.morse_reading = false;
|
||||||
|
|
||||||
for (j = 0; morse_alphabets[j] != '\0'; j++)
|
for (j = 0; morse_alphabets[j] != '\0'; j++)
|
||||||
{
|
{
|
||||||
if (morse_codes[j] == morse_code)
|
if (morse_codes[j] == state.morse_code)
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1088,12 +1098,11 @@ int kbd_input(char* text, int buflen)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* turn off hangul input */
|
/* turn off hangul input */
|
||||||
FOR_NB_SCREENS(l)
|
state.hangul = false;
|
||||||
param[l].hangul = false;
|
kbd_inschar(&state, morse_alphabets[j]);
|
||||||
kbd_inschar(text, buflen, &editpos, morse_alphabets[j]);
|
|
||||||
|
|
||||||
if (global_settings.talk_menu) /* voice UI? */
|
if (global_settings.talk_menu) /* voice UI? */
|
||||||
talk_spell(text, false); /* speak revised text */
|
talk_spell(state.text, false); /* speak revised text */
|
||||||
}
|
}
|
||||||
#endif /* HAVE_MORSE_INPUT */
|
#endif /* HAVE_MORSE_INPUT */
|
||||||
break;
|
break;
|
||||||
|
|
@ -1108,9 +1117,9 @@ int kbd_input(char* text, int buflen)
|
||||||
|
|
||||||
} /* end switch */
|
} /* end switch */
|
||||||
|
|
||||||
if (button != BUTTON_NONE)
|
if (button != ACTION_NONE)
|
||||||
{
|
{
|
||||||
cur_blink = true;
|
state.cur_blink = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1122,9 +1131,9 @@ int kbd_input(char* text, int buflen)
|
||||||
splash(HZ/2, ID2P(LANG_CANCEL));
|
splash(HZ/2, ID2P(LANG_CANCEL));
|
||||||
|
|
||||||
#if defined(HAVE_MORSE_INPUT) && defined(KBD_TOGGLE_INPUT)
|
#if defined(HAVE_MORSE_INPUT) && defined(KBD_TOGGLE_INPUT)
|
||||||
if(global_settings.morse_input != morse_mode)
|
if (global_settings.morse_input != state.morse_mode)
|
||||||
{
|
{
|
||||||
global_settings.morse_input = morse_mode;
|
global_settings.morse_input = state.morse_mode;
|
||||||
settings_save();
|
settings_save();
|
||||||
}
|
}
|
||||||
#endif /* HAVE_MORSE_INPUT && KBD_TOGGLE_INPUT */
|
#endif /* HAVE_MORSE_INPUT && KBD_TOGGLE_INPUT */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue