Formatting: clean up indentation

This commit is contained in:
Morgan Aldridge 2020-03-07 11:46:51 -05:00
parent ca8f15da73
commit 67f6bf5d9a

265
mlclock.c
View File

@ -82,7 +82,7 @@ int main(int argc, char **argv) {
if ( !strcmp("-display", argv[i]) ) { if ( !strcmp("-display", argv[i]) ) {
i++; i++;
if ( argc >= argc ) if ( argc >= argc )
usage(argv[0]); usage(argv[0]);
strcpy(str, argv[i]); strcpy(str, argv[i]);
break; break;
} }
@ -139,7 +139,8 @@ int main(int argc, char **argv) {
xcol.blue = Color[i][2]; xcol.blue = Color[i][2];
if ( XAllocColor(dpy, cmap, &xcol) ) if ( XAllocColor(dpy, cmap, &xcol) )
iro[i] = xcol.pixel; iro[i] = xcol.pixel;
else fprintf(stderr,"Can't allocate Color \n"); else
fprintf(stderr,"Can't allocate Color \n");
} }
win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy),
@ -169,43 +170,41 @@ int main(int argc, char **argv) {
if ( Mode == FOCUS ) { if ( Mode == FOCUS ) {
XQueryPointer(dpy, win, &root, &child, &rootx, &rooty, &wx, &wy, &key); XQueryPointer(dpy, win, &root, &child, &rootx, &rooty, &wx, &wy, &key);
if ( (-Near < wx) && (wx < width + Near) && if ( (-Near < wx) && (wx < width + Near) &&
(-Near < wy) && (wy < height + Near + Head) ) (-Near < wy) && (wy < height + Near + Head) )
form = Form2;
else
form = Form1; }
else
if ( Mode == CLICK ) {
if ( XEventsQueued(dpy, QueuedAfterFlush) ) {
XNextEvent(dpy, &eve);
if ( eve.type == ButtonRelease ) {
if ( !sw ) {
sw = True;
lsec = tmm->tm_sec;
form = Form2; form = Form2;
} else
else {
sw = False;
form = Form1; form = Form1;
} else if ( Mode == CLICK ) {
if ( XEventsQueued(dpy, QueuedAfterFlush) ) {
XNextEvent(dpy, &eve);
if ( eve.type == ButtonRelease ) {
if ( !sw ) {
sw = True;
lsec = tmm->tm_sec;
form = Form2;
} else {
sw = False;
form = Form1;
}
}
} }
}
} if ( sw ) {
if ( tmm->tm_sec < lsec )
if ( sw ) { tmm->tm_sec += 60;
if ( tmm->tm_sec < lsec ) if ( tmm->tm_sec > lsec + 2 ) {
tmm->tm_sec += 60; sw = False;
if ( tmm->tm_sec > lsec + 2 ) { form = Form1;
sw = False; }
form = Form1; }
} }
}
}
strftime(str, sizeof(str), form, tmm); strftime(str, sizeof(str), form, tmm);
if ( strcmp(str, str2) ) { if ( strcmp(str, str2) ) {
XClearWindow(dpy, win); XClearWindow(dpy, win);
XmbDrawString(dpy, win, fs, gc, 1, - uhead + Head + 1, str, strlen(str)); XmbDrawString(dpy, win, fs, gc, 1, - uhead + Head + 1, str, strlen(str));
if ( Bold ) if ( Bold )
XmbDrawString(dpy, win, fs, gc, 2, - uhead + Head + 1, str, strlen(str)); XmbDrawString(dpy, win, fs, gc, 2, - uhead + Head + 1, str, strlen(str));
XSync(dpy, 0); XSync(dpy, 0);
strcpy(str2, str); strcpy(str2, str);
} }
@ -214,8 +213,7 @@ int main(int argc, char **argv) {
return 0; return 0;
} }
void SetFont(char *localename, Display *dpy, char *fsname) void SetFont(char *localename, Display *dpy, char *fsname) {
{
char **miss, *def; char **miss, *def;
int nMiss; int nMiss;
@ -238,7 +236,7 @@ void readrc() {
FILE *file; FILE *file;
struct _name N[] ={ struct _name N[] = {
{ "FORM1", 1 }, { "FORM1", 1 },
{ "FORM2", 2 }, { "FORM2", 2 },
{ "NEAR", 3 }, { "NEAR", 3 },
@ -249,7 +247,8 @@ void readrc() {
{ "FONTCOLOR", 8 }, { "FONTCOLOR", 8 },
{ "BACKCOLOR", 9 }, { "BACKCOLOR", 9 },
{ "BOLD", 10 }, { "BOLD", 10 },
{ "", 0 }}; { "", 0 }
};
Mode = Near = Head = NONE; Mode = Near = Head = NONE;
@ -269,7 +268,7 @@ void readrc() {
if ( (file = fopen(RCFile, "a")) == NULL ) if ( (file = fopen(RCFile, "a")) == NULL )
fprintf(stderr, "You can't make rc file in your own dirctory.\n"); fprintf(stderr, "You can't make rc file in your own dirctory.\n");
else{ else {
fprintf(file, "FORM1 = \"(%%a)%%l:%%M:%%S%%p\"\n"); fprintf(file, "FORM1 = \"(%%a)%%l:%%M:%%S%%p\"\n");
fprintf(file, "FORM2 = \"(%%a)%%b-%%d\"\n"); fprintf(file, "FORM2 = \"(%%a)%%b-%%d\"\n");
fprintf(file, "EVENT = FOCUS ; FOCUS or CLICK\n"); fprintf(file, "EVENT = FOCUS ; FOCUS or CLICK\n");
@ -283,112 +282,112 @@ void readrc() {
fclose(file); fclose(file);
fprintf(stderr, "Created %s file.\n", RCFile); fprintf(stderr, "Created %s file.\n", RCFile);
} }
} } else {
else while ( fgets(string, 500, file) ) {
while ( fgets(string, 500, file) ) { end = FALSE;
end = FALSE; i = 0;
i = 0; sw1 = False;
sw1 = False; while ( string[i] != ';' && string[i] != '\0' && string[i] != '\n' ) {
while ( string[i] != ';' && string[i] != '\0' && string[i] != '\n' ) { if ( string[i] == '=' && sw1 == False ) {
if ( string[i] == '=' && sw1 == False ) { string[i] = ' ';
string[i] = ' '; sw1 = True;
sw1 = True; }
work[i] = string[i];
i++;
} }
work[i] = string[i]; work[i] = '\0';
i++;
}
work[i] = '\0';
if ( sw1 == False ) if ( sw1 == False )
continue; continue;
code[0] = '\0'; code[0] = '\0';
data[0] = '\0'; data[0] = '\0';
sscanf(work, "%s %s", code, data); sscanf(work, "%s %s", code, data);
if ( code[0] == '\0' ) if ( code[0] == '\0' )
continue; continue;
i = 0; i = 0;
while ( True ) { while ( True ) {
if ( N[i].name[0] == '\0' ) { if ( N[i].name[0] == '\0' ) {
cn = 0; cn = 0;
break; break;
}
if ( !strcmp(N[i].name, code) ) {
cn = N[i].sw;
break;
}
i++;
} }
if ( !strcmp(N[i].name, code) ) {
cn = N[i].sw;
break;
}
i++;
}
switch ( cn ) { switch ( cn ) {
case 1: case 1:
len = strlen(data); len = strlen(data);
Form1 = malloc(len); Form1 = malloc(len);
strcpy(Form1, &data[1]); strcpy(Form1, &data[1]);
Form1[len-2] = '\0'; Form1[len-2] = '\0';
break; break;
case 2: case 2:
len = strlen(data); len = strlen(data);
Form2 = malloc(len); Form2 = malloc(len);
strcpy(Form2, &data[1]); strcpy(Form2, &data[1]);
Form2[len-2] = '\0'; Form2[len-2] = '\0';
break; break;
case 3: case 3:
Near = atoi(data); Near = atoi(data);
break; break;
case 4: case 4:
if ( !strcmp(data, "FOCUS") ) { if ( !strcmp(data, "FOCUS") ) {
Mode = FOCUS; Mode = FOCUS;
break; break;
}
if ( !strcmp(data, "CLICK") ) {
Mode = CLICK;
break;
}
break;
case 5:
len = strlen(data);
LocaleName = malloc(len);
strcpy(LocaleName, &data[1]);
LocaleName[len-2] = '\0';
break;
case 6:
len = strlen(data);
FSName = malloc(len);
strcpy(FSName, &data[1]);
FSName[len-2] = '\0';
break;
case 7:
Head = atoi(data);
break;
case 8:
len = strlen(data);
fore = malloc(len);
strcpy(fore, &data[1]);
fore[len-2] = '\0';
getRGB(fore, Color[0]);
break;
case 9:
len = strlen(data);
back = malloc(len);
strcpy(back, &data[1]);
back[len-2] = '\0';
getRGB(back, Color[1]);
break;
case 10:
if ( !strcmp(data, "TRUE") ) {
Bold = True;
break;
}
if ( !strcmp(data, "FALSE") ) {
Bold = False;
break;
}
break;
default:
break;
} }
if ( !strcmp(data, "CLICK") ) {
Mode = CLICK;
break;
}
break;
case 5:
len = strlen(data);
LocaleName = malloc(len);
strcpy(LocaleName, &data[1]);
LocaleName[len-2] = '\0';
break;
case 6:
len = strlen(data);
FSName = malloc(len);
strcpy(FSName, &data[1]);
FSName[len-2] = '\0';
break;
case 7:
Head = atoi(data);
break;
case 8:
len = strlen(data);
fore = malloc(len);
strcpy(fore, &data[1]);
fore[len-2] = '\0';
getRGB(fore, Color[0]);
break;
case 9:
len = strlen(data);
back = malloc(len);
strcpy(back, &data[1]);
back[len-2] = '\0';
getRGB(back, Color[1]);
break;
case 10:
if ( !strcmp(data, "TRUE") ) {
Bold = True;
break;
}
if ( !strcmp(data, "FALSE") ) {
Bold = False;
break;
}
break;
default:
break;
} }
} }