diff options
author | James McCoy <jamessan@debian.org> | 2023-02-04 10:19:23 -0500 |
---|---|---|
committer | James McCoy <jamessan@debian.org> | 2023-02-04 10:19:23 -0500 |
commit | cac44a8f5450c6f06e05474ec8da3f5d1aba913d (patch) | |
tree | 57d93dd10c5d86336c0c6e3ff9eea6ff700bbc86 /examples | |
parent | 0b77495c340fc0e2798fba0766ae381c242bd4fd (diff) |
New upstream version 0.4.3
Diffstat (limited to 'examples')
-rw-r--r-- | examples/demo-rgb8.c | 13 | ||||
-rw-r--r-- | examples/print-termctl.c | 73 |
2 files changed, 86 insertions, 0 deletions
diff --git a/examples/demo-rgb8.c b/examples/demo-rgb8.c index ddcc5b4..448ee04 100644 --- a/examples/demo-rgb8.c +++ b/examples/demo-rgb8.c @@ -91,9 +91,22 @@ int main(int argc, char *argv[]) return 1; } + tickit_term_setctl_str(tickit_get_term(t), + TICKIT_TERMCTL_TITLE_TEXT, "XTerm RGB8 colour demo"); + tickit_window_bind_event(root, TICKIT_WINDOW_ON_GEOMCHANGE, 0, &on_geomchange, NULL); tickit_window_bind_event(root, TICKIT_WINDOW_ON_EXPOSE, 0, &on_expose, NULL); + if(argc > 1 && argv[1]) { + TickitTerm *tt = tickit_get_term(t); + tickit_term_await_started_msec(tt, 100); + + if(streq(argv[1], "force-on")) + tickit_term_setctl_int(tt, tickit_termctl_lookup("xterm.cap_rgb8"), 1); + else if(streq(argv[1], "force-off")) + tickit_term_setctl_int(tt, tickit_termctl_lookup("xterm.cap_rgb8"), 0); + } + tickit_run(t); tickit_window_close(root); diff --git a/examples/print-termctl.c b/examples/print-termctl.c new file mode 100644 index 0000000..dfaf05d --- /dev/null +++ b/examples/print-termctl.c @@ -0,0 +1,73 @@ +#include "tickit.h" + +#include <errno.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> + +void printctl(TickitTerm *tt, const char *name, int ctl) +{ + switch(tickit_termctl_type(ctl)) { + case TICKIT_TYPE_NONE: + break; + + case TICKIT_TYPE_BOOL: + { + int b; + tickit_term_getctl_int(tt, ctl, &b); + printf(" %-26s: %s\n", name, b ? "true" : "false"); + break; + } + + case TICKIT_TYPE_INT: + { + int i; + tickit_term_getctl_int(tt, ctl, &i); + printf(" %-26s: %d\n", name, i); + break; + } + + // currently there are no controls of type STR or COLOUR + case TICKIT_TYPE_STR: + case TICKIT_TYPE_COLOUR: + break; + } +} + +int main(int argc, char *argv[]) +{ + Tickit *t = tickit_new_stdtty(); + + TickitTerm *tt = tickit_get_term(t); + if(!tt) { + fprintf(stderr, "Cannot create TickitTerm - %s\n", strerror(errno)); + return 1; + } + + tickit_term_await_started_msec(tt, 100); + + // First the common controls + printf("Common:\n"); + for(int ctl = 1; ; ctl++) { + const char *name = tickit_termctl_name(ctl); + if(!name) + break; + + printctl(tt, name, ctl); + } + + // Now the custom ones + printf("Driver %s\n", tickit_term_get_drivername(tt)); + int range = tickit_term_get_driverctl_range(tt); + for(int ctl = range+1; range; ctl++) { + const char *name = tickit_termctl_name(ctl); + if(!name) + break; + + printctl(tt, name, ctl); + } + + tickit_unref(t); + + return 0; +} |