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"
|
2003-11-04 12:36:55 +00:00
|
|
|
|
#include "status.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"
|
2002-12-04 15:04:43 +00:00
|
|
|
|
|
|
|
|
|
#define KEYBOARD_LINES 4
|
|
|
|
|
#define KEYBOARD_PAGES 3
|
|
|
|
|
|
2004-10-22 17:00:30 +00:00
|
|
|
|
|
2004-11-19 10:54:59 +00:00
|
|
|
|
#if CONFIG_KEYPAD == IRIVER_H100_PAD
|
|
|
|
|
#define KBD_CURSOR_RIGHT (BUTTON_ON | BUTTON_RIGHT)
|
|
|
|
|
#define KBD_CURSOR_LEFT (BUTTON_ON | BUTTON_LEFT)
|
|
|
|
|
#define KBD_SELECT BUTTON_SELECT
|
|
|
|
|
#define KBD_PAGE_FLIP BUTTON_MODE
|
|
|
|
|
#define KBD_DONE BUTTON_ON
|
|
|
|
|
#define KBD_ABORT BUTTON_OFF
|
|
|
|
|
#define KBD_BACKSPACE BUTTON_REC
|
2005-01-23 01:01:14 +00:00
|
|
|
|
|
2004-11-19 10:54:59 +00:00
|
|
|
|
#elif CONFIG_KEYPAD == RECORDER_PAD
|
2004-10-22 17:00:30 +00:00
|
|
|
|
#define KBD_CURSOR_RIGHT (BUTTON_ON | BUTTON_RIGHT)
|
|
|
|
|
#define KBD_CURSOR_LEFT (BUTTON_ON | BUTTON_LEFT)
|
|
|
|
|
#define KBD_SELECT BUTTON_PLAY
|
|
|
|
|
#define KBD_PAGE_FLIP BUTTON_F1
|
|
|
|
|
#define KBD_DONE BUTTON_F2
|
|
|
|
|
#define KBD_ABORT BUTTON_OFF
|
|
|
|
|
#define KBD_BACKSPACE BUTTON_F3
|
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 */
|
|
|
|
|
#define KBD_SELECT (BUTTON_MENU | BUTTON_REL) /* backspace in line edit */
|
2004-10-22 17:00:30 +00:00
|
|
|
|
#define KBD_SELECT_PRE BUTTON_MENU
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#define KBD_DONE (BUTTON_MENU | BUTTON_REPEAT)
|
|
|
|
|
#define KBD_ABORT BUTTON_OFF
|
2005-01-23 01:01:14 +00:00
|
|
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == GMINI100_PAD
|
|
|
|
|
#define KBD_CURSOR_RIGHT (BUTTON_MENU | BUTTON_RIGHT)
|
|
|
|
|
#define KBD_CURSOR_LEFT (BUTTON_MENU | BUTTON_LEFT)
|
|
|
|
|
#define KBD_SELECT (BUTTON_PLAY | BUTTON_REL)
|
|
|
|
|
#define KBD_SELECT_PRE BUTTON_PLAY
|
|
|
|
|
#define KBD_PAGE_FLIP BUTTON_ON
|
|
|
|
|
#define KBD_DONE (BUTTON_PLAY | BUTTON_REPEAT)
|
|
|
|
|
#define KBD_ABORT BUTTON_OFF
|
|
|
|
|
#define KBD_BACKSPACE (BUTTON_MENU | BUTTON_PLAY)
|
|
|
|
|
|
2004-10-22 17:00:30 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
2004-08-18 19:59:06 +00:00
|
|
|
|
static void kbd_setupkeys(const char* line[KEYBOARD_LINES], int page)
|
2002-12-04 15:04:43 +00:00
|
|
|
|
{
|
2005-02-07 00:56:26 +00:00
|
|
|
|
switch (page)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
line[0] = "ABCDEFG !?\" @#$%+'";
|
|
|
|
|
line[1] = "HIJKLMN 789 &_()-`";
|
|
|
|
|
line[2] = "OPQRSTU 456 <20>|{}/<";
|
|
|
|
|
line[3] = "VWXYZ.,0123 ~=[]*>";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
line[0] = "abcdefg <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
|
|
|
|
line[1] = "hijklmn <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
|
|
|
|
line[2] = "opqrstu <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
|
|
|
|
line[3] = "vwxyz., <20><><EFBFBD> ";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
line[0] = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>";
|
|
|
|
|
line[1] = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>";
|
|
|
|
|
line[2] = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>";
|
|
|
|
|
line[3] = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>";
|
|
|
|
|
break;
|
2002-12-04 15:04:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-11-17 02:10:09 +00:00
|
|
|
|
|
2004-05-21 06:29:55 +00:00
|
|
|
|
/* helper function to spell a char if voice UI is enabled */
|
2005-02-07 00:56:26 +00:00
|
|
|
|
static void kbd_spellchar(char 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
|
|
|
|
|
|
|
|
|
if (global_settings.talk_menu) /* voice UI? */
|
|
|
|
|
{
|
|
|
|
|
spell_char[0] = c;
|
2005-02-07 00:56:26 +00:00
|
|
|
|
talk_spell(spell_char, false);
|
2004-05-21 06:29:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-12-04 15:04:43 +00:00
|
|
|
|
int kbd_input(char* text, int buflen)
|
|
|
|
|
{
|
|
|
|
|
bool done = false;
|
|
|
|
|
int page = 0;
|
|
|
|
|
|
|
|
|
|
int font_w = 0, font_h = 0, i;
|
|
|
|
|
int x = 0, y = 0;
|
|
|
|
|
int main_x, main_y, max_chars, margin;
|
2005-02-07 00:56:26 +00:00
|
|
|
|
int status_y1, status_y2;
|
2002-12-04 15:04:43 +00:00
|
|
|
|
int len;
|
2005-02-07 00:56:26 +00:00
|
|
|
|
int editpos, curpos, leftpos;
|
2003-11-17 02:10:09 +00:00
|
|
|
|
bool redraw = true;
|
2004-08-18 19:59:06 +00:00
|
|
|
|
const char* line[KEYBOARD_LINES];
|
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];
|
2002-12-04 15:04:43 +00:00
|
|
|
|
char c = 0;
|
|
|
|
|
struct font* font = font_get(FONT_SYSFIXED);
|
2004-10-22 17:00:30 +00:00
|
|
|
|
int button, lastbutton = 0;
|
2002-12-04 15:04:43 +00:00
|
|
|
|
|
2003-01-15 13:48:54 +00:00
|
|
|
|
lcd_setfont(FONT_SYSFIXED);
|
2002-12-04 15:04:43 +00:00
|
|
|
|
font_w = font->maxwidth;
|
|
|
|
|
font_h = font->height;
|
|
|
|
|
|
|
|
|
|
margin = 3;
|
2003-11-17 02:10:09 +00:00
|
|
|
|
main_y = (KEYBOARD_LINES + 1) * font_h + margin*2;
|
2002-12-04 15:04:43 +00:00
|
|
|
|
main_x = 0;
|
|
|
|
|
status_y1 = LCD_HEIGHT - font_h;
|
|
|
|
|
status_y2 = LCD_HEIGHT;
|
|
|
|
|
|
2003-03-10 15:09:27 +00:00
|
|
|
|
editpos = strlen(text);
|
|
|
|
|
|
2005-02-07 00:56:26 +00:00
|
|
|
|
max_chars = LCD_WIDTH / font_w - 2; /* leave room for < and > */
|
2002-12-04 15:04:43 +00:00
|
|
|
|
kbd_setupkeys(line, page);
|
|
|
|
|
|
2004-05-21 06:29:55 +00:00
|
|
|
|
if (global_settings.talk_menu) /* voice UI? */
|
|
|
|
|
talk_spell(text, true); /* spell initial text */
|
|
|
|
|
|
2002-12-04 15:04:43 +00:00
|
|
|
|
while(!done)
|
|
|
|
|
{
|
|
|
|
|
len = strlen(text);
|
2003-11-17 02:10:09 +00:00
|
|
|
|
|
|
|
|
|
if(redraw)
|
2003-03-10 15:09:27 +00:00
|
|
|
|
{
|
2003-11-17 02:10:09 +00:00
|
|
|
|
lcd_clear_display();
|
|
|
|
|
|
2005-02-07 00:56:26 +00:00
|
|
|
|
lcd_setfont(FONT_SYSFIXED);
|
|
|
|
|
|
2003-11-17 02:10:09 +00:00
|
|
|
|
/* draw page */
|
|
|
|
|
for (i=0; i < KEYBOARD_LINES; i++)
|
|
|
|
|
lcd_putsxy(0, 8+i * font_h, line[i]);
|
|
|
|
|
|
|
|
|
|
/* separator */
|
2005-06-25 00:28:09 +00:00
|
|
|
|
lcd_hline(0, LCD_WIDTH - 1, main_y - margin);
|
2003-11-17 02:10:09 +00:00
|
|
|
|
|
|
|
|
|
/* write out the text */
|
2005-02-07 00:56:26 +00:00
|
|
|
|
curpos = MIN(editpos, max_chars - MIN(len - editpos, 2));
|
|
|
|
|
leftpos = editpos - curpos;
|
|
|
|
|
strncpy(outline, text + leftpos, max_chars);
|
|
|
|
|
outline[max_chars] = 0;
|
2003-11-17 02:10:09 +00:00
|
|
|
|
|
2005-02-07 00:56:26 +00:00
|
|
|
|
lcd_putsxy(font_w, main_y, outline);
|
|
|
|
|
|
|
|
|
|
if (leftpos)
|
|
|
|
|
lcd_putsxy(0, main_y, "<");
|
|
|
|
|
if (len - leftpos > max_chars)
|
|
|
|
|
lcd_putsxy(LCD_WIDTH - font_w, main_y, ">");
|
2004-11-14 23:08:08 +00:00
|
|
|
|
|
2003-11-17 02:10:09 +00:00
|
|
|
|
/* cursor */
|
2005-02-07 00:56:26 +00:00
|
|
|
|
i = (curpos + 1) * font_w;
|
2005-06-25 00:28:09 +00:00
|
|
|
|
lcd_vline(i, main_y, main_y + font_h);
|
2005-02-07 00:56:26 +00:00
|
|
|
|
|
2004-10-22 17:00:30 +00:00
|
|
|
|
#if CONFIG_KEYPAD == RECORDER_PAD
|
2003-11-17 02:10:09 +00:00
|
|
|
|
/* draw the status bar */
|
|
|
|
|
buttonbar_set("Shift", "OK", "Del");
|
|
|
|
|
buttonbar_draw();
|
2005-02-07 00:56:26 +00:00
|
|
|
|
#endif
|
2003-11-17 02:10:09 +00:00
|
|
|
|
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#ifdef KBD_MODES
|
|
|
|
|
if (!line_edit)
|
|
|
|
|
#endif
|
2005-06-24 22:33:21 +00:00
|
|
|
|
{
|
2004-11-14 23:08:08 +00:00
|
|
|
|
/* highlight the key that has focus */
|
2005-06-24 22:33:21 +00:00
|
|
|
|
lcd_set_drawmode(DRMODE_COMPLEMENT);
|
|
|
|
|
lcd_fillrect(font_w * x, 8 + font_h * y, font_w, font_h);
|
|
|
|
|
lcd_set_drawmode(DRMODE_SOLID);
|
|
|
|
|
}
|
2004-11-14 23:08:08 +00:00
|
|
|
|
|
2003-11-17 02:10:09 +00:00
|
|
|
|
status_draw(true);
|
2003-03-17 23:16:20 +00:00
|
|
|
|
|
2003-11-17 02:10:09 +00:00
|
|
|
|
lcd_update();
|
|
|
|
|
}
|
2002-12-04 15:04:43 +00:00
|
|
|
|
|
2003-11-17 02:10:09 +00:00
|
|
|
|
/* The default action is to redraw */
|
|
|
|
|
redraw = true;
|
2004-07-26 16:06:59 +00:00
|
|
|
|
|
|
|
|
|
button = button_get_w_tmo(HZ/2);
|
|
|
|
|
switch ( button ) {
|
2002-12-04 15:04:43 +00:00
|
|
|
|
|
2004-10-22 17:00:30 +00:00
|
|
|
|
case KBD_ABORT:
|
2003-01-15 13:48:54 +00:00
|
|
|
|
lcd_setfont(FONT_UI);
|
|
|
|
|
return -1;
|
|
|
|
|
break;
|
|
|
|
|
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#ifdef KBD_PAGE_FLIP
|
2004-10-22 17:00:30 +00:00
|
|
|
|
case KBD_PAGE_FLIP:
|
2003-01-15 13:48:54 +00:00
|
|
|
|
if (++page == KEYBOARD_PAGES)
|
|
|
|
|
page = 0;
|
|
|
|
|
kbd_setupkeys(line, page);
|
2004-05-21 06:29:55 +00:00
|
|
|
|
kbd_spellchar(line[y][x]);
|
2003-01-15 13:48:54 +00:00
|
|
|
|
break;
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#endif
|
2003-01-15 13:48:54 +00:00
|
|
|
|
|
|
|
|
|
case BUTTON_RIGHT:
|
|
|
|
|
case BUTTON_RIGHT | BUTTON_REPEAT:
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#ifdef KBD_MODES
|
|
|
|
|
if (line_edit) /* right doubles as cursor_right in line_edit */
|
|
|
|
|
{
|
2005-02-07 00:56:26 +00:00
|
|
|
|
if (editpos < len)
|
|
|
|
|
{
|
|
|
|
|
editpos++;
|
2004-11-14 23:08:08 +00:00
|
|
|
|
kbd_spellchar(text[editpos]);
|
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
|
|
|
|
|
{
|
|
|
|
|
if (x < (int)strlen(line[y]) - 1)
|
|
|
|
|
x++;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
x = 0;
|
|
|
|
|
#ifndef KBD_PAGE_FLIP /* no dedicated flip key - flip page on wrap */
|
|
|
|
|
if (++page == KEYBOARD_PAGES)
|
|
|
|
|
page = 0;
|
|
|
|
|
kbd_setupkeys(line, page);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
kbd_spellchar(line[y][x]);
|
|
|
|
|
}
|
2003-01-15 13:48:54 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BUTTON_LEFT:
|
|
|
|
|
case BUTTON_LEFT | BUTTON_REPEAT:
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#ifdef KBD_MODES
|
|
|
|
|
if (line_edit) /* left doubles as cursor_left in line_edit */
|
|
|
|
|
{
|
2005-02-07 00:56:26 +00:00
|
|
|
|
if (editpos)
|
|
|
|
|
{
|
|
|
|
|
editpos--;
|
2004-11-14 23:08:08 +00:00
|
|
|
|
kbd_spellchar(text[editpos]);
|
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
|
|
|
|
|
{
|
|
|
|
|
if (x)
|
|
|
|
|
x--;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
#ifndef KBD_PAGE_FLIP /* no dedicated flip key - flip page on wrap */
|
|
|
|
|
if (--page < 0)
|
|
|
|
|
page = (KEYBOARD_PAGES-1);
|
|
|
|
|
kbd_setupkeys(line, page);
|
|
|
|
|
#endif
|
|
|
|
|
x = strlen(line[y]) - 1;
|
|
|
|
|
}
|
|
|
|
|
kbd_spellchar(line[y][x]);
|
|
|
|
|
}
|
2003-01-15 13:48:54 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BUTTON_DOWN:
|
|
|
|
|
case BUTTON_DOWN | BUTTON_REPEAT:
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#ifdef KBD_MODES
|
|
|
|
|
if (line_edit)
|
|
|
|
|
{
|
|
|
|
|
y = 0;
|
|
|
|
|
line_edit = false;
|
|
|
|
|
}
|
2003-01-15 13:48:54 +00:00
|
|
|
|
else
|
2004-11-14 23:08:08 +00:00
|
|
|
|
{
|
|
|
|
|
#endif
|
|
|
|
|
if (y < KEYBOARD_LINES - 1)
|
|
|
|
|
y++;
|
|
|
|
|
else
|
|
|
|
|
#ifndef KBD_MODES
|
|
|
|
|
y=0;
|
|
|
|
|
#else
|
|
|
|
|
line_edit = true;
|
|
|
|
|
}
|
|
|
|
|
if (!line_edit)
|
|
|
|
|
#endif
|
|
|
|
|
kbd_spellchar(line[y][x]);
|
2003-01-15 13:48:54 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BUTTON_UP:
|
|
|
|
|
case BUTTON_UP | BUTTON_REPEAT:
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#ifdef KBD_MODES
|
|
|
|
|
if (line_edit)
|
|
|
|
|
{
|
2003-01-15 13:48:54 +00:00
|
|
|
|
y = KEYBOARD_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
|
|
|
|
|
if (y)
|
|
|
|
|
y--;
|
|
|
|
|
else
|
|
|
|
|
#ifndef KBD_MODES
|
|
|
|
|
y = KEYBOARD_LINES - 1;
|
|
|
|
|
#else
|
|
|
|
|
line_edit = true;
|
2003-03-10 15:09:27 +00:00
|
|
|
|
}
|
2004-11-14 23:08:08 +00:00
|
|
|
|
if (!line_edit)
|
|
|
|
|
#endif
|
|
|
|
|
kbd_spellchar(line[y][x]);
|
2003-01-15 13:48:54 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2004-10-22 17:00:30 +00:00
|
|
|
|
case KBD_DONE:
|
|
|
|
|
/* accepts what was entered and continues */
|
2003-01-15 13:48:54 +00:00
|
|
|
|
done = true;
|
|
|
|
|
break;
|
|
|
|
|
|
2004-10-22 17:00:30 +00:00
|
|
|
|
case KBD_SELECT:
|
|
|
|
|
/* inserts the selected char */
|
|
|
|
|
#ifdef KBD_SELECT_PRE
|
|
|
|
|
if (lastbutton != KBD_SELECT_PRE)
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
2004-11-14 23:08:08 +00:00
|
|
|
|
#ifdef KBD_MODES
|
|
|
|
|
if (line_edit) /* select doubles as backspace in line_edit */
|
2003-01-15 13:48:54 +00:00
|
|
|
|
{
|
2004-11-14 23:08:08 +00:00
|
|
|
|
if (editpos > 0)
|
2003-03-10 15:09:27 +00:00
|
|
|
|
{
|
2005-02-07 00:56:26 +00:00
|
|
|
|
for (i = editpos; i < len; i++)
|
2004-11-14 23:08:08 +00:00
|
|
|
|
text[i-1] = text[i];
|
2005-02-07 00:56:26 +00:00
|
|
|
|
text[i-1] = '\0';
|
2004-11-14 23:08:08 +00:00
|
|
|
|
editpos--;
|
2003-03-10 15:09:27 +00:00
|
|
|
|
}
|
2004-11-14 23:08:08 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
#endif
|
|
|
|
|
{
|
2005-02-07 00:56:26 +00:00
|
|
|
|
if (len < buflen)
|
2003-03-10 15:09:27 +00:00
|
|
|
|
{
|
2004-11-14 23:08:08 +00:00
|
|
|
|
c = line[y][x];
|
2005-02-07 00:56:26 +00:00
|
|
|
|
if (editpos == len)
|
2004-11-14 23:08:08 +00:00
|
|
|
|
{
|
|
|
|
|
text[len] = c;
|
|
|
|
|
text[len+1] = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2005-02-07 00:56:26 +00:00
|
|
|
|
for (i = len ; i >= editpos; i--)
|
2004-11-14 23:08:08 +00:00
|
|
|
|
text[i+1] = text[i];
|
|
|
|
|
text[editpos] = c;
|
|
|
|
|
}
|
|
|
|
|
editpos++;
|
2003-03-10 15:09:27 +00:00
|
|
|
|
}
|
2004-11-14 23:08:08 +00:00
|
|
|
|
}
|
2005-02-07 00:56:26 +00:00
|
|
|
|
if (global_settings.talk_menu) /* voice UI? */
|
|
|
|
|
talk_spell(text, false); /* speak revised text */
|
2004-11-14 23:08:08 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
#ifndef KBD_MODES
|
|
|
|
|
case KBD_BACKSPACE:
|
|
|
|
|
case KBD_BACKSPACE | BUTTON_REPEAT:
|
|
|
|
|
if (editpos > 0)
|
|
|
|
|
{
|
2005-02-07 00:56:26 +00:00
|
|
|
|
for (i = editpos; i < len; i++)
|
2004-11-14 23:08:08 +00:00
|
|
|
|
text[i-1] = text[i];
|
2005-02-07 00:56:26 +00:00
|
|
|
|
text[i-1] = '\0';
|
2004-11-14 23:08:08 +00:00
|
|
|
|
editpos--;
|
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
|
|
|
|
|
2004-10-22 17:00:30 +00:00
|
|
|
|
case KBD_CURSOR_RIGHT:
|
|
|
|
|
case KBD_CURSOR_RIGHT | BUTTON_REPEAT:
|
2005-02-07 00:56:26 +00:00
|
|
|
|
if (editpos < len)
|
|
|
|
|
{
|
|
|
|
|
editpos++;
|
2004-05-21 06:29:55 +00:00
|
|
|
|
kbd_spellchar(text[editpos]);
|
2005-02-07 00:56:26 +00:00
|
|
|
|
}
|
2003-03-10 15:09:27 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2004-10-22 17:00:30 +00:00
|
|
|
|
case KBD_CURSOR_LEFT:
|
|
|
|
|
case KBD_CURSOR_LEFT | BUTTON_REPEAT:
|
2005-02-07 00:56:26 +00:00
|
|
|
|
if (editpos)
|
|
|
|
|
{
|
|
|
|
|
editpos--;
|
2004-05-21 06:29:55 +00:00
|
|
|
|
kbd_spellchar(text[editpos]);
|
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:
|
|
|
|
|
status_draw(false);
|
2003-11-17 02:10:09 +00:00
|
|
|
|
redraw = false;
|
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)
|
|
|
|
|
lcd_setfont(FONT_SYSFIXED);
|
|
|
|
|
break;
|
|
|
|
|
|
2002-12-04 15:04:43 +00:00
|
|
|
|
}
|
2004-10-22 17:00:30 +00:00
|
|
|
|
if (button != BUTTON_NONE)
|
|
|
|
|
lastbutton = button;
|
2002-12-04 15:04:43 +00:00
|
|
|
|
}
|
2003-01-15 13:48:54 +00:00
|
|
|
|
lcd_setfont(FONT_UI);
|
2004-09-19 21:58:37 +00:00
|
|
|
|
|
2002-12-04 15:04:43 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|