mirror of
https://git.freebsd.org/src.git
synced 2026-01-11 19:57:22 +00:00
ncal: make -h toggle highlighting of today.
This commit is contained in:
parent
d4eb2d3f30
commit
49224311fe
2 changed files with 8 additions and 9 deletions
|
|
@ -79,7 +79,8 @@ the current month is displayed.
|
|||
The options are as follows:
|
||||
.Bl -tag -width indent
|
||||
.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
|
||||
Display Julian Calendar, if combined with the
|
||||
.Fl e
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
" 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 nswitch; /* user defined switch date */
|
||||
static int nswitchb; /* switch date for backward compatibility */
|
||||
|
|
@ -216,7 +216,7 @@ main(int argc, char *argv[])
|
|||
int before, after;
|
||||
const char *locale; /* locale to get country code */
|
||||
|
||||
flag_nohighlight = 0;
|
||||
flag_highlight = isatty(STDOUT_FILENO);
|
||||
flag_weeks = 0;
|
||||
flag_monday = false;
|
||||
|
||||
|
|
@ -299,7 +299,7 @@ main(int argc, char *argv[])
|
|||
flag_highlightdate = optarg;
|
||||
break;
|
||||
case 'h':
|
||||
flag_nohighlight = 1;
|
||||
flag_highlight = !flag_highlight;
|
||||
break;
|
||||
case 'e':
|
||||
if (flag_backward)
|
||||
|
|
@ -834,8 +834,7 @@ mkmonthr(int y, int m, int jd_flag, struct monthlines *mlines)
|
|||
dt.d = j - jan1 + 1;
|
||||
else
|
||||
sdater(j, &dt);
|
||||
if (j == highlightdate && !flag_nohighlight
|
||||
&& isatty(STDOUT_FILENO))
|
||||
if (j == highlightdate && flag_highlight)
|
||||
highlight(mlines->lines[i] + k,
|
||||
ds + dt.d * dw, dw, &l);
|
||||
else
|
||||
|
|
@ -942,8 +941,7 @@ mkmonthb(int y, int m, int jd_flag, struct monthlines *mlines)
|
|||
dt.d = j - jan1 + 1;
|
||||
else
|
||||
sdateb(j, &dt);
|
||||
if (j == highlightdate && !flag_nohighlight
|
||||
&& isatty(STDOUT_FILENO))
|
||||
if (j == highlightdate && flag_highlight)
|
||||
highlight(mlines->lines[i] + k,
|
||||
ds + dt.d * dw, dw, &l);
|
||||
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 function.
|
||||
*/
|
||||
if (flag_nohighlight) {
|
||||
if (!flag_highlight) {
|
||||
memcpy(dst, src, len);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue