2002-12-04 15:04:43 +00:00
|
|
|
|
/***************************************************************************
|
|
|
|
|
* __________ __ ___.
|
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
|
* $Id$
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2002 by Bj<EFBFBD>rn Stenberg
|
|
|
|
|
*
|
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
|
*
|
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
|
* KIND, either express or implied.
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
#include "lcd.h"
|
|
|
|
|
#include "button.h"
|
|
|
|
|
#include "kernel.h"
|
2005-02-07 00:56:26 +00:00
|
|
|
|
#include "system.h"
|
2002-12-04 15:04:43 +00:00
|
|
|
|
#include "version.h"
|
|
|
|
|
#include "debug_menu.h"
|
|
|
|
|
#include "sprintf.h"
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include "font.h"
|
2003-03-10 15:09:27 +00:00
|
|
|
|
#include "screens.h"
|
2005-11-20 01:02:14 +00:00
|
|
|
|
#include "statusbar.h"
|
2004-05-21 06:29:55 +00:00
|
|
|
|
#include "talk.h"
|
|
|
|
|
#include "settings.h"
|
2004-07-26 16:06:59 +00:00
|
|
|
|
#include "misc.h"
|
2005-12-06 13:27:15 +00:00
|
|
|
|
#include "rbunicode.h"
|
2005-11-20 01:02:14 +00:00
|
|
|
|
#include "buttonbar.h"
|
2005-12-02 19:41:09 +00:00
|
|
|
|
#include "logf.h"
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#include "icons.h"
|
|
|
|
|
#include "file.h"
|
|
|
|
|
#include "hangul.h"
|
2006-08-22 13:21:13 +00:00
|
|
|
|
#include "action.h"
|
2002-12-04 15:04:43 +00:00
|
|
|
|
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#ifndef O_BINARY
|
|
|
|
|
#define O_BINARY 0
|
|
|
|
|
#endif
|
2005-10-08 07:12:28 +00:00
|
|
|
|
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#if CONFIG_KEYPAD == RECORDER_PAD
|
|
|
|
|
#define BUTTONBAR_HEIGHT 8
|
2005-10-08 07:12:28 +00:00
|
|
|
|
#else
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#define BUTTONBAR_HEIGHT 0
|
|
|
|
|
#endif
|
2005-10-08 07:12:28 +00:00
|
|
|
|
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#define DEFAULT_MARGIN 6
|
|
|
|
|
#define KBD_BUF_SIZE 500
|
2004-10-22 17:00:30 +00:00
|
|
|
|
|
2005-06-29 12:47:24 +00:00
|
|
|
|
#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
|
|
|
|
|
(CONFIG_KEYPAD == IRIVER_H300_PAD)
|
2006-08-22 13:21:13 +00:00
|
|
|
|
#define KBD_MORSE_INPUT /* I-Rivers have a Morse input mode */
|
2005-01-23 01:01:14 +00:00
|
|
|
|
|
2004-10-22 17:00:30 +00:00
|
|
|
|
#elif CONFIG_KEYPAD == ONDIO_PAD /* restricted Ondio keypad */
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#define KBD_MODES /* Ondio uses 2 modes, picker and line edit */
|
2005-01-23 01:01:14 +00:00
|
|
|
|
|
2006-02-05 21:18:19 +00:00
|
|
|
|
#elif (CONFIG_KEYPAD == IPOD_3G_PAD) || (CONFIG_KEYPAD == IPOD_4G_PAD)
|
2005-11-19 03:19:12 +00:00
|
|
|
|
#define KBD_MODES /* iPod uses 2 modes, picker and line edit */
|
2005-11-12 16:07:17 +00:00
|
|
|
|
|
2006-01-12 00:35:50 +00:00
|
|
|
|
#elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
|
|
|
|
|
#define KBD_MODES /* iFP7xx uses 2 modes, picker and line edit */
|
|
|
|
|
|
2006-01-18 11:09:06 +00:00
|
|
|
|
#elif CONFIG_KEYPAD == IAUDIO_X5_PAD
|
|
|
|
|
#define KBD_MODES /* iAudio X5 uses 2 modes, picker and line edit */
|
2006-02-24 15:42:52 +00:00
|
|
|
|
|
2006-08-03 20:17:25 +00:00
|
|
|
|
#elif CONFIG_KEYPAD == IRIVER_H10_PAD
|
|
|
|
|
#define KBD_MODES /* iriver H10 uses 2 modes, picker and line edit */
|
2004-10-22 17:00:30 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
struct keyboard_parameters {
|
|
|
|
|
const unsigned char* default_kbd;
|
|
|
|
|
int DEFAULT_LINES;
|
|
|
|
|
unsigned short kbd_buf[KBD_BUF_SIZE];
|
|
|
|
|
int nchars;
|
|
|
|
|
int font_w;
|
|
|
|
|
int font_h;
|
|
|
|
|
struct font* font;
|
|
|
|
|
int curfont;
|
|
|
|
|
int main_x;
|
|
|
|
|
int main_y;
|
|
|
|
|
int max_chars;
|
|
|
|
|
int max_chars_text;
|
|
|
|
|
int lines;
|
|
|
|
|
int pages;
|
|
|
|
|
int keyboard_margin;
|
|
|
|
|
int old_main_y;
|
|
|
|
|
int curpos;
|
|
|
|
|
int leftpos;
|
|
|
|
|
int page;
|
|
|
|
|
int x;
|
|
|
|
|
int y;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct keyboard_parameters param[NB_SCREENS];
|
2006-03-29 16:21:42 +00:00
|
|
|
|
static bool kbd_loaded = false;
|
|
|
|
|
|
|
|
|
|
#ifdef KBD_MORSE_INPUT
|
2005-12-02 19:41:09 +00:00
|
|
|
|
/* FIXME: We should put this to a configuration file. */
|
2006-04-22 09:43:43 +00:00
|
|
|
|
static const char *morse_alphabets =
|
2005-12-21 12:46:50 +00:00
|
|
|
|
"abcdefghijklmnopqrstuvwxyz1234567890,.?-@ ";
|
2005-12-02 19:41:09 +00:00
|
|
|
|
static const unsigned char morse_codes[] = {
|
|
|
|
|
0x05,0x18,0x1a,0x0c,0x02,0x12,0x0e,0x10,0x04,0x17,0x0d,0x14,0x07,
|
|
|
|
|
0x06,0x0f,0x16,0x1d,0x0a,0x08,0x03,0x09,0x11,0x0b,0x19,0x1b,0x1c,
|
2005-12-21 12:46:50 +00:00
|
|
|
|
0x2f,0x27,0x23,0x21,0x20,0x30,0x38,0x3c,0x3e,0x3f,
|
2005-12-04 08:45:24 +00:00
|
|
|
|
0x73,0x55,0x4c,0x61,0x5a,0x80 };
|
2005-12-02 19:41:09 +00:00
|
|
|
|
|
|
|
|
|
static bool morse_mode = false;
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-03-29 16:21:42 +00:00
|
|
|
|
/* Loads a custom keyboard into memory
|
|
|
|
|
call with NULL to reset keyboard */
|
|
|
|
|
int load_kbd(unsigned char* filename)
|
|
|
|
|
{
|
2006-07-19 12:07:51 +00:00
|
|
|
|
int fd, count, l;
|
2006-07-23 18:33:43 +00:00
|
|
|
|
int i = 0;
|
2006-07-23 18:54:00 +00:00
|
|
|
|
unsigned char buf[4];
|
2006-03-29 16:21:42 +00:00
|
|
|
|
|
|
|
|
|
if (filename == NULL) {
|
|
|
|
|
kbd_loaded = false;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fd = open(filename, O_RDONLY|O_BINARY);
|
|
|
|
|
if (fd < 0)
|
|
|
|
|
return 1;
|
|
|
|
|
|
2006-07-23 18:33:43 +00:00
|
|
|
|
while (read(fd, buf, 1) == 1 && i < KBD_BUF_SIZE) {
|
|
|
|
|
/* check how many bytes to read */
|
|
|
|
|
if (buf[0] < 0x80) {
|
|
|
|
|
count = 0;
|
|
|
|
|
} else if (buf[0] < 0xe0) {
|
|
|
|
|
count = 1;
|
|
|
|
|
} else if (buf[0] < 0xf0) {
|
|
|
|
|
count = 2;
|
|
|
|
|
} else if (buf[0] < 0xf5) {
|
|
|
|
|
count = 3;
|
|
|
|
|
} else {
|
|
|
|
|
/* Invalid size. */
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (read(fd, &buf[1], count) != count) {
|
|
|
|
|
close(fd);
|
|
|
|
|
kbd_loaded = false;
|
|
|
|
|
return 1;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
}
|
2006-07-23 18:54:00 +00:00
|
|
|
|
|
2006-07-23 18:33:43 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
utf8decode(buf, ¶m[l].kbd_buf[i]);
|
2006-07-23 18:54:00 +00:00
|
|
|
|
|
|
|
|
|
if (param[0].kbd_buf[i] != 0xFEFF &&
|
|
|
|
|
param[0].kbd_buf[i] != '\r') /*skip BOM & carriage returns */
|
2006-07-23 18:33:43 +00:00
|
|
|
|
i++;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
close(fd);
|
|
|
|
|
kbd_loaded = true;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
2006-07-23 18:33:43 +00:00
|
|
|
|
param[l].nchars = i;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2004-05-21 06:29:55 +00:00
|
|
|
|
/* helper function to spell a char if voice UI is enabled */
|
2006-03-29 16:21:42 +00:00
|
|
|
|
static void kbd_spellchar(unsigned short c)
|
2004-05-21 06:29:55 +00:00
|
|
|
|
{
|
2005-02-07 00:56:26 +00:00
|
|
|
|
static char spell_char[2] = "\0\0"; /* store char to pass to talk_spell */
|
2004-05-21 06:29:55 +00:00
|
|
|
|
|
2006-03-29 16:21:42 +00:00
|
|
|
|
if (global_settings.talk_menu && c < 128) /* voice UI? */
|
2004-05-21 06:29:55 +00:00
|
|
|
|
{
|
2006-03-29 16:21:42 +00:00
|
|
|
|
spell_char[0] = (char)c;
|
2005-02-07 00:56:26 +00:00
|
|
|
|
talk_spell(spell_char, false);
|
2004-05-21 06:29:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-03-29 16:21:42 +00:00
|
|
|
|
void kbd_inschar(unsigned char* text, int buflen, int* editpos, unsigned short ch)
|
|
|
|
|
{
|
|
|
|
|
int i, j, k, len;
|
|
|
|
|
unsigned char tmp[4];
|
|
|
|
|
unsigned char* utf8;
|
|
|
|
|
|
|
|
|
|
len = strlen(text);
|
|
|
|
|
k = utf8length(text);
|
|
|
|
|
utf8 = utf8encode(ch, tmp);
|
|
|
|
|
j = (long)utf8 - (long)tmp;
|
|
|
|
|
|
|
|
|
|
if (len + j < buflen)
|
|
|
|
|
{
|
|
|
|
|
for (i = len+j; k >= *editpos; i--) {
|
|
|
|
|
text[i] = text[i-j];
|
|
|
|
|
if ((text[i] & MASK) != COMP)
|
|
|
|
|
k--;
|
|
|
|
|
}
|
|
|
|
|
while (j--)
|
|
|
|
|
text[i--] = tmp[j];
|
|
|
|
|
(*editpos)++;
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void kbd_delchar(unsigned char* text, int* editpos)
|
|
|
|
|
{
|
|
|
|
|
int i = 0;
|
|
|
|
|
unsigned char* utf8;
|
|
|
|
|
|
|
|
|
|
if (*editpos > 0)
|
|
|
|
|
{
|
|
|
|
|
utf8 = text + utf8seek(text, *editpos);
|
|
|
|
|
do {
|
|
|
|
|
i++;
|
|
|
|
|
utf8--;
|
|
|
|
|
} while ((*utf8 & MASK) == COMP);
|
|
|
|
|
while (utf8[i]) {
|
|
|
|
|
*utf8 = utf8[i];
|
|
|
|
|
utf8++;
|
|
|
|
|
}
|
|
|
|
|
*utf8 = 0;
|
|
|
|
|
(*editpos)--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2002-12-04 15:04:43 +00:00
|
|
|
|
int kbd_input(char* text, int buflen)
|
|
|
|
|
{
|
2005-12-04 07:37:24 +00:00
|
|
|
|
bool done = false;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
int i, j, k, w, l;
|
|
|
|
|
int text_w = 0;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
int len_utf8, c = 0;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
int editpos;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
int statusbar_size = global_settings.statusbar ? STATUSBAR_HEIGHT : 0;
|
|
|
|
|
unsigned short ch, tmp, hlead = 0, hvowel = 0, htail = 0;
|
|
|
|
|
bool hangul = false;
|
2005-12-06 13:27:15 +00:00
|
|
|
|
unsigned char *utf8;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
const unsigned char *p;
|
2006-04-22 13:06:57 +00:00
|
|
|
|
bool cur_blink = true;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#ifdef KBD_MORSE_INPUT
|
2005-12-02 19:41:09 +00:00
|
|
|
|
bool morse_reading = false;
|
|
|
|
|
unsigned char morse_code = 0;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
int morse_tick = 0, morse_len;
|
2005-12-02 19:41:09 +00:00
|
|
|
|
char buf[2];
|
2006-07-23 17:16:38 +00:00
|
|
|
|
#endif
|
2006-07-19 12:07:51 +00:00
|
|
|
|
int char_screen = 0;
|
2006-07-23 17:16:38 +00:00
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
{
|
|
|
|
|
if ((screens[l].width >= 160) && (screens[l].height >= 96))
|
|
|
|
|
{
|
|
|
|
|
param[l].default_kbd =
|
|
|
|
|
"ABCDEFG abcdefg !?\" @#$%+'\n"
|
|
|
|
|
"HIJKLMN hijklmn 789 &_()-`\n"
|
|
|
|
|
"OPQRSTU opqrstu 456 §|{}/<\n"
|
|
|
|
|
"VWXYZ., vwxyz.,0123 ~=[]*>\n"
|
|
|
|
|
"ÀÁÂÃÄÅÆ ÌÍÎÏ ÈÉÊË ¢£¤¥¦§©®\n"
|
|
|
|
|
"àáâãäåæ ìíîï èéêë «»°ºª¹²³\n"
|
|
|
|
|
"ÓÒÔÕÖØ ÇÐÞÝß ÙÚÛÜ ¯±×÷¡¿µ·\n"
|
|
|
|
|
"òóôõöø çðþýÿ ùúûü ¼½¾¬¶¨";
|
2006-07-23 17:16:38 +00:00
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
param[l].DEFAULT_LINES = 8;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
param[l].default_kbd =
|
|
|
|
|
"ABCDEFG !?\" @#$%+'\n"
|
|
|
|
|
"HIJKLMN 789 &_()-`\n"
|
|
|
|
|
"OPQRSTU 456 §|{}/<\n"
|
|
|
|
|
"VWXYZ.,0123 ~=[]*>\n"
|
|
|
|
|
|
|
|
|
|
"abcdefg ¢£¤¥¦§©®¬\n"
|
|
|
|
|
"hijklmn «»°ºª¹²³¶\n"
|
|
|
|
|
"opqrstu ¯±×÷¡¿µ·¨\n"
|
|
|
|
|
"vwxyz., ¼½¾ \n"
|
|
|
|
|
|
|
|
|
|
"ÀÁÂÃÄÅÆ ÌÍÎÏ ÈÉÊË\n"
|
|
|
|
|
"àáâãäåæ ìíîï èéêë\n"
|
|
|
|
|
"ÓÒÔÕÖØ ÇÐÞÝß ÙÚÛÜ\n"
|
|
|
|
|
"òóôõöø çðþýÿ ùúûü";
|
2006-07-23 17:16:38 +00:00
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
param[l].DEFAULT_LINES = 4;
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#ifdef KBD_MODES
|
|
|
|
|
bool line_edit = false;
|
|
|
|
|
#endif
|
2002-12-04 15:04:43 +00:00
|
|
|
|
|
2003-03-10 15:09:27 +00:00
|
|
|
|
char outline[256];
|
2006-09-01 02:29:11 +00:00
|
|
|
|
int button;
|
2005-11-20 01:02:14 +00:00
|
|
|
|
#ifdef HAS_BUTTONBAR
|
|
|
|
|
struct gui_buttonbar buttonbar;
|
2006-03-11 22:31:53 +00:00
|
|
|
|
bool buttonbar_config = global_settings.buttonbar;
|
|
|
|
|
global_settings.buttonbar = true;
|
2005-11-20 01:02:14 +00:00
|
|
|
|
gui_buttonbar_init(&buttonbar);
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
gui_buttonbar_set_display(&buttonbar, &(screens[l]) );
|
|
|
|
|
#endif
|
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
{
|
2006-07-23 17:16:38 +00:00
|
|
|
|
if( !kbd_loaded )
|
|
|
|
|
{
|
|
|
|
|
/* Copy default keyboard to buffer */
|
|
|
|
|
i = 0;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
param[l].curfont = FONT_SYSFIXED;
|
|
|
|
|
p = param[l].default_kbd;
|
2006-07-23 17:16:38 +00:00
|
|
|
|
while (*p != 0)
|
|
|
|
|
p = utf8decode(p, ¶m[l].kbd_buf[i++]);
|
2006-07-19 12:07:51 +00:00
|
|
|
|
param[l].nchars = i;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
}
|
2006-07-19 12:07:51 +00:00
|
|
|
|
else
|
|
|
|
|
param[l].curfont = FONT_UI;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
}
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
{
|
|
|
|
|
param[l].font = font_get(param[l].curfont);
|
|
|
|
|
param[l].font_h = param[l].font->height;
|
|
|
|
|
|
|
|
|
|
/* check if FONT_UI fits the screen */
|
|
|
|
|
if (2*param[l].font_h+3+statusbar_size + BUTTONBAR_HEIGHT > screens[l].height) {
|
|
|
|
|
param[l].font = font_get(FONT_SYSFIXED);
|
|
|
|
|
param[l].font_h = param[l].font->height;
|
|
|
|
|
param[l].curfont = FONT_SYSFIXED;
|
|
|
|
|
}
|
2006-03-29 16:21:42 +00:00
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
screens[l].setfont(param[l].curfont);
|
|
|
|
|
/* find max width of keyboard glyphs */
|
|
|
|
|
for (i=0; i<param[l].nchars; i++) {
|
|
|
|
|
w = font_get_width(param[l].font, param[l].kbd_buf[i]);
|
|
|
|
|
if (w > param[l].font_w)
|
|
|
|
|
param[l].font_w = w;
|
|
|
|
|
}
|
2006-07-23 17:16:38 +00:00
|
|
|
|
/* Since we're going to be adding spaces, make sure that we check
|
|
|
|
|
* their width too */
|
|
|
|
|
w = font_get_width( param[l].font, ' ' );
|
|
|
|
|
if( w > param[l].font_w )
|
|
|
|
|
param[l].font_w = w;
|
|
|
|
|
}
|
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
{
|
|
|
|
|
i = 0;
|
|
|
|
|
/* Pad lines with spaces */
|
|
|
|
|
while( i < param[l].nchars )
|
|
|
|
|
{
|
|
|
|
|
if( param[l].kbd_buf[i] == '\n' )
|
|
|
|
|
{
|
|
|
|
|
k = ( screens[l].width / param[l].font_w )
|
|
|
|
|
- i % ( screens[l].width / param[l].font_w ) - 1;
|
|
|
|
|
if( k == ( screens[l].width / param[l].font_w ) - 1 )
|
|
|
|
|
{
|
|
|
|
|
param[l].nchars--;
|
|
|
|
|
for( j = i; j < param[l].nchars; j++ )
|
|
|
|
|
{
|
|
|
|
|
param[l].kbd_buf[j] = param[l].kbd_buf[j+1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if( param[l].nchars + k - 1 >= KBD_BUF_SIZE )
|
|
|
|
|
{ /* We don't want to overflow the buffer */
|
|
|
|
|
k = KBD_BUF_SIZE - param[l].nchars;
|
|
|
|
|
}
|
|
|
|
|
for( j = param[l].nchars + k - 1; j > i+k; j-- )
|
|
|
|
|
{
|
|
|
|
|
param[l].kbd_buf[j] = param[l].kbd_buf[j-k];
|
|
|
|
|
}
|
|
|
|
|
param[l].nchars += k;
|
|
|
|
|
k++;
|
|
|
|
|
while( k-- )
|
|
|
|
|
{
|
|
|
|
|
param[l].kbd_buf[i++] = ' ';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
i++;
|
|
|
|
|
}
|
2006-03-29 16:21:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* find max width for text string */
|
|
|
|
|
utf8 = text;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
{
|
|
|
|
|
text_w = param[l].font_w;
|
|
|
|
|
while (*utf8) {
|
|
|
|
|
utf8 = (unsigned char*)utf8decode(utf8, &ch);
|
|
|
|
|
w = font_get_width(param[l].font, ch);
|
|
|
|
|
if (w > text_w)
|
2006-07-23 17:16:38 +00:00
|
|
|
|
text_w = w;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
}
|
|
|
|
|
param[l].max_chars_text = screens[l].width / text_w - 2;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
|
|
|
|
|
/* calculate keyboard grid size */
|
2006-07-19 12:07:51 +00:00
|
|
|
|
param[l].max_chars = screens[l].width / param[l].font_w;
|
|
|
|
|
if (!kbd_loaded) {
|
|
|
|
|
param[l].lines = param[l].DEFAULT_LINES;
|
|
|
|
|
param[l].keyboard_margin = DEFAULT_MARGIN;
|
|
|
|
|
} else {
|
|
|
|
|
param[l].lines = (screens[l].height - BUTTONBAR_HEIGHT - statusbar_size) / param[l].font_h - 1;
|
2006-07-23 17:16:38 +00:00
|
|
|
|
param[l].keyboard_margin = screens[l].height - BUTTONBAR_HEIGHT -
|
2006-07-19 12:07:51 +00:00
|
|
|
|
statusbar_size - (param[l].lines+1)*param[l].font_h;
|
|
|
|
|
if (param[l].keyboard_margin < 3) {
|
|
|
|
|
param[l].lines--;
|
|
|
|
|
param[l].keyboard_margin += param[l].font_h;
|
|
|
|
|
}
|
|
|
|
|
if (param[l].keyboard_margin > 6)
|
|
|
|
|
param[l].keyboard_margin = 6;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
param[l].pages = (param[l].nchars + (param[l].lines*param[l].max_chars-1))
|
|
|
|
|
/(param[l].lines*param[l].max_chars);
|
|
|
|
|
if (param[l].pages == 1 && kbd_loaded)
|
|
|
|
|
param[l].lines = (param[l].nchars + param[l].max_chars - 1) / param[l].max_chars;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
param[l].main_y = param[l].font_h*param[l].lines + param[l].keyboard_margin + statusbar_size;
|
|
|
|
|
param[l].main_x = 0;
|
|
|
|
|
param[l].keyboard_margin -= param[l].keyboard_margin/2;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
|
|
|
|
|
#ifdef KBD_MORSE_INPUT
|
2006-07-19 12:07:51 +00:00
|
|
|
|
param[l].old_main_y = param[l].main_y;
|
|
|
|
|
if (morse_mode)
|
|
|
|
|
param[l].main_y = screens[l].height - param[l].font_h;
|
2005-12-04 08:45:24 +00:00
|
|
|
|
#endif
|
2006-07-19 12:07:51 +00:00
|
|
|
|
}
|
2005-12-06 13:27:15 +00:00
|
|
|
|
editpos = utf8length(text);
|
2002-12-04 15:04:43 +00:00
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
|
2004-05-21 06:29:55 +00:00
|
|
|
|
if (global_settings.talk_menu) /* voice UI? */
|
2005-12-02 19:41:09 +00:00
|
|
|
|
talk_spell(text, true); /* spell initial text */
|
2004-05-21 06:29:55 +00:00
|
|
|
|
|
2002-12-04 15:04:43 +00:00
|
|
|
|
while(!done)
|
|
|
|
|
{
|
2005-12-06 13:27:15 +00:00
|
|
|
|
len_utf8 = utf8length(text);
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
screens[l].clear_display();
|
2005-12-06 13:27:15 +00:00
|
|
|
|
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#ifdef KBD_MORSE_INPUT
|
2006-04-22 13:06:57 +00:00
|
|
|
|
if (morse_mode)
|
|
|
|
|
{
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
2005-12-02 19:41:09 +00:00
|
|
|
|
{
|
2006-07-19 12:07:51 +00:00
|
|
|
|
screens[l].setfont(FONT_SYSFIXED); /* Draw morse code screen with sysfont */
|
|
|
|
|
w = 6; /* sysfixed font width */
|
|
|
|
|
param[l].x = 0;
|
|
|
|
|
param[l].y = statusbar_size;
|
|
|
|
|
buf[1] = '\0';
|
|
|
|
|
/* Draw morse code table with code descriptions. */
|
|
|
|
|
for (i = 0; morse_alphabets[i] != '\0'; i++)
|
|
|
|
|
{
|
|
|
|
|
buf[0] = morse_alphabets[i];
|
|
|
|
|
screens[l].putsxy(param[l].x, param[l].y, buf);
|
2005-12-02 19:41:09 +00:00
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
for (j = 0; (morse_codes[i] >> j) > 0x01; j++) ;
|
|
|
|
|
morse_len = j;
|
2005-12-02 19:41:09 +00:00
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
param[l].x += w + 3;
|
|
|
|
|
for (j = 0; j < morse_len; j++)
|
|
|
|
|
{
|
|
|
|
|
if ((morse_codes[i] >> (morse_len-j-1)) & 0x01)
|
|
|
|
|
screens[l].fillrect(param[l].x + j*4, param[l].y + 2, 3, 4);
|
|
|
|
|
else
|
|
|
|
|
screens[l].fillrect(param[l].x + j*4, param[l].y + 3, 1, 2);
|
|
|
|
|
}
|
2006-04-22 09:43:43 +00:00
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
param[l].x += w * 5 - 3;
|
|
|
|
|
if (param[l].x >= screens[l].width - (w*6))
|
|
|
|
|
{
|
|
|
|
|
param[l].x = 0;
|
|
|
|
|
param[l].y += 8; /* sysfixed font height */
|
|
|
|
|
}
|
2005-12-02 19:41:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2006-04-22 13:06:57 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2005-12-02 19:41:09 +00:00
|
|
|
|
#endif
|
2006-04-22 13:06:57 +00:00
|
|
|
|
{
|
|
|
|
|
/* draw page */
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
{
|
|
|
|
|
screens[l].setfont(param[l].curfont);
|
|
|
|
|
k = param[l].page*param[l].max_chars*param[l].lines;
|
|
|
|
|
for (i=j=0; j < param[l].lines && k < param[l].nchars; k++) {
|
|
|
|
|
utf8 = utf8encode(param[l].kbd_buf[k], outline);
|
|
|
|
|
*utf8 = 0;
|
|
|
|
|
screens[l].getstringsize(outline, &w, NULL);
|
|
|
|
|
screens[l].putsxy(i*param[l].font_w + (param[l].font_w-w)/2, j*param[l].font_h
|
|
|
|
|
+ statusbar_size, outline);
|
|
|
|
|
if (++i == param[l].max_chars) {
|
|
|
|
|
i = 0;
|
|
|
|
|
j++;
|
|
|
|
|
}
|
2006-03-29 16:21:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2006-04-22 13:06:57 +00:00
|
|
|
|
}
|
2006-03-29 16:21:42 +00:00
|
|
|
|
|
2006-04-22 13:06:57 +00:00
|
|
|
|
/* separator */
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
{
|
|
|
|
|
screens[l].hline(0, screens[l].width - 1, param[l].main_y - param[l].keyboard_margin);
|
2006-04-22 13:06:57 +00:00
|
|
|
|
|
|
|
|
|
/* write out the text */
|
2006-07-19 12:07:51 +00:00
|
|
|
|
screens[l].setfont(param[l].curfont);
|
2006-07-23 17:16:38 +00:00
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
i=j=0;
|
2006-07-23 17:16:38 +00:00
|
|
|
|
param[l].curpos = MIN(editpos, param[l].max_chars_text
|
2006-07-19 12:07:51 +00:00
|
|
|
|
- MIN(len_utf8 - editpos, 2));
|
|
|
|
|
param[l].leftpos = editpos - param[l].curpos;
|
|
|
|
|
utf8 = text + utf8seek(text, param[l].leftpos);
|
|
|
|
|
|
2006-07-23 17:16:38 +00:00
|
|
|
|
text_w = param[l].font_w;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
while (*utf8 && i < param[l].max_chars_text) {
|
|
|
|
|
outline[j++] = *utf8++;
|
|
|
|
|
if ((*utf8 & MASK) != COMP) {
|
|
|
|
|
outline[j] = 0;
|
|
|
|
|
j=0;
|
|
|
|
|
i++;
|
|
|
|
|
screens[l].getstringsize(outline, &w, NULL);
|
|
|
|
|
screens[l].putsxy(i*text_w + (text_w-w)/2, param[l].main_y, outline);
|
|
|
|
|
}
|
2005-12-06 13:27:15 +00:00
|
|
|
|
}
|
2006-03-29 16:21:42 +00:00
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
if (param[l].leftpos) {
|
|
|
|
|
screens[l].getstringsize("<", &w, NULL);
|
|
|
|
|
screens[l].putsxy(text_w - w, param[l].main_y, "<");
|
|
|
|
|
}
|
|
|
|
|
if (len_utf8 - param[l].leftpos > param[l].max_chars_text)
|
|
|
|
|
screens[l].putsxy(screens[l].width - text_w, param[l].main_y, ">");
|
2006-04-22 13:06:57 +00:00
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
/* cursor */
|
|
|
|
|
i = (param[l].curpos + 1) * text_w;
|
|
|
|
|
if (cur_blink)
|
|
|
|
|
screens[l].vline(i, param[l].main_y, param[l].main_y + param[l].font_h-1);
|
2006-03-29 16:21:42 +00:00
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
if (hangul) /* draw underbar */
|
|
|
|
|
screens[l].hline(param[l].curpos*text_w, (param[l].curpos+1)*text_w,
|
|
|
|
|
param[l].main_y+param[l].font_h-1);
|
|
|
|
|
}
|
|
|
|
|
cur_blink = !cur_blink;
|
2005-11-20 01:02:14 +00:00
|
|
|
|
#ifdef HAS_BUTTONBAR
|
2006-04-22 13:06:57 +00:00
|
|
|
|
/* draw the button bar */
|
|
|
|
|
gui_buttonbar_set(&buttonbar, "Shift", "OK", "Del");
|
|
|
|
|
gui_buttonbar_draw(&buttonbar);
|
2005-02-07 00:56:26 +00:00
|
|
|
|
#endif
|
2006-03-29 16:21:42 +00:00
|
|
|
|
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#ifdef KBD_MODES
|
2006-04-22 13:06:57 +00:00
|
|
|
|
if (!line_edit)
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#endif
|
2006-04-22 13:06:57 +00:00
|
|
|
|
{
|
|
|
|
|
/* highlight the key that has focus */
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
{
|
|
|
|
|
screens[l].set_drawmode(DRMODE_COMPLEMENT);
|
|
|
|
|
screens[l].fillrect(param[l].font_w * param[l].x,
|
|
|
|
|
statusbar_size + param[l].font_h * param[l].y,
|
|
|
|
|
param[l].font_w, param[l].font_h);
|
|
|
|
|
screens[l].set_drawmode(DRMODE_SOLID);
|
|
|
|
|
}
|
2006-04-22 13:06:57 +00:00
|
|
|
|
}
|
2006-04-22 09:43:43 +00:00
|
|
|
|
#ifdef KBD_MODES
|
2006-04-22 13:06:57 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
{
|
|
|
|
|
screens[l].set_drawmode(DRMODE_COMPLEMENT);
|
|
|
|
|
screens[l].fillrect(0, param[l].main_y - param[l].keyboard_margin + 2,
|
|
|
|
|
screens[l].width, param[l].font_h+2);
|
|
|
|
|
screens[l].set_drawmode(DRMODE_SOLID);
|
|
|
|
|
}
|
2003-11-17 02:10:09 +00:00
|
|
|
|
}
|
2006-04-22 13:06:57 +00:00
|
|
|
|
#endif
|
2002-12-04 15:04:43 +00:00
|
|
|
|
|
2006-04-22 13:06:57 +00:00
|
|
|
|
gui_syncstatusbar_draw(&statusbars, true);
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
screens[l].update();
|
2004-07-26 16:06:59 +00:00
|
|
|
|
|
2006-08-22 13:21:13 +00:00
|
|
|
|
button = get_action(CONTEXT_KEYBOARD,HZ/2);
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#ifdef KBD_MORSE_INPUT
|
2005-12-04 08:45:24 +00:00
|
|
|
|
if (morse_mode)
|
|
|
|
|
{
|
|
|
|
|
/* Remap some buttons for morse mode. */
|
2006-08-22 13:21:13 +00:00
|
|
|
|
if (button == ACTION_KBD_LEFT)
|
|
|
|
|
button = ACTION_KBD_CURSOR_LEFT;
|
|
|
|
|
if (button == ACTION_KBD_RIGHT)
|
|
|
|
|
button = ACTION_KBD_CURSOR_RIGHT;
|
2005-12-04 08:45:24 +00:00
|
|
|
|
}
|
|
|
|
|
#endif
|
2006-04-22 09:43:43 +00:00
|
|
|
|
|
2004-07-26 16:06:59 +00:00
|
|
|
|
switch ( button ) {
|
2002-12-04 15:04:43 +00:00
|
|
|
|
|
2006-08-22 13:21:13 +00:00
|
|
|
|
case ACTION_KBD_ABORT:
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
screens[l].setfont(FONT_UI);
|
2006-07-23 17:16:38 +00:00
|
|
|
|
|
2006-03-11 22:31:53 +00:00
|
|
|
|
#ifdef HAS_BUTTONBAR
|
|
|
|
|
global_settings.buttonbar=buttonbar_config;
|
|
|
|
|
#endif
|
2003-01-15 13:48:54 +00:00
|
|
|
|
return -1;
|
|
|
|
|
break;
|
|
|
|
|
|
2006-08-22 13:21:13 +00:00
|
|
|
|
case ACTION_KBD_PAGE_FLIP:
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#ifdef KBD_MORSE_INPUT
|
2005-12-02 19:41:09 +00:00
|
|
|
|
if (morse_mode)
|
2006-03-29 16:21:42 +00:00
|
|
|
|
break;
|
2005-12-02 19:41:09 +00:00
|
|
|
|
#endif
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
{
|
|
|
|
|
if (++param[l].page == param[l].pages)
|
|
|
|
|
param[l].page = 0;
|
2006-07-23 17:16:38 +00:00
|
|
|
|
k = (param[l].page*param[l].lines +
|
2006-07-19 12:07:51 +00:00
|
|
|
|
param[l].y)*param[l].max_chars + param[l].x;
|
|
|
|
|
kbd_spellchar(param[l].kbd_buf[k]);
|
|
|
|
|
}
|
2003-01-15 13:48:54 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#ifdef KBD_MORSE_INPUT
|
2006-08-22 13:21:13 +00:00
|
|
|
|
case ACTION_KBD_MORSE_INPUT:
|
|
|
|
|
|
2006-03-29 16:21:42 +00:00
|
|
|
|
morse_mode = !morse_mode;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
{
|
|
|
|
|
param[l].x = param[l].y = param[l].page = 0;
|
|
|
|
|
if (morse_mode) {
|
|
|
|
|
param[l].old_main_y = param[l].main_y;
|
|
|
|
|
param[l].main_y = screens[l].height - param[l].font_h;
|
|
|
|
|
} else
|
|
|
|
|
param[l].main_y = param[l].old_main_y;
|
|
|
|
|
}
|
2006-03-29 16:21:42 +00:00
|
|
|
|
/* FIXME: We should talk something like Morse mode.. */
|
|
|
|
|
break;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
#endif
|
2006-08-22 13:21:13 +00:00
|
|
|
|
|
|
|
|
|
case ACTION_KBD_RIGHT:
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#ifdef KBD_MORSE_INPUT
|
2005-12-02 19:41:09 +00:00
|
|
|
|
if (morse_mode)
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#ifdef KBD_MODES
|
|
|
|
|
if (line_edit) /* right doubles as cursor_right in line_edit */
|
|
|
|
|
{
|
2006-03-31 13:59:04 +00:00
|
|
|
|
if (hangul)
|
2006-03-29 16:21:42 +00:00
|
|
|
|
hangul = false;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
|
2005-12-06 13:27:15 +00:00
|
|
|
|
if (editpos < len_utf8)
|
2005-02-07 00:56:26 +00:00
|
|
|
|
{
|
|
|
|
|
editpos++;
|
2005-12-06 13:27:15 +00:00
|
|
|
|
c = utf8seek(text, editpos);
|
|
|
|
|
kbd_spellchar(text[c]);
|
2005-02-07 00:56:26 +00:00
|
|
|
|
}
|
2004-11-14 23:08:08 +00:00
|
|
|
|
}
|
2003-03-10 15:09:27 +00:00
|
|
|
|
else
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#endif
|
2006-04-22 09:43:43 +00:00
|
|
|
|
{
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
{
|
|
|
|
|
if (++param[l].x == param[l].max_chars) {
|
|
|
|
|
param[l].x = 0;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#if !defined(KBD_PAGE_FLIP)
|
2005-10-08 07:12:28 +00:00
|
|
|
|
/* no dedicated flip key - flip page on wrap */
|
2006-07-19 12:07:51 +00:00
|
|
|
|
if (++param[l].page == param[l].pages)
|
|
|
|
|
param[l].page = 0;
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#endif
|
2006-07-19 12:07:51 +00:00
|
|
|
|
}
|
|
|
|
|
k = (param[l].page*param[l].lines + param[l].y)*param[l].max_chars + param[l].x;
|
|
|
|
|
kbd_spellchar(param[l].kbd_buf[k]);
|
2004-11-14 23:08:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-01-15 13:48:54 +00:00
|
|
|
|
break;
|
2006-08-22 13:21:13 +00:00
|
|
|
|
|
|
|
|
|
case ACTION_KBD_LEFT:
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#ifdef KBD_MORSE_INPUT
|
2005-12-02 19:41:09 +00:00
|
|
|
|
if (morse_mode)
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#ifdef KBD_MODES
|
|
|
|
|
if (line_edit) /* left doubles as cursor_left in line_edit */
|
|
|
|
|
{
|
2006-03-31 13:59:04 +00:00
|
|
|
|
if (hangul)
|
2006-03-29 16:21:42 +00:00
|
|
|
|
hangul = false;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
|
2005-02-07 00:56:26 +00:00
|
|
|
|
if (editpos)
|
|
|
|
|
{
|
|
|
|
|
editpos--;
|
2005-12-06 13:27:15 +00:00
|
|
|
|
c = utf8seek(text, editpos);
|
|
|
|
|
kbd_spellchar(text[c]);
|
2005-02-07 00:56:26 +00:00
|
|
|
|
}
|
2004-11-14 23:08:08 +00:00
|
|
|
|
}
|
2003-01-15 13:48:54 +00:00
|
|
|
|
else
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#endif
|
2006-03-29 16:21:42 +00:00
|
|
|
|
{
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
2004-11-14 23:08:08 +00:00
|
|
|
|
{
|
2006-07-19 12:07:51 +00:00
|
|
|
|
if (param[l].x)
|
|
|
|
|
param[l].x--;
|
|
|
|
|
else
|
|
|
|
|
{
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#if !defined(KBD_PAGE_FLIP)
|
2005-10-08 07:12:28 +00:00
|
|
|
|
/* no dedicated flip key - flip page on wrap */
|
2006-07-19 12:07:51 +00:00
|
|
|
|
if (--param[l].page < 0)
|
|
|
|
|
param[l].page = (param[l].pages-1);
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#endif
|
2006-07-19 12:07:51 +00:00
|
|
|
|
param[l].x = param[l].max_chars - 1;
|
|
|
|
|
}
|
2006-07-23 17:16:38 +00:00
|
|
|
|
k = (param[l].page*param[l].lines +
|
2006-07-19 12:07:51 +00:00
|
|
|
|
param[l].y)*param[l].max_chars + param[l].x;
|
|
|
|
|
kbd_spellchar(param[l].kbd_buf[k]);
|
2004-11-14 23:08:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-01-15 13:48:54 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2006-08-22 13:21:13 +00:00
|
|
|
|
case ACTION_KBD_DOWN:
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#ifdef KBD_MORSE_INPUT
|
2005-12-02 19:41:09 +00:00
|
|
|
|
if (morse_mode)
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#ifdef KBD_MODES
|
|
|
|
|
if (line_edit)
|
|
|
|
|
{
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
param[l].y=0;
|
2004-11-14 23:08:08 +00:00
|
|
|
|
line_edit = false;
|
|
|
|
|
}
|
2003-01-15 13:48:54 +00:00
|
|
|
|
else
|
2004-11-14 23:08:08 +00:00
|
|
|
|
{
|
|
|
|
|
#endif
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
{
|
|
|
|
|
if (param[l].y < param[l].lines - 1)
|
|
|
|
|
param[l].y++;
|
|
|
|
|
else
|
2006-07-23 15:12:34 +00:00
|
|
|
|
#ifndef KBD_MODES
|
2006-07-19 12:07:51 +00:00
|
|
|
|
param[l].y=0;}
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#else
|
2006-07-23 15:12:34 +00:00
|
|
|
|
line_edit = true;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
}
|
2004-11-14 23:08:08 +00:00
|
|
|
|
}
|
|
|
|
|
if (!line_edit)
|
|
|
|
|
#endif
|
2006-03-29 16:21:42 +00:00
|
|
|
|
{
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
{
|
|
|
|
|
k = (param[l].page*param[l].lines + param[l].y)*
|
|
|
|
|
param[l].max_chars + param[l].x;
|
|
|
|
|
kbd_spellchar(param[l].kbd_buf[k]);
|
|
|
|
|
}
|
2006-03-29 16:21:42 +00:00
|
|
|
|
}
|
2003-01-15 13:48:54 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2006-08-22 13:21:13 +00:00
|
|
|
|
case ACTION_KBD_UP:
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#ifdef KBD_MORSE_INPUT
|
2005-12-02 19:41:09 +00:00
|
|
|
|
if (morse_mode)
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#ifdef KBD_MODES
|
|
|
|
|
if (line_edit)
|
|
|
|
|
{
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
param[l].y = param[l].lines - 1;
|
2004-11-14 23:08:08 +00:00
|
|
|
|
line_edit = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
2003-03-10 15:09:27 +00:00
|
|
|
|
{
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#endif
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
{
|
|
|
|
|
if (param[l].y)
|
|
|
|
|
param[l].y--;
|
|
|
|
|
else
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#ifndef KBD_MODES
|
2006-07-19 12:07:51 +00:00
|
|
|
|
param[l].y = param[l].lines - 1;}
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#else
|
|
|
|
|
line_edit = true;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
}
|
2003-03-10 15:09:27 +00:00
|
|
|
|
}
|
2004-11-14 23:08:08 +00:00
|
|
|
|
if (!line_edit)
|
|
|
|
|
#endif
|
2006-03-29 16:21:42 +00:00
|
|
|
|
{
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
{
|
|
|
|
|
k = (param[l].page*param[l].lines + param[l].y)*
|
|
|
|
|
param[l].max_chars + param[l].x;
|
|
|
|
|
kbd_spellchar(param[l].kbd_buf[k]);
|
|
|
|
|
}
|
2006-03-29 16:21:42 +00:00
|
|
|
|
}
|
2003-01-15 13:48:54 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2006-08-22 13:21:13 +00:00
|
|
|
|
case ACTION_KBD_DONE:
|
2004-10-22 17:00:30 +00:00
|
|
|
|
/* accepts what was entered and continues */
|
2003-01-15 13:48:54 +00:00
|
|
|
|
done = true;
|
|
|
|
|
break;
|
|
|
|
|
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#ifdef KBD_MORSE_INPUT
|
2006-08-22 13:21:13 +00:00
|
|
|
|
case ACTION_KBD_MORSE_SELECT:
|
2005-12-02 19:41:09 +00:00
|
|
|
|
if (morse_mode && morse_reading)
|
|
|
|
|
{
|
|
|
|
|
morse_code <<= 1;
|
|
|
|
|
if ((current_tick - morse_tick) > HZ/5)
|
|
|
|
|
morse_code |= 0x01;
|
|
|
|
|
}
|
2006-04-22 09:43:43 +00:00
|
|
|
|
|
2005-12-02 19:41:09 +00:00
|
|
|
|
break;
|
|
|
|
|
#endif
|
2006-04-22 09:43:43 +00:00
|
|
|
|
|
2006-08-22 13:21:13 +00:00
|
|
|
|
case ACTION_KBD_SELECT:
|
|
|
|
|
case ACTION_KBD_SELECT_REM:
|
|
|
|
|
if (button == ACTION_KBD_SELECT_REM)
|
2006-07-19 12:07:51 +00:00
|
|
|
|
char_screen = 1;
|
2006-08-22 13:21:13 +00:00
|
|
|
|
else
|
2006-07-19 12:07:51 +00:00
|
|
|
|
char_screen = 0;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#ifdef KBD_MORSE_INPUT
|
2005-12-02 19:41:09 +00:00
|
|
|
|
if (morse_mode)
|
|
|
|
|
{
|
|
|
|
|
morse_tick = current_tick;
|
|
|
|
|
if (!morse_reading)
|
|
|
|
|
{
|
|
|
|
|
morse_reading = true;
|
|
|
|
|
morse_code = 1;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2006-04-22 09:43:43 +00:00
|
|
|
|
|
2004-10-22 17:00:30 +00:00
|
|
|
|
/* inserts the selected char */
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#ifdef KBD_MODES
|
2006-03-29 16:21:42 +00:00
|
|
|
|
if (line_edit) { /* select doubles as backspace in line_edit */
|
|
|
|
|
if (hangul) {
|
2006-03-31 13:59:04 +00:00
|
|
|
|
if (htail)
|
2006-03-29 16:21:42 +00:00
|
|
|
|
htail = 0;
|
2006-03-31 13:59:04 +00:00
|
|
|
|
else if (hvowel)
|
2006-03-29 16:21:42 +00:00
|
|
|
|
hvowel = 0;
|
2006-03-31 13:59:04 +00:00
|
|
|
|
else
|
2006-03-29 16:21:42 +00:00
|
|
|
|
hangul = false;
|
|
|
|
|
}
|
|
|
|
|
kbd_delchar(text, &editpos);
|
|
|
|
|
if (hangul) {
|
2006-03-31 13:59:04 +00:00
|
|
|
|
if (hvowel)
|
2006-03-29 16:21:42 +00:00
|
|
|
|
ch = hangul_join(hlead, hvowel, htail);
|
|
|
|
|
else
|
|
|
|
|
ch = hlead;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
kbd_inschar(text, buflen, &editpos, ch);
|
2003-03-10 15:09:27 +00:00
|
|
|
|
}
|
2004-11-14 23:08:08 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
#endif
|
|
|
|
|
{
|
2006-03-29 16:21:42 +00:00
|
|
|
|
/* find input char */
|
2006-07-19 12:07:51 +00:00
|
|
|
|
k = (param[char_screen].page*param[char_screen].lines +
|
2006-07-23 17:16:38 +00:00
|
|
|
|
param[char_screen].y)*param[char_screen].max_chars +
|
2006-07-19 12:07:51 +00:00
|
|
|
|
param[char_screen].x;
|
|
|
|
|
if (k < param[char_screen].nchars)
|
|
|
|
|
ch = param[char_screen].kbd_buf[k];
|
|
|
|
|
else
|
|
|
|
|
ch = ' ';
|
2006-03-29 16:21:42 +00:00
|
|
|
|
/* check for hangul input */
|
2006-07-19 12:07:51 +00:00
|
|
|
|
if (ch >= 0x3131 && ch <= 0x3163)
|
|
|
|
|
{
|
2006-07-23 17:16:38 +00:00
|
|
|
|
if (!hangul)
|
2006-07-19 12:07:51 +00:00
|
|
|
|
{
|
2006-03-31 13:59:04 +00:00
|
|
|
|
hlead=hvowel=htail=0;
|
|
|
|
|
hangul = true;
|
|
|
|
|
}
|
|
|
|
|
if (!hvowel)
|
|
|
|
|
hvowel = ch;
|
|
|
|
|
else if (!htail)
|
2006-07-19 12:07:51 +00:00
|
|
|
|
htail = ch;
|
2006-07-23 17:16:38 +00:00
|
|
|
|
else
|
2006-07-19 12:07:51 +00:00
|
|
|
|
{ /* previous hangul complete */
|
2006-03-31 13:59:04 +00:00
|
|
|
|
/* check whether tail is actually lead of next char */
|
2006-07-23 17:16:38 +00:00
|
|
|
|
if ((tmp = hangul_join(htail, ch, 0)) != 0xfffd)
|
2006-07-19 12:07:51 +00:00
|
|
|
|
{
|
2006-03-31 13:59:04 +00:00
|
|
|
|
tmp = hangul_join(hlead, hvowel, 0);
|
2006-03-29 16:21:42 +00:00
|
|
|
|
kbd_delchar(text, &editpos);
|
2006-03-31 13:59:04 +00:00
|
|
|
|
kbd_inschar(text, buflen, &editpos, tmp);
|
|
|
|
|
/* insert dummy char */
|
|
|
|
|
kbd_inschar(text, buflen, &editpos, ' ');
|
|
|
|
|
hlead = htail;
|
|
|
|
|
hvowel = ch;
|
|
|
|
|
htail = 0;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
}
|
2006-07-23 17:16:38 +00:00
|
|
|
|
else
|
2006-07-19 12:07:51 +00:00
|
|
|
|
{
|
2006-03-31 13:59:04 +00:00
|
|
|
|
hvowel=htail=0;
|
|
|
|
|
hlead = ch;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2006-03-31 13:59:04 +00:00
|
|
|
|
/* combine into hangul */
|
2006-07-23 17:16:38 +00:00
|
|
|
|
if ((tmp = hangul_join(hlead, hvowel, htail)) != 0xfffd)
|
2006-07-19 12:07:51 +00:00
|
|
|
|
{
|
2006-03-29 16:21:42 +00:00
|
|
|
|
kbd_delchar(text, &editpos);
|
2006-03-31 13:59:04 +00:00
|
|
|
|
ch = tmp;
|
2006-07-23 17:16:38 +00:00
|
|
|
|
}
|
2006-07-19 12:07:51 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2006-03-31 13:59:04 +00:00
|
|
|
|
hvowel=htail=0;
|
|
|
|
|
hlead = ch;
|
2006-03-29 16:21:42 +00:00
|
|
|
|
}
|
2006-07-23 17:16:38 +00:00
|
|
|
|
}
|
2006-07-19 12:07:51 +00:00
|
|
|
|
else
|
2006-03-29 16:21:42 +00:00
|
|
|
|
hangul = false;
|
2006-07-23 17:16:38 +00:00
|
|
|
|
|
2006-03-29 16:21:42 +00:00
|
|
|
|
/* insert char */
|
|
|
|
|
kbd_inschar(text, buflen, &editpos, ch);
|
2004-11-14 23:08:08 +00:00
|
|
|
|
}
|
2005-02-07 00:56:26 +00:00
|
|
|
|
if (global_settings.talk_menu) /* voice UI? */
|
2006-07-23 17:16:38 +00:00
|
|
|
|
talk_spell(text, false);
|
|
|
|
|
|
2006-07-19 12:07:51 +00:00
|
|
|
|
/* speak revised text */
|
2004-11-14 23:08:08 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
#ifndef KBD_MODES
|
2006-08-22 13:21:13 +00:00
|
|
|
|
case ACTION_KBD_BACKSPACE:
|
2006-07-23 17:16:38 +00:00
|
|
|
|
if (hangul)
|
2006-07-19 12:07:51 +00:00
|
|
|
|
{
|
2006-03-31 13:59:04 +00:00
|
|
|
|
if (htail)
|
2006-03-29 16:21:42 +00:00
|
|
|
|
htail = 0;
|
2006-03-31 13:59:04 +00:00
|
|
|
|
else if (hvowel)
|
2006-03-29 16:21:42 +00:00
|
|
|
|
hvowel = 0;
|
2006-03-31 13:59:04 +00:00
|
|
|
|
else
|
2006-03-29 16:21:42 +00:00
|
|
|
|
hangul = false;
|
|
|
|
|
}
|
|
|
|
|
kbd_delchar(text, &editpos);
|
2006-07-23 17:16:38 +00:00
|
|
|
|
if (hangul)
|
2006-07-19 12:07:51 +00:00
|
|
|
|
{
|
2006-03-31 13:59:04 +00:00
|
|
|
|
if (hvowel)
|
2006-03-29 16:21:42 +00:00
|
|
|
|
ch = hangul_join(hlead, hvowel, htail);
|
|
|
|
|
else
|
|
|
|
|
ch = hlead;
|
|
|
|
|
kbd_inschar(text, buflen, &editpos, ch);
|
2003-01-15 13:48:54 +00:00
|
|
|
|
}
|
2005-02-07 00:56:26 +00:00
|
|
|
|
if (global_settings.talk_menu) /* voice UI? */
|
|
|
|
|
talk_spell(text, false); /* speak revised text */
|
2003-01-15 13:48:54 +00:00
|
|
|
|
break;
|
2003-03-10 15:09:27 +00:00
|
|
|
|
|
2006-08-22 13:21:13 +00:00
|
|
|
|
case ACTION_KBD_CURSOR_RIGHT:
|
|
|
|
|
|
2006-03-31 13:59:04 +00:00
|
|
|
|
if (hangul)
|
2006-03-29 16:21:42 +00:00
|
|
|
|
hangul = false;
|
2006-07-19 12:07:51 +00:00
|
|
|
|
|
2005-12-06 13:27:15 +00:00
|
|
|
|
if (editpos < len_utf8)
|
2005-02-07 00:56:26 +00:00
|
|
|
|
{
|
|
|
|
|
editpos++;
|
2005-12-06 13:27:15 +00:00
|
|
|
|
c = utf8seek(text, editpos);
|
|
|
|
|
kbd_spellchar(text[c]);
|
2005-02-07 00:56:26 +00:00
|
|
|
|
}
|
2003-03-10 15:09:27 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2006-08-22 13:21:13 +00:00
|
|
|
|
case ACTION_KBD_CURSOR_LEFT:
|
|
|
|
|
|
2006-03-31 13:59:04 +00:00
|
|
|
|
if (hangul)
|
2006-03-29 16:21:42 +00:00
|
|
|
|
hangul = false;
|
2005-02-07 00:56:26 +00:00
|
|
|
|
if (editpos)
|
|
|
|
|
{
|
|
|
|
|
editpos--;
|
2005-12-06 13:27:15 +00:00
|
|
|
|
c = utf8seek(text, editpos);
|
|
|
|
|
kbd_spellchar(text[c]);
|
2005-02-07 00:56:26 +00:00
|
|
|
|
}
|
2003-03-10 15:09:27 +00:00
|
|
|
|
break;
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#endif /* !KBD_MODES */
|
2003-03-10 15:09:27 +00:00
|
|
|
|
|
2003-11-04 12:36:55 +00:00
|
|
|
|
case BUTTON_NONE:
|
2005-11-20 01:02:14 +00:00
|
|
|
|
gui_syncstatusbar_draw(&statusbars, false);
|
2006-03-29 16:21:42 +00:00
|
|
|
|
#ifdef KBD_MORSE_INPUT
|
2005-12-02 19:41:09 +00:00
|
|
|
|
if (morse_reading)
|
|
|
|
|
{
|
|
|
|
|
logf("Morse: 0x%02x", morse_code);
|
|
|
|
|
morse_reading = false;
|
|
|
|
|
|
|
|
|
|
for (j = 0; morse_alphabets[j] != '\0'; j++)
|
|
|
|
|
{
|
|
|
|
|
if (morse_codes[j] == morse_code)
|
|
|
|
|
break ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (morse_alphabets[j] == '\0')
|
|
|
|
|
{
|
|
|
|
|
logf("Morse code not found");
|
|
|
|
|
break ;
|
|
|
|
|
}
|
2006-03-29 16:21:42 +00:00
|
|
|
|
|
2006-03-31 13:59:04 +00:00
|
|
|
|
/* turn off hangul input */
|
|
|
|
|
if (hangul)
|
2006-03-29 16:21:42 +00:00
|
|
|
|
hangul = false;
|
|
|
|
|
kbd_inschar(text, buflen, &editpos, morse_alphabets[j]);
|
|
|
|
|
|
2005-12-02 19:41:09 +00:00
|
|
|
|
if (global_settings.talk_menu) /* voice UI? */
|
|
|
|
|
talk_spell(text, false); /* speak revised text */
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2003-11-04 12:36:55 +00:00
|
|
|
|
break;
|
2004-07-26 16:06:59 +00:00
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
if(default_event_handler(button) == SYS_USB_CONNECTED)
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
screens[l].setfont(FONT_SYSFIXED);
|
2004-07-26 16:06:59 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2002-12-04 15:04:43 +00:00
|
|
|
|
}
|
2004-10-22 17:00:30 +00:00
|
|
|
|
if (button != BUTTON_NONE)
|
2006-04-22 13:06:57 +00:00
|
|
|
|
{
|
|
|
|
|
cur_blink = true;
|
|
|
|
|
}
|
2002-12-04 15:04:43 +00:00
|
|
|
|
}
|
2006-03-11 22:31:53 +00:00
|
|
|
|
#ifdef HAS_BUTTONBAR
|
|
|
|
|
global_settings.buttonbar=buttonbar_config;
|
|
|
|
|
#endif
|
2006-07-19 12:07:51 +00:00
|
|
|
|
FOR_NB_SCREENS(l)
|
|
|
|
|
screens[l].setfont(FONT_UI);
|
2002-12-04 15:04:43 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|