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

Merge branch 'master' into osx-functional

This commit is contained in:
James Booth 2015-11-22 01:40:38 +00:00
commit 86728bf987
11 changed files with 60 additions and 19 deletions

View File

@ -284,6 +284,7 @@ static struct cmd_t command_defs[] =
"/roster indent resource <indent>", "/roster indent resource <indent>",
"/roster indent presence <indent>", "/roster indent presence <indent>",
"/roster size <percent>", "/roster size <percent>",
"/roster wrap on|off",
"/roster add <jid> [<nick>]", "/roster add <jid> [<nick>]",
"/roster remove <jid>", "/roster remove <jid>",
"/roster remove_all contacts", "/roster remove_all contacts",
@ -323,6 +324,7 @@ static struct cmd_t command_defs[] =
{ "indent resource <indent>", "Indent resource line by <indent> spaces." }, { "indent resource <indent>", "Indent resource line by <indent> spaces." },
{ "indent presence <indent>", "Indent presence line by <indent> spaces." }, { "indent presence <indent>", "Indent presence line by <indent> spaces." },
{ "size <precent>", "Percentage of the screen taken up by the roster (1-99)." }, { "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." }, { "add <jid> [<nick>]", "Add a new item to the roster." },
{ "remove <jid>", "Removes an item from the roster." }, { "remove <jid>", "Removes an item from the roster." },
{ "remove_all contacts", "Remove all items from roster." }, { "remove_all contacts", "Remove all items from roster." },
@ -2041,6 +2043,7 @@ cmd_init(void)
autocomplete_add(roster_ac, "size"); autocomplete_add(roster_ac, "size");
autocomplete_add(roster_ac, "char"); autocomplete_add(roster_ac, "char");
autocomplete_add(roster_ac, "indent"); autocomplete_add(roster_ac, "indent");
autocomplete_add(roster_ac, "wrap");
roster_char_ac = autocomplete_new(); roster_char_ac = autocomplete_new();
autocomplete_add(roster_char_ac, "header"); autocomplete_add(roster_char_ac, "header");
@ -2953,6 +2956,10 @@ _roster_autocomplete(ProfWin *window, const char *const input)
if (result) { if (result) {
return 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", roster_ac, TRUE); result = autocomplete_param_with_ac(input, "/roster", roster_ac, TRUE);
if (result) { if (result) {
return result; return result;

View File

@ -1750,6 +1750,17 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args)
return TRUE; return TRUE;
} }
// set line wrapping
} else if (g_strcmp0(args[0], "wrap") == 0) {
if (!args[1]) {
cons_bad_cmd_usage(command);
return TRUE;
} else {
int res = _cmd_set_boolean_preference(args[1], command, "Roster panel line wrap", PREF_ROSTER_WRAP);
rosterwin_roster();
return res;
}
// set header character // set header character
} else if (g_strcmp0(args[0], "char") == 0) { } else if (g_strcmp0(args[0], "char") == 0) {
if (g_strcmp0(args[1], "header") == 0) { if (g_strcmp0(args[1], "header") == 0) {

View File

@ -732,6 +732,7 @@ _get_group(preference_t pref)
case PREF_ROSTER_ORDER: case PREF_ROSTER_ORDER:
case PREF_ROSTER_COUNT: case PREF_ROSTER_COUNT:
case PREF_ROSTER_PRIORITY: case PREF_ROSTER_PRIORITY:
case PREF_ROSTER_WRAP:
case PREF_RESOURCE_TITLE: case PREF_RESOURCE_TITLE:
case PREF_RESOURCE_MESSAGE: case PREF_RESOURCE_MESSAGE:
case PREF_ENC_WARN: case PREF_ENC_WARN:
@ -915,6 +916,8 @@ _get_key(preference_t pref)
return "roster.count"; return "roster.count";
case PREF_ROSTER_PRIORITY: case PREF_ROSTER_PRIORITY:
return "roster.priority"; return "roster.priority";
case PREF_ROSTER_WRAP:
return "roster.wrap";
case PREF_RESOURCE_TITLE: case PREF_RESOURCE_TITLE:
return "resource.title"; return "resource.title";
case PREF_RESOURCE_MESSAGE: case PREF_RESOURCE_MESSAGE:

View File

@ -71,6 +71,7 @@ typedef enum {
PREF_ROSTER_ORDER, PREF_ROSTER_ORDER,
PREF_ROSTER_COUNT, PREF_ROSTER_COUNT,
PREF_ROSTER_PRIORITY, PREF_ROSTER_PRIORITY,
PREF_ROSTER_WRAP,
PREF_MUC_PRIVILEGES, PREF_MUC_PRIVILEGES,
PREF_PRESENCE, PREF_PRESENCE,
PREF_WRAP, PREF_WRAP,

View File

@ -461,6 +461,7 @@ _load_preferences(void)
_set_boolean_preference("roster.presence", PREF_ROSTER_PRESENCE); _set_boolean_preference("roster.presence", PREF_ROSTER_PRESENCE);
_set_boolean_preference("roster.status", PREF_ROSTER_STATUS); _set_boolean_preference("roster.status", PREF_ROSTER_STATUS);
_set_boolean_preference("roster.empty", PREF_ROSTER_EMPTY); _set_boolean_preference("roster.empty", PREF_ROSTER_EMPTY);
_set_boolean_preference("roster.wrap", PREF_ROSTER_WRAP);
_set_string_preference("roster.by", PREF_ROSTER_BY); _set_string_preference("roster.by", PREF_ROSTER_BY);
_set_string_preference("roster.order", PREF_ROSTER_ORDER); _set_string_preference("roster.order", PREF_ROSTER_ORDER);
_set_boolean_preference("roster.count", PREF_ROSTER_COUNT); _set_boolean_preference("roster.count", PREF_ROSTER_COUNT);

View File

@ -1263,6 +1263,11 @@ cons_roster_setting(void)
gint presence_indent = prefs_get_roster_presence_indent(); gint presence_indent = prefs_get_roster_presence_indent();
cons_show("Roster presence indent (/roster) : %d", 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
cons_show("Roster wrap (/roster) : OFF");
} }
void void

View File

@ -48,13 +48,13 @@ _occuptantswin_occupant(ProfLayoutSplit *layout, Occupant *occupant, gboolean sh
GString *msg = g_string_new(" "); GString *msg = g_string_new(" ");
g_string_append(msg, occupant->nick); g_string_append(msg, occupant->nick);
win_sub_print(layout->subwin, msg->str, TRUE, FALSE); win_sub_print(layout->subwin, msg->str, TRUE, FALSE, 0);
g_string_free(msg, TRUE); g_string_free(msg, TRUE);
if (showjid && occupant->jid) { if (showjid && occupant->jid) {
GString *msg = g_string_new(" "); GString *msg = g_string_new(" ");
g_string_append(msg, occupant->jid); g_string_append(msg, occupant->jid);
win_sub_print(layout->subwin, msg->str, TRUE, FALSE); win_sub_print(layout->subwin, msg->str, TRUE, FALSE, 0);
g_string_free(msg, TRUE); g_string_free(msg, TRUE);
} }
@ -75,7 +75,7 @@ occupantswin_occupants(const char *const roomjid)
if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) { if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) {
wattron(layout->subwin, theme_attrs(THEME_OCCUPANTS_HEADER)); wattron(layout->subwin, theme_attrs(THEME_OCCUPANTS_HEADER));
win_sub_print(layout->subwin, " -Moderators", TRUE, FALSE); win_sub_print(layout->subwin, " -Moderators", TRUE, FALSE, 0);
wattroff(layout->subwin, theme_attrs(THEME_OCCUPANTS_HEADER)); wattroff(layout->subwin, theme_attrs(THEME_OCCUPANTS_HEADER));
GList *roster_curr = occupants; GList *roster_curr = occupants;
while (roster_curr) { while (roster_curr) {
@ -87,7 +87,7 @@ occupantswin_occupants(const char *const roomjid)
} }
wattron(layout->subwin, theme_attrs(THEME_OCCUPANTS_HEADER)); wattron(layout->subwin, theme_attrs(THEME_OCCUPANTS_HEADER));
win_sub_print(layout->subwin, " -Participants", TRUE, FALSE); win_sub_print(layout->subwin, " -Participants", TRUE, FALSE, 0);
wattroff(layout->subwin, theme_attrs(THEME_OCCUPANTS_HEADER)); wattroff(layout->subwin, theme_attrs(THEME_OCCUPANTS_HEADER));
roster_curr = occupants; roster_curr = occupants;
while (roster_curr) { while (roster_curr) {
@ -99,7 +99,7 @@ occupantswin_occupants(const char *const roomjid)
} }
wattron(layout->subwin, theme_attrs(THEME_OCCUPANTS_HEADER)); wattron(layout->subwin, theme_attrs(THEME_OCCUPANTS_HEADER));
win_sub_print(layout->subwin, " -Visitors", TRUE, FALSE); win_sub_print(layout->subwin, " -Visitors", TRUE, FALSE, 0);
wattroff(layout->subwin, theme_attrs(THEME_OCCUPANTS_HEADER)); wattroff(layout->subwin, theme_attrs(THEME_OCCUPANTS_HEADER));
roster_curr = occupants; roster_curr = occupants;
while (roster_curr) { while (roster_curr) {
@ -111,7 +111,7 @@ occupantswin_occupants(const char *const roomjid)
} }
} else { } else {
wattron(layout->subwin, theme_attrs(THEME_OCCUPANTS_HEADER)); wattron(layout->subwin, theme_attrs(THEME_OCCUPANTS_HEADER));
win_sub_print(layout->subwin, " -Occupants\n", TRUE, FALSE); win_sub_print(layout->subwin, " -Occupants\n", TRUE, FALSE, 0);
wattroff(layout->subwin, theme_attrs(THEME_OCCUPANTS_HEADER)); wattroff(layout->subwin, theme_attrs(THEME_OCCUPANTS_HEADER));
GList *roster_curr = occupants; GList *roster_curr = occupants;
while (roster_curr) { while (roster_curr) {

View File

@ -61,6 +61,8 @@ _rosterwin_presence(ProfLayoutSplit *layout, theme_item_t colour, const char *pr
current_indent += presence_indent; current_indent += presence_indent;
} }
gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP);
// show only status when grouped by presence // show only status when grouped by presence
if (by_presence) { if (by_presence) {
if (status && prefs_get_boolean(PREF_ROSTER_STATUS)) { if (status && prefs_get_boolean(PREF_ROSTER_STATUS)) {
@ -68,7 +70,7 @@ _rosterwin_presence(ProfLayoutSplit *layout, theme_item_t colour, const char *pr
if (presence_indent == -1) { if (presence_indent == -1) {
GString *msg = g_string_new(""); GString *msg = g_string_new("");
g_string_append_printf(msg, ": \"%s\"", status); g_string_append_printf(msg, ": \"%s\"", status);
win_sub_print(layout->subwin, msg->str, FALSE, FALSE); win_sub_print(layout->subwin, msg->str, FALSE, wrap, current_indent);
g_string_free(msg, TRUE); g_string_free(msg, TRUE);
wattroff(layout->subwin, theme_attrs(colour)); wattroff(layout->subwin, theme_attrs(colour));
} else { } else {
@ -79,7 +81,7 @@ _rosterwin_presence(ProfLayoutSplit *layout, theme_item_t colour, const char *pr
} }
g_string_append_printf(msg, "\"%s\"", status); g_string_append_printf(msg, "\"%s\"", status);
win_sub_newline_lazy(layout->subwin); win_sub_newline_lazy(layout->subwin);
win_sub_print(layout->subwin, msg->str, FALSE, FALSE); win_sub_print(layout->subwin, msg->str, FALSE, wrap, current_indent);
g_string_free(msg, TRUE); g_string_free(msg, TRUE);
wattroff(layout->subwin, theme_attrs(colour)); wattroff(layout->subwin, theme_attrs(colour));
} }
@ -98,7 +100,7 @@ _rosterwin_presence(ProfLayoutSplit *layout, theme_item_t colour, const char *pr
} else if (status && prefs_get_boolean(PREF_ROSTER_STATUS)) { } else if (status && prefs_get_boolean(PREF_ROSTER_STATUS)) {
g_string_append_printf(msg, ": \"%s\"", status); g_string_append_printf(msg, ": \"%s\"", status);
} }
win_sub_print(layout->subwin, msg->str, FALSE, FALSE); win_sub_print(layout->subwin, msg->str, FALSE, wrap, current_indent);
g_string_free(msg, TRUE); g_string_free(msg, TRUE);
wattroff(layout->subwin, theme_attrs(colour)); wattroff(layout->subwin, theme_attrs(colour));
} else { } else {
@ -116,7 +118,7 @@ _rosterwin_presence(ProfLayoutSplit *layout, theme_item_t colour, const char *pr
g_string_append_printf(msg, "\"%s\"", status); g_string_append_printf(msg, "\"%s\"", status);
} }
win_sub_newline_lazy(layout->subwin); win_sub_newline_lazy(layout->subwin);
win_sub_print(layout->subwin, msg->str, FALSE, FALSE); win_sub_print(layout->subwin, msg->str, FALSE, wrap, current_indent);
g_string_free(msg, TRUE); g_string_free(msg, TRUE);
wattroff(layout->subwin, theme_attrs(colour)); wattroff(layout->subwin, theme_attrs(colour));
} }
@ -151,7 +153,8 @@ _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_inde
g_string_append_printf(msg, " %d", resource->priority); g_string_append_printf(msg, " %d", resource->priority);
} }
win_sub_newline_lazy(layout->subwin); win_sub_newline_lazy(layout->subwin);
win_sub_print(layout->subwin, msg->str, FALSE, FALSE); gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP);
win_sub_print(layout->subwin, msg->str, FALSE, wrap, current_indent);
g_string_free(msg, TRUE); g_string_free(msg, TRUE);
wattroff(layout->subwin, theme_attrs(resource_presence_colour)); wattroff(layout->subwin, theme_attrs(resource_presence_colour));
@ -197,7 +200,8 @@ _rosterwin_contact(ProfLayoutSplit *layout, PContact contact)
} }
g_string_append(msg, name); g_string_append(msg, name);
win_sub_newline_lazy(layout->subwin); win_sub_newline_lazy(layout->subwin);
win_sub_print(layout->subwin, msg->str, FALSE, FALSE); gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP);
win_sub_print(layout->subwin, msg->str, FALSE, wrap, current_indent);
g_string_free(msg, TRUE); g_string_free(msg, TRUE);
wattroff(layout->subwin, theme_attrs(presence_colour)); wattroff(layout->subwin, theme_attrs(presence_colour));
@ -228,7 +232,8 @@ _rosterwin_contacts_by_presence(ProfLayoutSplit *layout, const char *const prese
if (prefs_get_boolean(PREF_ROSTER_COUNT)) { if (prefs_get_boolean(PREF_ROSTER_COUNT)) {
g_string_append_printf(title_str, " (%d)", g_slist_length(contacts)); g_string_append_printf(title_str, " (%d)", g_slist_length(contacts));
} }
win_sub_print(layout->subwin, title_str->str, FALSE, FALSE); gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP);
win_sub_print(layout->subwin, title_str->str, FALSE, wrap, 1);
g_string_free(title_str, TRUE); g_string_free(title_str, TRUE);
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER)); wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
} }
@ -272,7 +277,8 @@ _rosterwin_contacts_by_group(ProfLayoutSplit *layout, char *group, gboolean newl
if (prefs_get_boolean(PREF_ROSTER_COUNT)) { if (prefs_get_boolean(PREF_ROSTER_COUNT)) {
g_string_append_printf(title, " (%d)", g_slist_length(contacts)); g_string_append_printf(title, " (%d)", g_slist_length(contacts));
} }
win_sub_print(layout->subwin, title->str, FALSE, FALSE); gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP);
win_sub_print(layout->subwin, title->str, FALSE, wrap, 1);
g_string_free(title, TRUE); g_string_free(title, TRUE);
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER)); wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
@ -315,7 +321,8 @@ _rosterwin_contacts_by_no_group(ProfLayoutSplit *layout, gboolean newline)
if (prefs_get_boolean(PREF_ROSTER_COUNT)) { if (prefs_get_boolean(PREF_ROSTER_COUNT)) {
g_string_append_printf(title, " (%d)", g_slist_length(contacts)); g_string_append_printf(title, " (%d)", g_slist_length(contacts));
} }
win_sub_print(layout->subwin, title->str, FALSE, FALSE); gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP);
win_sub_print(layout->subwin, title->str, FALSE, wrap, 1);
g_string_free(title, TRUE); g_string_free(title, TRUE);
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER)); wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
@ -387,7 +394,8 @@ rosterwin_roster(void)
if (prefs_get_boolean(PREF_ROSTER_COUNT)) { if (prefs_get_boolean(PREF_ROSTER_COUNT)) {
g_string_append_printf(title, " (%d)", g_slist_length(contacts)); g_string_append_printf(title, " (%d)", g_slist_length(contacts));
} }
win_sub_print(layout->subwin, title->str, FALSE, FALSE); gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP);
win_sub_print(layout->subwin, title->str, FALSE, wrap, 1);
g_string_free(title, TRUE); g_string_free(title, TRUE);
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER)); wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));

