mirror of
https://git.savannah.gnu.org/git/screen.git
synced 2026-02-10 09:22:04 +02:00
Regression bugfix: harstatus string fails to display date & time
bug #66003 Signed-off-by: Alexander Naumov <alexander_naumov@opensuse.org>
This commit is contained in:
@@ -4050,6 +4050,20 @@ is used instead.
|
||||
Here is the full list of supported escapes:
|
||||
.IP %
|
||||
the escape character itself
|
||||
.IP A
|
||||
AM or PM. 'AM' stands for the Latin 'ante meridiem', translating to
|
||||
"before midday". This is the time before noon. 'PM' stands for post
|
||||
meridiem or 'after midday' – the time after noon.
|
||||
.IP a
|
||||
the same as 'A', but written in small letters: 'am' or 'pm'.
|
||||
.IP C
|
||||
12 hours time format like 1:48
|
||||
.IP c
|
||||
the same like 'C', but uses 24 hours time format (for example, 13:48)
|
||||
.IP D
|
||||
day of the week (for example, Mon, Wed, Fri)
|
||||
.IP d
|
||||
day of the month (number).
|
||||
.IP E
|
||||
sets %? to true if the escape character has been pressed.
|
||||
.IP e
|
||||
@@ -4064,6 +4078,10 @@ hardstatus of the window
|
||||
hostname of the system
|
||||
.IP O
|
||||
The count of screen windows. Prefix with '-' to limit to current window group.
|
||||
.IP M
|
||||
name of the month (for example, Aug, Dec)
|
||||
.IP m
|
||||
month of the year (number)
|
||||
.IP n
|
||||
window number
|
||||
.IP P
|
||||
@@ -4086,6 +4104,10 @@ all window numbers and names except the current one
|
||||
the executed command including arguments running in this windows
|
||||
.IP X
|
||||
the executed command without arguments running in this windows
|
||||
.IP Y
|
||||
year (four numbers like '2024')
|
||||
.IP y
|
||||
last two year's number (for example, '24')
|
||||
.IP ?
|
||||
the part to the next '%?' is displayed only if a '%' escape
|
||||
inside the part expands to a non-empty string
|
||||
|
||||
123
src/winmsg.c
123
src/winmsg.c
@@ -1,4 +1,6 @@
|
||||
/* Copyright (c) 2013
|
||||
/* Copyrigth (c) 2024
|
||||
* Alexander Naumov (alexander_naumov@opensuse.org)
|
||||
* Copyright (c) 2013
|
||||
* Mike Gerwitz (mtg@gnu.org)
|
||||
* Copyright (c) 2010
|
||||
* Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
|
||||
@@ -53,6 +55,11 @@ WinMsgBuf *g_winmsg;
|
||||
/* maximum limit on MakeWinMsgEv recursion */
|
||||
#define WINMSG_RECLIMIT 10
|
||||
|
||||
#ifndef USE_LOCALE
|
||||
static const char days[] = "SunMonTueWedThuFriSat";
|
||||
static const char months[] = "JanFebMarAprMayJunJulAugSepOctNovDec";
|
||||
#endif
|
||||
|
||||
/* escape char for backtick output */
|
||||
#define WINMSG_BT_ESC '\005'
|
||||
|
||||
@@ -406,6 +413,75 @@ winmsg_esc_ex(WinArgv, Window *win)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
__WinMsgEscEsc_YEAR(WinMsgBufContext *wmbc, struct tm *tm)
|
||||
{
|
||||
wmbc_printf(wmbc, "%04d", tm->tm_year + 1900);
|
||||
}
|
||||
|
||||
static void
|
||||
__WinMsgEscEsc_year(WinMsgBufContext *wmbc, struct tm *tm)
|
||||
{
|
||||
wmbc_printf(wmbc, "%02d", tm->tm_year % 100);
|
||||
}
|
||||
|
||||
static void
|
||||
__WinMsgEscEsc_MONTH(WinMsgBufContext *wmbc, struct tm *tm)
|
||||
{
|
||||
#ifdef USE_LOCALE
|
||||
strftime(wmbc, l, (longflg ? "%B" : "%b"), tm);
|
||||
#else
|
||||
wmbc_printf(wmbc, "%3.3s", months + 3 * tm->tm_mon);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
__WinMsgEscEsc_month(WinMsgBufContext *wmbc, struct tm *tm)
|
||||
{
|
||||
wmbc_printf(wmbc, "%02d", tm->tm_mon + 1);
|
||||
}
|
||||
|
||||
static void
|
||||
__WinMsgEscEsc_DAY(WinMsgBufContext *wmbc, struct tm *tm)
|
||||
{
|
||||
#ifdef USE_LOCALE
|
||||
strftime(wmbc, l, (longflg ? "%A" : "%a"), tm);
|
||||
#else
|
||||
wmbc_printf(wmbc, "%3.3s", days + 3 * tm->tm_wday);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
__WinMsgEscEsc_day(WinMsgBufContext *wmbc, struct tm *tm)
|
||||
{
|
||||
wmbc_printf(wmbc, "%02d", tm->tm_mday % 100);
|
||||
}
|
||||
|
||||
static void
|
||||
__WinMsgEscEsc_HOUR(WinMsgBufContext *wmbc, struct tm *tm)
|
||||
{
|
||||
wmbc_printf(wmbc, tm->tm_hour >= 12 ? "PM" : "AM");
|
||||
}
|
||||
|
||||
static void
|
||||
__WinMsgEscEsc_hour(WinMsgBufContext *wmbc, struct tm *tm)
|
||||
{
|
||||
wmbc_printf(wmbc, tm->tm_hour >= 12 ? "pm" : "am");
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
__WinMsgEscEsc_TIME(WinMsgBufContext *wmbc, struct tm *tm, WinMsgEsc esc)
|
||||
{
|
||||
wmbc_printf(wmbc, esc.flags.zero ? "%02d:%02d" : "%2d:%02d", (tm->tm_hour + 11) % 12 + 1, tm->tm_min);
|
||||
}
|
||||
|
||||
static void
|
||||
__WinMsgEscEsc_time(WinMsgBufContext *wmbc, struct tm *tm, WinMsgEsc esc)
|
||||
{
|
||||
wmbc_printf(wmbc, esc.flags.zero ? "%02d:%02d" : "%2d:%02d", tm->tm_hour, tm->tm_min);
|
||||
}
|
||||
|
||||
winmsg_esc_ex(WinNum, Window *win)
|
||||
{
|
||||
if (esc->num == 0)
|
||||
@@ -548,7 +624,6 @@ char *MakeWinMsgEv(WinMsgBuf *winmsg, char *str, Window *win,
|
||||
int chesc, int padlen, Event *ev, int rec)
|
||||
{
|
||||
static int tick;
|
||||
struct timeval now;
|
||||
int qmnumrend = 0;
|
||||
int numpad = 0;
|
||||
int lastpad = 0;
|
||||
@@ -556,6 +631,13 @@ char *MakeWinMsgEv(WinMsgBuf *winmsg, char *str, Window *win,
|
||||
WinMsgEsc esc;
|
||||
WinMsgCond *cond;
|
||||
|
||||
struct tm *tm;
|
||||
struct timeval now;
|
||||
tm = 0;
|
||||
gettimeofday(&now, NULL);
|
||||
time_t nowsec = now.tv_sec;
|
||||
tm = localtime(&nowsec);
|
||||
|
||||
/* TODO: temporary to work into existing code */
|
||||
if (winmsg == NULL) {
|
||||
if (g_winmsg == NULL) {
|
||||
@@ -615,7 +697,44 @@ char *MakeWinMsgEv(WinMsgBuf *winmsg, char *str, Window *win,
|
||||
if ((esc.flags.lng = (*s == 'L')) != 0)
|
||||
s++;
|
||||
|
||||
if (!tick || tick > 3600)
|
||||
tick = 3600;
|
||||
|
||||
switch (*s) {
|
||||
case WINESC_TIME:
|
||||
__WinMsgEscEsc_TIME(wmbc, tm, esc);
|
||||
if (!tick || tick > 60)
|
||||
tick = 60;
|
||||
break;
|
||||
case WINESC_time:
|
||||
__WinMsgEscEsc_time(wmbc, tm, esc);
|
||||
if (!tick || tick > 60)
|
||||
tick = 60;
|
||||
break;
|
||||
case WINESC_HOUR:
|
||||
__WinMsgEscEsc_HOUR(wmbc, tm);
|
||||
break;
|
||||
case WINESC_hour:
|
||||
__WinMsgEscEsc_hour(wmbc, tm);
|
||||
break;
|
||||
case WINESC_DAY:
|
||||
__WinMsgEscEsc_DAY(wmbc, tm);
|
||||
break;
|
||||
case WINESC_day:
|
||||
__WinMsgEscEsc_day(wmbc, tm);
|
||||
break;
|
||||
case WINESC_MONTH:
|
||||
__WinMsgEscEsc_MONTH(wmbc, tm);
|
||||
break;
|
||||
case WINESC_month:
|
||||
__WinMsgEscEsc_month(wmbc, tm);
|
||||
break;
|
||||
case WINESC_YEAR:
|
||||
__WinMsgEscEsc_YEAR(wmbc, tm);
|
||||
break;
|
||||
case WINESC_year:
|
||||
__WinMsgEscEsc_year(wmbc, tm);
|
||||
break;
|
||||
case WINESC_COND:
|
||||
WinMsgDoEscEx(Cond, &qmnumrend);
|
||||
break;
|
||||
|
||||
14
src/winmsg.h
14
src/winmsg.h
@@ -1,4 +1,6 @@
|
||||
/* Copyright (c) 2013
|
||||
/* Copyrigth (c) 2024
|
||||
* Alexander Naumov (alexander_naumov@opensuse.org)
|
||||
* Copyright (c) 2013
|
||||
* Mike Gerwitz (mtg@gnu.org)
|
||||
* Copyright (c) 2010
|
||||
* Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
|
||||
@@ -46,12 +48,20 @@
|
||||
|
||||
/* escape characters (alphabetical order) */
|
||||
typedef enum {
|
||||
WINESC_TIME = 'C',
|
||||
WINESC_time = 'c',
|
||||
WINESC_HOUR = 'A',
|
||||
WINESC_hour = 'a',
|
||||
WINESC_DAY = 'D',
|
||||
WINESC_day = 'd',
|
||||
WINESC_ESC_SEEN = 'E',
|
||||
WINESC_FOCUS = 'F',
|
||||
WINESC_WFLAGS = 'f',
|
||||
WINESC_WIN_GROUP = 'g',
|
||||
WINESC_HOST = 'H',
|
||||
WINESC_HSTATUS = 'h',
|
||||
WINESC_MONTH = 'M',
|
||||
WINESC_month = 'm',
|
||||
WINESC_WIN_LOGNAME = 'N',
|
||||
WINESC_WIN_NUM = 'n',
|
||||
WINESC_WIN_COUNT = 'O',
|
||||
@@ -65,6 +75,8 @@ typedef enum {
|
||||
WINESC_WIN_NAMES = 'w',
|
||||
WINESC_CMD = 'X',
|
||||
WINESC_CMD_ARGS = 'x',
|
||||
WINESC_YEAR = 'Y',
|
||||
WINESC_year = 'y',
|
||||
WINESC_REND_START = '{',
|
||||
WINESC_REND_END = '}',
|
||||
WINESC_REND_POP = '-',
|
||||
|
||||
Reference in New Issue
Block a user