[refresh] Add round-high-priority.diff, refresh => API 41-42
* add round-high-priority.diff
* refresh patches according to changes in upstream
* API version bump - 41-42
# HG changeset patch
# Parent f6642109fbfb5029d85f3f7c4dc9d93e100d607a
[experimental] Allow user to modify time formatting
* give user full control and full responsibility
* add time_prefix = 3, that uses
* time_format (normal prefix format string)
* time_format_special (special prefix format string)
* time_prefix_len (normal prefix width + 5)
* fall back to 0, if any of these unset
diff -r f6642109fbfb mcabber/mcabber/screen.c
--- a/mcabber/mcabber/screen.c Thu Oct 18 00:00:46 2012 +0300
+++ b/mcabber/mcabber/screen.c Thu Oct 18 01:49:44 2012 +0300
@@ -853,38 +853,100 @@
static const char *timeprefixes[] = {
"%m-%d %H:%M ",
"%H:%M ",
- " "
+ " ",
+ NULL,
};
static const char *spectimeprefixes[] = {
"%m-%d %H:%M:%S ",
"%H:%M:%S ",
- " "
+ " ",
+ NULL,
};
static int timepreflengths[] = {
// (length of the corresponding timeprefix + 5)
17,
11,
- 6
+ 6,
+ 0,
};
+/*
+static struct {
+ char format;
+ unsigned short len;
+} timeprefix_characters[] = {
+ { 'C', 2 },
+ { 'd', 2 },
+ { 'D', 10 },
+ { 'e', 2 },
+ { 'F', 10 },
+ { 'G', 4 },
+ { 'g', 2 },
+ { 'H', 2 },
+ { 'I', 2 },
+ { 'j', 3 },
+ { 'k', 2 },
+ { 'l', 2 },
+ { 'm', 2 },
+ { 'M', 2 },
+ { 'p', 2 }, // ? locale-dependent, can set LC_CTIME=C?
+ { 'P', 2 }, // ?
+ { 'R', 5 },
+ { 'S', 2 },
+ { 'T', 8 },
+ { 'u', 1 },
+ { 'U', 2 },
+ { 'V', 2 },
+ { 'w', 1 },
+ { 'W', 2 },
+ { 'y', 2 },
+ { 'Y', 4 },
+ { 'z', 5 },
+ { '%', 1 },
+ { '\0', 0 }, // end marker
+};
+*/
+
+static guint gettprefixnum (void)
+{
+ guint n = settings_opt_get_int ("time_prefix");
+ static gboolean initialized = FALSE;
+ if (n < 3)
+ return n;
+ if (n > 3)
+ return 0;
+ if (!initialized) {
+ const char *tp = settings_opt_get ("time_format");
+ const char *stp = settings_opt_get ("time_format_special");
+ guint tpl = settings_opt_get_int ("time_prefix_len");
+ if (!tp || !*tp || !stp || !*stp || tpl < 6) {
+ tp = timeprefixes[0];
+ stp = spectimeprefixes[0];
+ tpl = timepreflengths[0];
+ }
+ timeprefixes[3] = g_strdup (tp);
+ spectimeprefixes[3] = g_strdup (stp);
+ timepreflengths[3] = tpl;
+ initialized = TRUE;
+ }
+ return 3;
+}
+
static const char *gettprefix(void)
{
- guint n = settings_opt_get_int("time_prefix");
- return timeprefixes[(n < 3 ? n : 0)];
+ return timeprefixes[gettprefixnum()];
}
static const char *getspectprefix(void)
{
- guint n = settings_opt_get_int("time_prefix");
- return spectimeprefixes[(n < 3 ? n : 0)];
+ return spectimeprefixes[gettprefixnum()];
}
guint scr_getprefixwidth(void)
{
- guint n = settings_opt_get_int("time_prefix");
- return timepreflengths[(n < 3 ? n : 0)];
+ return timepreflengths[gettprefixnum()];
}
guint scr_gettextwidth(void)