From 6a8c2f09f96f7ac5e840c0ef4935a5641e83fc18 Mon Sep 17 00:00:00 2001 From: totoro Date: Wed, 19 Apr 2017 16:32:53 +0900 Subject: [PATCH] add colspan and rowspan attributes for editor and form table lines --- ds_files/ds_types.anubis | 20 ++++++++++++++++++++ view/types/hk_editor_table.anubis | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ view/types/hk_form_table.anubis | 19 ++++++++++++++++--- 3 files changed, 121 insertions(+), 9 deletions(-) diff --git a/ds_files/ds_types.anubis b/ds_files/ds_types.anubis index c0a3110..eccd69b 100644 --- a/ds_files/ds_types.anubis +++ b/ds_files/ds_types.anubis @@ -258,8 +258,18 @@ public define List(DS_Type_File) hayamiki_lib_types_description = ]) ]), + ds_type("HK_Editor_Table_Line_Attribute", [ + alternative("colspan", [ + component(int, "number") + ]), + alternative("rowspan", [ + component(int, "number") + ]) + ]), + ds_type("HK_Editor_Table_Line", [ alternative("line", [ + component(list, ds_type("HK_Editor_Table_Line_Attribute"), "line_attr"), component(list, ds_type("HK_Editor_Table_Cell"), "cells") ]) ]), @@ -282,8 +292,18 @@ public define List(DS_Type_File) hayamiki_lib_types_description = ]) ]), + ds_type("HK_Form_Table_Line_Attribute", no_message, [ + alternative("colspan", [ + component(int, "number") + ]), + alternative("rowspan", [ + component(int, "number") + ]) + ]), + ds_type("HK_Form_Table_Line", no_message, [ alternative("hk_form_table_line", [ + component(list, ds_type("HK_Form_Table_Line_Attribute"), "line_attr"), component(list, ds_type("HK_Form_Table_Cell"), "form_table_cells") ]) ]), diff --git a/view/types/hk_editor_table.anubis b/view/types/hk_editor_table.anubis index 71ff321..62ae5eb 100644 --- a/view/types/hk_editor_table.anubis +++ b/view/types/hk_editor_table.anubis @@ -1,8 +1,8 @@ /* * Created by 伝作 (Densaku). * Types & Messages generator written by フランスのトトロ aka (David RENÉ) - * Date: 2017-04-12 - * Time: 23:52:21 + * Date: 2017-04-19 + * Time: 16:17:58 * */ @@ -41,9 +41,20 @@ public type HK_Editor_Table_Cell: . +public type HK_Editor_Table_Line_Attribute: + colspan( + Int number + ), + rowspan( + Int number + ) +. + + public type HK_Editor_Table_Line: line( - List(HK_Editor_Table_Cell) cells + List(HK_Editor_Table_Line_Attribute) line_attr, + List(HK_Editor_Table_Cell) cells ) . @@ -136,6 +147,69 @@ public define Maybe(HK_Editor_Table_Cell) + HK_Editor_Table_Line_Attribute message format + ============================================= + + +public define Message + to_Message + ( + HK_Editor_Table_Line_Attribute _hk_editor_table_line_attribute + )= + with _hk_editor_table_line_attribute_message = message((Word32)0), // + forget(add_string(_hk_editor_table_line_attribute_message, "__TYPE__", "HK_Editor_Table_Line_Attribute")); + if _hk_editor_table_line_attribute is + { + //Alternative colspan + colspan(_number) then + forget(add_string(_hk_editor_table_line_attribute_message, "__TYPE_ALT__", "colspan")); + // [type = Int] colspan.number + forget(add_string(_hk_editor_table_line_attribute_message, "number", to_String(_number))), + + //Alternative rowspan + rowspan(_number) then + forget(add_string(_hk_editor_table_line_attribute_message, "__TYPE_ALT__", "rowspan")); + // [type = Int] rowspan.number + forget(add_string(_hk_editor_table_line_attribute_message, "number", to_String(_number))), + + }; + _hk_editor_table_line_attribute_message +. + +public define Maybe(HK_Editor_Table_Line_Attribute) + from_Message + ( + Message _hk_editor_table_line_attribute_message + )= + if find_string(_hk_editor_table_line_attribute_message, "__TYPE__") is {failure then failure, success(__type__) then + if find_string(_hk_editor_table_line_attribute_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then + if __type__ = "HK_Editor_Table_Line_Attribute" then + //Alternative colspan + if __type_alt__ = "colspan" then //Alternative colspan + // [type = Int] colspan.number + if find_string(_hk_editor_table_line_attribute_message, "number") is {failure then failure, success(__number_) then + if decimal_scan(__number_) is { failure then failure, success(_number_) then + + success(colspan(_number_)) + }} + else //Alternative rowspan + if __type_alt__ = "rowspan" then //Alternative rowspan + // [type = Int] rowspan.number + if find_string(_hk_editor_table_line_attribute_message, "number") is {failure then failure, success(__number_) then + if decimal_scan(__number_) is { failure then failure, success(_number_) then + + success(rowspan(_number_)) + }} + else + failure //No valid Alternative found ! + else + failure //Type not found in message ! + }} +. + + + + HK_Editor_Table_Line message format =================================== @@ -150,8 +224,10 @@ public define Message if _hk_editor_table_line is { //Alternative line - line(__cells) then + line(__line_attr, __cells) then forget(add_string(_hk_editor_table_line_message, "__TYPE_ALT__", "line")); + // [type = List(HK_Editor_Table_Line_Attribute)] line.line_attr + map_forget((HK_Editor_Table_Line_Attribute _line_attr) |-> add_message(_hk_editor_table_line_message, "line_attr", to_Message(_line_attr)), __line_attr); // [type = List(HK_Editor_Table_Cell)] line.cells map_forget((HK_Editor_Table_Cell _cells) |-> add_message(_hk_editor_table_line_message, "cells", to_Message(_cells)), __cells), @@ -169,12 +245,15 @@ public define Maybe(HK_Editor_Table_Line) if __type__ = "HK_Editor_Table_Line" then //Alternative line if __type_alt__ = "line" then //Alternative line + // [type = List(HK_Editor_Table_Line_Attribute)] line.line_attr + with mb__line_attr_ = map_escape(( Message msg ) |-> (Maybe(HK_Editor_Table_Line_Attribute)) from_Message(msg), find_messages(_hk_editor_table_line_message, "line_attr")), + if mb__line_attr_ is {failure then failure, success(_line_attr_) then // [type = List(HK_Editor_Table_Cell)] line.cells with mb__cells_ = map_escape(( Message msg ) |-> (Maybe(HK_Editor_Table_Cell)) from_Message(msg), find_messages(_hk_editor_table_line_message, "cells")), if mb__cells_ is {failure then failure, success(_cells_) then - success(line(_cells_)) - } + success(line(_line_attr_, _cells_)) + }} else failure //No valid Alternative found ! else diff --git a/view/types/hk_form_table.anubis b/view/types/hk_form_table.anubis index 0605fdb..c8ec778 100644 --- a/view/types/hk_form_table.anubis +++ b/view/types/hk_form_table.anubis @@ -1,8 +1,8 @@ /* * Created by 伝作 (Densaku). * Types & Messages generator written by フランスのトトロ aka (David RENÉ) - * Date: 2017-04-12 - * Time: 23:52:21 + * Date: 2017-04-19 + * Time: 15:54:06 * */ @@ -38,9 +38,20 @@ public type HK_Form_Table_Cell: . +public type HK_Form_Line_Attribute: + colspan( + Int number + ), + rowspan( + Int number + ) +. + + public type HK_Form_Table_Line: hk_form_table_line( - List(HK_Form_Table_Cell) form_table_cells + List(HK_Form_Line_Attribute) line_attr, + List(HK_Form_Table_Cell) form_table_cells ) . @@ -64,6 +75,8 @@ public type HK_Form_Table: + + HK_Form_Table_Attribute message format ====================================== -- libgit2 0.21.4