View File

@ -1266,13 +1266,17 @@ win_unread(ProfWin *window)
} }
void void
win_sub_print(WINDOW *win, char *msg, gboolean newline, gboolean wrap) win_sub_print(WINDOW *win, char *msg, gboolean newline, gboolean wrap, int indent)
{ {
int maxx = getmaxx(win); int maxx = getmaxx(win);
int curx = getcurx(win); int curx = getcurx(win);
int cury = getcury(win); int cury = getcury(win);
waddnstr(win, msg, maxx - curx); if (wrap) {
_win_print_wrapped(win, msg, 1, indent);
} else {
waddnstr(win, msg, maxx - curx);
}
if (newline) { if (newline) {
wmove(win, cury+1, 0); wmove(win, cury+1, 0);

View File

@ -67,7 +67,7 @@ void win_newline(ProfWin *window);
void win_redraw(ProfWin *window); void win_redraw(ProfWin *window);
int win_roster_cols(void); int win_roster_cols(void);
int win_occpuants_cols(void); int win_occpuants_cols(void);
void win_sub_print(WINDOW *win, char *msg, gboolean newline, gboolean wrap); void win_sub_print(WINDOW *win, char *msg, gboolean newline, gboolean wrap, int indent);
void win_sub_newline_lazy(WINDOW *win); void win_sub_newline_lazy(WINDOW *win);
void win_mark_received(ProfWin *window, const char *const id); void win_mark_received(ProfWin *window, const char *const id);

View File

@ -87,6 +87,7 @@ roster.contact.char=
roster.contact.indent= roster.contact.indent=
roster.resource.indent= roster.resource.indent=
roster.presence.indent= roster.presence.indent=
roster.wrap=
occupants= occupants=
occupants.size= occupants.size=
occupants.jid= occupants.jid=