handwritten and stroke order
This commit is contained in:
parent
7961c775d2
commit
9b66d3caf8
|
@ -9,6 +9,7 @@ project(
|
|||
HOMEPAGE_URL "https://github.com/Ajatt-Tools/gd-tools"
|
||||
LANGUAGES CXX
|
||||
)
|
||||
option(GUIX "Build for Guix" OFF) # OFF by default
|
||||
|
||||
include(cmake/project-is-top-level.cmake)
|
||||
include(cmake/variables.cmake)
|
||||
|
|
35
src/echo.cpp
35
src/echo.cpp
|
@ -41,7 +41,7 @@ EXAMPLES
|
|||
struct stroke_order_params
|
||||
{
|
||||
std::string_view gd_word{};
|
||||
std::string_view font_size{ "10rem" };
|
||||
std::string_view font_size{ "5rem" };
|
||||
std::string_view font_family{ "KanjiStrokeOrders" };
|
||||
std::size_t max_len{ default_len };
|
||||
|
||||
|
@ -90,3 +90,36 @@ void stroke_order(std::span<std::string_view const> const args)
|
|||
ajt::print("{}\n", ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
//Later just use stroke_order to print it
|
||||
void print_css_hw(stroke_order_params const& params)
|
||||
{
|
||||
static constexpr std::string_view css = R"EOF(
|
||||
<style>
|
||||
.gd_echo_{} {{
|
||||
font-size: {};
|
||||
font-family: "ArmedLemon";
|
||||
}}
|
||||
</style>
|
||||
)EOF";
|
||||
ajt::print(css, this_pid, params.font_size);
|
||||
}
|
||||
|
||||
void print_with_hw(stroke_order_params const& params)
|
||||
{
|
||||
if (params.gd_word.length() <= params.max_len) {
|
||||
ajt::print("<div class=\"gd_echo_{}\">{}</div>\n", this_pid, params.gd_word);
|
||||
print_css_hw(params);
|
||||
}
|
||||
}
|
||||
|
||||
void handwritten(std::span<std::string_view const> const args)
|
||||
{
|
||||
try {
|
||||
print_with_hw(fill_args<stroke_order_params>(args));
|
||||
} catch (gd::help_requested const& ex) {
|
||||
ajt::print(help_text);
|
||||
} catch (gd::runtime_error const& ex) {
|
||||
ajt::print("{}\n", ex.what());
|
||||
}
|
||||
}
|
|
@ -3,3 +3,5 @@
|
|||
#include "precompiled.h"
|
||||
|
||||
void stroke_order(std::span<std::string_view const> const args);
|
||||
|
||||
void handwritten(std::span<std::string_view const> const args);
|
|
@ -82,6 +82,10 @@ auto take_action(std::span<std::string_view const> const args) -> void
|
|||
return search_anki_cards(rest);
|
||||
case "gd-echo"_h:
|
||||
return stroke_order(rest);
|
||||
case "gd-strokeorder"_h:
|
||||
return stroke_order(rest);
|
||||
case "gd-handwritten"_h:
|
||||
return handwritten(rest);
|
||||
case "gd-massif"_h:
|
||||
return massif(rest);
|
||||
case "gd-images"_h:
|
||||
|
@ -102,6 +106,10 @@ auto take_action(std::span<std::string_view const> const args) -> void
|
|||
return search_anki_cards(rest);
|
||||
case "echo"_h:
|
||||
return stroke_order(rest);
|
||||
case "strokeorder"_h:
|
||||
return stroke_order(rest);
|
||||
case "handwritten"_h:
|
||||
return handwritten(rest);
|
||||
case "massif"_h:
|
||||
return massif(rest);
|
||||
case "images"_h:
|
||||
|
|
Loading…
Reference in a new issue