OSDN Git Service

* add textarea tag for JHTML.
authorkonn <konn@1a406e8e-add9-4483-a2c8-d8cac5b7c224>
Sun, 18 Jun 2006 08:11:22 +0000 (08:11 +0000)
committerkonn <konn@1a406e8e-add9-4483-a2c8-d8cac5b7c224>
Sun, 18 Jun 2006 08:11:22 +0000 (08:11 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/modchxj/mod_chxj/trunk@964 1a406e8e-add9-4483-a2c8-d8cac5b7c224

include/chxj_jhtml.h
src/chxj_jhtml.c

index de9d46b..40dbd18 100644 (file)
@@ -27,6 +27,7 @@ typedef struct _jhtml_t {
     char* out;
     int   out_len;
     int   pre_flag;
+    int   textarea_flag;
 
     device_table*    spec;
     mod_chxj_config* conf;
index 818264d..561f56f 100644 (file)
@@ -67,6 +67,8 @@ static char* s_jhtml_start_option_tag (jhtml_t* jhtml, Node* node);
 static char* s_jhtml_end_option_tag   (jhtml_t* jhtml, Node* node);
 static char* s_jhtml_start_div_tag    (jhtml_t* jhtml, Node* node);
 static char* s_jhtml_end_div_tag      (jhtml_t* jhtml, Node* node);
+static char* s_jhtml_start_textarea_tag(jhtml_t* jhtml, Node* child);
+static char* s_jhtml_end_textarea_tag(jhtml_t* jhtml, Node* child);
 static void  s_init_jhtml(jhtml_t* jhtml, Doc* doc, request_rec* r, device_table* spec);
 static int   s_jhtml_search_emoji(jhtml_t* jhtml, char* txt, char** rslt);
 static char* chxj_istyle_to_mode(request_rec* r, const char* s);
@@ -203,6 +205,15 @@ s_jhtml_node_exchange(jhtml_t* jhtml, Node* node, int indent)
     char* name = qs_get_node_name(doc,child);
 
     /*------------------------------------------------------------------------*/
+    /* <TEXTAREA> (for TEST)                                                  */
+    /*------------------------------------------------------------------------*/
+    if ((*name == 't' || *name == 'T') && strcasecmp(name, "textarea") == 0) {
+      s_jhtml_start_textarea_tag (jhtml, child);
+      s_jhtml_node_exchange      (jhtml, child, indent+1);
+      s_jhtml_end_textarea_tag   (jhtml, child);
+    }
+    else
+    /*------------------------------------------------------------------------*/
     /* <PRE> (for TEST)                                                       */
     /*------------------------------------------------------------------------*/
     if ((*name == 'p' || *name == 'P') && strcasecmp(name, "pre") == 0) {
@@ -582,6 +593,11 @@ s_jhtml_node_exchange(jhtml_t* jhtml, Node* node, int indent)
             one_byte[0] = textval[ii+0];
             tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
           }
+          else
+          if (jhtml->textarea_flag) {
+            one_byte[0] = textval[ii+0];
+            tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
+          }
           else {
             if (textval[ii] != '\r' && textval[ii] != '\n') {
               one_byte[0] = textval[ii+0];
@@ -2217,6 +2233,69 @@ s_jhtml_chxjif_tag(jhtml_t* jhtml, Node* node)
     s_jhtml_chxjif_tag(jhtml, child);
   }
 }
+
+/**
+ * It is a handler who processes the TEXTARE tag.
+ *
+ * @param jhtml  [i/o] The pointer to the CHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The TEXTAREA tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char*
+s_jhtml_start_textarea_tag(jhtml_t* jhtml, Node* node) 
+{
+  Doc*          doc = jhtml->doc;
+  request_rec*  r   = doc->r;
+  Attr* attr;
+
+  jhtml->textarea_flag++;
+  jhtml->out = apr_pstrcat(r->pool, jhtml->out, "<textarea ", NULL);
+
+  for (attr = qs_get_attr(doc,node);
+       attr;
+       attr = qs_get_next_attr(doc,attr)) {
+
+    char* name  = qs_get_attr_name(doc,attr);
+    char* value = qs_get_attr_value(doc,attr);
+
+    if ((*name == 'n' || *name == 'N') && strcasecmp(name, "name") == 0) {
+      jhtml->out = apr_pstrcat(r->pool, jhtml->out, " name=\"",value,"\"", NULL);
+    }
+    else 
+    if ((*name == 'r' || *name == 'R') && strcasecmp(name, "rows") == 0) {
+      jhtml->out = apr_pstrcat(r->pool, jhtml->out, " rows=\"",value,"\"", NULL);
+    }
+    else 
+    if ((*name == 'c' || *name == 'C') && strcasecmp(name, "cols") == 0) {
+      jhtml->out = apr_pstrcat(r->pool, jhtml->out, " cols=\"",value,"\"", NULL);
+    }
+  }
+
+  jhtml->out = apr_pstrcat(r->pool, jhtml->out, ">\r\n", NULL);
+
+  return jhtml->out;
+}
+
+/**
+ * It is a handler who processes the TEXTAREA tag.
+ *
+ * @param jhtml  [i/o] The pointer to the CHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The TEXTAREA tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char*
+s_jhtml_end_textarea_tag(jhtml_t* jhtml, Node* child) 
+{
+  Doc*          doc = jhtml->doc;
+  request_rec*  r   = doc->r;
+
+  jhtml->out = apr_pstrcat(r->pool, jhtml->out, "</textarea>\r\n", NULL);
+  jhtml->textarea_flag--;
+
+  return jhtml->out;
+}
 /*
  * vim:ts=2 et
  */