Fix set_center function

reverse-branch
Martin Duquesnoy 18 years ago
parent 3a30aea0e6
commit 1e050104ca
  1. 16
      clock.c

@ -53,6 +53,8 @@ push S for enable the second and T for enable the 12H hours format.\n");\
#define XLENGTH 5 #define XLENGTH 5
#define YLENGTH 52 #define YLENGTH 52
#define DEPTHB -1 #define DEPTHB -1
#define MAXW getmaxx(stdscr)
#define MAXH getmaxy(stdscr)
void start(void); void start(void);
void check_key(bool); void check_key(bool);
@ -118,8 +120,6 @@ date_t sdate;
char *meridiem; char *meridiem;
int SCHANGE = 19; int SCHANGE = 19;
int maxcol;
int maxlin;
int temp_dp; int temp_dp;
int defx = 1; int defx = 1;
int defy = 1; int defy = 1;
@ -268,7 +268,7 @@ check_key(bool keylock)
case KEY_DOWN: case KEY_DOWN:
case 'j': case 'j':
case 'J': case 'J':
if(defx + XLENGTH + 2 < maxcol) if(defx + XLENGTH + 2 < MAXH)
++defx; ++defx;
clear(); clear();
break; break;
@ -282,7 +282,7 @@ check_key(bool keylock)
case KEY_RIGHT: case KEY_RIGHT:
case 'l': case 'l':
case 'L': case 'L':
if(defy + YLENGTH - SCHANGE + 1 < maxlin) if(defy + YLENGTH - SCHANGE + 1 < MAXW)
++defy; ++defy;
clear(); clear();
break; break;
@ -372,11 +372,9 @@ void
set_center(void) set_center(void)
{ {
start(); start();
maxcol = getmaxy(stdscr);
maxlin = getmaxx(stdscr);
defy = maxlin / 2 - SCHANGE + 3; defy = MAXW / 2 - ((YLENGTH - SCHANGE) / 2);
defx = maxcol / 2 - XLENGTH + 2; defx = MAXH / 2 - (XLENGTH / 2);
} }
/* *********** */ /* *********** */
@ -389,8 +387,6 @@ run(void)
arrange_clock(sdate.hour[0], sdate.hour[1], arrange_clock(sdate.hour[0], sdate.hour[1],
sdate.minute[0], sdate.minute[1], sdate.minute[0], sdate.minute[1],
sdate.second[0], sdate.second[1]); sdate.second[0], sdate.second[1]);
maxcol = getmaxy(stdscr);
maxlin = getmaxx(stdscr);
refresh(); refresh();
halfdelay(1); halfdelay(1);
} }

Loading…
Cancel
Save