mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Allow /msg with no message, to open a chat window with a contact
This commit is contained in:
parent
478aa671fc
commit
846d3f848a
@ -220,18 +220,15 @@ static struct cmd_t main_commands[] =
|
||||
NULL } } },
|
||||
|
||||
{ "/msg",
|
||||
_cmd_msg, parse_args_with_freetext, 2, 2,
|
||||
{ "/msg user@host mesg", "Send mesg to user.",
|
||||
{ "/msg user@host mesg",
|
||||
"-------------------",
|
||||
"Send a message to the user specified.",
|
||||
"Use tab completion to autocomplete online contacts.",
|
||||
"If there is no current chat with the recipient, a new chat window",
|
||||
"will be opened, and highlighted in the status bar at the bottom.",
|
||||
"pressing the corresponding F key will take you to that window.",
|
||||
"This command can be called from any window, including chat with other users.",
|
||||
_cmd_msg, parse_args_with_freetext, 1, 2,
|
||||
{ "/msg user@host [message]", "Start chat window with user.",
|
||||
{ "/msg user@host [message]",
|
||||
"------------------------",
|
||||
"Open a chat window with user@host and send the message if one is supplied.",
|
||||
"Use tab completion to autocomplete conacts from the roster.",
|
||||
"",
|
||||
"Example : /msg boothj5@gmail.com Hey, here's a message!",
|
||||
"Example : /msg myfriend@server.com Hey, here's a message!",
|
||||
"Example : /msg otherfriend@server.com",
|
||||
NULL } } },
|
||||
|
||||
{ "/info",
|
||||
@ -1402,9 +1399,15 @@ _cmd_msg(gchar **args, struct cmd_help_t help)
|
||||
|
||||
if (conn_status != JABBER_CONNECTED) {
|
||||
cons_show("You are not currently connected.");
|
||||
} else if (ui_windows_full()) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (ui_windows_full()) {
|
||||
cons_bad_show("Windows all used, close a window and try again.");
|
||||
} else {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (msg != NULL) {
|
||||
jabber_send(msg, usr);
|
||||
win_show_outgoing_msg("me", usr, msg);
|
||||
|
||||
@ -1412,9 +1415,12 @@ _cmd_msg(gchar **args, struct cmd_help_t help)
|
||||
const char *jid = jabber_get_jid();
|
||||
chat_log_chat(jid, usr, msg, OUT, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
} else {
|
||||
win_new_chat_win(usr);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
1
src/ui.h
1
src/ui.h
@ -107,6 +107,7 @@ void win_show_gone(const char * const from);
|
||||
void win_show_system_msg(const char * const from, const char *message);
|
||||
void win_show_outgoing_msg(const char * const from, const char * const to,
|
||||
const char * const message);
|
||||
void win_new_chat_win(const char * const to);
|
||||
|
||||
void win_join_chat(const char * const room, const char * const nick);
|
||||
void win_show_room_roster(const char * const room);
|
||||
|
@ -637,6 +637,39 @@ win_show_gone(const char * const from)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
win_new_chat_win(const char * const to)
|
||||
{
|
||||
// if the contact is offline, show a message
|
||||
PContact contact = contact_list_get_contact(to);
|
||||
int win_index = _find_prof_win_index(to);
|
||||
WINDOW *win = NULL;
|
||||
|
||||
// create new window
|
||||
if (win_index == NUM_WINS) {
|
||||
win_index = _new_prof_win(to, WIN_CHAT);
|
||||
win = windows[win_index]->win;
|
||||
|
||||
if (prefs_get_chlog() && prefs_get_history()) {
|
||||
_win_show_history(win, win_index, to);
|
||||
}
|
||||
|
||||
if (contact != NULL) {
|
||||
if (strcmp(p_contact_presence(contact), "offline") == 0) {
|
||||
const char const *show = p_contact_presence(contact);
|
||||
const char const *status = p_contact_status(contact);
|
||||
_show_status_string(win, to, show, status, "--", "offline");
|
||||
}
|
||||
}
|
||||
|
||||
// use existing window
|
||||
} else {
|
||||
win = windows[win_index]->win;
|
||||
}
|
||||
|
||||
ui_switch_win(win_index);
|
||||
}
|
||||
|
||||
void
|
||||
win_show_outgoing_msg(const char * const from, const char * const to,
|
||||
const char * const message)
|
||||
|
Loading…
Reference in New Issue
Block a user