From 9b66d3caf8d7a758240de2e137d971a5383f9152 Mon Sep 17 00:00:00 2001 From: Xieamoe Date: Wed, 14 Feb 2024 22:01:00 -0800 Subject: [PATCH 1/2] handwritten and stroke order --- CMakeLists.txt | 1 + src/echo.cpp | 35 ++++++++++++++++++++++++++++++++++- src/echo.h | 2 ++ src/main.cpp | 8 ++++++++ 4 files changed, 45 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 418ef93..5484bdc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/src/echo.cpp b/src/echo.cpp index cc4f2e1..f8c3f81 100644 --- a/src/echo.cpp +++ b/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 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( + + )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("
{}
\n", this_pid, params.gd_word); + print_css_hw(params); + } +} + +void handwritten(std::span const args) +{ + try { + print_with_hw(fill_args(args)); + } catch (gd::help_requested const& ex) { + ajt::print(help_text); + } catch (gd::runtime_error const& ex) { + ajt::print("{}\n", ex.what()); + } +} \ No newline at end of file diff --git a/src/echo.h b/src/echo.h index 1684c0b..baff37e 100644 --- a/src/echo.h +++ b/src/echo.h @@ -3,3 +3,5 @@ #include "precompiled.h" void stroke_order(std::span const args); + +void handwritten(std::span const args); \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 37c59c2..0a87896 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -82,6 +82,10 @@ auto take_action(std::span 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 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: From 8668cb475153a7b025ed2832b65b815d53b46ff2 Mon Sep 17 00:00:00 2001 From: xieamoe Date: Thu, 15 Feb 2024 06:06:42 +0000 Subject: [PATCH 2/2] Update gd-tools.scm --- gd-tools.scm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gd-tools.scm b/gd-tools.scm index 9f154e1..6ad2cdc 100644 --- a/gd-tools.scm +++ b/gd-tools.scm @@ -136,8 +136,8 @@ (method git-fetch) (uri (git-reference (url "https://codeberg.org/xieamoe/gd-tools-plus.git") - (commit "71da66e0f1"))) - (sha256 (base32 "0nys30qy5930004j7xnipxbn9d9k4xgbv7lzcdkrm9mapjzryh95")))) + (commit "9b66d3caf8"))) + (sha256 (base32 "135flpfkp2sjgah92546vpznxz712c5prvbdj93637y9pyrw9rci")))) (build-system cmake-build-system) (arguments @@ -177,6 +177,6 @@ (home-page "https://codeberg.org/hashirama/gd-tools/") (license (list license:gpl3+ - license:zlib)))) - -gd-tools + license:zlib)))) + +gd-tools \ No newline at end of file