mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-23 01:40:12 -05:00
main: add --font/-f command line option
This commit is contained in:
parent
e6c27645fa
commit
2bca2a894e
1 changed files with 32 additions and 3 deletions
35
main.c
35
main.c
|
|
@ -6,6 +6,7 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
#include <getopt.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
|
@ -408,7 +409,6 @@ grid_render(struct context *c)
|
||||||
last_buf = buf;
|
last_buf = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
tll_foreach(c->term.grid->scroll_damage, it) {
|
tll_foreach(c->term.grid->scroll_damage, it) {
|
||||||
switch (it->item.type) {
|
switch (it->item.type) {
|
||||||
case DAMAGE_SCROLL:
|
case DAMAGE_SCROLL:
|
||||||
|
|
@ -803,10 +803,40 @@ keyboard_repeater(void *arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, const char *const *argv)
|
main(int argc, char *const *argv)
|
||||||
{
|
{
|
||||||
int ret = EXIT_FAILURE;
|
int ret = EXIT_FAILURE;
|
||||||
|
|
||||||
|
static const struct option longopts[] = {
|
||||||
|
{"font", required_argument, 0, 'f'},
|
||||||
|
{NULL, no_argument, 0, 0},
|
||||||
|
};
|
||||||
|
|
||||||
|
const char *font_name = "Dina:pixelsize=12";
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
int c = getopt_long(argc, argv, ":f:h", longopts, NULL);
|
||||||
|
if (c == -1)
|
||||||
|
break;
|
||||||
|
|
||||||
|
switch (c) {
|
||||||
|
case 'f':
|
||||||
|
font_name = optarg;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'h':
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ':':
|
||||||
|
fprintf(stderr, "error: -%c: missing required argument\n", optopt);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
|
case '?':
|
||||||
|
fprintf(stderr, "error: -%c: invalid option\n", optopt);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
|
|
||||||
int repeat_pipe_fds[2] = {-1, -1};
|
int repeat_pipe_fds[2] = {-1, -1};
|
||||||
|
|
@ -846,7 +876,6 @@ main(int argc, const char *const *argv)
|
||||||
thrd_t keyboard_repeater_id;
|
thrd_t keyboard_repeater_id;
|
||||||
thrd_create(&keyboard_repeater_id, &keyboard_repeater, &c.term);
|
thrd_create(&keyboard_repeater_id, &keyboard_repeater, &c.term);
|
||||||
|
|
||||||
const char *font_name = "Dina:pixelsize=12";
|
|
||||||
c.fonts[0] = font_from_name(font_name);
|
c.fonts[0] = font_from_name(font_name);
|
||||||
if (c.fonts[0] == NULL)
|
if (c.fonts[0] == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue