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

Added cons_show_padded

This commit is contained in:
James Booth 2015-07-29 23:48:28 +01:00
parent 79f618367d
commit 8ec931eb84
7 changed files with 64 additions and 45 deletions

View File

@ -1873,7 +1873,7 @@ cmd_status(ProfWin *window, const char * const command, gchar **args)
if (pcontact) { if (pcontact) {
win_show_contact(window, pcontact); win_show_contact(window, pcontact);
} else { } else {
win_println(window, "Error getting contact info."); win_println(window, 0, "Error getting contact info.");
} }
} }
break; break;
@ -1888,7 +1888,7 @@ cmd_status(ProfWin *window, const char * const command, gchar **args)
if (occupant) { if (occupant) {
win_show_occupant(window, occupant); win_show_occupant(window, occupant);
} else { } else {
win_println(window, "Error getting contact info."); win_println(window, 0, "Error getting contact info.");
} }
jid_destroy(jid); jid_destroy(jid);
} }
@ -1954,7 +1954,7 @@ cmd_info(ProfWin *window, const char * const command, gchar **args)
if (pcontact) { if (pcontact) {
win_show_info(window, pcontact); win_show_info(window, pcontact);
} else { } else {
win_println(window, "Error getting contact info."); win_println(window, 0, "Error getting contact info.");
} }
} }
break; break;
@ -1969,7 +1969,7 @@ cmd_info(ProfWin *window, const char * const command, gchar **args)
if (occupant) { if (occupant) {
win_show_occupant_info(window, jid->barejid, occupant); win_show_occupant_info(window, jid->barejid, occupant);
} else { } else {
win_println(window, "Error getting contact info."); win_println(window, 0, "Error getting contact info.");
} }
jid_destroy(jid); jid_destroy(jid);
} }

View File

