mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-16 06:18:47 +02:00
Add support for turning reminders with "URL" info strings into hyperlinks if your terminal supports it.
Use the "z" flag with -c.
This commit is contained in:
@@ -102,6 +102,12 @@ flag also enables the use of the UNICODE "left-to-right" mark that
|
||||
can fix up formatting problems with right-to-left languages in the calendar
|
||||
display.
|
||||
.TP
|
||||
.B 'z'
|
||||
causes \fBRemind\fR to use escape sequences to turn reminders with a
|
||||
"URL" info string into hyperlinks. In order to work, your terminal
|
||||
must support the escape sequences documented at
|
||||
https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
|
||||
.TP
|
||||
.B 'c'
|
||||
causes \fBRemind\fR to use VT100 escape sequences to approximate
|
||||
SPECIAL COLOR reminders. Note that this flag is kept for
|
||||
|
||||
@@ -99,6 +99,9 @@ static struct line_drawing UTF8Drawing = {
|
||||
"\xe2\x94\x80"
|
||||
};
|
||||
|
||||
static char const *start_link = "\x1B]8;;";
|
||||
static char const *end_link = "\x1B]8;;\x1B\\";
|
||||
|
||||
static char *VT100Colors[2][2][2][2] /* [Br][R][G][B] */ = {
|
||||
{
|
||||
/*** DIM COLORS ***/
|
||||
@@ -301,6 +304,7 @@ static void WriteTopCalLine (void);
|
||||
static void WriteBottomCalLine (void);
|
||||
static void WriteIntermediateCalLine (void);
|
||||
static void WriteCalDays (void);
|
||||
static char const *get_url(TrigInfo *infos);
|
||||
|
||||
static int
|
||||
DayOf(int dse)
|
||||
@@ -1557,6 +1561,10 @@ static int WriteOneColLine(int col)
|
||||
int clamp = 1;
|
||||
int numwritten = 0;
|
||||
int d = ColToDay[col];
|
||||
char const *url = NULL;
|
||||
if (LinksInTerminal) {
|
||||
url = get_url(e->infos);
|
||||
}
|
||||
if (d && UseBGVTColors && bgcolor[d][0] != -1) {
|
||||
clamp = 0;
|
||||
}
|
||||
@@ -1605,6 +1613,10 @@ static int WriteOneColLine(int col)
|
||||
ColorizeEntry(e, clamp);
|
||||
}
|
||||
|
||||
if (LinksInTerminal && url) {
|
||||
printf("%s", start_link);
|
||||
printf("%s\x1B\\", url);
|
||||
}
|
||||
/* If we couldn't find a space char, print what we have. */
|
||||
if (!wspace) {
|
||||
for (ws = e->wc_pos; numwritten < ColSpaces; ws++) {
|
||||
@@ -1639,6 +1651,9 @@ static int WriteOneColLine(int col)
|
||||
}
|
||||
}
|
||||
|
||||
if (LinksInTerminal && url) {
|
||||
printf("%s", end_link);
|
||||
}
|
||||
/* Decolorize reminder if necessary, but keep any SHADE */
|
||||
if (UseVTColors && e->is_color) {
|
||||
printf("%s", Decolorize());
|
||||
@@ -2462,6 +2477,30 @@ void WriteJSONTimeTrigger(TimeTrig const *tt)
|
||||
}
|
||||
}
|
||||
|
||||
static char const *
|
||||
get_url(TrigInfo *infos)
|
||||
{
|
||||
TrigInfo *ti = infos;
|
||||
char const *url;
|
||||
while (ti) {
|
||||
char const *colon = strchr(ti->info, ':');
|
||||
if (!colon) {
|
||||
ti = ti->next;
|
||||
continue;
|
||||
}
|
||||
if (!strncasecmp(ti->info, "url", colon-ti->info)) {
|
||||
url = colon+1;
|
||||
while (*url && isspace(*url)) {
|
||||
url++;
|
||||
}
|
||||
if (!*url) return NULL;
|
||||
return url;
|
||||
}
|
||||
ti = ti->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
WriteJSONInfoChain(TrigInfo *ti)
|
||||
{
|
||||
|
||||
@@ -106,6 +106,7 @@ EXTERN INIT( int DefaultPrio, NO_PRIORITY);
|
||||
EXTERN INIT( int SysTime, -1);
|
||||
EXTERN INIT( int LocalSysTime, -1);
|
||||
EXTERN INIT( int ParseUntriggered, 0);
|
||||
EXTERN INIT( int LinksInTerminal, 0);
|
||||
|
||||
EXTERN char const *InitialFile;
|
||||
EXTERN char const *LocalTimeZone;
|
||||
|
||||
@@ -519,6 +519,11 @@ void InitRemind(int argc, char const *argv[])
|
||||
arg++;
|
||||
continue;
|
||||
}
|
||||
if (*arg == 'z' || *arg == 'Z') {
|
||||
LinksInTerminal = 1;
|
||||
arg++;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (weeks) {
|
||||
|
||||
Reference in New Issue
Block a user