-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(InputMacro): introduce InputMacro classes for grouping #99
Conversation
This commit introduces a few InputMacro classes to avoid repetitive code. Most of replacement functions are doing the same with different set of parameters, we can move them to a parent class. * Use vector.size() to avoid a few magic numbers. * Use std::unique_ptr for icu objects * Mark virtual method overrides properly. * Add clang-tidy checks to catch virtual function issues.
@lukhnos this is the follow-up from #98 (comment), please kindly take a look. It'd be nice if my proposal of short keywords for the time macros can be back ported to the upstream. |
Just popped up another idea that we can add some more macros: 今年 -> 2023 / 2023 年 / 民國112年 / 令和5年 Would that be a good idea? |
* extract common tasks from formatDate and formatTime into formatWithStyle for more generic formatting. * add a new formatWithPattern helper to format datetime with patterns * implement THIS_YEAR/LAST_YEAR/NEXT_YEAR macros with formatWithPattern
While implementing the year macros, I noticed that we can apply some further extractions to make our helpers more generic. |
f3106cf
to
34860f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
I filed #100 to discuss the maintenance challenges that arise from this feature, which needs to be maintained on both source code and data levels in both McBopomofo macOS and fcitx5-mcbopomofo. For now let's take the diffs.
This commit introduces a few InputMacro classes to avoid repetitive
code. Most of the replacement functions are doing the same with different
set of parameters, we can move them to a parent class.
Add short keywords for the time macros as discussed in
#98 (comment)
refactor(InputMacro): provide formatWithPattern and formatWithStyle
for more generic formatting.
feat(InputMacro): implement weekday macros