Improve textes.

This commit is contained in:
Arthur Sonzogni
2018-05-01 14:50:01 +02:00
parent 623a683d5f
commit 1e825a2d33
7 changed files with 130 additions and 9 deletions
+1 -1
View File
@@ -1 +1 @@
Work in progress.
Work in progress...
+8
View File
@@ -28,6 +28,8 @@ add_subdirectory(screen)
add_subdirectory(translator/frame)
add_subdirectory(translator/planar_graph)
add_subdirectory(translator/sequence)
add_subdirectory(translator/table)
add_subdirectory(translator/tree)
if (Web)
@@ -73,6 +75,8 @@ if (Web)
translator_frame
translator_planar_graph
translator_sequence
translator_table
translator_tree
screen
antlr4_static
)
@@ -87,6 +91,8 @@ else()
translator_frame
translator_planar_graph
translator_sequence
translator_table
translator_tree
screen
antlr4_static
)
@@ -99,6 +105,8 @@ else()
translator_frame
translator_planar_graph
translator_sequence
translator_table
translator_tree
antlr4_static
screen
stdc++fs
+20 -4
View File
@@ -57,7 +57,7 @@
<!--2 Input / Output -->
<div class="container horizontal flex">
<div class="gutter"></div>
<textarea id="input" class="flex" placeholder='input, for instance (1+2)*(3-4)/5'></textarea>
<textarea id="input" class="flex" placeholder='input'></textarea>
<div class="gutter"></div>
<textarea id="output" class = "flex" placeholder='output' readonly></textarea>
<div class="gutter"></div>
@@ -123,10 +123,10 @@ function UpdateOptions() {
option_box.className = "option";
let label = document.createElement('label');
label.innerText = option.label + ":";
label.innerText = option.label + " : ";
option_box.appendChild(label);
if (option.type = "checkbox") {
if (option.type == "checkbox") {
let checkbox = document.createElement("input");
checkbox.type = "checkbox";
checkbox.data = option.name;
@@ -135,6 +135,17 @@ function UpdateOptions() {
option_box.appendChild(checkbox);
}
if (option.type == "combobox") {
let select = document.createElement('select');
select.data = option.name
select.type = "text";
for(let i in option.values) {
select.options[i] = new Option(option.values[i]);
}
select.addEventListener("change", UpdateOutput);
option_box.appendChild(select);
}
options.appendChild(option_box);
}
}
@@ -147,13 +158,18 @@ function GetOptions() {
let option = tool.options[i];
let name;
let value;
if (option.type = "checkbox") {
if (option.type == "checkbox") {
name = options.childNodes[i].childNodes[1].data;
value = options.childNodes[i].childNodes[1].checked;
}
if (option.type == "combobox") {
name = options.childNodes[i].childNodes[1].data;
value = options.childNodes[i].childNodes[1].value;
}
output += name + "\n";
output += value + "\n";
}
console.log(output);
return output;
}
+2 -1
View File
@@ -21,8 +21,9 @@ void translate(const char* translator_name, const char* input, const char* optio
std::string translator_string = translator_name;
auto translator = TranslatorFromName(translator_name);
std::string command = (*translator)(input, options);
replaceAll(command, "\n", "\\n");
replaceAll(command, "\\", "\\\\");
replaceAll(command, "\"", "\\\"");
replaceAll(command, "\n", "\\n");
command = "output.value=\"" + command + "\";";
emscripten_run_script(command.c_str());
}
+91 -2
View File
@@ -66,7 +66,6 @@
}
]
},
{
"tool": "PlanarGraph",
"description": "Planar graph",
@@ -195,9 +194,53 @@
}
]
},
{
"tool": "Tree",
"description": "Tree",
"options": [
{
"type":"combobox",
"default":true,
"label":"Style",
"name":"style",
"values": [
"unicode 1",
"unicode 2",
"ASCII 1",
"ASCII 2",
"ASCII 3",
"unicode right top",
"unicode right center",
"unicode right bottom"
]
}
],
"examples": [
{
"title": "------------------------",
"empty": true
},
{
"title":"1 - Simple",
"content": [
"Linux",
" Android",
" Debian",
" Ubuntu",
" Lubuntu",
" Kubuntu",
" Xubuntu",
" Xubuntu",
" Mint",
" Centos",
" Fedora"
]
}
]
},
{
"tool": "Frame",
"description": "Frame/border/line_number",
"description": "Frame",
"options": [
{
"type":"checkbox",
@@ -231,5 +274,51 @@
]
}
]
},
{
"tool": "Table",
"description": "Table",
"options": [
{
"type":"combobox",
"default":true,
"label":"Style",
"name":"style",
"values": [
"unicode",
"unicode rounded",
"unicode bold",
"unicode double",
"unicode with bold header",
"unicode with double header",
"unicode cells",
"unicode cells 2",
"ascii",
"ascii rounded",
"ascii with header 1",
"ascii with header 2",
"ascii light header",
"ascii light header/separator",
"ascii light header/separator/border",
"ascii light separator/border",
"ascii light border",
"conceptual"
]
}
],
"examples": [
{
"title": "------------------------",
"empty": true
},
{
"title":"1-simple",
"content": [
"Column 1,Column 2,Column 3",
"C++,Web,Assembly",
"Javascript,CSS,HTML"
]
}
]
}
]
+4
View File
@@ -8,8 +8,12 @@ std::unique_ptr<Translator> TranslatorFromName(const std::string name) {
return SequenceTranslator();
if (name == "Frame")
return FrameTranslator();
if (name == "Table")
return TableTranslator();
if (name == "PlanarGraph")
return PlanarGraphTranslator();
if (name == "Tree")
return TreeTranslator();
return nullptr;
}
+4 -1
View File
@@ -14,9 +14,12 @@ class Translator {
const std::string& options);
};
std::unique_ptr<Translator> SequenceTranslator();
std::unique_ptr<Translator> FrameTranslator();
std::unique_ptr<Translator> PlanarGraphTranslator();
std::unique_ptr<Translator> SequenceTranslator();
std::unique_ptr<Translator> TableTranslator();
std::unique_ptr<Translator> TreeTranslator();
std::unique_ptr<Translator> TranslatorFromName(const std::string name);
#endif /* end of include guard: TRANSLATOR_TRANSLATOR */