ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rclock.C
(Generate patch)

Comparing rxvt-unicode/src/rclock.C (file contents):
Revision 1.8 by sf-exg, Sun Nov 7 14:22:27 2021 UTC vs.
Revision 1.13 by root, Sat Dec 24 00:15:31 2022 UTC

39#include <X11/Xlib.h> 39#include <X11/Xlib.h>
40#include <X11/Xutil.h> 40#include <X11/Xutil.h>
41 41
42#include "ecb.h" 42#include "ecb.h"
43 43
44#include "version.h"
45
44#define APL_CLASS "Clock" 46#define APL_CLASS "Clock"
45#define APL_NAME "rclock" 47#define APL_NAME "rclock"
46#define MSG_CLASS "Appointment" 48#define MSG_CLASS "Appointment"
47#define MSG_NAME "Appointment" 49#define MSG_NAME "Appointment"
48#define CONFIG_FILE ".rclock" 50#define CONFIG_FILE ".rclock"
50#ifndef EXIT_SUCCESS /* missed from <stdlib.h> ? */ 52#ifndef EXIT_SUCCESS /* missed from <stdlib.h> ? */
51# define EXIT_SUCCESS 0 53# define EXIT_SUCCESS 0
52# define EXIT_FAILURE 1 54# define EXIT_FAILURE 1
53#endif 55#endif
54 56
55#define VERSION "TODO: fetch from urxvt somehow"
56
57/*--------------------------------*-C-*---------------------------------* 57/*--------------------------------*-C-*---------------------------------*
58 * Compile-time configuration. 58 * Compile-time configuration.
59 *----------------------------------------------------------------------* 59 *----------------------------------------------------------------------*
60 * Copyright (C) 1997 1998 mj olesen <olesen@me.QueensU.CA> 60 * Copyright (C) 1997 1998 mj olesen <olesen@me.QueensU.CA>
61 * 61 *
128 * to define the amount (minutes) to defer a message 128 * to define the amount (minutes) to defer a message
129 * 129 *
130 * #define ADJUST_TIME 130 * #define ADJUST_TIME
131 * to add -adjust command-line option 131 * to add -adjust command-line option
132 * 132 *
133 * #define CENTURY 2000 133 * #define CENTURY 1900
134 * to set the base century for 2 digit year short-hand 134 * to set the base century for 2 digit year short-hand
135 *----------------------------------------------------------------------*/ 135 *----------------------------------------------------------------------*/
136#define CLOCKUPDATE 30 136#define CLOCKUPDATE 30
137#define MAILUPDATE 60 137#define MAILUPDATE 60
138#define REMINDERS_TIME 10 138#define REMINDERS_TIME 10
139#define DEFER_TIME 3 139#define DEFER_TIME 3
140#define ADJUST_TIME 140#define ADJUST_TIME
141 141
142#define CENTURY 2000 /* TODO: verify */ 142#define CENTURY 1900
143 143
144/*----------------------------------------------------------------------* 144/*----------------------------------------------------------------------*
145 * #define FONT_NAME "7x14" 145 * #define FONT_NAME "7x14"
146 * to define the font to be used for appointment reminders 146 * to define the font to be used for appointment reminders
147 * 147 *
356# endif 356# endif
357#endif 357#endif
358 {"#geom", "icon window geometry"} 358 {"#geom", "icon window geometry"}
359 }; 359 };
360 360
361 fprintf (stderr, "\nUsage v" VERSION ":\n " APL_NAME " [options]\n\n" "where options include:\n"); 361 fprintf (stderr, "\nUsage for urclock version " VERSION "\n\n urclock [options]\n\n" "where options include:\n");
362 362
363 for (i = 0; i < (int)optList_size (); i++) 363 for (i = 0; i < (int)optList_size (); i++)
364 fprintf (stderr, " %-29s%s\n", optList[i].opt, optList[i].desc); 364 fprintf (stderr, " %-29s%s\n", optList[i].opt, optList[i].desc);
365} 365}
366 366
837#ifdef ICONWIN 837#ifdef ICONWIN
838 static hands_t HandsOld_icon = { -1 }; 838 static hands_t HandsOld_icon = { -1 };
839#endif 839#endif
840#ifdef REMINDERS 840#ifdef REMINDERS
841 static int lastUpdateTime = -10; 841 static int lastUpdateTime = -10;
842#endif
843#ifdef DATE_ON_CLOCK_FACE
844 static char clockdate[10];
842#endif 845#endif
843 846
844#ifdef MAIL 847#ifdef MAIL
845 static time_t mailTime = 0; 848 static time_t mailTime = 0;
846 static int MailUp = 0, MailUp_rvideo = 0; 849 static int MailUp = 0, MailUp_rvideo = 0;
908 911
909 savedDay = tmval->tm_yday; 912 savedDay = tmval->tm_yday;
910 strftime (str, sizeof (str), "%a %h %d", tmval); 913 strftime (str, sizeof (str), "%a %h %d", tmval);
911 XStoreName (Xdisplay, Clock.win, str); 914 XStoreName (Xdisplay, Clock.win, str);
912 XSetIconName (Xdisplay, Clock.win, str); 915 XSetIconName (Xdisplay, Clock.win, str);
913 }
914 916
917#if defined(REMINDERS) && defined(DATE_ON_CLOCK_FACE)
918 if (show_date)
919 {
920 strftime (clockdate, sizeof (clockdate), "%d", tmval);
921 full_redraw = 1;
922 }
923 }
924
925#endif
915 if (full_redraw) 926 if (full_redraw)
916 XClearWindow (Xdisplay, W->win); 927 XClearWindow (Xdisplay, W->win);
917 928
918#ifdef REMINDERS 929#ifdef REMINDERS
919 /* for a message window, just re-draw the message */ 930 /* for a message window, just re-draw the message */
940 Xgc, 951 Xgc,
941 (Msg.width - 952 (Msg.width -
942 XTextWidth (Xfont, beg, (end - beg))) / 2, 10 + Xfont->ascent + FontHeight () * lines, beg, (end - beg)); 953 XTextWidth (Xfont, beg, (end - beg))) / 2, 10 + Xfont->ascent + FontHeight () * lines, beg, (end - beg));
943 } 954 }
944 955
945 XDrawString (Xdisplay, msgButton.Dismiss, Xrvgc, (msgButton.width - XTextWidth (Xfont, "Done", 4)) / 2, Xfont->ascent + 2, "Done", 4); 956 XDrawString (Xdisplay, msgButton.Dismiss, Xrvgc, (msgButton.width - XTextWidth (Xfont, "Done" , 4)) / 2, Xfont->ascent + 2, "Done" , 4);
946 957
947 XDrawString (Xdisplay, msgButton.Defer, Xrvgc, (msgButton.width - XTextWidth (Xfont, "Defer", 5)) / 2, Xfont->ascent + 2, "Defer", 5); 958 XDrawString (Xdisplay, msgButton.Defer , Xrvgc, (msgButton.width - XTextWidth (Xfont, "Defer", 5)) / 2, Xfont->ascent + 2, "Defer", 5);
948 959
949# ifndef NO_REMINDER_EXEC 960# ifndef NO_REMINDER_EXEC
950 XDrawString (Xdisplay, msgButton.Start, Xrvgc, (msgButton.width - XTextWidth (Xfont, "Start", 5)) / 2, Xfont->ascent + 2, "Start", 5); 961 XDrawString (Xdisplay, msgButton.Start , Xrvgc, (msgButton.width - XTextWidth (Xfont, "Start", 5)) / 2, Xfont->ascent + 2, "Start", 5);
951 962
952 if (strlen (execPrgm) > 1) 963 if (strlen (execPrgm) > 1)
953 XMapWindow (Xdisplay, msgButton.Start); 964 XMapWindow (Xdisplay, msgButton.Start);
954 else 965 else
955 XUnmapWindow (Xdisplay, msgButton.Start); 966 XUnmapWindow (Xdisplay, msgButton.Start);
1031 1042
1032 /* 1043 /*
1033 * Draw the date in the lower half of the clock window. 1044 * Draw the date in the lower half of the clock window.
1034 * The code is enclosed in REMINDERS because it uses the same 1045 * The code is enclosed in REMINDERS because it uses the same
1035 * font as the reminders code. 1046 * font as the reminders code.
1036 * I believe this should be drawn always so it does not get
1037 * "swept away" by the minute hand.
1038 */ 1047 */
1039#if defined(REMINDERS) && defined(DATE_ON_CLOCK_FACE) 1048#if defined(REMINDERS) && defined(DATE_ON_CLOCK_FACE)
1040 if (show_date) 1049 if (show_date)
1041 {
1042 char date[10];
1043
1044 currentTime = time (NULL) + adjustTime; /* get the current time */
1045 tmval = localtime (&currentTime);
1046 strftime (date, sizeof (date), "%d", tmval);
1047 XDrawString (Xdisplay, W->win, X_gc, 1050 XDrawString (Xdisplay, W->win, X_gc,
1048 ctr_x - XTextWidth (Xfont, date, strlen (date)) / 2, 1051 ctr_x - XTextWidth (Xfont, clockdate, strlen (clockdate)) / 2,
1049 ctr_y + FontHeight () + (ctr_y - FontHeight ()) / 2, date, strlen (date)); 1052 ctr_y + FontHeight () + (ctr_y - FontHeight ()) / 2, clockdate, strlen (clockdate));
1050 }
1051#endif 1053#endif
1052 1054
1053 if (full_redraw) 1055 if (full_redraw)
1054 { 1056 {
1055 int mintick; 1057 int mintick;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines