📄 auieditor.c
字号:
{
/* Entered less than the required number of chars: Alternate Left Softkey appears */
if (textLen < data->editor_data.min_enter)
{
leftSK = data->editor_data.AltLeftSoftKey;
}
else
{
leftSK = data->editor_data.LeftSoftKey;
}
/* Buffer is empty and alternative rsk enabled: alternative rsk appears */
if (textLen==0 && data->editor_data.change_rsk_on_empty)
{
rightSK = data->editor_data.AltRightSoftKey;
}
else
{
rightSK = data->editor_data.RightSoftKey;
}
}
displaySoftKeys(leftSK, rightSK);
}
/* Finished drawing screen */
}
break;
default:
return MFW_EVENT_PASSED;
break;
}
data->editor->update = ED_UPDATE_DEFAULT;
return MFW_EVENT_CONSUMED;
}
/*******************************************************************************
$Function: AUI_edit_KbdCb
$Description: Editor keyboard event handler
$Returns: None.
$Arguments: event - the keyboard event
keyboard
*******************************************************************************/
static int AUI_edit_KbdCb(T_MFW_EVENT event, T_MFW_KBD *keyboard)
{
T_MFW_HND win = mfw_parent (mfw_header());
T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data;
T_AUI_EDITOR_INFO *data = (T_AUI_EDITOR_INFO *)win_data->user;
T_ATB_TEXT *PredText = &data->predText;
ED_RES result;
USHORT character;
TRACE_FUNCTION("AUI_edit_KbdCb()");
/* Suppress unwanted long keypresses */
data->doNextLongPress = TRUE; /* next Key_long event is correct */
/* Restart the timer */
if (data->timer !=NULL)
{
tim_stop(data->timer);
tim_start(data->timer);
}
#ifdef EASY_TEXT_ENABLED
if (FFS_flashData.PredTextSelected==FALSE || !ATB_edit_Mode(data->editor, ED_MODE_PREDTEXT))
{
/* Predictive text is off */
#endif
switch (keyboard->code)
{
/* UP key */
case KCD_MNUUP:
/* For DSample, up and down move cursor up and down a line in all modes */
#ifdef LSCREEN
ATB_edit_MoveCursor(data->editor, ctrlUp, TRUE);
/* For other samples, up and down move left and right when not in read only mode */
#else
if (ATB_edit_Mode(data->editor, ED_MODE_READONLY)) /* Acts as up key in read-only mode */
{
ATB_edit_MoveCursor(data->editor, ctrlUp, TRUE);
}
else
{
ATB_edit_MoveCursor(data->editor, ctrlRight, TRUE);
}
#endif
data->editor->update = ED_UPDATE_TRIVIAL; /* This flag speeds up update */
win_show(data->win);
break;
/* DOWN key */
case KCD_MNUDOWN:
/* For DSample, up and down move cursor up and down a line in all modes */
#ifdef LSCREEN
ATB_edit_MoveCursor(data->editor, ctrlDown, TRUE);
/* For other samples, up and down move left and right when not in read only mode */
#else
if (ATB_edit_Mode(data->editor, ED_MODE_READONLY)) /* Act as down key in read-only mode */
{
ATB_edit_MoveCursor(data->editor, ctrlDown, TRUE);
}
else
{
ATB_edit_MoveCursor(data->editor, ctrlLeft, TRUE); /* Otherwise, move cursor left */
}
#endif
data->editor->update = ED_UPDATE_TRIVIAL; /* This flag speeds up update - no change to text */
win_show(data->win);
break;
/* For DSample, left and right keys move cursor left and right */
#ifdef LSCREEN
/* MENU LEFT */
case KCD_MNULEFT:
ATB_edit_MoveCursor(data->editor, ctrlLeft, TRUE); /* Move cursor left */
data->editor->update = ED_UPDATE_TRIVIAL; /* This flag speeds up update - no change to text */
win_show(data->win);
break;
/* MENU RIGHT */
case KCD_MNURIGHT:
ATB_edit_MoveCursor(data->editor, ctrlRight, TRUE); /* Move cursor right */
data->editor->update = ED_UPDATE_TRIVIAL; /* This flag speeds up update - no change to text */
win_show(data->win);
break;
#endif
/* LEFT SOFT KEY */
case KCD_LEFT:
if (data->editor_data.editor_attr.text.len < data->editor_data.min_enter)
{
/* Entered less than the required number of chars */
if (data->editor_data.AltLeftSoftKey!=TxtNull)
{
/* an alternate softkey is defined: execute it */
SEND_EVENT (win, E_ED_DEINIT, INFO_KCD_ALTERNATELEFT, NULL);
}
}
else if (data->editor_data.LeftSoftKey!=TxtNull)
{
/* Left Softkey is enabled (and entered sufficient number of chars): execute it
* get the orginal text back into the editor instead of the hide buffer ( only filled with '*') */
if (ATB_edit_Mode(data->editor, ED_MODE_HIDDEN))
{
ATB_edit_HiddenExit(data->editor);
}
SEND_EVENT (win, E_ED_DEINIT, INFO_KCD_LEFT, NULL);
}
break;
/* HANGUP key */
case KCD_HUP:
if (data->editor_data.RightSoftKey NEQ TxtNull) /* Right softkey is enabled: execute it */
{
SEND_EVENT (win, E_ED_DEINIT, INFO_KCD_HUP, NULL); /* Deinitialise the editor */
}
break;
/* SEND KEY */
case KCD_CALL:
//API - 23-01-03 - SPR 1600 - Send this event to generate an MO call in SMS editor
SEND_EVENT (win, E_ED_DEINIT, INFO_KCD_CALL, NULL);
break;
/* RIGHT SOFT KEY */
case KCD_RIGHT:
TRACE_EVENT("KCD_RIGHT");
if (ATB_edit_Mode(data->editor, ED_MODE_READONLY)) /* in read only mode, */
{
TRACE_EVENT("SENDING DEINIT EVENT");
SEND_EVENT (win, E_ED_DEINIT, INFO_KCD_RIGHT, NULL); /* just deinitialise editor */
}
else /* otherwise, RSK acts as clear key */
{
result = ATB_edit_DeleteLeft(data->editor);
/* If we delete from first character in the editor, exit editor */
if (result==ED_DONE)
{
SEND_EVENT (win, E_ED_DEINIT, INFO_KCD_RIGHT, NULL);
}
else
{
win_show(data->win);
}
}
break;
/* Switch text mode: uppercase, lowercase */
case KCD_HASH:
if (ATB_edit_Mode(data->editor, ED_MODE_ALPHA))
{
switch(ATB_edit_GetCase(data->editor))
{
case ED_CASE_LOWER:
ATB_edit_SetCase(data->editor, ED_CASE_CAPS);
break;
case ED_CASE_CAPS:
ATB_edit_SetCase(data->editor, ED_CASE_UPPER);
break;
case ED_CASE_UPPER:
ATB_edit_SetCase(data->editor, ED_CASE_LOWER);
/* If easy text selected, switch to it */
#ifdef EASY_TEXT_ENABLED
if (ATB_edit_Mode(data->editor, ED_MODE_PREDTEXT) && FFS_flashData.PredTextAvailable)
{
FFS_flashData.PredTextSelected = TRUE;
}
#endif
break;
case ED_CASE_NUM:
ATB_edit_SetCase(data->editor, ED_CASE_LOWER);
break;
}
}
else
{
/* SPR#1788 - SH - Forbid '#' entry in read only mode */
if (!ATB_edit_Mode(data->editor, ED_MODE_READONLY))
AUI_entry_EventKey(data->entry_data, event, keyboard);
}
win_show(data->win);
break;
case (KCD_STAR):
/* If we're in apha mode and not in read-only mode, display the symbol screen */
if (ATB_edit_Mode(data->editor, ED_MODE_ALPHA) && !ATB_edit_Mode(data->editor, ED_MODE_READONLY))
{
AUI_symbol_Start (data->win, E_ED_INSERT);
}
else
{
/* SPR#1788 - SH - Allow '*' to be entered in numeric mode */
if (!ATB_edit_Mode(data->editor, ED_MODE_READONLY))
AUI_entry_EventKey(data->entry_data, event, keyboard);
}
win_show(data->win);
break;
/* KEY ENTRY 0 - 9 */
case KCD_0:
case KCD_1:
case KCD_2:
case KCD_3:
case KCD_4:
case KCD_5:
case KCD_6:
case KCD_7:
case KCD_8:
case KCD_9:
if (!ATB_edit_Mode(data->editor, ED_MODE_READONLY))
{
AUI_entry_EventKey(data->entry_data, event, keyboard);
win_show(data->win);
}
break;
}
#ifdef EASY_TEXT_ENABLED
}
else
/* Short key press in EasyText */
{
if(FFS_flashData.PredTextAvailable == TRUE)
{
switch (keyboard->code)
{
case KCD_MNUUP:
if(PredText->len==0)
{
#ifdef LSCREEN
ATB_edit_MoveCursor(data->editor, ctrlUp, TRUE);
/* For other samples, up and down move left and right when not in read only mode */
#else
ATB_edit_MoveCursor(data->editor,ctrlRight, TRUE);
#endif
data->editor->update = ED_UPDATE_TRIVIAL; /* This flag speeds up update */
win_show(data->win);
}
break;
case KCD_MNUDOWN:
if(PredText->len==0)
{
#ifdef LSCREEN
ATB_edit_MoveCursor(data->editor, ctrlDown, TRUE);
/* For other samples, up and down move left and right when not in read only mode */
#else
ATB_edit_MoveCursor(data->editor,ctrlLeft, TRUE);
#endif
data->editor->update = ED_UPDATE_TRIVIAL; /* This flag speeds up update */
win_show(data->win);
}
break;
#ifdef LSCREEN
case KCD_MNURIGHT:
if(PredText->len==0)
{
ATB_edit_MoveCursor(data->editor, ctrlRight, TRUE);
data->editor->update = ED_UPDATE_TRIVIAL; /* This flag speeds up update */
win_show(data->win);
}
break;
case KCD_MNULEFT:
if(PredText->len==0)
{
ATB_edit_MoveCursor(data->editor,ctrlLeft, TRUE);
data->editor->update = ED_UPDATE_TRIVIAL; /* This flag speeds up update */
win_show(data->win);
}
break;
#endif
case KCD_LEFT:
if(PredText->len==0)
{
if (data->editor_data.LeftSoftKey NEQ TxtNull)
{
SEND_EVENT (win, E_ED_DEINIT, INFO_KCD_LEFT, NULL);
}
}
else
{
if ((data->editor_data.editor_attr.text.len + PredText->len) < data->editor_data.editor_attr.size)
{
if (ATB_string_GetChar(PredText,0)!=UNICODE_STAR)
{
/* Capitalise first letter of words and the letter 'I' */
if (ATB_edit_CapitaliseWord(data->editor) || (PredText->len==1 && ATB_string_GetChar(PredText, 0)==ATB_char_Unicode('i')))
{
ATB_string_SetChar(PredText, 0, ATB_edit_FindCapital(ATB_string_GetChar(PredText, 0)));/*SPR1508*/
}
character = ATB_edit_GetCursorChar(data->editor, -1);
if ( character != UNICODE_SPACE && character != UNICODE_EOLN)
{
ATB_string_MoveRight(PredText,0,1,ED_PREDTEXT_MAX);
ATB_string_SetChar(PredText, 0, UNICODE_SPACE);
}
ATB_edit_InsertString(data->editor,PredText);
}
}
ResetDictSearch();
AUI_edit_ClearPredText(data);
ATB_edit_SetCase(data->editor, ED_CASE_LOWER);
win_show(data->win);
}
break;
case KCD_HUP:
if (data->editor_data.RightSoftKey NEQ TxtNull) /* Right softkey is enabled: execute it */
{
SEND_EVENT (win, E_ED_DEINIT, INFO_KCD_HUP, NULL);
}
break;
case KCD_RIGHT:
if(PredText->len==0)
{
if(ATB_string_GetChar(&data->editor_data.editor_attr.text, 0)!=UNICODE_EOLN)
{
ATB_edit_Char(data->editor,ctrlBack,TRUE);
win_show(data->win);
}
else
{
/* leave editor if buffer already empty */
SEND_EVENT (win, E_ED_DEINIT, INFO_KCD_RIGHT, NULL);
}
}
else
{
if (PredText->len==1)
{
DictBackSpace((char *)data->predText.data);
AUI_edit_ClearPredText(data);
ATB_edit_SetCase(data->editor, ED_CASE_LOWER);
}
else
{
DictBackSpace((char *)data->predText.data);
data->predTextChar.pos--; /* char deleted, move cursor pos back */
AUI_edit_CalcPredText(data);
}
win_show(data->win);
}
break;
case KCD_2:
case KCD_3:
case KCD_4:
case KCD_5:
case KCD_6:
case KCD_7:
case KCD_8:
case KCD_9:
if (PredText->len==0)
{
AUI_edit_ClearPredText(data);
}
if (DictAlphaKeyPress(keyboard->code,(char *)PredText->data))
{
PredText->len = ATB_string_Length(PredText);
data->predTextChar.pos++; /* The keypress was used to find a word, advance cursor */
AUI_edit_CalcPredText(data);
}
win_show(data->win);
break;
case KCD_HASH:
switch(ATB_edit_GetCase(data->editor))
{
/* Press # once to switch into capitalise mode */
case ED_CASE_CAPS:
ATB_edit_SetCase(data->editor, ED_CASE_LOWER);
/* Switch out of easy text mode, if we're not entering a word */
if (PredText->len==0)
{
FFS_flashData.PredTextSelected = FALSE;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -