⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mfw_edt.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 5 页
字号:
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
};

static  const unsigned char chinese_bmp[] =
{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
};
#endif

//static U16 curLineStart;                /* start of current line    */
//static U16 curLineChars;                /* chars in current line    */
//static U16 prevLineChars;               /* chars in previous line   */
//static U16 nextLineChars;               /* chars in next line       */
//static U16 firstLineChars;              /* chars in first line      */
//static U16 dispChars;                   /* chars displayed so far   */

//static int edtCurDown (MfwEdt *e, int tbl, int bottom);
//static int edtSplitLine (int px, int py, int ls, int ly, char *tp);
//static void edtShowLine (int px, int py, char *tp);
static int edtInsert (int c, char *b, int s);
static int edtCommand (U32 cmd, void *h);
//static void lineUpDown (MfwEdt *e, U16 start, U16 stop);
void moveLeft (char * str, int ofs);
static void moveRight (char *b, int s, int d);

static void edtUnicodeSplitLine (int px, int py, int ls, int ly, U16 *tp);
static void moveRightUnicode(U16 *unicodeStr, int nChars);
static void moveLeftUnicode(U16 *unicodeStr, int nChars);
static int  edtInsertUnicode (MfwEdt *e, int c, U16 *b, int s);

U16 strlenUnicode(U16* str);

static void edtOutTextLines (int px, int py, int ls, int ly, U16 *tpUnicode, unsigned char* tpAscii);
MfwRes updateWindow (MfwEdt *e, int  dy );

int isAWordChar( char chr);
void redrawcursor(U16 pre_x,U16 pre_y,U16 pre_w,U16 cur_x,U16 cur_y,U16 cur_w,int flag,UINT32 fgcolor);

//Define the chars that correspond to the end of a word.
#define STR_WORDBREAK " .?!"

/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_EDT            |
| STATE   : code                        ROUTINE : edtInit            |
+--------------------------------------------------------------------+

  PURPOSE : initialize edit handler

*/

MfwRes edtInit (void)
{
    mfwCommand[MfwTypEdt] = (MfwCb) edtCommand;

    return MfwResOk;
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_EDT            |
| STATE   : code                        ROUTINE : edtExit            |
+--------------------------------------------------------------------+

  PURPOSE : finalize edit handler

*/

MfwRes edtExit (void)
{
    mfwCommand[MfwTypEdt] = 0;

    return MfwResOk;
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_EDT            |
| STATE   : code                        ROUTINE : edtCreate          |
+--------------------------------------------------------------------+

  PURPOSE : create editor control

*/

MfwHnd edtCreate (MfwHnd w, MfwEdtAttr *a, MfwEvt e, MfwCb f)
{
    MfwHdr *hdr = (MfwHdr *) mfwAlloc(sizeof(MfwHdr));
    MfwEdt *edt = (MfwEdt *) mfwAlloc(sizeof(MfwEdt));

    if( !hdr || !edt )
        return 0;

    edt->mask = e;
    edt->flags = 0;
    edt->handler = f;
    edt->attr = a;
    edt->cp = 0;                        /* cursor position          */
    edt->curOffs = 0;

    hdr->data = edt;
    hdr->type = MfwTypEdt;

    //zgz, 2002.6.18  edtUpdate(edt);

    return mfwInsert(w,hdr);
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_EDT            |
| STATE   : code                        ROUTINE : edtDelete          |
+--------------------------------------------------------------------+

  PURPOSE : delete editor control

*/

MfwRes edtDelete (MfwHnd e)
{
    MfwRes res;

    if( !e )
        return MfwResIllHnd;

    edtHide(e);                         /* hide editor contents     */
    res = (mfwRemove(e)) ? MfwResOk : MfwResIllHnd;

    mfwFree(((MfwHdr *) e)->data,sizeof(MfwEdt));
    mfwFree(e,sizeof(MfwHdr));

    return res;
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_EDT            |
| STATE   : code                        ROUTINE : edtReset           |
+--------------------------------------------------------------------+

  PURPOSE : reset editor control

*/

MfwRes edtReset (MfwHnd w)
{
    MfwEdt *e;

    if( !w )
        return MfwResIllHnd;            /* editor does not exist    */

    e = ((MfwHdr *) w)->data;

    if( !e )
        return MfwResIllHnd;            /* editor does not exist    */

    e->cp = 0;                          /* cursor position          */
    e->curOffs = 0;

    return MfwResOk;
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_EDT            |
| STATE   : code                        ROUTINE : edtShow            |
+--------------------------------------------------------------------+

  PURPOSE : show editor

*/

MfwRes edtShow (MfwHnd e)
{
    MfwEdt *edt;
    U8 uMode;

    if( !e )
        return MfwResIllHnd;            /* editor does not exist    */
    uMode = dspl_Enable(0);//ganchh 2002/6/12

    edt = ((MfwHdr *) e)->data;         /* get control block        */

    edt->flags |= MfwEdtVisible;        /* editor is visible        */
    if( edt->handler )                   /* call event handler       */
        if( edt->mask & MfwEdtVisible )
            edt->handler(MfwEdtVisible,edt);
    display = 1;                        /* really show it           */
    updateWindow(edt, 0);               //zhangxp added 2003/3/27
    edtUpdate(edt,1);                     /* draw editor elements     */
    dspl_Enable(uMode);//ganchh 2002/6/12

    return MfwResOk;
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_EDT            |
| STATE   : code                        ROUTINE : edtHide            |
+--------------------------------------------------------------------+

  PURPOSE : hide editor

*/

MfwRes edtHide (MfwHnd e)
{
    MfwEdt *edt;

    if( !e )
        return MfwResIllHnd;            /* element does not exist   */

    edt = ((MfwHdr *) e)->data;         /* get edit control block   */
    edt->flags &= ~MfwEdtVisible;       /* editor is not visible    */
    if( edt->handler )                   /* call event handler       */
        if( edt->mask & MfwEdtVisible )
            edt->handler(MfwEdtVisible,edt);

    return MfwResOk;
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_EDT            |
| STATE   : code                        ROUTINE : edtUnhide          |
+--------------------------------------------------------------------+

  PURPOSE : unhide editor (without drawing)

*/

MfwRes edtUnhide (MfwHnd e)
{
    MfwEdt *edt;

    if( !e )
        return MfwResIllHnd;            /* element does not exist   */

    edt = ((MfwHdr *) e)->data;         /* get edit control block   */
    edt->flags |= MfwEdtVisible;        /* editor is visible        */
    if( edt->handler )                   /* call event handler       */
        if( edt->mask & MfwEdtVisible )
            edt->handler(MfwEdtVisible,edt);

    return MfwResOk;
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_EDT            |
| STATE   : code                        ROUTINE : edtClear           |
+--------------------------------------------------------------------+

  PURPOSE : clear editor

*/

MfwRes edtClear (MfwHnd e)
{
    MfwEdt *edt;

    if( !e )
        return MfwResIllHnd;            /* element does not exist   */

    edt = ((MfwHdr *) e)->data;         /* get edit control block   */
    if( edtReset(e) && edt->attr->text )
    {
        *(edt->attr->text) = 0;         /* clear buffer             */
        edtUpdate(edt,1);                 /* clear edit area          */
    }

    return MfwResOk;
}

/*
zgz, 2002.06.26 

Just only initialize the editor buffer.
*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -