mirror of https://github.com/fairyglade/ly.git
Added option to change character used by bigclock
This commit is contained in:
parent
dc7477951a
commit
8c7ad4ac97
|
|
@ -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 = *
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
15
src/draw.c
15
src/draw.c
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue