1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Added indent padding

This commit is contained in:
James Booth 2015-07-29 22:48:03 +01:00
parent 30c1cdd318
commit 5576b88a04
10 changed files with 452 additions and 422 deletions

View File

@ -779,9 +779,9 @@ _cmd_help_cmd_list(const char * const tag)
cons_show("");
ProfWin *console = wins_get_console();
if (tag) {
win_vprint(console, '-', NULL, 0, THEME_WHITE_BOLD, "", "%s commands", tag);
win_vprint(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "%s commands", tag);
} else {
win_print(console, '-', NULL, 0, THEME_WHITE_BOLD, "", "All commands");
win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "All commands");
}
GList *ordered_commands = NULL;
@ -1857,7 +1857,7 @@ cmd_status(ProfWin *window, const char * const command, gchar **args)
if (occupant) {
win_show_occupant(window, occupant);
} else {
win_vprint(window, '-', NULL, 0, 0, "", "No such participant \"%s\" in room.", usr);
win_vprint(window, '-', 0, NULL, 0, 0, "", "No such participant \"%s\" in room.", usr);
}
} else {
ui_current_print_line("You must specify a nickname.");
@ -2610,7 +2610,7 @@ cmd_kick(ProfWin *window, const char * const command, gchar **args)
char *reason = args[1];
iq_room_kick_occupant(mucwin->roomjid, nick, reason);
} else {
win_vprint((ProfWin*) mucwin, '!', NULL, 0, 0, "", "Occupant does not exist: %s", nick);
win_vprint((ProfWin*) mucwin, '!', 0, NULL, 0, 0, "", "Occupant does not exist: %s", nick);
}
} else {
cons_bad_cmd_usage(command);
@ -2668,10 +2668,10 @@ cmd_subject(ProfWin *window, const char * const command, gchar **args)
if (args[0] == NULL) {
char *subject = muc_subject(mucwin->roomjid);
if (subject) {
win_vprint(window, '!', NULL, NO_EOL, THEME_ROOMINFO, "", "Room subject: ");
win_vprint(window, '!', NULL, NO_DATE, 0, "", "%s", subject);
win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room subject: ");
win_vprint(window, '!', 0, NULL, NO_DATE, 0, "", "%s", subject);
} else {
win_print(window, '!', NULL, 0, THEME_ROOMINFO, "", "Room has no subject");
win_print(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room has no subject");
}
return TRUE;
}
@ -2736,7 +2736,7 @@ cmd_affiliation(ProfWin *window, const char * const command, gchar **args)
iq_room_affiliation_list(mucwin->roomjid, "member");
iq_room_affiliation_list(mucwin->roomjid, "outcast");
} else if (g_strcmp0(affiliation, "none") == 0) {
win_print((ProfWin*) mucwin, '!', NULL, 0, 0, "", "Cannot list users with no affiliation.");
win_print((ProfWin*) mucwin, '!', 0, NULL, 0, 0, "", "Cannot list users with no affiliation.");
} else {
iq_room_affiliation_list(mucwin->roomjid, affiliation);
}
@ -2804,7 +2804,7 @@ cmd_role(ProfWin *window, const char * const command, gchar **args)
iq_room_role_list(mucwin->roomjid, "participant");
iq_room_role_list(mucwin->roomjid, "visitor");
} else if (g_strcmp0(role, "none") == 0) {
win_print((ProfWin*) mucwin, '!', NULL, 0, 0, "", "Cannot list users with no role.");
win_print((ProfWin*) mucwin, '!', 0, NULL, 0, 0, "", "Cannot list users with no role.");
} else {
iq_room_role_list(mucwin->roomjid, role);
}
@ -2866,12 +2866,12 @@ cmd_room(ProfWin *window, const char * const command, gchar **args)
if (g_strcmp0(args[0], "accept") == 0) {
gboolean requires_config = muc_requires_config(mucwin->roomjid);
if (!requires_config) {
win_print(window, '!', NULL, 0, THEME_ROOMINFO, "", "Current room does not require configuration.");
win_print(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Current room does not require configuration.");
return TRUE;
} else {
iq_confirm_instant_room(mucwin->roomjid);
muc_set_requires_config(mucwin->roomjid, FALSE);
win_print(window, '!', NULL, 0, THEME_ROOMINFO, "", "Room unlocked.");
win_print(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room unlocked.");
return TRUE;
}
}
@ -3247,13 +3247,13 @@ cmd_tiny(ProfWin *window, const char * const command, gchar **args)
}
if (!tinyurl_valid(url)) {
win_vprint(window, '-', NULL, 0, THEME_ERROR, "", "/tiny, badly formed URL: %s", url);
win_vprint(window, '-', 0, NULL, 0, THEME_ERROR, "", "/tiny, badly formed URL: %s", url);
return TRUE;
}
char *tiny = tinyurl_get(url);
if (!tiny) {
win_print(window, '-', NULL, 0, THEME_ERROR, "", "Couldn't create tinyurl.");
win_print(window, '-', 0, NULL, 0, THEME_ERROR, "", "Couldn't create tinyurl.");
return TRUE;
}

View File

@ -80,11 +80,12 @@ buffer_free(ProfBuff buffer)
}
void
buffer_push(ProfBuff buffer, const char show_char, GDateTime *time,
buffer_push(ProfBuff buffer, const char show_char, int pad_indent, GDateTime *time,
int flags, theme_item_t theme_item, const char * const from, const char * const message, DeliveryReceipt *receipt)
{
ProfBuffEntry *e = malloc(sizeof(struct prof_buff_entry_t));
e->show_char = show_char;
e->pad_indent = pad_indent;
e->flags = flags;
e->theme_item = theme_item;
e->time = g_date_time_ref(time);

View File

@ -47,6 +47,7 @@ typedef struct delivery_receipt_t {
typedef struct prof_buff_entry_t {
char show_char;
int pad_indent;
GDateTime *time;
int flags;
theme_item_t theme_item;
@ -59,7 +60,7 @@ typedef struct prof_buff_t *ProfBuff;
ProfBuff buffer_create();
void buffer_free(ProfBuff buffer);
void buffer_push(ProfBuff buffer, const char show_char, GDateTime *time, int flags, theme_item_t theme_item,
void buffer_push(ProfBuff buffer, const char show_char, int pad_indent, GDateTime *time, int flags, theme_item_t theme_item,
const char * const from, const char * const message, DeliveryReceipt *receipt);
int buffer_size(ProfBuff buffer);
ProfBuffEntry* buffer_yield_entry(ProfBuff buffer, int entry);

View File

@ -67,14 +67,14 @@ void
cons_show_time(void)
{
ProfWin *console = wins_get_console();
win_print(console, '-', NULL, NO_EOL, 0, "", "");
win_print(console, '-', 0, NULL, NO_EOL, 0, "", "");
}
void
cons_show_word(const char * const word)
{
ProfWin *console = wins_get_console();
win_print(console, '-', NULL, NO_DATE | NO_EOL, 0, "", word);
win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", word);
}
void
@ -111,20 +111,20 @@ cons_show_help(Command *command)
ProfWin *console = wins_get_console();
cons_show("");
win_vprint(console, '-', NULL, 0, THEME_WHITE_BOLD, "", "%s", &command->cmd[1]);
win_print(console, '-', NULL, NO_EOL, THEME_WHITE_BOLD, "", "");
win_vprint(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "%s", &command->cmd[1]);
win_print(console, '-', 0, NULL, NO_EOL, THEME_WHITE_BOLD, "", "");
int i;
for (i = 0; i < strlen(command->cmd) - 1 ; i++) {
win_print(console, '-', NULL, NO_EOL | NO_DATE, THEME_WHITE_BOLD, "", "-");
win_print(console, '-', 0, NULL, NO_EOL | NO_DATE, THEME_WHITE_BOLD, "", "-");
}
win_print(console, '-', NULL, NO_DATE, THEME_WHITE_BOLD, "", "");
win_print(console, '-', 0, NULL, NO_DATE, THEME_WHITE_BOLD, "", "");
cons_show("");
win_print(console, '-', NULL, 0, THEME_WHITE_BOLD, "", "Synopsis");
win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Synopsis");
ui_show_lines(console, command->help.synopsis);
cons_show("");
win_print(console, '-', NULL, 0, THEME_WHITE_BOLD, "", "Description");
win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Description");
win_println(console, command->help.desc);
int maxlen = 0;
@ -135,15 +135,15 @@ cons_show_help(Command *command)
if (i > 0) {
cons_show("");
win_print(console, '-', NULL, 0, THEME_WHITE_BOLD, "", "Arguments");
win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Arguments");
for (i = 0; command->help.args[i][0] != NULL; i++) {
win_vprint(console, '-', NULL, 0, 0, "", "%-*s: %s", maxlen + 1, command->help.args[i][0], command->help.args[i][1]);
win_vprint(console, '-', maxlen + 3, NULL, 0, 0, "", "%-*s: %s", maxlen + 1, command->help.args[i][0], command->help.args[i][1]);
}
}
if (g_strv_length((gchar**)command->help.examples) > 0) {
cons_show("");
win_print(console, '-', NULL, 0, THEME_WHITE_BOLD, "", "Examples");
win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Examples");
ui_show_lines(console, command->help.examples);
}
}
@ -168,7 +168,7 @@ cons_show_error(const char * const msg, ...)
va_start(arg, msg);
GString *fmt_msg = g_string_new(NULL);
g_string_vprintf(fmt_msg, msg, arg);
win_print(console, '-', NULL, 0, THEME_ERROR, "", fmt_msg->str);
win_print(console, '-', 0, NULL, 0, THEME_ERROR, "", fmt_msg->str);
g_string_free(fmt_msg, TRUE);
va_end(arg);
@ -191,7 +191,7 @@ cons_show_typing(const char * const barejid)
display_usr = barejid;
}
win_vprint(console, '-', NULL, 0, THEME_TYPING, "", "!! %s is typing a message...", display_usr);
win_vprint(console, '-', 0, NULL, 0, THEME_TYPING, "", "!! %s is typing a message...", display_usr);
cons_alert();
}
@ -204,7 +204,7 @@ cons_show_incoming_message(const char * const short_from, const int win_index)
if (ui_index == 10) {
ui_index = 0;
}
win_vprint(console, '-', NULL, 0, THEME_INCOMING, "", "<< incoming from %s (%d)", short_from, ui_index);
win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< incoming from %s (%d)", short_from, ui_index);
cons_alert();
}
@ -222,16 +222,16 @@ cons_about(void)
if (strcmp(PACKAGE_STATUS, "development") == 0) {
#ifdef HAVE_GIT_VERSION
win_vprint(console, '-', NULL, 0, 0, "", "Welcome to Profanity, version %sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION);
win_vprint(console, '-', 0, NULL, 0, 0, "", "Welcome to Profanity, version %sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION);
#else
win_vprint(console, '-', NULL, 0, 0, "", "Welcome to Profanity, version %sdev", PACKAGE_VERSION);
win_vprint(console, '-', 0, NULL, 0, 0, "", "Welcome to Profanity, version %sdev", PACKAGE_VERSION);
#endif
} else {
win_vprint(console, '-', NULL, 0, 0, "", "Welcome to Profanity, version %s", PACKAGE_VERSION);
win_vprint(console, '-', 0, NULL, 0, 0, "", "Welcome to Profanity, version %s", PACKAGE_VERSION);
}
}
win_vprint(console, '-', NULL, 0, 0, "", "Copyright (C) 2012 - 2015 James Booth <%s>.", PACKAGE_BUGREPORT);
win_vprint(console, '-', 0, NULL, 0, 0, "", "Copyright (C) 2012 - 2015 James Booth <%s>.", PACKAGE_BUGREPORT);
win_println(console, "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>");
win_println(console, "");
win_println(console, "This is free software; you are free to change and redistribute it.");
@ -260,7 +260,7 @@ cons_check_version(gboolean not_available_msg)
if (relase_valid) {
if (release_is_new(latest_release)) {
win_vprint(console, '-', NULL, 0, 0, "", "A new version of Profanity is available: %s", latest_release);
win_vprint(console, '-', 0, NULL, 0, 0, "", "A new version of Profanity is available: %s", latest_release);
win_println(console, "Check <http://www.profanity.im> for details.");
win_println(console, "");
} else {
@ -280,16 +280,16 @@ void
cons_show_login_success(ProfAccount *account)
{
ProfWin *console = wins_get_console();
win_vprint(console, '-', NULL, NO_EOL, 0, "", "%s logged in successfully, ", account->jid);
win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", "%s logged in successfully, ", account->jid);
resource_presence_t presence = accounts_get_login_presence(account->name);
const char *presence_str = string_from_resource_presence(presence);
theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
win_vprint(console, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", presence_str);
win_vprint(console, '-', NULL, NO_DATE | NO_EOL, 0, "", " (priority %d)",
win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", presence_str);
win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " (priority %d)",
accounts_get_priority_for_presence_type(account->name, presence));
win_print(console, '-', NULL, NO_DATE, 0, "", ".");
win_print(console, '-', 0, NULL, NO_DATE, 0, "", ".");
cons_alert();
}
@ -349,43 +349,43 @@ cons_show_caps(const char * const fulljid, resource_presence_t presence)
const char *resource_presence = string_from_resource_presence(presence);
theme_item_t presence_colour = theme_main_presence_attrs(resource_presence);
win_vprint(console, '-', NULL, NO_EOL, presence_colour, "", "%s", fulljid);
win_print(console, '-', NULL, NO_DATE, 0, "", ":");
win_vprint(console, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", fulljid);
win_print(console, '-', 0, NULL, NO_DATE, 0, "", ":");
// show identity
if (caps->category || caps->type || caps->name) {
win_print(console, '-', NULL, NO_EOL, 0, "", "Identity: ");
win_print(console, '-', 0, NULL, NO_EOL, 0, "", "Identity: ");
if (caps->name) {
win_print(console, '-', NULL, NO_DATE | NO_EOL, 0, "", caps->name);
win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->name);
if (caps->category || caps->type) {
win_print(console, '-', NULL, NO_DATE | NO_EOL, 0, "", " ");
win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " ");
}
}
if (caps->type) {
win_print(console, '-', NULL, NO_DATE | NO_EOL, 0, "", caps->type);
win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->type);
if (caps->category) {
win_print(console, '-', NULL, NO_DATE | NO_EOL, 0, "", " ");
win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " ");
}
}
if (caps->category) {
win_print(console, '-', NULL, NO_DATE | NO_EOL, 0, "", caps->category);
win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->category);
}
win_newline(console);
}
if (caps->software) {
win_vprint(console, '-', NULL, NO_EOL, 0, "", "Software: %s", caps->software);
win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", "Software: %s", caps->software);
}
if (caps->software_version) {
win_vprint(console, '-', NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->software_version);
win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->software_version);
}
if (caps->software || caps->software_version) {
win_newline(console);
}
if (caps->os) {
win_vprint(console, '-', NULL, NO_EOL, 0, "", "OS: %s", caps->os);
win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", "OS: %s", caps->os);
}
if (caps->os_version) {
win_vprint(console, '-', NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->os_version);
win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->os_version);
}
if (caps->os || caps->os_version) {
win_newline(console);
@ -395,7 +395,7 @@ cons_show_caps(const char * const fulljid, resource_presence_t presence)
win_println(console, "Features:");
GSList *feature = caps->features;
while (feature) {
win_vprint(console, '-', NULL, 0, 0, "", " %s", feature->data);
win_vprint(console, '-', 0, NULL, 0, 0, "", " %s", feature->data);
feature = g_slist_next(feature);
}
}
@ -416,8 +416,8 @@ cons_show_software_version(const char * const jid, const char * const presence,
if (name || version || os) {
cons_show("");
theme_item_t presence_colour = theme_main_presence_attrs(presence);
win_vprint(console, '-', NULL, NO_EOL, presence_colour, "", "%s", jid);
win_print(console, '-', NULL, NO_DATE, 0, "", ":");
win_vprint(console, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", jid);
win_print(console, '-', 0, NULL, NO_DATE, 0, "", ":");
}
if (name) {
cons_show("Name : %s", name);
@ -481,9 +481,9 @@ cons_show_room_list(GSList *rooms, const char * const conference_node)
cons_show("Chat rooms at %s:", conference_node);
while (rooms) {
DiscoItem *room = rooms->data;
win_vprint(console, '-', NULL, NO_EOL, 0, "", " %s", room->jid);
win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", " %s", room->jid);
if (room->name) {
win_vprint(console, '-', NULL, NO_DATE | NO_EOL, 0, "", ", (%s)", room->name);
win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", (%s)", room->name);
}
win_newline(console);
rooms = g_slist_next(rooms);
@ -515,21 +515,21 @@ cons_show_bookmarks(const GList *list)
if (muc_active(item->jid)) {
presence_colour = THEME_ONLINE;
}
win_vprint(console, '-', NULL, NO_EOL, presence_colour, "", " %s", item->jid);
win_vprint(console, '-', 0, NULL, NO_EOL, presence_colour, "", " %s", item->jid);
if (item->nick) {
win_vprint(console, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", "/%s", item->nick);
win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "/%s", item->nick);
}
if (item->autojoin) {
win_print(console, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", " (autojoin)");
win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (autojoin)");
}
if (item->password) {
win_print(console, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", " (private)");
win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (private)");
}
if (muc_active(item->jid)) {
ProfWin *roomwin = (ProfWin*)wins_get_muc(item->jid);
if (roomwin) {
int num = wins_get_num(roomwin);
win_vprint(console, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", " (%d)", num);
win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (%d)", num);
}
}
win_newline(console);
@ -590,11 +590,11 @@ cons_show_disco_items(GSList *items, const char * const jid)
cons_show("Service discovery items for %s:", jid);
while (items) {
DiscoItem *item = items->data;
win_vprint(console, '-', NULL, NO_EOL, 0, "", " %s", item->jid);
win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", " %s", item->jid);
if (item->name) {
win_vprint(console, '-', NULL, NO_DATE | NO_EOL, 0, "", ", (%s)", item->name);
win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", (%s)", item->name);
}
win_vprint(console, '-', NULL, NO_DATE, 0, "", "");
win_vprint(console, '-', 0, NULL, NO_DATE, 0, "", "");
items = g_slist_next(items);
}
} else {
@ -669,7 +669,7 @@ cons_show_account_list(gchar **accounts)
(g_strcmp0(jabber_get_account_name(), accounts[i]) == 0)) {
resource_presence_t presence = accounts_get_last_presence(accounts[i]);
theme_item_t presence_colour = theme_main_presence_attrs(string_from_resource_presence(presence));
win_vprint(console, '-', NULL, 0, presence_colour, "", "%s", accounts[i]);
win_vprint(console, '-', 0, NULL, 0, presence_colour, "", "%s", accounts[i]);
} else {
cons_show(accounts[i]);
}
@ -798,12 +798,12 @@ cons_show_account(ProfAccount *account)
Resource *resource = curr->data;
const char *resource_presence = string_from_resource_presence(resource->presence);
theme_item_t presence_colour = theme_main_presence_attrs(resource_presence);
win_vprint(console, '-', NULL, NO_EOL, presence_colour, "", " %s (%d), %s", resource->name, resource->priority, resource_presence);
win_vprint(console, '-', 0, NULL, NO_EOL, presence_colour, "", " %s (%d), %s", resource->name, resource->priority, resource_presence);
if (resource->status) {
win_vprint(console, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", resource->status);
win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", resource->status);
}
win_vprint(console, '-', NULL, NO_DATE, 0, "", "");
win_vprint(console, '-', 0, NULL, NO_DATE, 0, "", "");
Jid *jidp = jid_create_from_bare_and_resource(account->jid, resource->name);
Capabilities *caps = caps_lookup(jidp->fulljid);
jid_destroy(jidp);
@ -811,38 +811,38 @@ cons_show_account(ProfAccount *account)
if (caps) {
// show identity
if (caps->category || caps->type || caps->name) {
win_print(console, '-', NULL, NO_EOL, 0, "", " Identity: ");
win_print(console, '-', 0, NULL, NO_EOL, 0, "", " Identity: ");
if (caps->name) {
win_print(console, '-', NULL, NO_DATE | NO_EOL, 0, "", caps->name);
win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->name);
if (caps->category || caps->type) {
win_print(console, '-', NULL, NO_DATE | NO_EOL, 0, "", " ");
win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " ");
}
}
if (caps->type) {
win_print(console, '-', NULL, NO_DATE | NO_EOL, 0, "", caps->type);
win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->type);
if (caps->category) {
win_print(console, '-', NULL, NO_DATE | NO_EOL, 0, "", " ");
win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " ");
}
}
if (caps->category) {
win_print(console, '-', NULL, NO_DATE | NO_EOL, 0, "", caps->category);
win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->category);
}
win_newline(console);
}
if (caps->software) {
win_vprint(console, '-', NULL, NO_EOL, 0, "", " Software: %s", caps->software);
win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", " Software: %s", caps->software);
}
if (caps->software_version) {
win_vprint(console, '-', NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->software_version);
win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->software_version);
}
if (caps->software || caps->software_version) {
win_newline(console);
}
if (caps->os) {
win_vprint(console, '-', NULL, NO_EOL, 0, "", " OS: %s", caps->os);
win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", " OS: %s", caps->os);
}
if (caps->os_version) {
win_vprint(console, '-', NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->os_version);
win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->os_version);
}
if (caps->os || caps->os_version) {
win_newline(console);
@ -1554,7 +1554,7 @@ cons_navigation_help(void)
{
ProfWin *console = wins_get_console();
cons_show("");
win_print(console, '-', NULL, 0, THEME_WHITE_BOLD, "", "Navigation");
win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Navigation");
cons_show("Alt-1..Alt-0, F1..F10 : Choose window.");
cons_show("Alt-LEFT, Alt-RIGHT : Previous/next chat window");
cons_show("PAGEUP, PAGEDOWN : Page the main window.");
@ -1659,22 +1659,22 @@ cons_theme_colours(void)
ProfWin *console = wins_get_console();
cons_show("Theme colours:");
win_print(console, '-', NULL, NO_EOL, THEME_WHITE, "", " white ");
win_print(console, '-', NULL, NO_DATE, THEME_WHITE_BOLD, "", " bold_white");
win_print(console, '-', NULL, NO_EOL, THEME_GREEN, "", " green ");
win_print(console, '-', NULL, NO_DATE, THEME_GREEN_BOLD, "", " bold_green");
win_print(console, '-', NULL, NO_EOL, THEME_RED, "", " red ");
win_print(console, '-', NULL, NO_DATE, THEME_RED_BOLD, "", " bold_red");
win_print(console, '-', NULL, NO_EOL, THEME_YELLOW, "", " yellow ");
win_print(console, '-', NULL, NO_DATE, THEME_YELLOW_BOLD, "", " bold_yellow");
win_print(console, '-', NULL, NO_EOL, THEME_BLUE, "", " blue ");
win_print(console, '-', NULL, NO_DATE, THEME_BLUE_BOLD, "", " bold_blue");
win_print(console, '-', NULL, NO_EOL, THEME_CYAN, "", " cyan ");
win_print(console, '-', NULL, NO_DATE, THEME_CYAN_BOLD, "", " bold_cyan");
win_print(console, '-', NULL, NO_EOL, THEME_MAGENTA, "", " magenta ");
win_print(console, '-', NULL, NO_DATE, THEME_MAGENTA_BOLD, "", " bold_magenta");
win_print(console, '-', NULL, NO_EOL, THEME_BLACK, "", " black ");
win_print(console, '-', NULL, NO_DATE, THEME_BLACK_BOLD, "", " bold_black");
win_print(console, '-', 0, NULL, NO_EOL, THEME_WHITE, "", " white ");
win_print(console, '-', 0, NULL, NO_DATE, THEME_WHITE_BOLD, "", " bold_white");
win_print(console, '-', 0, NULL, NO_EOL, THEME_GREEN, "", " green ");
win_print(console, '-', 0, NULL, NO_DATE, THEME_GREEN_BOLD, "", " bold_green");
win_print(console, '-', 0, NULL, NO_EOL, THEME_RED, "", " red ");
win_print(console, '-', 0, NULL, NO_DATE, THEME_RED_BOLD, "", " bold_red");
win_print(console, '-', 0, NULL, NO_EOL, THEME_YELLOW, "", " yellow ");
win_print(console, '-', 0, NULL, NO_DATE, THEME_YELLOW_BOLD, "", " bold_yellow");
win_print(console, '-', 0, NULL, NO_EOL, THEME_BLUE, "", " blue ");
win_print(console, '-', 0, NULL, NO_DATE, THEME_BLUE_BOLD, "", " bold_blue");
win_print(console, '-', 0, NULL, NO_EOL, THEME_CYAN, "", " cyan ");
win_print(console, '-', 0, NULL, NO_DATE, THEME_CYAN_BOLD, "", " bold_cyan");
win_print(console, '-', 0, NULL, NO_EOL, THEME_MAGENTA, "", " magenta ");
win_print(console, '-', 0, NULL, NO_DATE, THEME_MAGENTA_BOLD, "", " bold_magenta");
win_print(console, '-', 0, NULL, NO_EOL, THEME_BLACK, "", " black ");
win_print(console, '-', 0, NULL, NO_DATE, THEME_BLACK_BOLD, "", " bold_black");
cons_show("");
}
@ -1684,23 +1684,23 @@ _cons_splash_logo(void)
ProfWin *console = wins_get_console();
win_println(console, "Welcome to");
win_print(console, '-', NULL, 0, THEME_SPLASH, "", " ___ _ ");
win_print(console, '-', NULL, 0, THEME_SPLASH, "", " / __) (_)_ ");
win_print(console, '-', NULL, 0, THEME_SPLASH, "", " ____ ____ ___ | |__ ____ ____ _| |_ _ _ ");
win_print(console, '-', NULL, 0, THEME_SPLASH, "", "| _ \\ / ___) _ \\| __) _ | _ \\| | _) | | |");
win_print(console, '-', NULL, 0, THEME_SPLASH, "", "| | | | | | |_| | | ( ( | | | | | | |_| |_| |");
win_print(console, '-', NULL, 0, THEME_SPLASH, "", "| ||_/|_| \\___/|_| \\_||_|_| |_|_|\\___)__ |");
win_print(console, '-', NULL, 0, THEME_SPLASH, "", "|_| (____/ ");
win_print(console, '-', NULL, 0, THEME_SPLASH, "", "");
win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", " ___ _ ");
win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", " / __) (_)_ ");
win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", " ____ ____ ___ | |__ ____ ____ _| |_ _ _ ");
win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", "| _ \\ / ___) _ \\| __) _ | _ \\| | _) | | |");
win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", "| | | | | | |_| | | ( ( | | | | | | |_| |_| |");
win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", "| ||_/|_| \\___/|_| \\_||_|_| |_|_|\\___)__ |");
win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", "|_| (____/ ");
win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", "");
if (strcmp(PACKAGE_STATUS, "development") == 0) {
#ifdef HAVE_GIT_VERSION
win_vprint(console, '-', NULL, 0, 0, "", "Version %sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION);
win_vprint(console, '-', 0, NULL, 0, 0, "", "Version %sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION);
#else
win_vprint(console, '-', NULL, 0, 0, "", "Version %sdev", PACKAGE_VERSION);
win_vprint(console, '-', 0, NULL, 0, 0, "", "Version %sdev", PACKAGE_VERSION);
#endif
} else {
win_vprint(console, '-', NULL, 0, 0, "", "Version %s", PACKAGE_VERSION);
win_vprint(console, '-', 0, NULL, 0, 0, "", "Version %s", PACKAGE_VERSION);
}
}
@ -1727,11 +1727,11 @@ _show_roster_contacts(GSList *list, gboolean show_groups)
} else {
presence_colour = theme_main_presence_attrs("offline");
}
win_vprint(console, '-', NULL, NO_EOL, presence_colour, "", title->str);
win_vprint(console, '-', 0, NULL, NO_EOL, presence_colour, "", title->str);
g_string_free(title, TRUE);
win_print(console, '-', NULL, NO_DATE | NO_EOL, 0, "", " - ");
win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " - ");
GString *sub = g_string_new("");
sub = g_string_append(sub, p_contact_subscription(contact));
if (p_contact_pending_out(contact)) {
@ -1747,9 +1747,9 @@ _show_roster_contacts(GSList *list, gboolean show_groups)
}
if (show_groups) {
win_vprint(console, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", sub->str);
win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", sub->str);
} else {
win_vprint(console, '-', NULL, NO_DATE, presence_colour, "", "%s", sub->str);
win_vprint(console, '-', 0, NULL, NO_DATE, presence_colour, "", "%s", sub->str);
}
g_string_free(sub, TRUE);
@ -1765,10 +1765,10 @@ _show_roster_contacts(GSList *list, gboolean show_groups)
}
groups = g_slist_next(groups);
}
win_vprint(console, '-', NULL, NO_DATE, 0, "", "%s", groups_str->str);
win_vprint(console, '-', 0, NULL, NO_DATE, 0, "", "%s", groups_str->str);
g_string_free(groups_str, TRUE);
} else {
win_print(console, '-', NULL, NO_DATE, 0, "", " ");
win_print(console, '-', 0, NULL, NO_DATE, 0, "", " ");
}
}

File diff suppressed because it is too large Load Diff

View File

@ -352,8 +352,8 @@ void win_hide_subwin(ProfWin *window);
void win_show_subwin(ProfWin *window);
void win_refresh_without_subwin(ProfWin *window);
void win_refresh_with_subwin(ProfWin *window);
void win_print(ProfWin *window, const char show_char, GDateTime *timestamp, int flags, theme_item_t theme_item, const char * const from, const char * const message);
void win_vprint(ProfWin *window, const char show_char, GDateTime *timestamp, int flags, theme_item_t theme_item, const char * const from, const char * const message, ...);
void win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char * const from, const char * const message);
void win_vprint(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char * const from, const char * const message, ...);
char* win_get_title(ProfWin *window);
void win_show_occupant(ProfWin *window, Occupant *occupant);
void win_show_occupant_info(ProfWin *window, const char * const room, Occupant *occupant);

View File

@ -59,9 +59,9 @@
#define CEILING(X) (X-(int)(X) > 0 ? (int)(X+1) : (int)(X))
static void _win_print(ProfWin *window, const char show_char, GDateTime *time,
static void _win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *time,
int flags, theme_item_t theme_item, const char * const from, const char * const message, DeliveryReceipt *receipt);
static void _win_print_wrapped(WINDOW *win, const char * const message, size_t indent);
static void _win_print_wrapped(WINDOW *win, const char * const message, size_t indent, int pad_indent);
int
win_roster_cols(void)
@ -577,14 +577,14 @@ win_show_occupant(ProfWin *window, Occupant *occupant)
theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
win_print(window, '-', NULL, NO_EOL, presence_colour, "", occupant->nick);
win_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str);
win_print(window, '-', 0, NULL, NO_EOL, presence_colour, "", occupant->nick);
win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str);
if (occupant->status) {
win_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", occupant->status);
win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", occupant->status);
}
win_print(window, '-', NULL, NO_DATE, presence_colour, "", "");
win_print(window, '-', 0, NULL, NO_DATE, presence_colour, "", "");
}
void
@ -599,12 +599,12 @@ win_show_contact(ProfWin *window, PContact contact)
theme_item_t presence_colour = theme_main_presence_attrs(presence);
if (name) {
win_print(window, '-', NULL, NO_EOL, presence_colour, "", name);
win_print(window, '-', 0, NULL, NO_EOL, presence_colour, "", name);
} else {
win_print(window, '-', NULL, NO_EOL, presence_colour, "", barejid);
win_print(window, '-', 0, NULL, NO_EOL, presence_colour, "", barejid);
}
win_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence);
win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence);
if (last_activity) {
GDateTime *now = g_date_time_new_now_local();
@ -617,18 +617,18 @@ win_show_contact(ProfWin *window, PContact contact)
int seconds = span / G_TIME_SPAN_SECOND;
if (hours > 0) {
win_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", ", idle %dh%dm%ds", hours, minutes, seconds);
win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", idle %dh%dm%ds", hours, minutes, seconds);
}
else {
win_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", ", idle %dm%ds", minutes, seconds);
win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", idle %dm%ds", minutes, seconds);
}
}
if (status) {
win_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", p_contact_status(contact));
win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", p_contact_status(contact));
}
win_print(window, '-', NULL, NO_DATE, presence_colour, "", "");
win_print(window, '-', 0, NULL, NO_DATE, presence_colour, "", "");
}
void
@ -640,21 +640,21 @@ win_show_occupant_info(ProfWin *window, const char * const room, Occupant *occup
theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
win_print(window, '!', NULL, NO_EOL, presence_colour, "", occupant->nick);
win_vprint(window, '!', NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str);
win_print(window, '!', 0, NULL, NO_EOL, presence_colour, "", occupant->nick);
win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str);
if (occupant->status) {
win_vprint(window, '!', NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", occupant->status);
win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", occupant->status);
}
win_newline(window);
if (occupant->jid) {
win_vprint(window, '!', NULL, 0, 0, "", " Jid: %s", occupant->jid);
win_vprint(window, '!', 0, NULL, 0, 0, "", " Jid: %s", occupant->jid);
}
win_vprint(window, '!', NULL, 0, 0, "", " Affiliation: %s", occupant_affiliation);
win_vprint(window, '!', NULL, 0, 0, "", " Role: %s", occupant_role);
win_vprint(window, '!', 0, NULL, 0, 0, "", " Affiliation: %s", occupant_affiliation);
win_vprint(window, '!', 0, NULL, 0, 0, "", " Role: %s", occupant_role);
Jid *jidp = jid_create_from_bare_and_resource(room, occupant->nick);
Capabilities *caps = caps_lookup(jidp->fulljid);
@ -663,38 +663,38 @@ win_show_occupant_info(ProfWin *window, const char * const room, Occupant *occup
if (caps) {
// show identity
if (caps->category || caps->type || caps->name) {
win_print(window, '!', NULL, NO_EOL, 0, "", " Identity: ");
win_print(window, '!', 0, NULL, NO_EOL, 0, "", " Identity: ");
if (caps->name) {
win_print(window, '!', NULL, NO_DATE | NO_EOL, 0, "", caps->name);
win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->name);
if (caps->category || caps->type) {
win_print(window, '-', NULL, NO_DATE | NO_EOL, 0, "", " ");
win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " ");
}
}
if (caps->type) {
win_print(window, '!', NULL, NO_DATE | NO_EOL, 0, "", caps->type);
win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->type);
if (caps->category) {
win_print(window, '!', NULL, NO_DATE | NO_EOL, 0, "", " ");
win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", " ");
}
}
if (caps->category) {
win_print(window, '!', NULL, NO_DATE | NO_EOL, 0, "", caps->category);
win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->category);
}
win_newline(window);
}
if (caps->software) {
win_vprint(window, '!', NULL, NO_EOL, 0, "", " Software: %s", caps->software);
win_vprint(window, '!', 0, NULL, NO_EOL, 0, "", " Software: %s", caps->software);
}
if (caps->software_version) {
win_vprint(window, '!', NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->software_version);
win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->software_version);
}
if (caps->software || caps->software_version) {
win_newline(window);
}
if (caps->os) {
win_vprint(window, '!', NULL, NO_EOL, 0, "", " OS: %s", caps->os);
win_vprint(window, '!', 0, NULL, NO_EOL, 0, "", " OS: %s", caps->os);
}
if (caps->os_version) {
win_vprint(window, '!', NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->os_version);
win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->os_version);
}
if (caps->os || caps->os_version) {
win_newline(window);
@ -702,7 +702,7 @@ win_show_occupant_info(ProfWin *window, const char * const room, Occupant *occup
caps_destroy(caps);
}
win_print(window, '-', NULL, 0, 0, "", "");
win_print(window, '-', 0, NULL, 0, 0, "", "");
}
void
@ -716,15 +716,15 @@ win_show_info(ProfWin *window, PContact contact)
theme_item_t presence_colour = theme_main_presence_attrs(presence);
win_print(window, '-', NULL, 0, 0, "", "");
win_print(window, '-', NULL, NO_EOL, presence_colour, "", barejid);
win_print(window, '-', 0, NULL, 0, 0, "", "");
win_print(window, '-', 0, NULL, NO_EOL, presence_colour, "", barejid);
if (name) {
win_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", " (%s)", name);
win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (%s)", name);
}
win_print(window, '-', NULL, NO_DATE, 0, "", ":");
win_print(window, '-', 0, NULL, NO_DATE, 0, "", ":");
if (sub) {
win_vprint(window, '-', NULL, 0, 0, "", "Subscription: %s", sub);
win_vprint(window, '-', 0, NULL, 0, 0, "", "Subscription: %s", sub);
}
if (last_activity) {
@ -738,10 +738,10 @@ win_show_info(ProfWin *window, PContact contact)
int seconds = span / G_TIME_SPAN_SECOND;
if (hours > 0) {
win_vprint(window, '-', NULL, 0, 0, "", "Last activity: %dh%dm%ds", hours, minutes, seconds);
win_vprint(window, '-', 0, NULL, 0, 0, "", "Last activity: %dh%dm%ds", hours, minutes, seconds);
}
else {
win_vprint(window, '-', NULL, 0, 0, "", "Last activity: %dm%ds", minutes, seconds);
win_vprint(window, '-', 0, NULL, 0, 0, "", "Last activity: %dm%ds", minutes, seconds);
}
g_date_time_unref(now);
@ -750,7 +750,7 @@ win_show_info(ProfWin *window, PContact contact)
GList *resources = p_contact_get_available_resources(contact);
GList *ordered_resources = NULL;
if (resources) {
win_print(window, '-', NULL, 0, 0, "", "Resources:");
win_print(window, '-', 0, NULL, 0, 0, "", "Resources:");
// sort in order of availability
GList *curr = resources;
@ -768,9 +768,9 @@ win_show_info(ProfWin *window, PContact contact)
Resource *resource = curr->data;
const char *resource_presence = string_from_resource_presence(resource->presence);
theme_item_t presence_colour = theme_main_presence_attrs(resource_presence);
win_vprint(window, '-', NULL, NO_EOL, presence_colour, "", " %s (%d), %s", resource->name, resource->priority, resource_presence);
win_vprint(window, '-', 0, NULL, NO_EOL, presence_colour, "", " %s (%d), %s", resource->name, resource->priority, resource_presence);
if (resource->status) {
win_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", resource->status);
win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", resource->status);
}
win_newline(window);
@ -781,38 +781,38 @@ win_show_info(ProfWin *window, PContact contact)
if (caps) {
// show identity
if (caps->category || caps->type || caps->name) {
win_print(window, '-', NULL, NO_EOL, 0, "", " Identity: ");
win_print(window, '-', 0, NULL, NO_EOL, 0, "", " Identity: ");
if (caps->name) {
win_print(window, '-', NULL, NO_DATE | NO_EOL, 0, "", caps->name);
win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->name);
if (caps->category || caps->type) {
win_print(window, '-', NULL, NO_DATE | NO_EOL, 0, "", " ");
win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " ");
}
}
if (caps->type) {
win_print(window, '-', NULL, NO_DATE | NO_EOL, 0, "", caps->type);
win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->type);
if (caps->category) {
win_print(window, '-', NULL, NO_DATE | NO_EOL, 0, "", " ");
win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " ");
}
}
if (caps->category) {
win_print(window, '-', NULL, NO_DATE | NO_EOL, 0, "", caps->category);
win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->category);
}
win_newline(window);
}
if (caps->software) {
win_vprint(window, '-', NULL, NO_EOL, 0, "", " Software: %s", caps->software);
win_vprint(window, '-', 0, NULL, NO_EOL, 0, "", " Software: %s", caps->software);
}
if (caps->software_version) {
win_vprint(window, '-', NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->software_version);
win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->software_version);
}
if (caps->software || caps->software_version) {
win_newline(window);
}
if (caps->os) {
win_vprint(window, '-', NULL, NO_EOL, 0, "", " OS: %s", caps->os);
win_vprint(window, '-', 0, NULL, NO_EOL, 0, "", " OS: %s", caps->os);
}
if (caps->os_version) {
win_vprint(window, '-', NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->os_version);
win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->os_version);
}
if (caps->os || caps->os_version) {
win_newline(window);
@ -842,12 +842,12 @@ win_show_status_string(ProfWin *window, const char * const from,
}
win_vprint(window, '-', NULL, NO_EOL, presence_colour, "", "%s %s", pre, from);
win_vprint(window, '-', 0, NULL, NO_EOL, presence_colour, "", "%s %s", pre, from);
if (show)
win_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", show);
win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", show);
else
win_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", default_show);
win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", default_show);
if (last_activity) {
GDateTime *now = g_date_time_new_now_local();
@ -861,17 +861,17 @@ win_show_status_string(ProfWin *window, const char * const from,
int seconds = span / G_TIME_SPAN_SECOND;
if (hours > 0) {
win_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", ", idle %dh%dm%ds", hours, minutes, seconds);
win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", idle %dh%dm%ds", hours, minutes, seconds);
}
else {
win_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", ", idle %dm%ds", minutes, seconds);
win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", idle %dm%ds", minutes, seconds);
}
}
if (status)
win_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", status);
win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", status);
win_print(window, '-', NULL, NO_DATE, presence_colour, "", "");
win_print(window, '-', 0, NULL, NO_DATE, presence_colour, "", "");
}
@ -883,7 +883,7 @@ win_print_incoming_message(ProfWin *window, GDateTime *timestamp,
{
case WIN_CHAT:
case WIN_PRIVATE:
win_print(window, '-', timestamp, NO_ME, THEME_TEXT_THEM, from, message);
win_print(window, '-', 0, timestamp, NO_ME, THEME_TEXT_THEM, from, message);
break;
default:
assert(FALSE);
@ -892,31 +892,31 @@ win_print_incoming_message(ProfWin *window, GDateTime *timestamp,
}
void
win_vprint(ProfWin *window, const char show_char, GDateTime *timestamp,
win_vprint(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp,
int flags, theme_item_t theme_item, const char * const from, const char * const message, ...)
{
va_list arg;
va_start(arg, message);
GString *fmt_msg = g_string_new(NULL);
g_string_vprintf(fmt_msg, message, arg);
win_print(window, show_char, timestamp, flags, theme_item, from, fmt_msg->str);
win_print(window, show_char, pad_indent, timestamp, flags, theme_item, from, fmt_msg->str);
g_string_free(fmt_msg, TRUE);
}
void
win_print(ProfWin *window, const char show_char, GDateTime *timestamp,
win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp,
int flags, theme_item_t theme_item, const char * const from, const char * const message)
{
if (timestamp == NULL) timestamp = g_date_time_new_now_local();
buffer_push(window->layout->buffer, show_char, timestamp, flags, theme_item, from, message, NULL);
_win_print(window, show_char, timestamp, flags, theme_item, from, message, NULL);
buffer_push(window->layout->buffer, show_char, pad_indent, timestamp, flags, theme_item, from, message, NULL);
_win_print(window, show_char, pad_indent, timestamp, flags, theme_item, from, message, NULL);
// TODO: cross-reference.. this should be replaced by a real event-based system
ui_input_nonblocking(TRUE);
}
void
win_print_with_receipt(ProfWin *window, const char show_char, GTimeVal *tstamp,
win_print_with_receipt(ProfWin *window, const char show_char, int pad_indent, GTimeVal *tstamp,
int flags, theme_item_t theme_item, const char * const from, const char * const message, char *id)
{
GDateTime *time;
@ -931,8 +931,8 @@ win_print_with_receipt(ProfWin *window, const char show_char, GTimeVal *tstamp,
receipt->id = strdup(id);
receipt->received = FALSE;
buffer_push(window->layout->buffer, show_char, time, flags, theme_item, from, message, receipt);
_win_print(window, show_char, time, flags, theme_item, from, message, receipt);
buffer_push(window->layout->buffer, show_char, pad_indent, time, flags, theme_item, from, message, receipt);
_win_print(window, show_char, pad_indent, time, flags, theme_item, from, message, receipt);
// TODO: cross-reference.. this should be replaced by a real event-based system
ui_input_nonblocking(TRUE);
}
@ -949,17 +949,17 @@ win_mark_received(ProfWin *window, const char * const id)
void
win_println(ProfWin *window, const char * const message)
{
win_print(window, '-', NULL, 0, 0, "", message);
win_print(window, '-', 0, NULL, 0, 0, "", message);
}
void
win_newline(ProfWin *window)
{
win_print(window, '-', NULL, NO_DATE, 0, "", "");
win_print(window, '-', 0, NULL, NO_DATE, 0, "", "");
}
static void
_win_print(ProfWin *window, const char show_char, GDateTime *time,
_win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *time,
int flags, theme_item_t theme_item, const char * const from, const char * const message, DeliveryReceipt *receipt)
{
// flags : 1st bit = 0/1 - me/not me
@ -1028,7 +1028,7 @@ _win_print(ProfWin *window, const char show_char, GDateTime *time,
}
if (prefs_get_boolean(PREF_WRAP)) {
_win_print_wrapped(window->layout->win, message+offset, indent);
_win_print_wrapped(window->layout->win, message+offset, indent, pad_indent);
} else {
wprintw(window->layout->win, "%s", message+offset);
}
@ -1058,23 +1058,29 @@ _win_indent(WINDOW *win, int size)
}
static void
_win_print_wrapped(WINDOW *win, const char * const message, size_t indent)
_win_print_wrapped(WINDOW *win, const char * const message, size_t indent, int pad_indent)
{
int starty = getcury(win);
int wordi = 0;
char *word = malloc(strlen(message) + 1);
gchar *curr_ch = g_utf8_offset_to_pointer(message, 0);
while (*curr_ch != '\0') {
// handle space
if (*curr_ch == ' ') {
waddch(win, ' ');
curr_ch = g_utf8_next_char(curr_ch);
// handle newline
} else if (*curr_ch == '\n') {
waddch(win, '\n');
_win_indent(win, indent);
_win_indent(win, indent + pad_indent);
curr_ch = g_utf8_next_char(curr_ch);
// handle word
} else {
// get word
wordi = 0;
while (*curr_ch != ' ' && *curr_ch != '\n' && *curr_ch != '\0') {
size_t ch_len = mbrlen(curr_ch, 4, NULL);
@ -1087,23 +1093,33 @@ _win_print_wrapped(WINDOW *win, const char * const message, size_t indent)
word[wordi] = '\0';
int curx = getcurx(win);
int cury = getcury(win);
int maxx = getmaxx(win);
gboolean firstline = (cury == starty);
// word larger than line
if (utf8_display_len(word) > (maxx - indent)) {
if ((firstline && (utf8_display_len(word) > (maxx - indent))) ||
(!firstline && (utf8_display_len(word) > (maxx - (indent + pad_indent))))) {
gchar *word_ch = g_utf8_offset_to_pointer(word, 0);
while(*word_ch != '\0') {
curx = getcurx(win);
if (curx < indent) {
cury = getcury(win);
firstline = cury == starty;
if (firstline && curx < indent) {
_win_indent(win, indent);
}
if (!firstline && curx < (indent + pad_indent)) {
_win_indent(win, indent + pad_indent);
}
gchar copy[wordi++];
g_utf8_strncpy(copy, word_ch, 1);
if (curx + utf8_display_len(copy) > maxx) {
waddch(win, '\n');
_win_indent(win, indent);
_win_indent(win, indent + pad_indent);
}
waddstr(win, copy);
@ -1112,14 +1128,26 @@ _win_print_wrapped(WINDOW *win, const char * const message, size_t indent)
} else {
if (curx + utf8_display_len(word) > maxx) {
waddch(win, '\n');
_win_indent(win, indent + pad_indent);
}
if (firstline && curx < indent) {
_win_indent(win, indent);
}
if (curx < indent) {
_win_indent(win, indent);
if (!firstline && curx < (indent + pad_indent)) {
_win_indent(win, indent + pad_indent);
}
wprintw(win, "%s", word);
}
}
// consume first space of next line
int curx = getcurx(win);
int cury = getcury(win);
gboolean firstline = (cury == starty);
if (!firstline && curx == 0 && *curr_ch == ' ') {
curr_ch = g_utf8_next_char(curr_ch);
}
}
free(word);
@ -1134,7 +1162,7 @@ win_redraw(ProfWin *window)
for (i = 0; i < size; i++) {
ProfBuffEntry *e = buffer_yield_entry(window->layout->buffer, i);
_win_print(window, e->show_char, e->time, e->flags, e->theme_item, e->from, e->message, e->receipt);
_win_print(window, e->show_char, e->pad_indent, e->time, e->flags, e->theme_item, e->from, e->message, e->receipt);
}
}

View File

@ -61,7 +61,7 @@ void win_show_status_string(ProfWin *window, const char * const from,
const char * const default_show);
void win_print_incoming_message(ProfWin *window, GDateTime *timestamp,
const char * const from, const char * const message);
void win_print_with_receipt(ProfWin *window, const char show_char, GTimeVal *tstamp, int flags,
void win_print_with_receipt(ProfWin *window, const char show_char, int pad_indent, GTimeVal *tstamp, int flags,
theme_item_t theme_item, const char * const from, const char * const message, char *id);
void win_newline(ProfWin *window);
void win_redraw(ProfWin *window);

View File

@ -497,7 +497,7 @@ wins_lost_connection(void)
while (curr) {
ProfWin *window = curr->data;
if (window->type != WIN_CONSOLE) {
win_print(window, '-', NULL, 0, THEME_ERROR, "", "Lost connection.");
win_print(window, '-', 0, NULL, 0, THEME_ERROR, "", "Lost connection.");
// if current win, set current_win_dirty
if (wins_is_current(window)) {

View File

@ -539,8 +539,8 @@ void win_hide_subwin(ProfWin *window) {}
void win_show_subwin(ProfWin *window) {}
void win_refresh_without_subwin(ProfWin *window) {}
void win_refresh_with_subwin(ProfWin *window) {}
void win_print(ProfWin *window, const char show_char, GDateTime *timestamp, int flags, theme_item_t theme_item, const char * const from, const char * const message) {}
void win_vprint(ProfWin *window, const char show_char, GDateTime *timestamp, int flags, theme_item_t theme_item, const char * const from, const char * const message, ...) {}
void win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char * const from, const char * const message) {}
void win_vprint(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char * const from, const char * const message, ...) {}
char* win_get_title(ProfWin *window)
{
return NULL;