Merge duplicating code to move cursor left/right.

remove ACTION_KBD_SELECT_REM, use ACTION_KBD_SELECT instead as they seem to be equivalent.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23543 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Teruaki Kawashima 2009-11-06 12:53:02 +00:00
parent e9f389a9e7
commit b6cd045767
3 changed files with 29 additions and 82 deletions

View file

@ -227,7 +227,6 @@ enum {
ACTION_KBD_CURSOR_LEFT,
ACTION_KBD_CURSOR_RIGHT,
ACTION_KBD_SELECT,
ACTION_KBD_SELECT_REM,
ACTION_KBD_PAGE_FLIP,
ACTION_KBD_DONE,
ACTION_KBD_ABORT,

View file

@ -643,7 +643,7 @@ static const struct button_mapping button_context_keyboard_h100remote[] = {
{ ACTION_KBD_CURSOR_LEFT, BUTTON_RC_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_KBD_CURSOR_RIGHT, BUTTON_RC_VOL_UP, BUTTON_NONE },
{ ACTION_KBD_CURSOR_RIGHT, BUTTON_RC_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_KBD_SELECT_REM, BUTTON_RC_MENU, BUTTON_NONE },
{ ACTION_KBD_SELECT, BUTTON_RC_MENU, BUTTON_NONE },
{ ACTION_KBD_PAGE_FLIP, BUTTON_RC_MODE, BUTTON_NONE },
{ ACTION_KBD_DONE, BUTTON_RC_ON|BUTTON_REL, BUTTON_RC_ON },
{ ACTION_KBD_ABORT, BUTTON_RC_STOP, BUTTON_NONE },
@ -668,7 +668,7 @@ static const struct button_mapping button_context_keyboard_h300lcdremote[] = {
{ ACTION_KBD_CURSOR_LEFT, BUTTON_RC_SOURCE|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_KBD_CURSOR_RIGHT, BUTTON_RC_BITRATE, BUTTON_NONE },
{ ACTION_KBD_CURSOR_RIGHT, BUTTON_RC_BITRATE|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_KBD_SELECT_REM, BUTTON_RC_MENU, BUTTON_NONE },
{ ACTION_KBD_SELECT, BUTTON_RC_MENU, BUTTON_NONE },
{ ACTION_KBD_PAGE_FLIP, BUTTON_RC_MODE, BUTTON_NONE },
{ ACTION_KBD_DONE, BUTTON_RC_ON, BUTTON_NONE },
{ ACTION_KBD_ABORT, BUTTON_RC_STOP, BUTTON_NONE },

View file

@ -771,16 +771,23 @@ int kbd_input(char* text, int buflen)
pm = &param[button_screen];
sc = &screens[button_screen];
#if defined KBD_MORSE_INPUT && !defined KBD_MODES
#if defined(KBD_MODES) || defined(KBD_MORSE_INPUT)
/* Remap some buttons to allow to move
* cursor in line edit mode and morse mode. */
#if defined(KBD_MODES) && defined(KBD_MORSE_INPUT)
if (pm->line_edit || morse_mode)
#elif defined(KBD_MODES)
if (pm->line_edit)
#else /* defined(KBD_MORSE_INPUT) */
if (morse_mode)
#endif
{
/* Remap some buttons for morse mode. */
if (button == ACTION_KBD_LEFT)
button = ACTION_KBD_CURSOR_LEFT;
if (button == ACTION_KBD_RIGHT)
button = ACTION_KBD_CURSOR_RIGHT;
}
#endif
#endif /* defined(KBD_MODES) || defined(KBD_MORSE_INPUT) */
switch ( button )
{
@ -827,91 +834,33 @@ int kbd_input(char* text, int buflen)
#endif /* KBD_MORSE_INPUT */
case ACTION_KBD_RIGHT:
#ifdef KBD_MODES
#ifdef KBD_MORSE_INPUT
/* allow cursor change in non line edit morse mode */
if (pm->line_edit || morse_mode)
#else
/* right doubles as cursor_right in line_edit */
if (pm->line_edit)
#endif
if (++pm->x >= pm->max_chars)
{
pm->hangul = false;
if (editpos < len_utf8)
{
int c = utf8seek(text, ++editpos);
kbd_spellchar(text[c]);
}
#if CONFIG_CODEC == SWCODEC
else if (global_settings.talk_menu)
pcmbuf_beep(1000, 150, 1500);
#endif
}
else
#endif /* KBD_MODES */
{
#ifdef KBD_MORSE_INPUT
if (morse_mode)
break;
#endif
if (++pm->x >= pm->max_chars)
{
#ifndef KBD_PAGE_FLIP
/* no dedicated flip key - flip page on wrap */
if (++pm->page >= pm->pages)
pm->page = 0;
/* no dedicated flip key - flip page on wrap */
if (++pm->page >= pm->pages)
pm->page = 0;
#endif
pm->x = 0;
}
ch = get_kbd_ch(pm);
kbd_spellchar(ch);
pm->x = 0;
}
ch = get_kbd_ch(pm);
kbd_spellchar(ch);
break;
case ACTION_KBD_LEFT:
#ifdef KBD_MODES
#ifdef KBD_MORSE_INPUT
/* allow cursor change in non line edit morse mode */
if (pm->line_edit || morse_mode)
#else
/* left doubles as cursor_left in line_edit */
if (pm->line_edit)
#endif
if (--pm->x < 0)
{
pm->hangul = false;
if (editpos > 0)
{
int c = utf8seek(text, --editpos);
kbd_spellchar(text[c]);
}
#if CONFIG_CODEC == SWCODEC
else if (global_settings.talk_menu)
pcmbuf_beep(1000, 150, 1500);
#endif
}
else
#endif /* KBD_MODES */
{
#ifdef KBD_MORSE_INPUT
if (morse_mode)
break;
#endif
if (--pm->x < 0)
{
#ifndef KBD_PAGE_FLIP
/* no dedicated flip key - flip page on wrap */
if (--pm->page < 0)
pm->page = pm->pages - 1;
/* no dedicated flip key - flip page on wrap */
if (--pm->page < 0)
pm->page = pm->pages - 1;
#endif
pm->x = pm->max_chars - 1;
}
ch = get_kbd_ch(pm);
kbd_spellchar(ch);
pm->x = pm->max_chars - 1;
}
ch = get_kbd_ch(pm);
kbd_spellchar(ch);
break;
case ACTION_KBD_DOWN:
@ -1019,7 +968,6 @@ int kbd_input(char* text, int buflen)
#endif /* KBD_MORSE_INPUT */
case ACTION_KBD_SELECT:
case ACTION_KBD_SELECT_REM:
#ifdef KBD_MORSE_INPUT
#ifdef KBD_MODES
if (morse_mode && !pm->line_edit)
@ -1166,6 +1114,7 @@ int kbd_input(char* text, int buflen)
if (global_settings.talk_menu) /* voice UI? */
talk_spell(text, false); /* speak revised text */
break;
#endif /* !defined (KBD_MODES) || defined (KBD_CURSOR_KEYS) */
case ACTION_KBD_CURSOR_RIGHT:
pm->hangul = false;
@ -1194,7 +1143,6 @@ int kbd_input(char* text, int buflen)
pcmbuf_beep(1000, 150, 1500);
#endif
break;
#endif /* !defined (KBD_MODES) || defined (KBD_CURSOR_KEYS) */
case BUTTON_NONE:
#ifdef KBD_MORSE_INPUT