ncal: make -h toggle highlighting of today.
This commit is contained in:
+2
-1
@@ -79,7 +79,8 @@ the current month is displayed.
|
|||||||
The options are as follows:
|
The options are as follows:
|
||||||
.Bl -tag -width indent
|
.Bl -tag -width indent
|
||||||
.It Fl h
|
.It Fl h
|
||||||
Turns off highlighting of today.
|
Toggle highlighting of today.
|
||||||
|
By default highlighting is enabled if stdout is a TTY.
|
||||||
.It Fl J
|
.It Fl J
|
||||||
Display Julian Calendar, if combined with the
|
Display Julian Calendar, if combined with the
|
||||||
.Fl e
|
.Fl e
|
||||||
|
|||||||
+6
-8
@@ -158,7 +158,7 @@ static char jdaystr[] = " 1 2 3 4 5 6 7 8 9"
|
|||||||
" 350 351 352 353 354 355 356 357 358 359"
|
" 350 351 352 353 354 355 356 357 358 359"
|
||||||
" 360 361 362 363 364 365 366";
|
" 360 361 362 363 364 365 366";
|
||||||
|
|
||||||
static int flag_nohighlight; /* user doesn't want a highlighted today */
|
static int flag_highlight; /* highlighted today */
|
||||||
static int flag_weeks; /* user wants number of week */
|
static int flag_weeks; /* user wants number of week */
|
||||||
static int nswitch; /* user defined switch date */
|
static int nswitch; /* user defined switch date */
|
||||||
static int nswitchb; /* switch date for backward compatibility */
|
static int nswitchb; /* switch date for backward compatibility */
|
||||||
@@ -216,7 +216,7 @@ main(int argc, char *argv[])
|
|||||||
int before, after;
|
int before, after;
|
||||||
const char *locale; /* locale to get country code */
|
const char *locale; /* locale to get country code */
|
||||||
|
|
||||||
flag_nohighlight = 0;
|
flag_highlight = isatty(STDOUT_FILENO);
|
||||||
flag_weeks = 0;
|
flag_weeks = 0;
|
||||||
flag_monday = false;
|
flag_monday = false;
|
||||||
|
|
||||||
@@ -299,7 +299,7 @@ main(int argc, char *argv[])
|
|||||||
flag_highlightdate = optarg;
|
flag_highlightdate = optarg;
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
flag_nohighlight = 1;
|
flag_highlight = !flag_highlight;
|
||||||
break;
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
if (flag_backward)
|
if (flag_backward)
|
||||||
@@ -834,8 +834,7 @@ mkmonthr(int y, int m, int jd_flag, struct monthlines *mlines)
|
|||||||
dt.d = j - jan1 + 1;
|
dt.d = j - jan1 + 1;
|
||||||
else
|
else
|
||||||
sdater(j, &dt);
|
sdater(j, &dt);
|
||||||
if (j == highlightdate && !flag_nohighlight
|
if (j == highlightdate && flag_highlight)
|
||||||
&& isatty(STDOUT_FILENO))
|
|
||||||
highlight(mlines->lines[i] + k,
|
highlight(mlines->lines[i] + k,
|
||||||
ds + dt.d * dw, dw, &l);
|
ds + dt.d * dw, dw, &l);
|
||||||
else
|
else
|
||||||
@@ -942,8 +941,7 @@ mkmonthb(int y, int m, int jd_flag, struct monthlines *mlines)
|
|||||||
dt.d = j - jan1 + 1;
|
dt.d = j - jan1 + 1;
|
||||||
else
|
else
|
||||||
sdateb(j, &dt);
|
sdateb(j, &dt);
|
||||||
if (j == highlightdate && !flag_nohighlight
|
if (j == highlightdate && flag_highlight)
|
||||||
&& isatty(STDOUT_FILENO))
|
|
||||||
highlight(mlines->lines[i] + k,
|
highlight(mlines->lines[i] + k,
|
||||||
ds + dt.d * dw, dw, &l);
|
ds + dt.d * dw, dw, &l);
|
||||||
else
|
else
|
||||||
@@ -1143,7 +1141,7 @@ highlight(char *dst, char *src, int len, int *extralen)
|
|||||||
* This check is not necessary, should have been handled before calling
|
* This check is not necessary, should have been handled before calling
|
||||||
* this function.
|
* this function.
|
||||||
*/
|
*/
|
||||||
if (flag_nohighlight) {
|
if (!flag_highlight) {
|
||||||
memcpy(dst, src, len);
|
memcpy(dst, src, len);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user