Add option to change shutdown/reboot keys (#487)

Include options in the configuration to change which function keys to use for shutdown and reboot.
Fix config.map_len size in src/config.c.
Add missing defaults in config_defaults() in src/config.c.
This commit is contained in:
lolicon0930
2023-06-20 11:22:38 +00:00
committed by GitHub
parent 0edb0012ab
commit 42bf929756
23 changed files with 150 additions and 86 deletions

View File

@@ -192,7 +192,7 @@ char* time_str(char* fmt, int maxlen)
{
buffer[0] = '\0';
}
return buffer;
}
@@ -373,30 +373,54 @@ void draw_labels(struct term_buf* buf) // throws
}
}
void draw_f_commands()
void draw_key_hints()
{
struct tb_cell* f1 = str_cell(lang.f1);
struct tb_cell* shutdown_key = str_cell(config.shutdown_key);
int len = strlen(config.shutdown_key);
if (dgn_catch())
{
dgn_reset();
}
else
{
tb_blit(0, 0, strlen(lang.f1), 1, f1);
free(f1);
tb_blit(0, 0, len, 1, shutdown_key);
free(shutdown_key);
}
struct tb_cell* f2 = str_cell(lang.f2);
struct tb_cell* shutdown = str_cell(lang.shutdown);
len += 1;
if (dgn_catch())
{
dgn_reset();
}
else
{
tb_blit(strlen(lang.f1) + 1, 0, strlen(lang.f2), 1, f2);
free(f2);
tb_blit(len, 0, strlen(lang.shutdown), 1, shutdown);
free(shutdown);
}
struct tb_cell* restart_key = str_cell(config.restart_key);
len += strlen(lang.shutdown) + 1;
if (dgn_catch())
{
dgn_reset();
}
else
{
tb_blit(len, 0, strlen(config.restart_key), 1, restart_key);
free(restart_key);
}
struct tb_cell* restart = str_cell(lang.restart);
len += strlen(config.restart_key) + 1;
if (dgn_catch())
{
dgn_reset();
}
else
{
tb_blit(len, 0, strlen(lang.restart), 1, restart);
free(restart);
}
}
@@ -962,7 +986,7 @@ bool cascade(struct term_buf* term_buf, uint8_t* fails)
}
c_under = buf[(i + 1) * width + k].ch;
if (!isspace(c_under))
{
continue;
@@ -983,7 +1007,7 @@ bool cascade(struct term_buf* term_buf, uint8_t* fails)
}
}
// stop force-updating
// stop force-updating
if (!changes)
{
sleep(7);