diff --git a/res/config.ini b/res/config.ini index 97384ac..63cdea9 100644 --- a/res/config.ini +++ b/res/config.ini @@ -15,6 +15,9 @@ # Big clock formatting (see strftime specification) [allowed symbols 1-9,-,:] #bigclock_format = %H:%M +# Unicode Number of Big Block character. Supports UTF-16(Example █ = U+2588 = 0x2588 = 9608) +#bigclock_char = 9608 + # The character used to mask the password #asterisk = * diff --git a/src/bigclock.h b/src/bigclock.h index 2236d2c..bdfafc1 100644 --- a/src/bigclock.h +++ b/src/bigclock.h @@ -3,13 +3,8 @@ #define CLOCK_W 5 #define CLOCK_H 5 -#if defined(__linux__) || defined(__FreeBSD__) - #define X 0x2593 - #define _ 0x0000 -#else - #define X '#' - #define _ 0 -#endif +#define X '.' +#define _ 0 #if CLOCK_W == 5 && CLOCK_H == 5 @@ -122,6 +117,9 @@ uint32_t CLOCK_D[] = { #undef X #undef _ +// I wish these were in a premade dictionary... Writing this felt like hell +uint32_t* CLOCK_CHARS[] = {CLOCK_0,CLOCK_1,CLOCK_2,CLOCK_3,CLOCK_4,CLOCK_5,CLOCK_6,CLOCK_7,CLOCK_8,CLOCK_9,CLOCK_S,CLOCK_E,CLOCK_D}; + static inline uint32_t* CLOCK_N(char c) { switch(c) diff --git a/src/config.c b/src/config.c index 36577ae..f9f1cfb 100644 --- a/src/config.c +++ b/src/config.c @@ -162,6 +162,7 @@ void config_load(const char *cfg_path) {"asterisk", &config.asterisk, config_handle_char}, {"bg", &config.bg, config_handle_u8}, {"bigclock", &config.bigclock, config_handle_bool}, + {"bigclock_char", &config.bigclock_char, config_handle_u16}, {"bigclock_format", &config.bigclock_format, config_handle_str}, {"blank_box", &config.blank_box, config_handle_bool}, {"blank_password", &config.blank_password, config_handle_bool}, @@ -276,6 +277,7 @@ void config_defaults() config.bg = 0; config.bigclock = false; config.bigclock_format = NULL; + config.bigclock_char = 0x2588; config.blank_box = true; config.blank_password = false; config.clock = NULL; diff --git a/src/config.h b/src/config.h index 376f099..eb4de06 100644 --- a/src/config.h +++ b/src/config.h @@ -67,6 +67,7 @@ struct config uint8_t bg; bool bigclock; char* bigclock_format; + uint32_t bigclock_char; bool blank_box; bool blank_password; char* clock; diff --git a/src/draw.c b/src/draw.c index 709591a..6cfd74c 100644 --- a/src/draw.c +++ b/src/draw.c @@ -3,7 +3,7 @@ #include "inputs.h" #include "utils.h" -#include "config.h" +#include "config.h" #include "draw.h" #include "bigclock.h" @@ -70,6 +70,7 @@ void draw_init(struct term_buf* buf) buf->box_chars.left = '|'; buf->box_chars.right = '|'; #endif + bigclock_character_change(); } static void doom_free(struct term_buf* buf); @@ -91,6 +92,20 @@ void draw_free(struct term_buf* buf) } } +void bigclock_character_change(){ + for(int i = 0; i < sizeof(CLOCK_CHARS)/sizeof(CLOCK_CHARS[0]);i++){ + uint32_t* curent_clock_char = CLOCK_CHARS[i]; + + for(int j = 0;j < 25;j++){ + uint32_t current_char = curent_clock_char[j]; + + if(current_char!=0){ + curent_clock_char[j] = config.bigclock_char; + } + } + } +} + void draw_box(struct term_buf* buf) { uint16_t box_x = (buf->width - buf->box_width) / 2; diff --git a/src/draw.h b/src/draw.h index b8a64c4..92895d3 100644 --- a/src/draw.h +++ b/src/draw.h @@ -88,5 +88,6 @@ bool cascade(struct term_buf* buf, uint8_t* fails); void draw_bigclock(struct term_buf *buf); void draw_clock(struct term_buf *buf); +void bigclock_character_change(); #endif