📄 mfw_edt.c
字号:
bs=edit->attr->e_size;
dy = 0;
switch( c )
{
case ecEscape: //* quit editor
return MfwResDone;
case ecLeft: //* cursor left
if( edit->cp == 0 )
edit->cp = strlen(tbString); // zgz, change it
else
{
edit->cp = edit->cp-1;
}
break;
case ecRight: //* cursor right
edit->cp = edit->cp+1;
if( edit->cp > (strlen(tbString)) ) // zgz, change it
edit->cp = 0;
break;
case ecUp: //* cursor up
dy = -1;
break;
case ecDown: //* cursor down
dy = 1;
break;
case ecTop: //* cursor to start of text
edit->cp = 0;
edit->curOffs = 0;
break;
case ecBottom: //* cursor to end of text
edit->cp = strlen(tbString);
edit->curOffs = 0;
// dy = 999;
break;
case ecBack: //* backspace *
if( (edit->cp != 0) && (strlen(tbString)+1 > edit->cp) )
{
moveLeft(&tbString[edit->cp-1],1);
// edit->cp = edit->cp-1;
}
return(edtCharf(e,ecLeft, 0));
break;
case ecDel: //* delete *
if( strlen(tbString) > edit->cp )
{
moveLeft(&tbString[edit->cp],1);
}
break;
case ecEnter: //* cr/lf
c = UNICODE_LINEFEED;
edtInsert(c,tbString,bs);
return(edtCharf(e,ecRight, 0));
break;
default: //* normal char
if( edtInsert(c,tbString,bs) ) //zgz,2002.5.15 ,if the buffer is full, don't make the cursor right
return(edtCharf(e,ecRight, 0));
else if( edit->cp != (edit->attr->size - 3) )
return(edtCharf(e,ecRight, 0));
else
return MfwResOk;
break;
}
display = disp; //*if really show it by var disp
updateWindow( edit, dy);
edtUpdate(edit,1);
return MfwResOk;
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_EDT |
| STATE : code ROUTINE : edtCharUnicode |
+--------------------------------------------------------------------+
PURPOSE :
GW 06/09/01 - Created
*/
MfwRes edtCharUnicode (MfwHnd e, int c)
{
MfwEdt *edit;
U16 bs;
int dy;
// char *tb = edit->attr->text;
U16 *tbUnicode;
U16 pre_offs;
U8 * p; //zgz, 2002.7.3 point to the string using 8bits len
UINT32 oldColor;
fontHeight = dspl_GetFontHeight(); /* 2003/12/29 sunsj add */
TRACE_EVENT("edtCharUnicode()");
if( !e )
return MfwResIllHnd;
if( ((MfwHdr *)e)->type != MfwTypEdt )
return MfwResIllHnd; //* not an editor
edit = ((MfwHdr *) e)->data;
bs = edit->attr->size;
tbUnicode = (U16*) &(edit->attr->text[1]); // zgz,tbUnicode = (U16*) &edit->attr->text[2];
p = (U8*) &(edit->attr->text[1]);
curMode = edit->attr->mode;
dy = 0;
switch( c )
{
case ecEscape: //* quit editor
return MfwResDone;
case ecLeft: //* cursor left
preCP=edit->cp;
preZi[0]=0x80;
preZi[1]=edit->attr->text[1+2*preCP];
preZi[2]=edit->attr->text[2+2*preCP];
preZi[3]=0x00;
preZi[4]=0x00;
preZi[5]=0x00;
if( edit->cp == 0 )
edit->cp = (wstrlen(edit->attr->text)-1)/2; // zgz, change it
else
{
edit->cp = edit->cp-1;
}
pre_offs=edit->curOffs;
updateWindow( edit, dy);
if( edit->curOffs==pre_offs )
redrawcursor(preCX,preCY, preCSize,curCX,curCY,curCSize,1,edit->attr->fgColor);
else
{
display=1;
edtUpdateUnicode(edit,1);
}
break;
case ecRight: //* cursor right
//zgz, 2002.7.3 if (tbUnicode[edit->cp]!=UNICODE_EOLN)
preCP=edit->cp;
preZi[0]=0x80;
preZi[1]=edit->attr->text[1+2*preCP];
preZi[2]=edit->attr->text[2+2*preCP];
preZi[3]=0x00;
preZi[4]=0x00;
preZi[5]=0x00;
if( (p[2*edit->cp] != 0) || (p[2*edit->cp + 1] != 0) )
{
edit->cp = edit->cp +1;
}
else
{
edit->cp = 0;
}
pre_offs=edit->curOffs;
updateWindow( edit, dy);
if( edit->curOffs==pre_offs )
redrawcursor(preCX,preCY, preCSize,curCX,curCY,curCSize,1,edit->attr->fgColor);
else
{
display=1;
edtUpdateUnicode(edit,1);
}
break;
case ecUp: //* cursor up
dy = -1;
pre_offs=edit->curOffs;
preCP=edit->cp;
preZi[0]=0x80;
preZi[1]=edit->attr->text[1+2*preCP];
preZi[2]=edit->attr->text[2+2*preCP];
preZi[3]=0x00;
preZi[4]=0x00;
preZi[5]=0x00;
updateWindow( edit, dy);
if( edit->curOffs==pre_offs )
redrawcursor(preCX,preCY, preCSize,curCX,curCY,curCSize,1,edit->attr->fgColor);
else
{
display=1;
edtUpdateUnicode(edit,1);
}
break;
case ecDown: //* cursor down
dy = 1;
pre_offs=edit->curOffs;
preCP=edit->cp;
preZi[0]=0x80;
preZi[1]=edit->attr->text[1+2*preCP];
preZi[2]=edit->attr->text[2+2*preCP];
preZi[3]=0x00;
preZi[4]=0x00;
preZi[5]=0x00;
updateWindow( edit, dy);
if( edit->curOffs==pre_offs )
redrawcursor(preCX,preCY, preCSize,curCX,curCY,curCSize,1,edit->attr->fgColor);
else
{
display=1;
edtUpdateUnicode(edit,1);
}
break;
case ecTop: //* cursor to start of text
edit->cp = 0;
pre_offs=edit->curOffs;
edit->curOffs = 0;
dy = 0;
preCP=edit->cp;
preZi[0]=0x80;
preZi[1]=edit->attr->text[1+2*preCP];
preZi[2]=edit->attr->text[2+2*preCP];
preZi[3]=0x00;
preZi[4]=0x00;
preZi[5]=0x00;
updateWindow( edit, dy);
if( edit->curOffs==pre_offs )
redrawcursor(preCX,preCY, preCSize,curCX,curCY,curCSize,1,edit->attr->fgColor);
else
{
display=1;
edtUpdateUnicode(edit,1);
}
break;
case ecBottom: //* cursor to end of text
//zgz, 2002.7.3 while (tbUnicode[edit->cp]!=UNICODE_EOLN)
while( (p[2*edit->cp] != 0) || (p[2*edit->cp + 1] != 0) )
{
edit->cp = edit->cp +1;
}
pre_offs=edit->curOffs;
edit->curOffs = 0;
dy = 0;
preCP=edit->cp;
preZi[0]=0x80;
preZi[1]=edit->attr->text[1+2*preCP];
preZi[2]=edit->attr->text[2+2*preCP];
preZi[3]=0x00;
preZi[4]=0x00;
preZi[5]=0x00;
updateWindow( edit, dy);
if( edit->curOffs==pre_offs )
redrawcursor(preCX,preCY, preCSize,curCX,curCY,curCSize,1,edit->attr->fgColor);
else
{
display=1;
edtUpdateUnicode(edit,1);
}
break;
case ecBack: //* backspace
if( edit->cp != 0 )
{
moveLeftUnicode(tbUnicode+edit->cp-1,1);
if( strlenUnicode(tbUnicode) == 1 ) //zgz, 2002.7.31 add the if case for del the first byte 0x80 in buffer
edit->attr->text[0] = 0;
}
pre_offs=edit->curOffs;
if( edit->cp == 0 )
{
edit->cp = (wstrlen(edit->attr->text)-1)/2; // zgz, change it
}
else
{
edit->cp = edit->cp-1;
}
updateWindow( edit, dy);
display=1;
if( edit->attr->text[0] ==0 )
{
oldColor=dspl_GetBkgColor();
if( edit->attr->fgColor<1 )
edit->attr->fgColor=0xffffff;
dspl_SetBkgColor(edit->attr->fgColor);
/* 2003/11/29 sunsj modify for different font height */
//dspl_Clear(edit->attr->win.px,edit->attr->win.py,edit->attr->win.px+32,edit->attr->win.py+32);
dspl_Clear(edit->attr->win.px,edit->attr->win.py,edit->attr->win.px+32,edit->attr->win.py+fontHeight+1);
inputIndicate_update(edit);
/* 2003/12/29 sunsj modify for different font height */
dspl_DrawLine(edit->attr->win.px,edit->attr->win.py+fontHeight,edit->attr->win.px+8,edit->attr->win.py+fontHeight);
dspl_SetBkgColor(oldColor);
}
else
{
if( pre_offs==edit->curOffs )
edtUpdateUnicode(edit,0);
else
edtUpdateUnicode(edit,1);
}
break;
case ecDel: //* delete
moveLeftUnicode(tbUnicode+edit->cp,1);
//return edtCharUnicode(e,ecLeft);
break;
case ecEnter: //* cr/l
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -