Add win_print
This commit is contained in:
@@ -682,7 +682,7 @@ win_show_occupant(ProfWin *window, Occupant *occupant)
|
||||
|
||||
theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
|
||||
|
||||
win_printf(window, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", occupant->nick);
|
||||
win_print(window, presence_colour, '-', "%s", occupant->nick);
|
||||
win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str);
|
||||
|
||||
if (occupant->status) {
|
||||
@@ -704,9 +704,9 @@ win_show_contact(ProfWin *window, PContact contact)
|
||||
theme_item_t presence_colour = theme_main_presence_attrs(presence);
|
||||
|
||||
if (name) {
|
||||
win_printf(window, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", name);
|
||||
win_print(window, presence_colour, '-', "%s", name);
|
||||
} else {
|
||||
win_printf(window, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", barejid);
|
||||
win_print(window, presence_colour, '-', "%s", barejid);
|
||||
}
|
||||
|
||||
win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence);
|
||||
@@ -746,7 +746,7 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa
|
||||
|
||||
theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
|
||||
|
||||
win_printf(window, '!', 0, NULL, NO_EOL, presence_colour, "", "%s", occupant->nick);
|
||||
win_print(window, presence_colour, '!', "%s", occupant->nick);
|
||||
win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str);
|
||||
|
||||
if (occupant->status) {
|
||||
@@ -756,11 +756,11 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa
|
||||
win_newline(window);
|
||||
|
||||
if (occupant->jid) {
|
||||
win_printf_line(window, THEME_DEFAULT, '!', " Jid: %s", occupant->jid);
|
||||
win_println(window, THEME_DEFAULT, '!', " Jid: %s", occupant->jid);
|
||||
}
|
||||
|
||||
win_printf_line(window, THEME_DEFAULT, '!', " Affiliation: %s", occupant_affiliation);
|
||||
win_printf_line(window, THEME_DEFAULT, '!', " Role: %s", occupant_role);
|
||||
win_println(window, THEME_DEFAULT, '!', " Affiliation: %s", occupant_affiliation);
|
||||
win_println(window, THEME_DEFAULT, '!', " Role: %s", occupant_role);
|
||||
|
||||
Jid *jidp = jid_create_from_bare_and_resource(room, occupant->nick);
|
||||
EntityCapabilities *caps = caps_lookup(jidp->fulljid);
|
||||
@@ -770,7 +770,7 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa
|
||||
// show identity
|
||||
if (caps->identity) {
|
||||
DiscoIdentity *identity = caps->identity;
|
||||
win_printf(window, '!', 0, NULL, NO_EOL, THEME_DEFAULT, "", " Identity: ");
|
||||
win_print(window, THEME_DEFAULT, '!', " Identity: ");
|
||||
if (identity->name) {
|
||||
win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->name);
|
||||
if (identity->category || identity->type) {
|
||||
@@ -814,7 +814,7 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa
|
||||
caps_destroy(caps);
|
||||
}
|
||||
|
||||
win_printf_line(window, THEME_DEFAULT, '-', "");
|
||||
win_println(window, THEME_DEFAULT, '-', "");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -828,7 +828,7 @@ win_show_info(ProfWin *window, PContact contact)
|
||||
|
||||
theme_item_t presence_colour = theme_main_presence_attrs(presence);
|
||||
|
||||
win_printf_line(window, THEME_DEFAULT, '-', "");
|
||||
win_println(window, THEME_DEFAULT, '-', "");
|
||||
win_printf(window, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", barejid);
|
||||
if (name) {
|
||||
win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (%s)", name);
|
||||
@@ -836,7 +836,7 @@ win_show_info(ProfWin *window, PContact contact)
|
||||
win_printf(window, '-', 0, NULL, NO_DATE, THEME_DEFAULT, "", ":");
|
||||
|
||||
if (sub) {
|
||||
win_printf_line(window, THEME_DEFAULT, '-', "Subscription: %s", sub);
|
||||
win_println(window, THEME_DEFAULT, '-', "Subscription: %s", sub);
|
||||
}
|
||||
|
||||
if (last_activity) {
|
||||
@@ -850,10 +850,10 @@ win_show_info(ProfWin *window, PContact contact)
|
||||
int seconds = span / G_TIME_SPAN_SECOND;
|
||||
|
||||
if (hours > 0) {
|
||||
win_printf_line(window, THEME_DEFAULT, '-', "Last activity: %dh%dm%ds", hours, minutes, seconds);
|
||||
win_println(window, THEME_DEFAULT, '-', "Last activity: %dh%dm%ds", hours, minutes, seconds);
|
||||
}
|
||||
else {
|
||||
win_printf_line(window, THEME_DEFAULT, '-', "Last activity: %dm%ds", minutes, seconds);
|
||||
win_println(window, THEME_DEFAULT, '-', "Last activity: %dm%ds", minutes, seconds);
|
||||
}
|
||||
|
||||
g_date_time_unref(now);
|
||||
@@ -862,7 +862,7 @@ win_show_info(ProfWin *window, PContact contact)
|
||||
GList *resources = p_contact_get_available_resources(contact);
|
||||
GList *ordered_resources = NULL;
|
||||
if (resources) {
|
||||
win_printf_line(window, THEME_DEFAULT, '-', "Resources:");
|
||||
win_println(window, THEME_DEFAULT, '-', "Resources:");
|
||||
|
||||
// sort in order of availability
|
||||
GList *curr = resources;
|
||||
@@ -1037,7 +1037,27 @@ win_printf(ProfWin *window, const char show_char, int pad_indent, GDateTime *tim
|
||||
}
|
||||
|
||||
void
|
||||
win_printf_line(ProfWin *window, theme_item_t theme_item, const char ch, const char *const message, ...)
|
||||
win_print(ProfWin *window, theme_item_t theme_item, const char ch, const char *const message, ...)
|
||||
{
|
||||
GDateTime *timestamp = g_date_time_new_now_local();
|
||||
|
||||
va_list arg;
|
||||
va_start(arg, message);
|
||||
GString *fmt_msg = g_string_new(NULL);
|
||||
g_string_vprintf(fmt_msg, message, arg);
|
||||
|
||||
buffer_push(window->layout->buffer, ch, 0, timestamp, NO_EOL, theme_item, "", fmt_msg->str, NULL);
|
||||
|
||||
_win_print(window, ch, 0, timestamp, NO_EOL, theme_item, "", fmt_msg->str, NULL);
|
||||
inp_nonblocking(TRUE);
|
||||
g_date_time_unref(timestamp);
|
||||
|
||||
g_string_free(fmt_msg, TRUE);
|
||||
va_end(arg);
|
||||
}
|
||||
|
||||
void
|
||||
win_println(ProfWin *window, theme_item_t theme_item, const char ch, const char *const message, ...)
|
||||
{
|
||||
GDateTime *timestamp = g_date_time_new_now_local();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user