mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-23 07:51:10 +01:00
[gpu] Add --type / -T option to replay keystrokes on startup
Allows simulating keyboard input at launch, e.g. -T '30= f' zooms 30x, toggles fullscreen and starts animation. Assisted-by: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
355bd4b011
commit
6c1bd94816
3 files changed
+19
No files matched your search
@@ -46,12 +46,14 @@ struct gpu_output_t
|
||||
hb_bool_t use_metal = false;
|
||||
hb_bool_t use_d3d11 = false;
|
||||
hb_bool_t demo = false;
|
||||
char *type_text = nullptr;
|
||||
|
||||
void add_options (option_parser_t *parser)
|
||||
{
|
||||
GOptionEntry entries[] =
|
||||
{
|
||||
{"demo", 0, 0, G_OPTION_ARG_NONE, &this->demo, "Use built-in demo font and text", nullptr},
|
||||
{"type", 'T', 0, G_OPTION_ARG_STRING, &this->type_text, "Type these keystrokes on start", "keys"},
|
||||
#ifdef __APPLE__
|
||||
{"metal", 0, 0, G_OPTION_ARG_NONE, &this->use_metal, "Use Metal renderer", nullptr},
|
||||
#endif
|
||||
@@ -244,6 +246,9 @@ struct gpu_output_t
|
||||
demo_view_print_help (vu);
|
||||
demo_view_setup (vu);
|
||||
|
||||
if (type_text)
|
||||
demo_view_type (vu, type_text);
|
||||
|
||||
demo_view_display (vu, buf);
|
||||
glfwPollEvents ();
|
||||
demo_view_display (vu, buf);
|
||||
|
||||
@@ -815,6 +815,17 @@ demo_view_setup (demo_view_t *vu)
|
||||
vu->renderer->set_stem_darkening (true);
|
||||
}
|
||||
|
||||
void
|
||||
demo_view_type (demo_view_t *vu, const char *keys)
|
||||
{
|
||||
for (const char *p = keys; *p; p++)
|
||||
{
|
||||
int key = (unsigned char) *p;
|
||||
demo_view_key_func (vu, key >= 'a' && key <= 'z' ? key - 32 : key, 0, GLFW_PRESS, 0);
|
||||
demo_view_char_func (vu, key);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
demo_view_request_redraw (demo_view_t *vu)
|
||||
{
|
||||
|
||||
@@ -81,6 +81,9 @@ demo_view_display (demo_view_t *vu, demo_buffer_t *buffer);
|
||||
void
|
||||
demo_view_setup (demo_view_t *vu);
|
||||
|
||||
void
|
||||
demo_view_type (demo_view_t *vu, const char *keys);
|
||||
|
||||
void
|
||||
demo_view_request_redraw (demo_view_t *vu);
|
||||
|
||||
|
||||
Reference in new issue
Block a user