@ -208,12 +208,12 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *enc_m
prof_enc_t enc_mode = chatwin->enc_mode; prof_enc_t enc_mode = chatwin->enc_mode;
if (enc_message) { if (enc_message) {
if (enc_mode == PROF_ENC_OTR) { if (enc_mode == PROF_ENC_OTR) {
win_println((ProfWin*)chatwin, "PGP encrypted message received whilst in OTR session."); win_println((ProfWin*)chatwin, 0, "PGP encrypted message received whilst in OTR session.");
} else { // PROF_ENC_NONE, PROF_ENC_PGP } else { // PROF_ENC_NONE, PROF_ENC_PGP
char *decrypted = p_gpg_decrypt(barejid, enc_message); char *decrypted = p_gpg_decrypt(barejid, enc_message);
if (decrypted) { if (decrypted) {
if (enc_mode == PROF_ENC_NONE) { if (enc_mode == PROF_ENC_NONE) {
win_println((ProfWin*)chatwin, "PGP encryption enabled."); win_println((ProfWin*)chatwin, 0, "PGP encryption enabled.");
} }
ui_incoming_msg(chatwin, resource, decrypted, NULL, new_win); ui_incoming_msg(chatwin, resource, decrypted, NULL, new_win);
chat_log_pgp_msg_in(barejid, decrypted); chat_log_pgp_msg_in(barejid, decrypted);
@ -226,7 +226,7 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *enc_m
} }
} else { } else {
if (enc_mode == PROF_ENC_PGP) { if (enc_mode == PROF_ENC_PGP) {
win_println((ProfWin*)chatwin, "PGP encryption disabled."); win_println((ProfWin*)chatwin, 0, "PGP encryption disabled.");
ui_incoming_msg(chatwin, resource, message, NULL, new_win); ui_incoming_msg(chatwin, resource, message, NULL, new_win);
chat_log_msg_in(barejid, message); chat_log_msg_in(barejid, message);
chatwin->enc_mode = PROF_ENC_NONE; chatwin->enc_mode = PROF_ENC_NONE;

View File

@ -86,7 +86,7 @@ cons_debug(const char * const msg, ...)
va_start(arg, msg); va_start(arg, msg);
GString *fmt_msg = g_string_new(NULL); GString *fmt_msg = g_string_new(NULL);
g_string_vprintf(fmt_msg, msg, arg); g_string_vprintf(fmt_msg, msg, arg);
win_println(console, fmt_msg->str); win_println(console, 0, fmt_msg->str);
g_string_free(fmt_msg, TRUE); g_string_free(fmt_msg, TRUE);
va_end(arg); va_end(arg);
} }
@ -100,7 +100,20 @@ cons_show(const char * const msg, ...)
va_start(arg, msg); va_start(arg, msg);
GString *fmt_msg = g_string_new(NULL); GString *fmt_msg = g_string_new(NULL);
g_string_vprintf(fmt_msg, msg, arg); g_string_vprintf(fmt_msg, msg, arg);
win_println(console, fmt_msg->str); win_println(console, 0, fmt_msg->str);
g_string_free(fmt_msg, TRUE);
va_end(arg);
}
void
cons_show_padded(int pad, const char * const msg, ...)
{
ProfWin *console = wins_get_console();
va_list arg;
va_start(arg, msg);
GString *fmt_msg = g_string_new(NULL);
g_string_vprintf(fmt_msg, msg, arg);
win_println(console, pad, fmt_msg->str);
g_string_free(fmt_msg, TRUE); g_string_free(fmt_msg, TRUE);
va_end(arg); va_end(arg);
} }
@ -125,7 +138,7 @@ cons_show_help(Command *command)
cons_show(""); cons_show("");
win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Description"); win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Description");
win_println(console, command->help.desc); win_println(console, 0, command->help.desc);
int maxlen = 0; int maxlen = 0;
for (i = 0; command->help.args[i][0] != NULL; i++) { for (i = 0; command->help.args[i][0] != NULL; i++) {
@ -232,13 +245,13 @@ cons_about(void)
} }
win_vprint(console, '-', 0, 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, 0, "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>");
win_println(console, ""); win_println(console, 0, "");
win_println(console, "This is free software; you are free to change and redistribute it."); win_println(console, 0, "This is free software; you are free to change and redistribute it.");
win_println(console, "There is NO WARRANTY, to the extent permitted by law."); win_println(console, 0, "There is NO WARRANTY, to the extent permitted by law.");
win_println(console, ""); win_println(console, 0, "");
win_println(console, "Type '/help' to show complete help."); win_println(console, 0, "Type '/help' to show complete help.");
win_println(console, ""); win_println(console, 0, "");
if (prefs_get_boolean(PREF_VERCHECK)) { if (prefs_get_boolean(PREF_VERCHECK)) {
cons_check_version(FALSE); cons_check_version(FALSE);
@ -261,12 +274,12 @@ cons_check_version(gboolean not_available_msg)
if (relase_valid) { if (relase_valid) {
if (release_is_new(latest_release)) { if (release_is_new(latest_release)) {
win_vprint(console, '-', 0, 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, 0, "Check <http://www.profanity.im> for details.");
win_println(console, ""); win_println(console, 0, "");
} else { } else {
if (not_available_msg) { if (not_available_msg) {
win_println(console, "No new version available."); win_println(console, 0, "No new version available.");
win_println(console, ""); win_println(console, 0, "");
} }
} }
@ -303,7 +316,7 @@ cons_show_wins(void)
GSList *curr = window_strings; GSList *curr = window_strings;
while (curr) { while (curr) {
win_println(console, curr->data); win_println(console, 0, curr->data);
curr = g_slist_next(curr); curr = g_slist_next(curr);
} }
g_slist_free_full(window_strings, free); g_slist_free_full(window_strings, free);
@ -392,7 +405,7 @@ cons_show_caps(const char * const fulljid, resource_presence_t presence)
} }
if (caps->features) { if (caps->features) {
win_println(console, "Features:"); win_println(console, 0, "Features:");
GSList *feature = caps->features; GSList *feature = caps->features;
while (feature) { while (feature) {
win_vprint(console, '-', 0, NULL, 0, 0, "", " %s", feature->data); win_vprint(console, '-', 0, NULL, 0, 0, "", " %s", feature->data);
@ -780,7 +793,7 @@ cons_show_account(ProfAccount *account)
GList *curr = resources; GList *curr = resources;
if (curr) { if (curr) {
win_println(console, "Resources:"); win_println(console, 0, "Resources:");
// sort in order of availability // sort in order of availability
while (curr) { while (curr) {
@ -1531,19 +1544,21 @@ cons_prefs(void)
void void
cons_help(void) cons_help(void)
{ {
int pad = strlen("/help commands connection") + 3;
cons_show(""); cons_show("");
cons_show("Choose a help option:"); cons_show("Choose a help option:");
cons_show(""); cons_show("");
cons_show("/help commands - List all commands."); cons_show_padded(pad, "/help commands : List all commands.");
cons_show("/help commands chat - List chat commands."); cons_show_padded(pad, "/help commands chat : List chat commands.");
cons_show("/help commands groupchat - List groupchat commands."); cons_show_padded(pad, "/help commands groupchat : List groupchat commands.");
cons_show("/help commands roster - List commands for manipulating your roster."); cons_show_padded(pad, "/help commands roster : List commands for manipulating your roster.");
cons_show("/help commands presence - List commands to change your presence."); cons_show_padded(pad, "/help commands presence : List commands to change your presence.");
cons_show("/help commands discovery - List service discovery commands."); cons_show_padded(pad, "/help commands discovery : List service discovery commands.");
cons_show("/help commands connection - List commands related to managing your connection."); cons_show_padded(pad, "/help commands connection : List commands related to managing your connection.");
cons_show("/help commands ui - List commands for manipulating the user interface."); cons_show_padded(pad, "/help commands ui : List commands for manipulating the user interface.");
cons_show("/help [command] - Detailed help on a specific command."); cons_show_padded(pad, "/help [command] : Detailed help on a specific command.");
cons_show("/help navigation - How to navigate around Profanity."); cons_show_padded(pad, "/help navigation : How to navigate around Profanity.");
cons_show(""); cons_show("");
cons_alert(); cons_alert();
@ -1552,13 +1567,14 @@ cons_help(void)
void void
cons_navigation_help(void) cons_navigation_help(void)
{ {
int pad = strlen("Alt-PAGEUP, Alt-PAGEDOWN") + 3;
ProfWin *console = wins_get_console(); ProfWin *console = wins_get_console();
cons_show(""); cons_show("");
win_print(console, '-', 0, 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_padded(pad, "Alt-1..Alt-0, F1..F10 : Choose window.");
cons_show("Alt-LEFT, Alt-RIGHT : Previous/next chat window"); cons_show_padded(pad, "Alt-LEFT, Alt-RIGHT : Previous/next chat window");
cons_show("PAGEUP, PAGEDOWN : Page the main window."); cons_show_padded(pad, "PAGEUP, PAGEDOWN : Page the main window.");
cons_show("Alt-PAGEUP, Alt-PAGEDOWN : Page occupants/roster panel."); cons_show_padded(pad, "Alt-PAGEUP, Alt-PAGEDOWN : Page occupants/roster panel.");
cons_show(""); cons_show("");
cons_alert(); cons_alert();
@ -1682,7 +1698,7 @@ static void
_cons_splash_logo(void) _cons_splash_logo(void)
{ {
ProfWin *console = wins_get_console(); ProfWin *console = wins_get_console();
win_println(console, "Welcome to"); win_println(console, 0, "Welcome to");
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, "", " / __) (_)_ ");

View File

@ -1150,7 +1150,7 @@ ui_current_print_line(const char * const msg, ...)
va_start(arg, msg); va_start(arg, msg);
GString *fmt_msg = g_string_new(NULL); GString *fmt_msg = g_string_new(NULL);
g_string_vprintf(fmt_msg, msg, arg); g_string_vprintf(fmt_msg, msg, arg);
win_println(window, fmt_msg->str); win_println(window, 0, fmt_msg->str);
va_end(arg); va_end(arg);
g_string_free(fmt_msg, TRUE); g_string_free(fmt_msg, TRUE);
} }
@ -2526,7 +2526,7 @@ ui_show_form_field(ProfWin *window, DataForm *form, char *tag)
{ {
FormField *field = form_get_field_by_tag(form, tag); FormField *field = form_get_field_by_tag(form, tag);
_ui_handle_form_field(window, tag, field); _ui_handle_form_field(window, tag, field);
win_println(window, ""); win_println(window, 0, "");
} }
void void

View File

@ -240,6 +240,7 @@ void ui_inp_history_append(char *inp);
// console window actions // console window actions
void cons_show(const char * const msg, ...); void cons_show(const char * const msg, ...);
void cons_show_padded(int pad, const char * const msg, ...);
void cons_about(void); void cons_about(void);
void cons_help(void); void cons_help(void);
void cons_show_help(Command *command); void cons_show_help(Command *command);
@ -359,7 +360,7 @@ void win_show_occupant(ProfWin *window, Occupant *occupant);
void win_show_occupant_info(ProfWin *window, const char * const room, Occupant *occupant); void win_show_occupant_info(ProfWin *window, const char * const room, Occupant *occupant);
void win_show_contact(ProfWin *window, PContact contact); void win_show_contact(ProfWin *window, PContact contact);
void win_show_info(ProfWin *window, PContact contact); void win_show_info(ProfWin *window, PContact contact);
void win_println(ProfWin *window, const char * const message); void win_println(ProfWin *window, int pad, const char * const message);
// desktop notifier actions // desktop notifier actions
void notifier_initialise(void); void notifier_initialise(void);

View File

@ -947,9 +947,9 @@ win_mark_received(ProfWin *window, const char * const id)
} }
void void
win_println(ProfWin *window, const char * const message) win_println(ProfWin *window, int pad, const char * const message)
{ {
win_print(window, '-', 0, NULL, 0, 0, "", message); win_print(window, '-', pad, NULL, 0, 0, "", message);
} }
void void

View File

@ -358,6 +358,8 @@ void cons_show(const char * const msg, ...)
va_end(args); va_end(args);
} }
void cons_show_padded(int pad, const char * const msg, ...) {}
void cons_show_help(Command *command) {} void cons_show_help(Command *command) {}
void cons_about(void) {} void cons_about(void) {}
@ -549,7 +551,7 @@ void win_show_occupant(ProfWin *window, Occupant *occupant) {}
void win_show_occupant_info(ProfWin *window, const char * const room, Occupant *occupant) {} void win_show_occupant_info(ProfWin *window, const char * const room, Occupant *occupant) {}
void win_show_contact(ProfWin *window, PContact contact) {} void win_show_contact(ProfWin *window, PContact contact) {}
void win_show_info(ProfWin *window, PContact contact) {} void win_show_info(ProfWin *window, PContact contact) {}
void win_println(ProfWin *window, const char * const message) {} void win_println(ProfWin *window, int pad, const char * const message) {}
// desktop notifier actions // desktop notifier actions
void notifier_uninit(void) {} void notifier_uninit(void) {}