Update window when date string change

master^2
aboven 5 years ago
parent 9e00c32098
commit 84fd64b77c
  1. 10
      ttyclock.c
  2. 1
      ttyclock.h

@ -200,6 +200,7 @@ update_hour(void)
ttyclock.date.minute[1] = ttyclock.tm->tm_min % 10; ttyclock.date.minute[1] = ttyclock.tm->tm_min % 10;
/* Set date string */ /* Set date string */
strcpy(ttyclock.date.old_datestr, ttyclock.date.datestr);
strftime(tmpstr, strftime(tmpstr,
sizeof(tmpstr), sizeof(tmpstr),
ttyclock.option.format, ttyclock.option.format,
@ -242,6 +243,15 @@ draw_number(int n, int x, int y)
void void
draw_clock(void) draw_clock(void)
{ {
if (ttyclock.option.date && !ttyclock.option.rebound &&
strcmp(ttyclock.date.datestr, ttyclock.date.old_datestr) != 0)
{
clock_move(ttyclock.geo.x,
ttyclock.geo.y,
ttyclock.geo.w,
ttyclock.geo.h);
}
/* Draw hour numbers */ /* Draw hour numbers */
draw_number(ttyclock.date.hour[0], 1, 1); draw_number(ttyclock.date.hour[0], 1, 1);
draw_number(ttyclock.date.hour[1], 1, 8); draw_number(ttyclock.date.hour[1], 1, 8);

@ -102,6 +102,7 @@ typedef struct
unsigned int minute[2]; unsigned int minute[2];
unsigned int second[2]; unsigned int second[2];
char datestr[256]; char datestr[256];
char old_datestr[256];
} date; } date;
/* time.h utils */ /* time.h utils */

Loading…
Cancel
Save