diff options
| author | Michael Vetter <jubalh@iodoru.org> | 2019-04-18 20:53:02 +0200 |
|---|---|---|
| committer | Michael Vetter <jubalh@iodoru.org> | 2019-04-18 20:53:02 +0200 |
| commit | 0c248a0b16e9c159b274667c7149f50299328804 (patch) | |
| tree | 08a7db8e9aa5f14546c9ba1e203b1c8ed3ba0b68 /src/command | |
| parent | 7e4e9e668853d8cc404ace0c160376d113069c32 (diff) | |
| download | profani-tty-0c248a0b16e9c159b274667c7149f50299328804.tar.gz | |
Add /occupants indent command
Roster has a `/roster contact indent` option.
Now we have the same for occupants. So contacts in roster and in MUC can
have configurable indentation.
Regards https://github.com/boothj5/profanity/issues/690
Diffstat (limited to 'src/command')
| -rw-r--r-- | src/command/cmd_defs.c | 6 | ||||
| -rw-r--r-- | src/command/cmd_funcs.c | 32 |
2 files changed, 36 insertions, 2 deletions
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 15d072a4..c1797e3c 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -753,7 +753,8 @@ static struct cmd_t command_defs[] = CMD_SYN( "/occupants show|hide [jid]", "/occupants default show|hide [jid]", - "/occupants size [<percent>]") + "/occupants size [<percent>]", + "/occupants indent <indent>") CMD_DESC( "Show or hide room occupants, and occupants panel display settings.") CMD_ARGS( @@ -763,7 +764,8 @@ static struct cmd_t command_defs[] = { "hide jid", "Hide jid in the occupants panel in current room." }, { "default show|hide", "Whether occupants are shown by default in new rooms." }, { "default show|hide jid", "Whether occupants jids are shown by default in new rooms." }, - { "size <percent>", "Percentage of the screen taken by the occupants list in rooms (1-99)." }) + { "size <percent>", "Percentage of the screen taken by the occupants list in rooms (1-99)." }, + { "indent <indent>", "Indent contact line by <indent> spaces (0 to 10)." }) CMD_NOEXAMPLES }, diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index abd83492..788c2f32 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -4409,6 +4409,38 @@ cmd_occupants(ProfWin *window, const char *const command, gchar **args) ProfMucWin *mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); + if (g_strcmp0(args[0], "indent") == 0) { + if (!args[1]) { + cons_bad_cmd_usage(command); + return TRUE; + } else { + int intval = 0; + char *err_msg = NULL; + gboolean res = strtoi_range(args[1], &intval, 0, 10, &err_msg); + if (res) { + prefs_set_occupants_indent(intval); + cons_show("Occupants indent set to: %d", intval); + + // get the list of joined rooms + GList *rooms = muc_rooms(); + GList *curr = rooms; + while (curr) { + char* roomjid = curr->data; + ProfMucWin *mw = wins_get_muc(roomjid); + if (mw != NULL) + mucwin_update_occupants(mw); + + curr = g_list_next(curr); + } + } else { + cons_show(err_msg); + free(err_msg); + } + return TRUE; + } + } + + if (g_strcmp0(args[0], "show") == 0) { if (g_strcmp0(args[1], "jid") == 0) { mucwin->showjid = TRUE; |