mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Add occupants wrap option
Wrapping for the occupants panel like already exists for the roster panel. See `/occupants wrap on`. Regards https://github.com/boothj5/profanity/issues/690
This commit is contained in:
parent
637dfca6dd
commit
125ca2f0d2
@ -687,6 +687,7 @@ cmd_ac_init(void)
|
||||
autocomplete_add(occupants_ac, "size");
|
||||
autocomplete_add(occupants_ac, "indent");
|
||||
autocomplete_add(occupants_ac, "header");
|
||||
autocomplete_add(occupants_ac, "wrap");
|
||||
|
||||
occupants_default_ac = autocomplete_new();
|
||||
autocomplete_add(occupants_default_ac, "show");
|
||||
@ -2592,6 +2593,11 @@ _occupants_autocomplete(ProfWin *window, const char *const input, gboolean previ
|
||||
return found;
|
||||
}
|
||||
|
||||
found = autocomplete_param_with_func(input, "/occupants wrap", prefs_autocomplete_boolean_choice, previous);
|
||||
if (found) {
|
||||
return found;
|
||||
}
|
||||
|
||||
found = autocomplete_param_with_ac(input, "/occupants", occupants_ac, TRUE, previous);
|
||||
if (found) {
|
||||
return found;
|
||||
|
@ -4391,6 +4391,17 @@ cmd_occupants(ProfWin *window, const char *const command, gchar **args)
|
||||
}
|
||||
}
|
||||
|
||||
if (g_strcmp0(args[0], "wrap") == 0) {
|
||||
if (!args[1]) {
|
||||
cons_bad_cmd_usage(command);
|
||||
return TRUE;
|
||||
} else {
|
||||
_cmd_set_boolean_preference(args[1], command, "Occupants panel line wrap", PREF_OCCUPANTS_WRAP);
|
||||
occupantswin_occupants_all();
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_strcmp0(args[0], "default") == 0) {
|
||||
if (g_strcmp0(args[1], "show") == 0) {
|
||||
if (g_strcmp0(args[2], "jid") == 0) {
|
||||
|
@ -1641,6 +1641,7 @@ _get_group(preference_t pref)
|
||||
case PREF_HISTORY:
|
||||
case PREF_OCCUPANTS:
|
||||
case PREF_OCCUPANTS_JID:
|
||||
case PREF_OCCUPANTS_WRAP:
|
||||
case PREF_STATUSES:
|
||||
case PREF_STATUSES_CONSOLE:
|
||||
case PREF_STATUSES_CHAT:
|
||||
@ -1788,6 +1789,8 @@ _get_key(preference_t pref)
|
||||
return "occupants";
|
||||
case PREF_OCCUPANTS_JID:
|
||||
return "occupants.jid";
|
||||
case PREF_OCCUPANTS_WRAP:
|
||||
return "occupants.wrap";
|
||||
case PREF_MUC_PRIVILEGES:
|
||||
return "privileges";
|
||||
case PREF_STATUSES:
|
||||
|
@ -150,6 +150,7 @@ typedef enum {
|
||||
PREF_STATUSBAR_ROOM,
|
||||
PREF_OMEMO_LOG,
|
||||
PREF_OMEMO_POLICY,
|
||||
PREF_OCCUPANTS_WRAP,
|
||||
} preference_t;
|
||||
|
||||
typedef struct prof_alias_t {
|
||||
|
@ -388,6 +388,7 @@ _load_preferences(void)
|
||||
_set_boolean_preference("resource.message", PREF_RESOURCE_MESSAGE);
|
||||
_set_boolean_preference("occupants", PREF_OCCUPANTS);
|
||||
_set_boolean_preference("occupants.jid", PREF_OCCUPANTS_JID);
|
||||
_set_boolean_preference("occupants.wrap", PREF_OCCUPANTS_WRAP);
|
||||
_set_boolean_preference("roster", PREF_ROSTER);
|
||||
_set_boolean_preference("roster.offline", PREF_ROSTER_OFFLINE);
|
||||
_set_boolean_preference("roster.resource", PREF_ROSTER_RESOURCE);
|
||||
|
@ -1232,6 +1232,11 @@ cons_occupants_setting(void)
|
||||
else
|
||||
cons_show("Occupant jids (/occupants) : hide");
|
||||
|
||||
if (prefs_get_boolean(PREF_OCCUPANTS_WRAP))
|
||||
cons_show("Occupants wrap (/occupants) : ON");
|
||||
else
|
||||
cons_show("Occupants wrap (/occupants) : OFF");
|
||||
|
||||
gint occupant_indent = prefs_get_occupants_indent();
|
||||
cons_show("Occupant indent (/occupants) : %d", occupant_indent);
|
||||
|
||||
|
@ -49,7 +49,9 @@ _occuptantswin_occupant(ProfLayoutSplit *layout, Occupant *occupant, gboolean sh
|
||||
GString *spaces = g_string_new(" ");
|
||||
|
||||
int indent = prefs_get_occupants_indent();
|
||||
int current_indent = 0;
|
||||
if (indent > 0) {
|
||||
current_indent += indent;
|
||||
while (indent > 0) {
|
||||
g_string_append(spaces, " ");
|
||||
indent--;
|
||||
@ -59,8 +61,10 @@ _occuptantswin_occupant(ProfLayoutSplit *layout, Occupant *occupant, gboolean sh
|
||||
GString *msg = g_string_new("");
|
||||
g_string_append(msg, spaces->str);
|
||||
|
||||
gboolean wrap = prefs_get_boolean(PREF_OCCUPANTS_WRAP);
|
||||
|
||||
g_string_append(msg, occupant->nick);
|
||||
win_sub_print(layout->subwin, msg->str, TRUE, FALSE, 0);
|
||||
win_sub_print(layout->subwin, msg->str, TRUE, wrap, current_indent);
|
||||
g_string_free(msg, TRUE);
|
||||
|
||||
if (showjid && occupant->jid) {
|
||||
@ -69,7 +73,7 @@ _occuptantswin_occupant(ProfLayoutSplit *layout, Occupant *occupant, gboolean sh
|
||||
g_string_append(msg, " ");
|
||||
|
||||
g_string_append(msg, occupant->jid);
|
||||
win_sub_print(layout->subwin, msg->str, TRUE, FALSE, 0);
|
||||
win_sub_print(layout->subwin, msg->str, TRUE, wrap, current_indent);
|
||||
g_string_free(msg, TRUE);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user