Skip to content

Commit

Permalink
Add fancy welcome text
Browse files Browse the repository at this point in the history
  • Loading branch information
abbec committed Aug 14, 2024
1 parent 8f456ac commit 24d24e0
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/dged/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions src/dged/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
13 changes: 9 additions & 4 deletions src/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
#include "completion.h"
#include "version.h"

/* welcome.h is generated from welcome.inc with
* xxd -n welcome_text -i <path-to-welcome.inc> <path-to-welcome.h>
* or similar.
*/
#include "welcome.h"

static struct frame_allocator frame_allocator;

void *frame_alloc(size_t sz) {
Expand Down Expand Up @@ -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);
Expand Down
45 changes: 45 additions & 0 deletions src/main/welcome.h
Original file line number Diff line number Diff line change
@@ -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;
9 changes: 9 additions & 0 deletions src/main/welcome.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

██████ ██████ ███████ ██████
██ ██ ██ ██ ██ ██
██ ██ ██ ███ █████ ██ ██
██ ██ ██ ██ ██ ██ ██
██████ ██████ ███████ ██████


Welcome to the text editor for datagubbar and datagummor! 👴👵

0 comments on commit 24d24e0

Please sign in to comment.