support to write web page in Chinese, 支持中文编写网页
authoryu.dongliang <18588496441@163.com>
Mon, 21 Oct 2024 08:04:23 +0000 (16:04 +0800)
committeryu.dongliang <18588496441@163.com>
Mon, 21 Oct 2024 08:06:10 +0000 (16:06 +0800)
examples/中文表单.html [new file with mode: 0644]
html/abc_html.c
html/abc_obj.c
html/abc_obj.h
ui/abc_layout.c
ui/abc_render_img.c
ui/main.c

diff --git a/examples/中文表单.html b/examples/中文表单.html
new file mode 100644 (file)
index 0000000..4e1ed04
--- /dev/null
@@ -0,0 +1,19 @@
+<网页>
+<标题>test</标题>
+<主体>
+
+<表单 action="/" method="post">
+
+<标签 for="name">用户:</标签>
+<输入 type="text" id="name" name="name">
+<换行>
+
+<标签 for="password">密码:</标签>
+<输入 type="password" id="password" name="password">
+<换行>
+
+<输入 type="submit" value="提交">
+</表单>
+
+</主体>
+</网页>
index d4c4e532257a4bed75976d355bb2f1321a51c48e..346de8713231b2421b39aa4ed805f0b67c70677f 100644 (file)
@@ -1,14 +1,14 @@
 #include"abc_html.h"
 
 typedef struct {
-       char* name;
-       char* value;
-       int   type;
-       int   flags;
+       char** names;
+       char*  value;
+       int    type;
+       int    flags;
 } html_attr_t;
 
 typedef struct {
-       char*         name;
+       char**        names;
        int           type;
 
        int           n_attrs;
@@ -19,116 +19,157 @@ typedef struct {
 
 #define abc_number_of(__array)  (sizeof(__array) / sizeof(__array[0]))
 
+static char* src_keys[]        = {"src",        "源",       NULL};
+static char* href_keys[]       = {"href",       "地址",     NULL};
+
+static char* width_keys[]      = {"width",      "宽度",     NULL};
+static char* height_keys[]     = {"height",     "高度",     NULL};
+
+static char* font_keys[]       = {"font",       "字体",     NULL};
+static char* font_size_keys[]  = {"font-size",  "字号",     NULL};
+static char* font_color_keys[] = {"font-color", "字体颜色", NULL};
+
+static char* type_keys[]       = {"type",       "类型",     NULL};
+static char* name_keys[]       = {"name",       "名字",     NULL};
+static char* for_keys[]        = {"for",        "关于",     NULL};
+static char* id_keys[]         = {"id",         "编号",     NULL};
+
+static char* value_keys[]      = {"value",      "值",       NULL};
+static char* action_keys[]     = {"action",     "动作",     NULL};
+static char* method_keys[]     = {"method",     "方法",     NULL};
+
+static char* html_keys[]       = {"html",       "网页",     NULL};
+static char* head_keys[]       = {"head",       "头部",     NULL};
+static char* body_keys[]       = {"body",       "主体",     NULL};
+static char* form_keys[]       = {"form",       "表单",     NULL};
+static char* div_keys[]        = {"div",        "分区",     NULL};
+static char* img_keys[]        = {"img",        "图片",     NULL};
+
+static char* title_keys[]      = {"title",      "标题",     NULL};
+static char* input_keys[]      = {"input",      "输入",     NULL};
+static char* label_keys[]      = {"label",      "标签",     NULL};
+
+static char* br_keys[]         = {"br",         "换行",     NULL};
+static char* h1_keys[]         = {"h1",         "标题1",    NULL};
+static char* h2_keys[]         = {"h2",         "标题2",    NULL};
+static char* h3_keys[]         = {"h3",         "标题3",    NULL};
+static char* h4_keys[]         = {"h4",         "标题4",    NULL};
+static char* h5_keys[]         = {"h5",         "标题5",    NULL};
+static char* h6_keys[]         = {"h6",         "标题6",    NULL};
+static char* p_keys[]          = {"p",          "段落",     NULL};
+static char* a_keys[]          = {"a",          "超链接",   NULL};
+
+
 static html_attr_t  h1_attrs[] =
 {
-       {"font",        "SimHei",     ABC_HTML_ATTR_FONT,      0},
-       {"font-size",   "40",         ABC_HTML_ATTR_FONT_SIZE, 0},
+       {font_keys,        "SimHei",     ABC_HTML_ATTR_FONT,      0},
+       {font_size_keys,   "40",         ABC_HTML_ATTR_FONT_SIZE, 0},
 };
 
 static html_attr_t  h2_attrs[] =
 {
-       {"font",        "SimHei",     ABC_HTML_ATTR_FONT,      0},
-       {"font-size",   "32",         ABC_HTML_ATTR_FONT_SIZE, 0},
+       {font_keys,        "SimHei",     ABC_HTML_ATTR_FONT,      0},
+       {font_size_keys,   "32",         ABC_HTML_ATTR_FONT_SIZE, 0},
 };
 
 static html_attr_t  h3_attrs[] =
 {
-       {"font",        "SimHei",     ABC_HTML_ATTR_FONT,      0},
-       {"font-size",   "28",         ABC_HTML_ATTR_FONT_SIZE, 0},
+       {font_keys,        "SimHei",     ABC_HTML_ATTR_FONT,      0},
+       {font_size_keys,   "28",         ABC_HTML_ATTR_FONT_SIZE, 0},
 };
 
 static html_attr_t  h4_attrs[] =
 {
-       {"font",        "SimHei",     ABC_HTML_ATTR_FONT,      0},
-       {"font-size",   "24",         ABC_HTML_ATTR_FONT_SIZE, 0},
+       {font_keys,        "SimHei",     ABC_HTML_ATTR_FONT,      0},
+       {font_size_keys,   "24",         ABC_HTML_ATTR_FONT_SIZE, 0},
 };
 
 static html_attr_t  h5_attrs[] =
 {
-       {"font",        "SimHei",     ABC_HTML_ATTR_FONT,      0},
-       {"font-size",   "20",         ABC_HTML_ATTR_FONT_SIZE, 0},
+       {font_keys,        "SimHei",     ABC_HTML_ATTR_FONT,      0},
+       {font_size_keys,   "20",         ABC_HTML_ATTR_FONT_SIZE, 0},
 };
 
 static html_attr_t  h6_attrs[] =
 {
-       {"font",        "SimHei",     ABC_HTML_ATTR_FONT,      0},
-       {"font-size",   "16",         ABC_HTML_ATTR_FONT_SIZE, 0},
+       {font_keys,        "SimHei",     ABC_HTML_ATTR_FONT,      0},
+       {font_size_keys,   "16",         ABC_HTML_ATTR_FONT_SIZE, 0},
 };
 
 static html_attr_t  p_attrs[] =
 {
-       {"font",        "SimSong",    ABC_HTML_ATTR_FONT,      0},
-       {"font-size",   "16",         ABC_HTML_ATTR_FONT_SIZE, 0},
+       {font_keys,        "SimSong",    ABC_HTML_ATTR_FONT,      0},
+       {font_size_keys,   "16",         ABC_HTML_ATTR_FONT_SIZE, 0},
 };
 
 static html_attr_t  a_attrs[] =
 {
-       {"href",        "",           ABC_HTML_ATTR_HREF,       ABC_HTML_FLAG_SHOW},
-       {"font",        "SimHei",     ABC_HTML_ATTR_FONT,       0},
-       {"font-size",   "24",         ABC_HTML_ATTR_FONT_SIZE,  0},
-       {"font-color",  "blue",       ABC_HTML_ATTR_FONT_COLOR, 0},
+       {href_keys,        "",           ABC_HTML_ATTR_HREF,       ABC_HTML_FLAG_SHOW},
+       {font_keys,        "SimHei",     ABC_HTML_ATTR_FONT,       0},
+       {font_size_keys,   "24",         ABC_HTML_ATTR_FONT_SIZE,  0},
+       {font_color_keys,  "blue",       ABC_HTML_ATTR_FONT_COLOR, 0},
 };
 
 static html_attr_t  img_attrs[] =
 {
-       {"src",         "",           ABC_HTML_ATTR_SRC,        ABC_HTML_FLAG_SHOW},
-       {"width",       "100",        ABC_HTML_ATTR_WIDTH,      ABC_HTML_FLAG_SHOW},
-       {"height",      "100",        ABC_HTML_ATTR_HEIGHT,     ABC_HTML_FLAG_SHOW},
+       {src_keys,         "",           ABC_HTML_ATTR_SRC,        ABC_HTML_FLAG_SHOW},
+       {width_keys,       "100",        ABC_HTML_ATTR_WIDTH,      ABC_HTML_FLAG_SHOW},
+       {height_keys,      "100",        ABC_HTML_ATTR_HEIGHT,     ABC_HTML_FLAG_SHOW},
 };
 
 static html_attr_t  input_attrs[] =
 {
-       {"type",        "text",       ABC_HTML_ATTR_TYPE,       ABC_HTML_FLAG_SHOW},
-       {"id",          "",           ABC_HTML_ATTR_ID,         ABC_HTML_FLAG_SHOW},
-       {"name",        "",           ABC_HTML_ATTR_NAME,       ABC_HTML_FLAG_SHOW},
-       {"value",       "",           ABC_HTML_ATTR_VALUE,      ABC_HTML_FLAG_SHOW},
+       {type_keys,        "text",       ABC_HTML_ATTR_TYPE,       ABC_HTML_FLAG_SHOW},
+       {id_keys,          "",           ABC_HTML_ATTR_ID,         ABC_HTML_FLAG_SHOW},
+       {name_keys,        "",           ABC_HTML_ATTR_NAME,       ABC_HTML_FLAG_SHOW},
+       {value_keys,       "",           ABC_HTML_ATTR_VALUE,      ABC_HTML_FLAG_SHOW},
 
-       {"font",        "SimSong",    ABC_HTML_ATTR_FONT,       0},
-       {"font-size",   "16",         ABC_HTML_ATTR_FONT_SIZE,  0},
+       {font_keys,        "SimSong",    ABC_HTML_ATTR_FONT,       0},
+       {font_size_keys,   "16",         ABC_HTML_ATTR_FONT_SIZE,  0},
 };
 
 static html_attr_t  label_attrs[] =
 {
-       {"for",         "",           ABC_HTML_ATTR_FOR,        ABC_HTML_FLAG_SHOW},
+       {for_keys,         "",           ABC_HTML_ATTR_FOR,        ABC_HTML_FLAG_SHOW},
 
-       {"font",        "SimSong",    ABC_HTML_ATTR_FONT,       0},
-       {"font-size",   "16",         ABC_HTML_ATTR_FONT_SIZE,  0},
+       {font_keys,        "SimSong",    ABC_HTML_ATTR_FONT,       0},
+       {font_size_keys,   "16",         ABC_HTML_ATTR_FONT_SIZE,  0},
 };
 
 static html_attr_t  form_attrs[] =
 {
-       {"action",      "/",          ABC_HTML_ATTR_ACTION,     ABC_HTML_FLAG_SHOW},
-       {"method",      "post",       ABC_HTML_ATTR_METHOD,     ABC_HTML_FLAG_SHOW},
+       {action_keys,      "/",          ABC_HTML_ATTR_ACTION,     ABC_HTML_FLAG_SHOW},
+       {method_keys,      "post",       ABC_HTML_ATTR_METHOD,     ABC_HTML_FLAG_SHOW},
 
-       {"font",        "SimSong",    ABC_HTML_ATTR_FONT,       0},
-       {"font-size",   "16",         ABC_HTML_ATTR_FONT_SIZE,  0},
+       {font_keys,        "SimSong",    ABC_HTML_ATTR_FONT,       0},
+       {font_size_keys,   "16",         ABC_HTML_ATTR_FONT_SIZE,  0},
 };
 
 static html_label_t  html_labels[] =
 {
-       {"html",  ABC_HTML,       0, NULL, ABC_HTML_FLAG_CLOSE},
-       {"title", ABC_HTML_TITLE, 0, NULL, ABC_HTML_FLAG_CLOSE},
-       {"head",  ABC_HTML_HEAD,  0, NULL, ABC_HTML_FLAG_CLOSE},
-       {"body",  ABC_HTML_BODY,  0, NULL, ABC_HTML_FLAG_CLOSE},
+       {html_keys,   ABC_HTML,       0, NULL, ABC_HTML_FLAG_CLOSE},
+       {title_keys,  ABC_HTML_TITLE, 0, NULL, ABC_HTML_FLAG_CLOSE},
+       {head_keys,   ABC_HTML_HEAD,  0, NULL, ABC_HTML_FLAG_CLOSE},
+       {body_keys,   ABC_HTML_BODY,  0, NULL, ABC_HTML_FLAG_CLOSE},
 
-       {"div",   ABC_HTML_DIV,   0, NULL, ABC_HTML_FLAG_CLOSE},
+       {div_keys,    ABC_HTML_DIV,   0, NULL, ABC_HTML_FLAG_CLOSE},
 
-       {"h1",    ABC_HTML_H1,    abc_number_of(h1_attrs),    h1_attrs,    ABC_HTML_FLAG_CLOSE},
-       {"h2",    ABC_HTML_H2,    abc_number_of(h2_attrs),    h2_attrs,    ABC_HTML_FLAG_CLOSE},
-       {"h3",    ABC_HTML_H3,    abc_number_of(h3_attrs),    h3_attrs,    ABC_HTML_FLAG_CLOSE},
-       {"h4",    ABC_HTML_H4,    abc_number_of(h4_attrs),    h4_attrs,    ABC_HTML_FLAG_CLOSE},
-       {"h5",    ABC_HTML_H5,    abc_number_of(h5_attrs),    h5_attrs,    ABC_HTML_FLAG_CLOSE},
-       {"h6",    ABC_HTML_H6,    abc_number_of(h6_attrs),    h6_attrs,    ABC_HTML_FLAG_CLOSE},
+       {h1_keys,     ABC_HTML_H1,    abc_number_of(h1_attrs),    h1_attrs,    ABC_HTML_FLAG_CLOSE},
+       {h2_keys,     ABC_HTML_H2,    abc_number_of(h2_attrs),    h2_attrs,    ABC_HTML_FLAG_CLOSE},
+       {h3_keys,     ABC_HTML_H3,    abc_number_of(h3_attrs),    h3_attrs,    ABC_HTML_FLAG_CLOSE},
+       {h4_keys,     ABC_HTML_H4,    abc_number_of(h4_attrs),    h4_attrs,    ABC_HTML_FLAG_CLOSE},
+       {h5_keys,     ABC_HTML_H5,    abc_number_of(h5_attrs),    h5_attrs,    ABC_HTML_FLAG_CLOSE},
+       {h6_keys,     ABC_HTML_H6,    abc_number_of(h6_attrs),    h6_attrs,    ABC_HTML_FLAG_CLOSE},
 
-       {"p",     ABC_HTML_P,     abc_number_of(p_attrs),     p_attrs,     ABC_HTML_FLAG_CLOSE},
-       {"br",    ABC_HTML_BR,    0,                          NULL,        ABC_HTML_FLAG_OPEN},
+       {p_keys,      ABC_HTML_P,     abc_number_of(p_attrs),     p_attrs,     ABC_HTML_FLAG_CLOSE},
+       {br_keys,     ABC_HTML_BR,    0,                          NULL,        ABC_HTML_FLAG_OPEN},
 
-       {"a",     ABC_HTML_A,     abc_number_of(a_attrs),     a_attrs,     ABC_HTML_FLAG_CLOSE},
-       {"img",   ABC_HTML_IMG,   abc_number_of(img_attrs),   img_attrs,   ABC_HTML_FLAG_CLOSE | ABC_HTML_FLAG_SINGLE},
+       {a_keys,      ABC_HTML_A,     abc_number_of(a_attrs),     a_attrs,     ABC_HTML_FLAG_CLOSE},
+       {img_keys,    ABC_HTML_IMG,   abc_number_of(img_attrs),   img_attrs,   ABC_HTML_FLAG_CLOSE | ABC_HTML_FLAG_SINGLE},
 
-       {"form",  ABC_HTML_FORM,  abc_number_of(form_attrs),  form_attrs,  ABC_HTML_FLAG_CLOSE},
-       {"input", ABC_HTML_INPUT, abc_number_of(input_attrs), input_attrs, ABC_HTML_FLAG_OPEN},
-       {"label", ABC_HTML_LABEL, abc_number_of(label_attrs), label_attrs, ABC_HTML_FLAG_CLOSE},
+       {form_keys,   ABC_HTML_FORM,  abc_number_of(form_attrs),  form_attrs,  ABC_HTML_FLAG_CLOSE},
+       {input_keys,  ABC_HTML_INPUT, abc_number_of(input_attrs), input_attrs, ABC_HTML_FLAG_OPEN},
+       {label_keys,  ABC_HTML_LABEL, abc_number_of(label_attrs), label_attrs, ABC_HTML_FLAG_CLOSE},
 };
 
 static int __html_parse_obj(abc_html_t* html, abc_char_t* c);
@@ -139,27 +180,28 @@ static html_label_t* __html_find_label(const char* name)
        html_label_t* label;
 
        int i;
+       int j;
+
        for (i = 0; i < sizeof(html_labels) / sizeof(html_labels[0]); i++) {
                label     =       &html_labels[i];
 
-               if (!strcmp(label->name, name))
-                       return  label;
+               for (j = 0; label->names[j]; j++) {
+
+                       if (!strcmp(label->names[j], name))
+                               return  label;
+               }
        }
 
        return NULL;
 }
 
-static int __html_add_attr(abc_obj_t* obj, int type, const char* name, const char* value, int flags)
+static int __html_add_attr(abc_obj_t* obj, int type, char** names, const char* value, int flags)
 {
        abc_obj_t* attr = abc_obj_alloc(NULL, 0, 0, type);
        if (!attr)
                return -ENOMEM;
 
-       attr->key = scf_string_cstr(name);
-       if (!attr->key) {
-               abc_obj_free(attr);
-               return -ENOMEM;
-       }
+       attr->keys = names;
 
        attr->value = scf_string_cstr(value);
        if (!attr->value) {
@@ -184,7 +226,7 @@ static int __html_load_attrs(abc_obj_t* obj, html_attr_t* attrs, int n_attrs)
        if (attrs && n_attrs > 0) {
 
                for (i = 0; i < n_attrs; i++) {
-                       ret = __html_add_attr(obj, attrs[i].type, attrs[i].name, attrs[i].value, attrs[i].flags);
+                       ret = __html_add_attr(obj, attrs[i].type, attrs[i].names, attrs[i].value, attrs[i].flags);
                        if (ret < 0)
                                return ret;
                }
@@ -194,7 +236,7 @@ static int __html_load_attrs(abc_obj_t* obj, html_attr_t* attrs, int n_attrs)
                for (l   = scf_list_head(&obj->parent->attrs); l != scf_list_sentinel(&obj->parent->attrs); l = scf_list_next(l)) {
                        attr = scf_list_data(l, abc_obj_t, list);
 
-                       ret = __html_add_attr(obj, attr->type, attr->key->data, attr->value->data, 0);
+                       ret = __html_add_attr(obj, attr->type, attr->keys, attr->value->data, 0);
                        if (ret < 0)
                                return ret;
                }
@@ -289,16 +331,20 @@ static int __html_parse_end(abc_html_t* html, abc_obj_t* obj)
        free(c);
        c = NULL;
 
-       int ret = 0;
-       if (scf_string_cmp(obj->key, end)) {
-               ret = -1;
+       int j;
+       for (j = 0; obj->keys[j]; j++) {
 
-               scf_loge("end label '%s' file: %s, line: %d, NOT for label '%s' line: %d\n",
-                               end->data, html->file->data, html->n_lines, obj->key->data, obj->line);
+               if (!strcmp(obj->keys[j], end->data)) {
+                       scf_string_free(end);
+                       return 0;
+               }
        }
 
+       scf_loge("end label '%s' file: %s, line: %d, NOT for label '%s' line: %d\n",
+                       end->data, html->file->data, html->n_lines, obj->keys[0], obj->line);
+
        scf_string_free(end);
-       return ret;
+       return -1;
 }
 
 static int __html_parse_text(abc_html_t* html, abc_obj_t* obj)
@@ -519,8 +565,12 @@ static int __html_parse_attr2(abc_html_t* html, abc_obj_t* obj, const html_attr_
        for (l   = scf_list_head(&obj->attrs); l != scf_list_sentinel(&obj->attrs); l = scf_list_next(l)) {
                attr = scf_list_data(l, abc_obj_t, list);
 
-               if (!strcmp(attr->key->data, key->data))
-                       break;
+               int j;
+               for (j = 0; attr->keys[j]; j++) {
+
+                       if (!strcmp(attr->keys[j], key->data))
+                               goto found;
+               }
        }
 
        if (l == scf_list_sentinel(&obj->attrs)) {
@@ -530,6 +580,7 @@ static int __html_parse_attr2(abc_html_t* html, abc_obj_t* obj, const html_attr_
                return -1;
        }
 
+found:
        scf_string_free(key);
        key = NULL;
 
@@ -612,15 +663,15 @@ static int __html_parse_obj(abc_html_t* html, abc_char_t* c)
                return -1;
        }
 
+       scf_string_free(key);
+       key = NULL;
+
        obj = abc_obj_alloc(html->file, html->n_lines, html->pos, label->type);
-       if (!obj) {
-               scf_string_free(key);
+       if (!obj)
                return -ENOMEM;
-       }
 
        obj->flags = label->flags;
-       obj->key   = key;
-       key = NULL;
+       obj->keys  = label->names;
 
        obj->parent = html->current;
 
@@ -630,7 +681,7 @@ static int __html_parse_obj(abc_html_t* html, abc_char_t* c)
                return ret;
        }
 
-       scf_logi("key: %s\n", obj->key->data);
+       scf_logi("key: %s\n", obj->keys[0]);
 
        switch (tmp) {
                case ' ':
@@ -673,7 +724,7 @@ static int __html_parse_obj(abc_html_t* html, abc_char_t* c)
 
                if ('>' != tmp) {
                        scf_loge("HTML label '%s' (%d) not closed, in file: %s, line: %d\n",
-                                       obj->key->data, tmp, html->file->data, html->n_lines);
+                                       obj->keys[0], tmp, html->file->data, html->n_lines);
                        return -1;
                }
        } else
@@ -735,7 +786,8 @@ int abc_html_parse(abc_html_t* html)
                        continue;
                }
 
-               if ('a' <= c->c && 'z' >= c->c) {
+               if (('a' <= c->c && 'z' >= c->c)
+                               || (0x4e00 <= c->c && 0x9fa5 >= c->c)) {
 
                        int ret = __html_parse_obj(html, c);
                        if (ret < 0) {
index d7d0fd7e0a23b187bbd16e67f75a72f48d20de35..f268cba6c226ce16bcd2f88a605241a78c39eb0a 100644 (file)
@@ -30,9 +30,6 @@ abc_obj_t*    abc_obj_alloc(scf_string_t* file, int line, int pos, int type)
 void abc_obj_free(abc_obj_t* obj)
 {
        if (obj) {
-               if (obj->key)
-                       scf_string_free(obj->key);
-
                if (obj->value)
                        scf_string_free(obj->value);
 
@@ -135,9 +132,9 @@ void abc_obj_print(abc_obj_t* obj)
                return;
 
        if (obj->value)
-               printf(" %s=\"%s\"", obj->key->data, obj->value->data);
-       else if (obj->key)
-               printf("<%s", obj->key->data);
+               printf(" %s=\"%s\"", obj->keys[0], obj->value->data);
+       else if (obj->keys)
+               printf("<%s", obj->keys[0]);
 
 
        for (l = scf_list_head(&obj->attrs); l != scf_list_sentinel(&obj->attrs); l = scf_list_next(l)) {
@@ -150,7 +147,7 @@ void abc_obj_print(abc_obj_t* obj)
        if (!obj->value) {
                if (obj->flags & ABC_HTML_FLAG_SINGLE)
                        printf(" />\n");
-               else if (obj->key)
+               else if (obj->keys)
                        printf(">\n");
        }
 
@@ -164,7 +161,7 @@ void abc_obj_print(abc_obj_t* obj)
        }
 
        if (ABC_HTML_FLAG_CLOSE == (obj->flags & (ABC_HTML_FLAG_CLOSE | ABC_HTML_FLAG_SINGLE))) {
-               if (obj->key)
-                       printf("</%s>\n", obj->key->data);
+               if (obj->keys)
+                       printf("</%s>\n", obj->keys[0]);
        }
 }
index 92a8917a29eb07b426aa5ac10eb2884848eccb37..d3de45764359b16e61105f3cdb655694a81435e8 100644 (file)
@@ -88,7 +88,7 @@ struct abc_obj_s
        int             progress;
        uint32_t        jiffies; // timeout numbers of sys timer
 
-       scf_string_t*   key;
+       char**          keys;
        scf_string_t*   value;
        scf_string_t*   text;
 
index 7b64e5da65460bede0809ca2b2a871348394846c..7332b456708d2d13cfb650ac5a3a26e1b83184e8 100644 (file)
@@ -116,8 +116,8 @@ int abc_layout_root(abc_ctx_t* abc, abc_obj_t* root, int width, int height)
                                break;
                };
 
-               if (child->key)
-                       scf_logd("key: %s, x: %d, y: %d, w: %d, h: %d\n\n", child->key->data, child->x, child->y, child->w, child->h);
+               if (child->keys)
+                       scf_logd("key: %s, x: %d, y: %d, w: %d, h: %d\n\n", child->keys[0], child->x, child->y, child->w, child->h);
 
                if (__w < child->x + child->w)
                        __w = child->x + child->w;
@@ -136,8 +136,8 @@ int abc_layout_root(abc_ctx_t* abc, abc_obj_t* root, int width, int height)
        if (root->h < __h)
                root->h = __h;
 
-       if (root->key)
-               scf_logd("key: %s, x: %d, y: %d, w: %d, h: %d\n", root->key->data, root->x, root->y, root->w, root->h);
+       if (root->keys)
+               scf_logd("key: %s, x: %d, y: %d, w: %d, h: %d\n", root->keys[0], root->x, root->y, root->w, root->h);
 
        return 0;
 }
index 5e9feb717fe4b9f8e95361e1078ab80603b10f00..e5e2f8763b3e393a31857e584e7c58e42fb9d890 100644 (file)
@@ -53,7 +53,7 @@ static int _render_draw_img(abc_render_t* render, abc_obj_t* obj, int width, int
        }
 
        if (l == scf_list_sentinel(&obj->attrs)) {
-               scf_loge("src image of '%s' not found\n", obj->key->data);
+               scf_loge("src image of '%s' not found\n", obj->keys[0]);
                return -1;
        }
 
@@ -86,7 +86,7 @@ static int _render_draw_img(abc_render_t* render, abc_obj_t* obj, int width, int
        float mvp[16];
        __compute_mvp(mvp, 0, 0, 0);
 
-       scf_logi("%s, x: %d, y: %d, w: %d, h: %d\n", obj->key->data, obj->x, obj->y, obj->w, obj->h);
+       scf_logi("%s, x: %d, y: %d, w: %d, h: %d\n", obj->keys[0], obj->x, obj->y, obj->w, obj->h);
 
        GLfloat vert_update[] =
        {
index 51d2397055e368874ce62dab04ac53404bc2893d..8e1f68e165cd2c831217e16cffeb7390862e4cc7 100644 (file)
--- a/ui/main.c
+++ b/ui/main.c
@@ -402,10 +402,16 @@ static void im_commit(GtkIMContext* self, gchar* str, gpointer user_data)
 
        scf_logw("str: %s\n", str);
 
-       if (ctx->current) {
-               obj = ctx->current->current;
+       if (!ctx->current)
+               return;
+
+       obj = ctx->current->current;
+
+       if (obj && ABC_HTML_INPUT == obj->type) {
+               attr = abc_obj_get_attr(obj, ABC_HTML_ATTR_TYPE);
+
+               if (!strcmp(attr->value->data, "text") || !strcmp(attr->value->data, "password")) {
 
-               if (obj && ABC_HTML_INPUT == obj->type) {
                        attr = abc_obj_get_attr(obj, ABC_HTML_ATTR_VALUE);
 
                        scf_string_cat_cstr(attr->value, str);