亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? textedit.c

?? 這是ARM嵌入式系統的實驗教程中的MINIGUI的實驗源代碼!
?? C
?? 第 1 頁 / 共 5 頁
字號:
/*
** $Id: textedit.c,v 1.107 2004/10/18 00:49:28 snig Exp $
**
** textedit.c: text edit control
**
** Copyright (C) 2004 Feynman Software.
** 
** Current maintainer: Zhong Shuyi (zhongsy@minigui.org).
**
** Create date: 2004/03/01
**
** Note:
**    the textedit control is written from scratch
**    to replace the buggy medit control.
**
**    The textedit control inherits scrollview.
**
*/

/*
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

/*
 * TODO
 * tab
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#include "common.h"
#include "minigui.h"
#include "gdi.h"
#include "window.h"
#include "control.h"
#include "cliprect.h"
#include "internals.h"
#include "ctrlclass.h"

#ifdef _CTRL_TEXTEDIT

#include "ctrlmisc.h"
#include "scrolled.h"
#include "scrollview.h"
#include "text.h"
#include "textedit.h"


#ifdef _UNDO_SUPPORT
static void teUndoBackup (TextDoc *txtoc);
#endif

#undef _TEXTEDIT_DEBUG
//#define _TEXTEDIT_DEBUG

#ifdef _TEXTEDIT_DEBUG
static void dump_text (TextDoc *txtdoc, BOOL bSel)
{
    list_t *me;
    TextNode *node;
    SIZE txtsize;
    HWND hWnd = (HWND)txtdoc->fn_data;
    HDC hdc;

    printf ("\n\n\n\n");
    printf ("------------------------------------------------------\n");
    list_for_each (me, &txtdoc->queue) {
        node  = list_entry (me, TextNode, list);
        /*
        if (scrollview_is_item_selected ((HSVITEM)node->addData)) {
            printf ("sv select---<< %s\n", node->content.string);
        }
        */
#ifdef _SELECT_SUPPORT
        if (bSel && textnode_is_selected(txtdoc, node)) {
            printf ("%d:\n", node->content.txtlen);
            printf ("%s----->", node->content.string);
        }
#endif
    }
    hdc = GetClientDC (hWnd);
    GetTabbedTextExtent(hdc, "\t", 1, &txtsize);
    ReleaseDC (hdc);
    printf ("tab size = %d\n", txtsize.cx);
}

static void print_selected (TextDoc *txtdoc)
{
    dump_text (txtdoc, TRUE);
}

#endif


/* ------------------------------ text document/buffer ------------------------ */

/* 
 * set_current_node : Sets a node as the current insertion/selection node,
 *                    must be called when the current node is/will be changed.
 * Params           : newnode - the new node with insertion/selection point
 *                    bSel    - insertion or selection
 *                    bChange - Whether to call change function
 * Return           : TRUE on changed, FALSE otherwise.
 */
static BOOL
set_current_node (TextDoc *txtdoc, TextNode *newnode, BOOL bSel, BOOL bChange)
{
    TextMark *mark;
    TextNode *oldnode;

    mark = GETMARK(bSel);
    oldnode = mark->curNode;

    if (newnode == oldnode)
        return FALSE;

    mark->curNode = newnode;
    mark->pos_lnOff = 0;

    /* called when the current insertion node is changed */
    if (bChange && txtdoc->change_fn)
        txtdoc->change_fn (txtdoc, bSel);

    return TRUE;
}

/* 
 * textnode_create: creat a new text node and initialize it with text
 */
static TextNode* textnode_create (TextDoc *txtdoc, const char *line, int len)
{
    TextNode *newnode;

    if ( !(newnode = textnode_alloc ()) )
        return NULL;

    /* create a new blank line */
    if (!line || len < 0) len = 0;

    if ( !(testr_alloc (&newnode->content, len, txtdoc->nBlockSize)) ) {
        textnode_free (newnode);
        return NULL;
    }

    testr_setstr (&newnode->content, line, len);
    newnode->addData = 0;

    return newnode;
}

/* 
 * textnode_destroy: destroy a text node
 */
static void textnode_destroy (TextNode *node)
{
    if (node) {
        list_del (&node->list);
        testr_free (&node->content);
        textnode_free (node);
    }
}

/* 
 * textdoc_free : free TextDoc nodes
 * Description  : only changes the status fields of a TextDoc object, does not 
 *                affect the properties.
 */
static void textdoc_free (TextDoc *txtdoc)
{
    TextNode *node;
    if (!txtdoc) return;

    while (!list_empty(&txtdoc->queue)) {
        node = list_entry (txtdoc->queue.next, TextNode, list);
        textnode_destroy (node);
    }
    txtdoc->insert.pos_lnOff = 0;
    txtdoc->insert.curNode = NULL;
#ifdef _SELECT_SUPPORT
    txtdoc->selection.curNode = 0;
    txtdoc->selection.pos_lnOff = 0;
#endif
}

/*
 * txtAddNode : add a textnode after a specified node
 * params     : node - the previous text node, if NULL, the new node will be
 *                     inserted at the tail.
 */
static TextNode*
txtAddNode (TextDoc *txtdoc, const char*pLine, int len, TextNode *node)
{
    TextNode *newnode;

    if ( !(newnode = textnode_create (txtdoc, pLine, len)) )
        return NULL;

    if (node)
        list_add (&newnode->list, &node->list);
    else
        list_add_tail (&newnode->list, &txtdoc->queue);

    if (txtdoc->init_fn) txtdoc->init_fn(txtdoc, newnode, node);

    return newnode;
}

/*
 * txtDelNode : deletes a text node
 */
static void txtDelNode (TextDoc *txtdoc, TextNode *node)
{
    /* deletes scrollview item */
    if (txtdoc->del_fn)
        txtdoc->del_fn(txtdoc, node);

    textnode_destroy (node);
}

/*
 * textdoc_get_textlen : gets the total length of the text document
 */
static int textdoc_get_textlen (TextDoc *txtdoc)
{
    list_t *me;
    TextNode *node;
    int total_len = 0;

    list_for_each (me, &txtdoc->queue) {
        node = list_entry (me, TextNode, list);
        total_len += node->content.txtlen;
    }
    return total_len;
}

/*
 * textdoc_gettext : get text string from text document
 */
static int textdoc_gettext (TextDoc *txtdoc, int len, unsigned char *buffer)
{
    list_t *me;
    TextNode *node;
    unsigned char *pch = buffer;
    int total_len = 0, copy_len = 0;

    if (!buffer || len <= 0)
        return 0;

    list_for_each (me, &txtdoc->queue) {
        node = list_entry (me, TextNode, list);
        copy_len = MIN(node->content.txtlen, len - total_len);
        if (copy_len <= 0) break;
        memcpy (pch, node->content.string, copy_len);
        pch += copy_len;
        total_len += copy_len;
    }
    *pch = '\0';
    return total_len;
}

/* 
 * textdoc_settext : setting TextDoc object using a new text content and 
 *                   free the old one
 * Params          : content - new text content, if NULL, the content of the 
 *                             TextDoc object will not be changed; if content
 *                             is a null string, txtdoc content will be cleared.
 * TODO            : for not null-terminated text
 */
static int textdoc_settext (TextDoc *txtdoc, const char*content)
{
    const char *pLine, *ptmp;

    if (!txtdoc || !content) return -1;

    /* free the old text content */
    textdoc_free (txtdoc);

    ptmp = pLine = content;
    if (content) {
        while (*ptmp != '\0') {
            if (*ptmp == txtdoc->lnsep) {
                /* adds a new line, including the line seperator */
                txtAddNode (txtdoc, pLine, ptmp-pLine+1, NULL);
                pLine = ptmp + 1;
            }
            ptmp ++;
        }
    }
    /* adds a new blank line or the last line without a line seperator */
    txtAddNode (txtdoc, pLine, ptmp-pLine, NULL);

    set_current_node (txtdoc, FIRSTNODE(txtdoc), FALSE, TRUE);

    return 0;
}

static void
insert_string (TextDoc *txtdoc, TextNode *curnode, int insert_pos, 
               const char *newtext, int len)
{
    StrBuffer *strbuff = &curnode->content;
    unsigned char *pLn, *pIns;

    if (len > 0) {
        pLn = testr_realloc (strbuff, strbuff->txtlen + len);
        if (!pLn) return;
        pIns = pLn + insert_pos;
        memmove (pIns + len, pIns, strbuff->txtlen+1 - insert_pos);
        memcpy (pIns, newtext, len);
    }
    else {
        pIns = strbuff->string + insert_pos;
        memmove (pIns + len, pIns, strbuff->txtlen+1 - insert_pos);
        pLn = testr_realloc (strbuff, strbuff->txtlen + len);
    }

    strbuff->txtlen += len;
}

#ifdef _SELECT_SUPPORT
static TextMark* get_start_mark (PTEDATA ptedata)
{
    TextDoc *txtdoc = &ptedata->txtdoc;

    if (ptedata->curItemY < ptedata->selItemY ||
             (ptedata->curItemY == ptedata->selItemY && 
              txtdoc->insert.pos_lnOff < txtdoc->selection.pos_lnOff) )
        return &txtdoc->insert;
    else
        return &txtdoc->selection;
}

/* Gets the start and end selection points in a text node */
static void
get_selection_points (PTEDATA ptedata, TextNode *node, int *pos_start, int *pos_end)
{
    TextDoc *txtdoc = &ptedata->txtdoc;
    TextMark *markStart = get_start_mark (ptedata);
    TextMark *markEnd = (markStart == &txtdoc->insert) ? 
                          &txtdoc->selection : &txtdoc->insert;

    if (node ==  txtdoc->insert.curNode || node == txtdoc->selection.curNode) {
        if (txtdoc->insert.curNode == txtdoc->selection.curNode) {
            *pos_start = markStart->pos_lnOff;
            *pos_end = markEnd->pos_lnOff;
        }
        else if (node == markStart->curNode) {
            *pos_start = markStart->pos_lnOff;
            *pos_end = node->content.txtlen;
        }
        else {
            *pos_start = 0;
            *pos_end = markEnd->pos_lnOff;
        }
    }
    else {
        *pos_start = 0;
        *pos_end = node->content.txtlen;
    }
}

/*
 * delete_selection : deletes the selected texts
 */
static int delete_selection (TextDoc *txtdoc)
{
    int pos_start, pos_end;
    int pos_start2, pos_end2;
    TextNode *node, *startnode, *endnode;
    TextMark *markStart, *markEnd;
    HWND hWnd = (HWND)txtdoc->fn_data;
    PTEDATA ptedata = (PTEDATA)GetWindowAdditionalData2 (hWnd);

    markStart = get_start_mark (ptedata);
    markEnd = (markStart == &txtdoc->insert) ? 
                          &txtdoc->selection : &txtdoc->insert;

    startnode = markStart->curNode;
    endnode = markEnd->curNode;

    get_selection_points (ptedata, endnode, &pos_start, &pos_end);
    get_selection_points (ptedata, startnode, &pos_start2, &pos_end2);

    txtdoc->selection.curNode = NULL;

    scrollview_freeze (hWnd, &ptedata->svdata, TRUE);

    insert_string (txtdoc, endnode, pos_end, NULL, pos_start-pos_end);

    if (startnode != endnode) {

        while ( (node = TXTNODE_NEXT(startnode)) != endnode ) {
            txtDelNode (txtdoc, node);
        }

        if (pos_start2 == 0) {
            txtDelNode (txtdoc, startnode);
            startnode = NULL;
            txtdoc->insert.curNode = endnode;
            txtdoc->insert.pos_lnOff = 0;
            txtdoc->change_fn (txtdoc, FALSE);
        }
        else {
            char del[1] = {127};
            textdoc_insert_string_ex (txtdoc, startnode, pos_end2-1, NULL, 
                                      pos_start2-pos_end2+1);
            textdoc_insert_string_ex_2 (txtdoc, startnode, pos_start2, del, 1);
            txtdoc->insert.curNode = startnode;
            endnode = NULL;
        }
    }

    if (txtdoc->change_cont) {
        txtdoc->change_cont (txtdoc, endnode);
        txtdoc->change_cont (txtdoc, startnode);
    }

    txtdoc->selection.curNode = NULL;
    scrollview_unselect_all (&ptedata->svdata);
    scrollview_freeze (hWnd, &ptedata->svdata, FALSE);

    return pos_start2;
}
#endif

static TextNode*
insert_ln_sep (TextDoc *txtdoc, TextNode *curnode, int insert_pos, 
                           BOOL bChRn)
{
    StrBuffer *strbuff = &curnode->content;
    TextNode *newnode;
    unsigned char *pIns;
    int len = bChRn ? 2 : 1;

    pIns = strbuff->string + insert_pos;

    newnode = txtAddNode ( txtdoc, pIns, strbuff->txtlen - 
                          (pIns-strbuff->string), curnode );

    strbuff->txtlen = insert_pos + len; /* add a line sep */
    if (*pIns == '\0') {
        testr_realloc (strbuff, strbuff->txtlen);
        pIns = strbuff->string + insert_pos ;
    }

    if (bChRn)
        strncpy(pIns, CH_RN, len);
    else

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美在线免费视屏| 狠狠色丁香久久婷婷综合丁香| 国产在线精品一区二区| 日韩视频在线一区二区| 蜜臀a∨国产成人精品| 日韩免费看的电影| 国产一区二区三区不卡在线观看| 精品国免费一区二区三区| 国产精品亚洲第一| 国产精品美女久久福利网站| 91一区二区三区在线播放| 亚洲精品免费电影| 欧美剧情片在线观看| 久久99国产精品免费网站| 国产欧美日韩精品一区| 91免费在线视频观看| 亚洲h动漫在线| 欧美一级一区二区| 岛国av在线一区| 亚洲一二三区在线观看| 精品国产一区二区三区av性色| 国产传媒日韩欧美成人| 亚洲一区二区三区美女| 欧美mv日韩mv亚洲| 一本一道波多野结衣一区二区| 五月天婷婷综合| 国产午夜精品一区二区三区视频| 色一区在线观看| 久久99久久久欧美国产| 亚洲三级久久久| 91精品黄色片免费大全| 波多野结衣中文一区| 首页综合国产亚洲丝袜| 中日韩免费视频中文字幕| 在线不卡欧美精品一区二区三区| 国产精品一区二区三区网站| 亚洲国产人成综合网站| 久久久亚洲精品一区二区三区| 日本久久精品电影| 国产精品亚洲视频| 午夜不卡av在线| 久久超碰97中文字幕| 伊人色综合久久天天| 久久蜜臀精品av| 欧美精品123区| 色婷婷av一区| 国产成人8x视频一区二区| 婷婷丁香激情综合| 日韩伦理av电影| 日本一区二区三区免费乱视频| 欧美老年两性高潮| 91国偷自产一区二区三区成为亚洲经典 | 26uuu另类欧美| 欧美日韩视频第一区| av中文字幕在线不卡| 国产精一区二区三区| 日本午夜一本久久久综合| 有坂深雪av一区二区精品| 国产欧美一区二区精品性色超碰| 91精品国产综合久久精品app| 色综合久久99| 色综合久久中文字幕| 成人涩涩免费视频| 国产福利视频一区二区三区| 蜜桃传媒麻豆第一区在线观看| 亚洲va韩国va欧美va| 亚洲国产欧美在线| 亚洲一区二区三区四区的| 亚洲人吸女人奶水| 国产精品初高中害羞小美女文| 久久久久久久综合日本| 欧美www视频| 日韩欧美中文字幕精品| 欧美一级高清片| 日韩一区二区三区视频| 欧美一三区三区四区免费在线看| 欧美日韩国产综合久久| 欧美在线啊v一区| 欧美三级资源在线| 欧美日本国产视频| 91精品欧美一区二区三区综合在| 欧美老肥妇做.爰bbww| 在线综合视频播放| 日韩亚洲电影在线| 精品久久久网站| 亚洲欧洲制服丝袜| 国产精品成人免费在线| 最新国产成人在线观看| 亚洲激情av在线| 亚洲chinese男男1069| 午夜精品在线看| 久久aⅴ国产欧美74aaa| 国产成人啪免费观看软件| 成人av中文字幕| 色诱视频网站一区| 欧美三级三级三级| 欧美一区二区三区视频在线| 日韩欧美成人激情| 国产精品丝袜久久久久久app| 自拍偷拍国产精品| 午夜私人影院久久久久| 裸体健美xxxx欧美裸体表演| 国产一区不卡在线| 成人黄色免费短视频| 欧美性欧美巨大黑白大战| 正在播放亚洲一区| 国产日韩成人精品| 亚洲最大成人网4388xx| 日本色综合中文字幕| 国产一区二区电影| 91福利视频在线| 91精品国产麻豆| 欧美国产精品一区二区三区| 一区二区三区在线高清| 蜜臀久久久久久久| 成人av网站免费观看| 欧美日韩国产中文| 亚洲国产精品精华液ab| 亚洲电影你懂得| 丁香激情综合国产| 欧美美女黄视频| 中文子幕无线码一区tr| 日韩高清不卡在线| 成人免费视频免费观看| 91麻豆精品国产91久久久久久久久 | 国产毛片精品国产一区二区三区| 成人h精品动漫一区二区三区| 欧美日韩国产大片| 中文字幕日韩精品一区| 麻豆精品一区二区av白丝在线| www.久久精品| 精品国产sm最大网站免费看| 亚洲精品乱码久久久久久久久| 三级一区在线视频先锋 | 国产欧美一区二区精品秋霞影院| 一区二区三区在线视频播放| 国产一区二区三区高清播放| 777xxx欧美| 玉米视频成人免费看| 波多野结衣在线aⅴ中文字幕不卡| 欧美一级免费大片| 亚洲一区免费在线观看| 成人aaaa免费全部观看| 久久综合国产精品| 免费成人av在线播放| 欧美四级电影网| 亚洲免费观看在线视频| 成年人国产精品| 国产嫩草影院久久久久| 久久草av在线| 日韩一区二区三区视频在线观看| 亚洲午夜av在线| 91色九色蝌蚪| 亚洲日本乱码在线观看| 成人污视频在线观看| 久久久久久免费毛片精品| 美女网站色91| 日韩欧美亚洲另类制服综合在线| 亚洲h动漫在线| 欧美日韩一区精品| 亚洲成人久久影院| 欧美日韩亚洲丝袜制服| 一区二区三区在线影院| 91黄色在线观看| 亚洲综合精品自拍| 欧美日韩一区中文字幕| 婷婷一区二区三区| 欧美美女直播网站| 日韩激情在线观看| 欧美一区二区视频在线观看2020 | 中文字幕巨乱亚洲| 成人免费三级在线| 久久精品免费观看| 日韩视频在线你懂得| 精品在线播放午夜| 久久你懂得1024| 成人免费高清视频| 亚洲日本va午夜在线电影| 色噜噜偷拍精品综合在线| 亚洲一区中文日韩| 欧美一区二区在线视频| 精品中文av资源站在线观看| 亚洲精品一区二区三区福利| 国产精品69毛片高清亚洲| 欧美国产国产综合| 91麻豆精东视频| 香蕉久久夜色精品国产使用方法 | 精品国产欧美一区二区| 国产精品456| 成人免费在线观看入口| 色综合天天综合网天天看片| 亚洲一二三四在线| 日韩亚洲电影在线| 成人爱爱电影网址| 天天爽夜夜爽夜夜爽精品视频| 日韩欧美国产一区二区三区| 国产成人亚洲综合色影视| 亚洲欧美激情插| 欧美一区二区三区成人| 福利视频网站一区二区三区|