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

Tidied roster commands

This commit is contained in:
James Booth 2015-11-22 17:45:38 +00:00
parent 0f22179eef
commit 216493ef07
8 changed files with 200 additions and 166 deletions

View File

@ -278,12 +278,12 @@ static struct cmd_t command_defs[] =
"/roster hide [offline|resource|presence|status|empty|count|priority]",
"/roster by group|presence|none",
"/roster order name|presence",
"/roster char header <char>|none",
"/roster char contact <char>|none",
"/roster char resource <char>|none",
"/roster indent contact <indent>",
"/roster indent resource <indent>",
"/roster indent presence <indent>",
"/roster header char <char>|none",
"/roster presence indent <indent>",
"/roster contact char <char>|none",
"/roster contact indent <indent>",
"/roster resource char <char>|none",
"/roster resource indent <indent>",
"/roster resource join on|off",
"/roster size <percent>",
"/roster wrap on|off",
@ -318,16 +318,16 @@ static struct cmd_t command_defs[] =
{ "by none", "No grouping in the roster panel." },
{ "order name", "Order roster items by name only." },
{ "order presence", "Order roster items by presence, and then by name." },
{ "char header <char>", "Prefix roster headers with specificed character." },
{ "char header none", "Remove roster header character prefix." },
{ "char contact <char>", "Prefix roster contacts with specificed character." },
{ "char contact none", "Remove roster contact character prefix." },
{ "char resource <char>", "Prefix roster resources with specificed character." },
{ "char resource none", "Remove roster resource character prefix." },
{ "indent contact <indent>", "Indent contact line by <indent> spaces (0 to 10)." },
{ "indent resource <indent>", "Indent resource line by <indent> spaces (0 to 10)." },
{ "indent presence <indent>", "Indent presence line by <indent> spaces (-1 to 10), a value of -1 will show presence on the previous line." },
{ "header char <char>", "Prefix roster headers with specificed character." },
{ "header char none", "Remove roster header character prefix." },
{ "contact char <char>", "Prefix roster contacts with specificed character." },
{ "contact char none", "Remove roster contact character prefix." },
{ "contact indent <indent>", "Indent contact line by <indent> spaces (0 to 10)." },
{ "resource char <char>", "Prefix roster resources with specificed character." },
{ "resource char none", "Remove roster resource character prefix." },
{ "resource indent <indent>", "Indent resource line by <indent> spaces (0 to 10)." },
{ "resource join on|off", "Join resource with previous line when only one available resource." },
{ "presence indent <indent>", "Indent presence line by <indent> spaces (-1 to 10), a value of -1 will show presence on the previous line." },
{ "size <precent>", "Percentage of the screen taken up by the roster (1-99)." },
{ "wrap on|off", "Enabled or disanle line wrapping in roster panel." },
{ "add <jid> [<nick>]", "Add a new item to the roster." },
@ -1795,13 +1795,14 @@ static Autocomplete disco_ac;
static Autocomplete close_ac;
static Autocomplete wins_ac;
static Autocomplete roster_ac;
static Autocomplete roster_resource_ac;
static Autocomplete roster_char_ac;
static Autocomplete roster_char_none_ac;
static Autocomplete roster_indent_ac;
static Autocomplete roster_option_ac;
static Autocomplete roster_show_ac;
static Autocomplete roster_by_ac;
static Autocomplete roster_order_ac;
static Autocomplete roster_header_ac;
static Autocomplete roster_contact_ac;
static Autocomplete roster_resource_ac;
static Autocomplete roster_presence_ac;
static Autocomplete roster_char_ac;
static Autocomplete roster_remove_all_ac;
static Autocomplete group_ac;
static Autocomplete bookmark_ac;
@ -2047,35 +2048,38 @@ cmd_init(void)
autocomplete_add(roster_ac, "by");
autocomplete_add(roster_ac, "order");
autocomplete_add(roster_ac, "size");
autocomplete_add(roster_ac, "char");
autocomplete_add(roster_ac, "indent");
autocomplete_add(roster_ac, "wrap");
autocomplete_add(roster_ac, "header");
autocomplete_add(roster_ac, "contact");
autocomplete_add(roster_ac, "resource");
autocomplete_add(roster_ac, "presence");
roster_header_ac = autocomplete_new();
autocomplete_add(roster_header_ac, "char");
roster_contact_ac = autocomplete_new();
autocomplete_add(roster_contact_ac, "char");
autocomplete_add(roster_contact_ac, "indent");
roster_resource_ac = autocomplete_new();
autocomplete_add(roster_resource_ac, "char");
autocomplete_add(roster_resource_ac, "indent");
autocomplete_add(roster_resource_ac, "join");
roster_presence_ac = autocomplete_new();
autocomplete_add(roster_presence_ac, "indent");
roster_char_ac = autocomplete_new();
autocomplete_add(roster_char_ac, "header");
autocomplete_add(roster_char_ac, "contact");
autocomplete_add(roster_char_ac, "resource");
autocomplete_add(roster_char_ac, "none");
roster_char_none_ac = autocomplete_new();
autocomplete_add(roster_char_none_ac, "none");
roster_indent_ac = autocomplete_new();
autocomplete_add(roster_indent_ac, "contact");
autocomplete_add(roster_indent_ac, "resource");
autocomplete_add(roster_indent_ac, "presence");
roster_option_ac = autocomplete_new();
autocomplete_add(roster_option_ac, "offline");
autocomplete_add(roster_option_ac, "resource");
autocomplete_add(roster_option_ac, "presence");
autocomplete_add(roster_option_ac, "status");
autocomplete_add(roster_option_ac, "empty");
autocomplete_add(roster_option_ac, "count");
autocomplete_add(roster_option_ac, "priority");
roster_show_ac = autocomplete_new();
autocomplete_add(roster_show_ac, "offline");
autocomplete_add(roster_show_ac, "resource");
autocomplete_add(roster_show_ac, "presence");
autocomplete_add(roster_show_ac, "status");
autocomplete_add(roster_show_ac, "empty");
autocomplete_add(roster_show_ac, "count");
autocomplete_add(roster_show_ac, "priority");
roster_by_ac = autocomplete_new();
autocomplete_add(roster_by_ac, "group");
@ -2338,11 +2342,12 @@ cmd_uninit(void)
autocomplete_free(close_ac);
autocomplete_free(wins_ac);
autocomplete_free(roster_ac);
autocomplete_free(roster_header_ac);
autocomplete_free(roster_contact_ac);
autocomplete_free(roster_resource_ac);
autocomplete_free(roster_presence_ac);
autocomplete_free(roster_char_ac);
autocomplete_free(roster_char_none_ac);
autocomplete_free(roster_indent_ac);
autocomplete_free(roster_option_ac);
autocomplete_free(roster_show_ac);
autocomplete_free(roster_by_ac);
autocomplete_free(roster_order_ac);
autocomplete_free(roster_remove_all_ac);
@ -2529,11 +2534,12 @@ cmd_reset_autocomplete(ProfWin *window)
autocomplete_reset(close_ac);
autocomplete_reset(wins_ac);
autocomplete_reset(roster_ac);
autocomplete_reset(roster_header_ac);
autocomplete_reset(roster_contact_ac);
autocomplete_reset(roster_resource_ac);
autocomplete_reset(roster_presence_ac);
autocomplete_reset(roster_char_ac);
autocomplete_reset(roster_char_none_ac);
autocomplete_reset(roster_indent_ac);
autocomplete_reset(roster_option_ac);
autocomplete_reset(roster_show_ac);
autocomplete_reset(roster_by_ac);
autocomplete_reset(roster_order_ac);
autocomplete_reset(roster_remove_all_ac);
@ -2921,22 +2927,22 @@ static char*
_roster_autocomplete(ProfWin *window, const char *const input)
{
char *result = NULL;
result = autocomplete_param_with_ac(input, "/roster header char", roster_char_ac, TRUE);
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/roster contact char", roster_char_ac, TRUE);
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/roster resource char", roster_char_ac, TRUE);
if (result) {
return result;
}
result = autocomplete_param_with_func(input, "/roster resource join", prefs_autocomplete_boolean_choice);
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/roster char header", roster_char_none_ac, TRUE);
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/roster char contact", roster_char_none_ac, TRUE);
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/roster char resource", roster_char_none_ac, TRUE);
if (result) {
return result;
}
result = autocomplete_param_with_func(input, "/roster nick", roster_barejid_autocomplete);
if (result) {
return result;
@ -2953,11 +2959,11 @@ _roster_autocomplete(ProfWin *window, const char *const input)
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/roster show", roster_option_ac, TRUE);
result = autocomplete_param_with_ac(input, "/roster show", roster_show_ac, TRUE);
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/roster hide", roster_option_ac, TRUE);
result = autocomplete_param_with_ac(input, "/roster hide", roster_show_ac, TRUE);
if (result) {
return result;
}
@ -2969,22 +2975,26 @@ _roster_autocomplete(ProfWin *window, const char *const input)
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/roster char", roster_char_ac, TRUE);
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/roster indent", roster_indent_ac, TRUE);
if (result) {
return result;
}
result = autocomplete_param_with_func(input, "/roster wrap", prefs_autocomplete_boolean_choice);
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/roster header", roster_header_ac, TRUE);
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/roster contact", roster_contact_ac, TRUE);
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/roster resource", roster_resource_ac, TRUE);
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/roster presence", roster_presence_ac, TRUE);
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/roster", roster_ac, TRUE);
if (result) {
return result;

View File

@ -1756,25 +1756,14 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args)
cons_bad_cmd_usage(command);
return TRUE;
} else {
int res = _cmd_set_boolean_preference(args[1], command, "Roster panel line wrap", PREF_ROSTER_WRAP);
int res = _cmd_set_boolean_preference(args[1], command, "Roster panel line wrap", PREF_ROSTER_WRAP);
rosterwin_roster();
return res;
}
// roster join with previous line
} else if (g_strcmp0(args[0], "resource") == 0) {
if (g_strcmp0(args[1], "join") == 0) {
int res = _cmd_set_boolean_preference(args[2], command, "Roster join", PREF_ROSTER_RESOURCE_JOIN);
rosterwin_roster();
return res;
} else {
cons_bad_cmd_usage(command);
return TRUE;
}
// set header character
} else if (g_strcmp0(args[0], "char") == 0) {
if (g_strcmp0(args[1], "header") == 0) {
// header settings
} else if (g_strcmp0(args[0], "header") == 0) {
if (g_strcmp0(args[1], "char") == 0) {
if (!args[2]) {
cons_bad_cmd_usage(command);
} else if (g_strcmp0(args[2], "none") == 0) {
@ -1786,7 +1775,14 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args)
cons_show("Roster header char set to %c.", args[2][0]);
rosterwin_roster();
}
} else if (g_strcmp0(args[1], "contact") == 0) {
} else {
cons_bad_cmd_usage(command);
}
return TRUE;
// contact settings
} else if (g_strcmp0(args[0], "contact") == 0) {
if (g_strcmp0(args[1], "char") == 0) {
if (!args[2]) {
cons_bad_cmd_usage(command);
} else if (g_strcmp0(args[2], "none") == 0) {
@ -1798,26 +1794,7 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args)
cons_show("Roster contact char set to %c.", args[2][0]);
rosterwin_roster();
}
} else if (g_strcmp0(args[1], "resource") == 0) {
if (!args[2]) {
cons_bad_cmd_usage(command);
} else if (g_strcmp0(args[2], "none") == 0) {
prefs_clear_roster_resource_char();
cons_show("Roster resource char removed.");
rosterwin_roster();
} else {
prefs_set_roster_resource_char(args[2][0]);
cons_show("Roster resource char set to %c.", args[2][0]);
rosterwin_roster();
}
} else {
cons_bad_cmd_usage(command);
}
return TRUE;
// set indentations
} else if (g_strcmp0(args[0], "indent") == 0) {
if (g_strcmp0(args[1], "contact") == 0) {
} else if (g_strcmp0(args[1], "indent") == 0) {
if (!args[2]) {
cons_bad_cmd_usage(command);
} else {
@ -1833,7 +1810,26 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args)
free(err_msg);
}
}
} else if (g_strcmp0(args[1], "resource") == 0) {
} else {
cons_bad_cmd_usage(command);
}
return TRUE;
// resource settings
} else if (g_strcmp0(args[0], "resource") == 0) {
if (g_strcmp0(args[1], "char") == 0) {
if (!args[2]) {
cons_bad_cmd_usage(command);
} else if (g_strcmp0(args[2], "none") == 0) {
prefs_clear_roster_resource_char();
cons_show("Roster resource char removed.");
rosterwin_roster();
} else {
prefs_set_roster_resource_char(args[2][0]);
cons_show("Roster resource char set to %c.", args[2][0]);
rosterwin_roster();
}
} else if (g_strcmp0(args[1], "indent") == 0) {
if (!args[2]) {
cons_bad_cmd_usage(command);
} else {
@ -1849,7 +1845,18 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args)
free(err_msg);
}
}
} else if (g_strcmp0(args[1], "presence") == 0) {
} else if (g_strcmp0(args[1], "join") == 0) {
int res = _cmd_set_boolean_preference(args[2], command, "Roster join", PREF_ROSTER_RESOURCE_JOIN);
rosterwin_roster();
return res;
} else {
cons_bad_cmd_usage(command);
}
return TRUE;
// presence settings
} else if (g_strcmp0(args[0], "presence") == 0) {
if (g_strcmp0(args[1], "indent") == 0) {
if (!args[2]) {
cons_bad_cmd_usage(command);
} else {
@ -1993,6 +2000,7 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args)
cons_bad_cmd_usage(command);
return TRUE;
}
// roster grouping
} else if (g_strcmp0(args[0], "by") == 0) {
if (g_strcmp0(args[1], "group") == 0) {
@ -2020,6 +2028,7 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args)
cons_bad_cmd_usage(command);
return TRUE;
}
// roster item order
} else if (g_strcmp0(args[0], "order") == 0) {
if (g_strcmp0(args[1], "name") == 0) {
@ -2040,6 +2049,7 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args)
cons_bad_cmd_usage(command);
return TRUE;
}
// add contact
} else if (strcmp(args[0], "add") == 0) {
if (conn_status != JABBER_CONNECTED) {

View File

@ -458,6 +458,7 @@ _load_preferences(void)
_set_boolean_preference("roster", PREF_ROSTER);
_set_boolean_preference("roster.offline", PREF_ROSTER_OFFLINE);
_set_boolean_preference("roster.resource", PREF_ROSTER_RESOURCE);
_set_boolean_preference("roster.resource.join", PREF_ROSTER_RESOURCE_JOIN);
_set_boolean_preference("roster.presence", PREF_ROSTER_PRESENCE);
_set_boolean_preference("roster.status", PREF_ROSTER_STATUS);
_set_boolean_preference("roster.empty", PREF_ROSTER_EMPTY);
@ -476,6 +477,8 @@ _load_preferences(void)
prefs_set_roster_header_char(ch[0]);
g_free(ch);
}
} else {
prefs_clear_roster_header_char();
}
if (g_key_file_has_key(theme, "ui", "roster.contact.char", NULL)) {
gchar *ch = g_key_file_get_string(theme, "ui", "roster.contact.char", NULL);
@ -483,6 +486,8 @@ _load_preferences(void)
prefs_set_roster_contact_char(ch[0]);
g_free(ch);
}
} else {
prefs_clear_roster_contact_char();
}
if (g_key_file_has_key(theme, "ui", "roster.resource.char", NULL)) {
gchar *ch = g_key_file_get_string(theme, "ui", "roster.resource.char", NULL);
@ -490,6 +495,8 @@ _load_preferences(void)
prefs_set_roster_resource_char(ch[0]);
g_free(ch);
}
} else {
prefs_clear_roster_resource_char();
}
if (g_key_file_has_key(theme, "ui", "roster.contact.indent", NULL)) {
gint contact_indent = g_key_file_get_integer(theme, "ui", "roster.contact.indent", NULL);

View File

@ -1202,16 +1202,48 @@ cons_roster_setting(void)
else
cons_show("Roster offline (/roster) : hide");
char header_ch = prefs_get_roster_header_char();
if (header_ch)
cons_show("Roster header char (/roster) : %c", header_ch);
else
cons_show("Roster header char (/roster) : none");
char contact_ch = prefs_get_roster_contact_char();
if (contact_ch)
cons_show("Roster contact char (/roster) : %c", contact_ch);
else
cons_show("Roster contact char (/roster) : none");
gint contact_indent = prefs_get_roster_contact_indent();
cons_show("Roster contact indent (/roster) : %d", contact_indent);
if (prefs_get_boolean(PREF_ROSTER_RESOURCE))
cons_show("Roster resource (/roster) : show");
else
cons_show("Roster resource (/roster) : hide");
char resource_ch = prefs_get_roster_resource_char();
if (resource_ch)
cons_show("Roster resource char (/roster) : %c", resource_ch);
else
cons_show("Roster resource char (/roster) : none");
gint resource_indent = prefs_get_roster_resource_indent();
cons_show("Roster resource indent (/roster) : %d", resource_indent);
if (prefs_get_boolean(PREF_ROSTER_RESOURCE_JOIN))
cons_show("Roster resource join (/roster) : on");
else
cons_show("Roster resource join (/roster) : off");
if (prefs_get_boolean(PREF_ROSTER_PRESENCE))
cons_show("Roster presence (/roster) : show");
else
cons_show("Roster presence (/roster) : hide");
gint presence_indent = prefs_get_roster_presence_indent();
cons_show("Roster presence indent (/roster) : %d", presence_indent);
if (prefs_get_boolean(PREF_ROSTER_STATUS))
cons_show("Roster status (/roster) : show");
else
@ -1243,33 +1275,6 @@ cons_roster_setting(void)
int size = prefs_get_roster_size();
cons_show("Roster size (/roster) : %d", size);
char header_ch = prefs_get_roster_header_char();
if (header_ch)
cons_show("Roster header char (/roster) : %c", header_ch);
else
cons_show("Roster header char (/roster) : none");
char contact_ch = prefs_get_roster_contact_char();
if (contact_ch)
cons_show("Roster contact char (/roster) : %c", contact_ch);
else
cons_show("Roster contact char (/roster) : none");
char resource_ch = prefs_get_roster_resource_char();
if (resource_ch)
cons_show("Roster resource char (/roster) : %c", resource_ch);
else
cons_show("Roster resource char (/roster) : none");
gint contact_indent = prefs_get_roster_contact_indent();
cons_show("Roster contact indent (/roster) : %d", contact_indent);
gint resource_indent = prefs_get_roster_resource_indent();
cons_show("Roster resource indent (/roster) : %d", resource_indent);
gint presence_indent = prefs_get_roster_presence_indent();
cons_show("Roster presence indent (/roster) : %d", presence_indent);
if (prefs_get_boolean(PREF_ROSTER_WRAP))
cons_show("Roster wrap (/roster) : ON");
else

View File

@ -73,22 +73,23 @@ statuses.chat=
statuses.muc=
roster=
roster.offline=
roster.resource=
roster.presence=
roster.status=
roster.empty=
roster.by=
roster.order=
roster.count=
roster.priority=
roster.size=
roster.wrap=
roster.header.char=
roster.contact.char=
roster.resource.char=
roster.contact.indent=
roster.resource=
roster.resource.char=
roster.resource.indent=
roster.resource.join=
roster.presence=
roster.presence.indent=
roster.wrap=
roster.status=
occupants=
occupants.size=
occupants.jid=

View File

@ -71,22 +71,24 @@ resource.message=true
statuses.console=all
statuses.chat=all
statuses.muc=all
roster.by=presence
roster.offline=true
roster.empty=false
roster.presence=true
roster.order=presence
roster.status=true
roster.resource=true
roster.priority=false
roster=true
roster.offline=true
roster.empty=true
roster.by=group
roster.order=presence
roster.count=true
roster.priority=true
roster.size=25
roster.contact.indent=1
roster.resource.indent=2
roster.presence.indent=-1
roster.header.char=@
roster.wrap=true
roster.header.char=@
roster.contact.indent=1
roster.resource=true
roster.resource.char=/
roster.resource.indent=1
roster.resource.join=true
roster.presence=true
roster.presence.indent=-1
roster.status=true
occupants=true
occupants.size=15
occupants.jid=false

View File

@ -20,22 +20,23 @@ occupants.size=15
occupants.jid=true
roster=true
roster.offline=true
roster.resource=true
roster.presence=true
roster.status=true
roster.empty=true
roster.by=presence
roster.order=presence
roster.count=true
roster.priority=true
roster.size=25
roster.header.char=-
roster.contact.char=-
roster.resource.char=-
roster.contact.indent=2
roster.resource.indent=2
roster.presence.indent=2
roster.wrap=true
roster.header.char=@
roster.contact.char=-
roster.contact.indent=1
roster.resource=true
roster.resource.char=/
roster.resource.indent=1
roster.resource.join=false
roster.presence=true
roster.presence.indent=1
roster.status=true
privileges=true
presence=true
intype=true

View File

@ -19,19 +19,17 @@ occupants=true
occupants.size=15
roster=true
roster.offline=false
roster.resource=false
roster.presence=false
roster.status=false
roster.empty=false
roster.by=none
roster.order=presence
roster.count=false
roster.priority=false
roster.size=25
roster.contact.indent=0
roster.resource.indent=0
roster.presence.indent=-1
roster.wrap=false
roster.contact.indent=0
roster.resource=false
roster.presence=false
roster.status=false
privileges=false
presence=false
intype=false