Include banner in --json output.

This commit is contained in:
Dianne Skoll
2025-08-11 20:47:00 -04:00
parent cb5fa62022
commit 1b5d34e5e6
2 changed files with 30 additions and 15 deletions

View File

@@ -753,6 +753,8 @@ proc CreateCalWindow { dayNames } {
button .b.quit -text {Quit} -command {Quit} -bd 0 -foreground $Option(LabelColor) -background $Option(WinBackground) -highlightthickness 1 -highlightcolor $Option(LineColor) -highlightbackground $Option(WinBackground)
balloon_add_help .b.quit "Quit TkRemind"
label .b.status -text "" -width 25 -relief flat -bd 0 -foreground $Option(LabelColor) -background $Option(WinBackground) -highlightthickness 0
bind .b.status <ButtonPress-1> [list ShowTodaysReminders 1]
balloon_add_help .b.status "Show Today's Reminders"
label .b.nqueued -text "" -width 20 -relief flat -bd 0 -foreground $Option(LabelColor) -background $Option(WinBackground) -highlightthickness 0
pack .b.prev .b.this .b.next .b.goto .b.print .b.options .b.queue .b.quit -side left -fill both -padx 1
pack .b.status -side left -fill both -expand 1 -padx 1
@@ -3014,7 +3016,7 @@ proc DaemonReadable { file } {
catch { unset Ignore }
Initialize
FillCalWindow
ShowTodaysReminders
ShowTodaysReminders 0
}
"reread" {
if {[dict exists $obj command]} {
@@ -3212,7 +3214,7 @@ proc main {} {
}
FindConfigFile
LoadOptions
ShowTodaysReminders
ShowTodaysReminders 0
ScanForTags $AppendFile
CreateCalWindow $DayNames
FillCalWindow
@@ -4243,18 +4245,18 @@ proc DisplayTimeContinuously {} {
#***********************************************************************
# %PROCEDURE: ShowTodaysReminders
# %ARGUMENTS:
# None
# force -- if true, show today's reminders even if option is disabled.
# %RETURNS:
# Nothing
# %DESCRIPTION:
# Shows all of today's non-timed reminders in a window
#***********************************************************************
proc ShowTodaysReminders {} {
proc ShowTodaysReminders { force } {
global Option
global Remind
global ReminderFile
global TwentyFourHourMode
if {!$Option(ShowTodaysReminders)} {
if {!$force && !$Option(ShowTodaysReminders)} {
return
}

View File

@@ -32,6 +32,18 @@ static int ParseUntil (ParsePtr s, Trigger *t, int type);
static int ShouldTriggerBasedOnWarn (Trigger const *t, int dse, int *err);
static int ComputeTrigDuration(TimeTrig const *t);
static void remove_trailing_newlines(DynamicBuffer *buf)
{
char *s = (char *) DBufValue(buf) + DBufLen(buf) - 1;
while (s >= DBufValue(buf)) {
if (*s == '\n') {
*s = 0;
s--;
} else {
break;
}
}
}
static int todo_filtered(Trigger const *t)
{
if (t->is_todo && TodoFilter == ONLY_EVENTS) return 1;
@@ -409,7 +421,6 @@ int DoRem(ParsePtr p)
if (JSONMode) {
DynamicBuffer body;
int y, m, d;
char *s;
int if_depth = get_if_pointer() - get_base_if_pointer();
DBufInit(&body);
int red=-1, green=-1, blue=-1;
@@ -419,15 +430,8 @@ int DoRem(ParsePtr p)
return r;
}
/* Remove trailing newlines from body */
s = (char *) DBufValue(&body) + DBufLen(&body) - 1;
while (s >= DBufValue(&body)) {
if (*s == '\n') {
*s = 0;
s--;
} else {
break;
}
}
remove_trailing_newlines(&body);
if (!*DBufValue(&body)) {
FreeTrig(&trig);
return r;
@@ -1363,6 +1367,15 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig const *tim, int dse, int is
DBufLen(&buf)) {
if (!JSONMode) {
printf("%s\n", DBufValue(&buf));
} else {
if (JSONLinesEmitted) {
printf("},\n");
}
JSONLinesEmitted++;
printf("{\"banner\":\"");
remove_trailing_newlines(&buf);
PrintJSONString(DBufValue(&buf));
printf("\"");
}
}
DBufFree(&buf);