From 24d24e0baae87f713dd0ffd3e44248296d4437d2 Mon Sep 17 00:00:00 2001 From: Albert Cervin Date: Wed, 14 Aug 2024 22:05:10 +0200 Subject: [PATCH] Add fancy welcome text --- src/dged/buffer.c | 3 ++- src/dged/buffer.h | 3 +++ src/main/main.c | 13 +++++++++---- src/main/welcome.h | 45 ++++++++++++++++++++++++++++++++++++++++++++ src/main/welcome.inc | 9 +++++++++ 5 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 src/main/welcome.h create mode 100644 src/main/welcome.inc diff --git a/src/dged/buffer.c b/src/dged/buffer.c index 0fac694..619eee1 100644 --- a/src/dged/buffer.c +++ b/src/dged/buffer.c @@ -1183,7 +1183,8 @@ void buffer_render(struct buffer *buffer, struct buffer_render_params *params) { .origin = params->origin, .width = params->width, .height = params->height, - .show_ws = show_ws != NULL ? show_ws->value.bool_value : true, + .show_ws = (show_ws != NULL ? show_ws->value.bool_value : true) && + !buffer->force_show_ws_off, .buffer = buffer, }; text_for_each_line(buffer->text, params->origin.line, params->height, diff --git a/src/dged/buffer.h b/src/dged/buffer.h index 2b53ec2..cd5bd95 100644 --- a/src/dged/buffer.h +++ b/src/dged/buffer.h @@ -60,6 +60,9 @@ struct buffer { /** Can rows be added lazily to this buffer */ bool lazy_row_add; + + /** If true, force whitespace indication off for this buffer */ + bool force_show_ws_off; }; void buffer_static_init(); diff --git a/src/main/main.c b/src/main/main.c index 8e3e862..45f72cb 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -34,6 +34,12 @@ #include "completion.h" #include "version.h" +/* welcome.h is generated from welcome.inc with + * xxd -n welcome_text -i + * or similar. + */ +#include "welcome.h" + static struct frame_allocator frame_allocator; void *frame_alloc(size_t sz) { @@ -311,10 +317,9 @@ int main(int argc, char *argv[]) { free((void *)filename); free((void *)absfile); } else { - const char *welcome_txt = - "Welcome to the editor for datagubbar and datagummor 👴👵\n"; - buffer_set_text(&initial_buffer, (uint8_t *)welcome_txt, - strlen(welcome_txt)); + initial_buffer.force_show_ws_off = true; + buffer_set_readonly(&initial_buffer, true); + buffer_set_text(&initial_buffer, (uint8_t *)welcome_text, welcome_text_len); } struct buffer *ib = buffers_add(&buflist, initial_buffer); diff --git a/src/main/welcome.h b/src/main/welcome.h new file mode 100644 index 0000000..7f9b720 --- /dev/null +++ b/src/main/welcome.h @@ -0,0 +1,45 @@ +unsigned char welcome_text[] = { + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, + 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0x20, + 0x20, 0x20, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, + 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0x20, 0x20, 0xe2, 0x96, + 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, + 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0x20, 0xe2, 0x96, 0x88, 0xe2, + 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, + 0x96, 0x88, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xe2, 0x96, 0x88, 0xe2, 0x96, + 0x88, 0x20, 0x20, 0x20, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0x20, 0xe2, + 0x96, 0x88, 0xe2, 0x96, 0x88, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0x20, 0x20, 0x20, 0xe2, 0x96, 0x88, + 0xe2, 0x96, 0x88, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xe2, 0x96, 0x88, 0xe2, + 0x96, 0x88, 0x20, 0x20, 0x20, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0x20, + 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0x20, 0x20, 0x20, 0xe2, 0x96, 0x88, + 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0x20, 0xe2, 0x96, 0x88, 0xe2, 0x96, + 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0x20, 0x20, + 0x20, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0x20, 0x20, 0x20, 0xe2, 0x96, + 0x88, 0xe2, 0x96, 0x88, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xe2, 0x96, 0x88, + 0xe2, 0x96, 0x88, 0x20, 0x20, 0x20, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, + 0x20, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0x20, 0x20, 0x20, 0x20, 0xe2, + 0x96, 0x88, 0xe2, 0x96, 0x88, 0x20, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, + 0x20, 0x20, 0x20, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0x0a, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, + 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0x20, 0x20, 0x20, 0xe2, + 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, + 0x96, 0x88, 0xe2, 0x96, 0x88, 0x20, 0x20, 0xe2, 0x96, 0x88, 0xe2, 0x96, + 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, + 0x88, 0xe2, 0x96, 0x88, 0x20, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, + 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0xe2, 0x96, 0x88, 0x0a, + 0x0a, 0x0a, 0x57, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, 0x20, 0x74, 0x6f, + 0x20, 0x74, 0x68, 0x65, 0x20, 0x74, 0x65, 0x78, 0x74, 0x20, 0x65, 0x64, + 0x69, 0x74, 0x6f, 0x72, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x64, 0x61, 0x74, + 0x61, 0x67, 0x75, 0x62, 0x62, 0x61, 0x72, 0x20, 0x61, 0x6e, 0x64, 0x20, + 0x64, 0x61, 0x74, 0x61, 0x67, 0x75, 0x6d, 0x6d, 0x6f, 0x72, 0x21, 0x20, + 0xf0, 0x9f, 0x91, 0xb4, 0xf0, 0x9f, 0x91, 0xb5, 0x0a +}; +unsigned int welcome_text_len = 501; diff --git a/src/main/welcome.inc b/src/main/welcome.inc new file mode 100644 index 0000000..7acbd6b --- /dev/null +++ b/src/main/welcome.inc @@ -0,0 +1,9 @@ + + ██████ ██████ ███████ ██████ + ██ ██ ██ ██ ██ ██ + ██ ██ ██ ███ █████ ██ ██ + ██ ██ ██ ██ ██ ██ ██ + ██████ ██████ ███████ ██████ + + +Welcome to the text editor for datagubbar and datagummor! 👴👵