📄 mmimain.c
字号:
#ifdef NO_ASCIIZ
/*MC, SPR 940/2 01/08/02, don't need to check for language, tag should be enough*/
if (edit->attr->text[0] == 0x80/*MC 22/07/02*/)
alphachar = alphachar << 8;
#endif
{/*NM p025*/
edit->attr->alphaMode = TRUE;
}
edtChar(myHandle,alphachar);
/*
is this actually useless after insert a
character to call "ecRight" and then "ecLeft"
For the multitap we need only two steps:
"ecDel" plus insert the character
edtChar(myHandle,ecLeft);*/
{edit->attr->alphaMode = FALSE;}
/*p025 end*/
}
/*******************************************************************************
$Function: editEventTim
$Description: executes the timer event from the edit component
$Returns: none.
$Arguments:
*******************************************************************************/
/*MC SPR 1242 merged in b-sample version of this function */
static int editEventTim (MfwEvt e, MfwTim *t)
{
char *format = formatHandle; // SH - temporary format template
TRACE_FUNCTION("editEventTim");
if (!(editAlphaMode || editFormatMode))
return 1;
/*MC, SPR925 23/07/02, removed variable assignment for chinese */
// SH - modifications for format mode & hidden mode
if (editFormatMode) // SH - advance format pointer when
{
if (editHiddenMode)
{
editCharFindNext('*');
}
else
editCharFindNext(ecRight);
}
else if (editHiddenMode)
{
edtChar(myHandle,'*');
}
// end of modifications
else
edtChar(myHandle,ecRight);
editAlphaLevel = KEY_PAD_MAX-1;
editAlphaKey = KCD_MAX;
return 1;
}
/*******************************************************************************
$Function: editEventKey
$Description: executes the timer event form the edit component
$Returns: none.
$Arguments:
*******************************************************************************/
int editEventKey (MfwEvt e, MfwKbd *k)
{
/*MC SPR 1242 merged in b-sample version of this function */
MfwEdt *edit;
char *tb;
UBYTE ch = '.';
char *format = formatHandle; // SH - temporary format template
char formatchar; // SH - Current format character
char alphachar; // SH - Current multi-tap character
int safetycounter; // SH - Stops searching forever to find compatible character
BOOL validCharacter; // SH - flag to indicate whether character is accepted
BOOL unicode; /* SPR957 - SH - TRUE if string is unicode */
/*NM p026*/
if (!myHandle) // If we've reached the end of the format string, don't allow input
return 1;
/* Over the editor handle "e" we have now the access to
* the editor buffer "tb". We need it e.g "editCalcMode"
* to check the buffer */
edit = ((MfwHdr *) myHandle)->data;
tb = edit->attr->text;
/*p026 end*/
/* SPR957 - SH - TRUE if string is unicode */
if (tb[0]==0x80)
unicode = TRUE;
else
unicode = FALSE;
/* SH - formatted input mode (for WAP) */
if (editFormatMode)
{
if (k->code==KCD_HUP) // Escape from edit screen
return 0;
if (edit->cp >= (edit->attr->size)) // If at last character of editor, don't
{
return 1; // print character
}
formatchar = format[*formatIndex];
if (formatchar == NULL) // If we've reached the end of the format string, don't allow input
return 1;
if ((formatchar>'0' && formatchar<='9') || formatchar=='*') // Delimiter for format field
{
(*formatIndex)++;
*fieldIndex = 0;
formatchar = format[*formatIndex]; // Next character is the format for the field
}
/* Multi-tap input
*
* The user presses a different key, meaning the previous character must be entered */
if (editAlphaKey != KCD_MAX && editAlphaKey != k->code)
{
timStop(editTim);
alphachar = NULL;
switch(formatchar)
{
case 'X': // Uppercase alphabetic only
case 'A': // Uppercase alphabetic or punctuation
alphachar = editAlphaU[editAlphaKey][editAlphaLevel];
break;
case 'x': // Lowercase alphabetic only
case 'a': // Lowercase alphabetic or punctuation
alphachar = editAlpha[editAlphaKey][editAlphaLevel];
break;
case 'M':
case 'm':
if (upCase)
alphachar = editAlphaU[editAlphaKey][editAlphaLevel];
else
alphachar = editAlpha[editAlphaKey][editAlphaLevel];
break;
}
if (alphachar!=NULL)
{
if (editHiddenMode) // SH - in hidden mode...
{
tmpBuf[edit->cp] = alphachar; // store character in buffer
alphachar = '*'; // ...and show star
}
editCharFindNext(alphachar); // Add number to buffer & advance cursor
editAlphaLevel = KEY_PAD_MAX-1;
editAlphaKey = KCD_MAX;
if (edit->cp >= (edit->attr->size)) // If at last character of editor, don't
return 1; // allow another character
}
}
formatchar = format[*formatIndex];
if (k->code <= KCD_9) // Key pressed is 0 - 9.
{
/* Numeric */
if (formatchar == 'N') // A numeric digit is expected
{
if (editHiddenMode)
{
tmpBuf[edit->cp] = editControls[k->code];
editCharFindNext('*');
}
else
editCharFindNext(editControls[k->code]); // Add number to buffer & advance cursor
editAlphaLevel = KEY_PAD_MAX-1; // Reset multi-tap settings
editAlphaKey = KCD_MAX;
return 1;
}
/* Multi-tap alphanumeric */
alphachar = NULL;
if (!strchr("XxAaMm",formatchar)) // If not a valid format code, exit
return 1;
if (strchr("Xx",formatchar) && k->code<KCD_2) // 0 and 1 keys not valid in these modes
return 1;
editAlphaKey = k->code; // Store the key pressed
editAlphaLevel++; // Increment through list of symbols
if (editAlphaLevel > (KEY_PAD_MAX-1)) // List wraps round
editAlphaLevel = 0;
safetycounter = 0;
while (alphachar==NULL && safetycounter<KEY_PAD_MAX)
{
validCharacter = FALSE;
switch(formatchar)
{
case 'X':
alphachar = editAlphaU[editAlphaKey][editAlphaLevel]; // Uppercase...
validCharacter = (alphachar>='A' && alphachar<='Z'); // ...alphabetic only
break;
case 'x':
alphachar = editAlpha[editAlphaKey][editAlphaLevel]; // Lowercase
validCharacter = (alphachar>='a' && alphachar<='z'); // ...alphabetic only
break;
case 'A':
alphachar = editAlphaU[editAlphaKey][editAlphaLevel]; // Uppercase...
validCharacter = (alphachar<'0' || alphachar>'9'); // ..non-numeric
break;
case 'a':
alphachar = editAlpha[editAlphaKey][editAlphaLevel]; // Lowercase...
validCharacter = (alphachar<'0' || alphachar>'9'); // ..non-numeric
break;
case 'M':
case 'm':
if (upCase) // User-selected case...
alphachar = editAlphaU[editAlphaKey][editAlphaLevel];
else
alphachar = editAlpha[editAlphaKey][editAlphaLevel];
validCharacter = TRUE; // ...any character accepted
break;
}
if (!validCharacter) // If character isn't uppercase alphabetic,
{ // find the next one that is,
alphachar = NULL;
safetycounter++; // (but don't search forever)
editAlphaLevel++;
if (editAlphaLevel > (KEY_PAD_MAX-1))
editAlphaLevel = 0;
}
}
if (alphachar!=NULL) // If we've found a character, and string isn't max size
{
if (editHiddenMode)
{
tmpBuf[edit->cp] = alphachar;
}
edtChar(myHandle,alphachar);
edtChar(myHandle,ecLeft);
timStart(editTim);
}
else
editAlphaKey = KEY_MAX;
return 1;
}
if (k->code==KCD_HASH) // Hash key
{
if (strchr("AaMm",formatchar))
{
if (editHiddenMode)
{
tmpBuf[edit->cp] = ' ';
editCharFindNext('*');
}
else
editCharFindNext(' '); // Prints a space in this mode
}
return 1;
}
if (k->code==KCD_STAR) // Star key
{
if (strchr("AaMm",formatchar))
{
if (editHiddenMode)
{
tmpBuf[edit->cp] = '*';
}
editCharFindNext('*');
}
return 1;
}
return 1;
}
/************************/
/* Normal multi-tap mode */
/************************/
if (editAlphaMode)
{
if (editAlphaKey != KCD_MAX && editAlphaKey != k->code)
{
timStop(editTim);
/*MC SPR 925, 23/07/02, removed editshowheader for chinese*/
edtChar(myHandle,ecRight);
/*MC SPR 925, 23/07/02,removed shifting of alphachar, not needed here, merged from ealier code*/
editAlphaLevel = KEY_PAD_MAX-1;
editAlphaKey = KCD_MAX;
}
if (k->code <= KCD_HASH)
{
editAlphaLevel++;
if (editAlphaLevel > (KEY_PAD_MAX-1))
editAlphaLevel = 0;
if (editAlphaKey == KCD_MAX) // Inserting a new character
{
TRACE_EVENT("Inserting character.");
/*MC, SPR 925, 23/07/02 removed insert space and ecLeft if Chinese*/
/* NM p01306
the patch p027 to reduce calling the edtChar as less as possible
was not working for inserting characters.
This additional change should work now:
*/
if (unicode) /*SPR957 - SH - use new unicode flag */
{
moveRightUnicode((U16 *)&edit->attr->text[edit->cp*2],1);
}
else
{
moveRight(&edit->attr->text[edit->cp],strlen(&edit->attr->text[edit->cp]),1);
}
/* NM p01306 END */
}
}
editAlphaKey = k->code;
editShowHeader();
timStart(editTim);
return 1;
}
alphachar = NULL;
switch (k->code)
{
case KCD_HUP:
return 0;
case KCD_HASH:
/* KGT: If not in an alpha mode insert blanc.
But in numeric mode insert '#'. */
if (editAlphaMode)
{
alphachar = ' ';
editShowHeader();
}
else
{
if (editCalcMode)
{
if(!(strchr(tb, ch ))) /* set '.' only once ! */
alphachar = '.';
}
else
alphachar = '#';
}
/* end KGT */
/* SH - hidden mode */
if (editHiddenMode)
{
tmpBuf[edit->cp] = alphachar;
alphachar = '*';
}
/* end of hidden mode */
/* SPR957 - In unicode mode, character is shifted to second byte */
if (unicode)
alphachar = alphachar << 8;
edtChar(myHandle,alphachar);
return 1;
case KCD_STAR:
if (editCalcMode)
{
if(!(strchr(tb, ch ))) /* set '.' only once ! */
alphachar = '.'; /* SPR957 - SH*/
/*edtChar(myHandle,'.');*/
}
else
{
/*if (!editAlphaMode)
edtChar(myHandle,'*');
else */
if (editAlphaMode)
{
editShowHeader();
}
alphachar = '*';
/* SH - hidden mode */
if (editHiddenMode)
{
tmpBuf[edit->cp] = '*';
}
/* end of hidden mode */
/* SPR957 - SH - In unicode mode, character is shifted to second byte */
if (unicode)
alphachar = alphachar << 8;
edtChar(myHandle,alphachar);
}
return 2; // SH - 2 indicates that character WAS printed
case KCD_ABC:
editAlphaMode = (UBYTE) !editAlphaMode;
if (editAlphaMode)
{
editAlphaLevel = KEY_PAD_MAX-1;
editAlphaKey = KCD_MAX;
}
editShowHeader();
return 1;
default:
if (editAlphaMode){
timStop(editTim);
edtChar(myHandle,ecRight);
return 1;
}
break;
}
/* SH - hidden mode */
if (editHiddenMode)
{
tmpBuf[edit->cp] = editControls[k->code];
alphachar = '*'; /* SPR957 - SH*/
/* SPR957 - In unicode mode, character is shifted to second byte */
if (unicode)
alphachar = alphachar << 8;
edtChar(myHandle,alphachar);
}
/* end of hidden mode */
else
{ /*MC SPR 964, sets alphamode to FALSE when in digits mode, so that cursor moves right*/
edit->attr->alphaMode = editAlphaMode;
edtChar(myHandle,editControls[k->code]);
}
return 1;
}
/*******************************************************************************
$Function: editClear
$Description: SH - For formatted input, clears everything except fixed characters
$Returns:
$Arguments:
*******************************************************************************/
/*MC SPR 1242 merged in b-sample version of this function */
void editClear()
{
int editIndex = 0;
MfwEdt *edit = ((MfwHdr *) myHandle)->data;
char *tb = edit->attr->text;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -