summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2013-09-02 18:56:58 +0200
committerSebastien Helleu <flashcode@flashtux.org>2013-09-02 18:56:58 +0200
commitdaf535c9af06ccc7a7a57b67189f8b85bf965c01 (patch)
tree26f6ca1e15ab6030a81f75f7378eacccb0d8f297
parent0409faee7faec765148cd8352ae4e2c605fcb6b7 (diff)
downloadweechat-daf535c9af06ccc7a7a57b67189f8b85bf965c01.zip
core: fix computation of columns in output of /help (take care about size of time/buffer/prefix)
-rw-r--r--ChangeLog2
-rw-r--r--src/core/wee-command.c25
2 files changed, 23 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 4a3a51dae..e82e1b44e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,8 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
Version 0.4.2 (under dev!)
--------------------------
+* core: fix computation of columns in output of /help (take care about size of
+ time/buffer/prefix)
* core: display day change message dynamically (do not store it as a line in
buffer), rename option weechat.look.day_change_time_format to
weechat.look.day_change_message, new options weechat.look.day_change_message2
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index 3c8f6fab2..ac272aa11 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -63,6 +63,7 @@
#include "../gui/gui-input.h"
#include "../gui/gui-key.h"
#include "../gui/gui-layout.h"
+#include "../gui/gui-line.h"
#include "../gui/gui-main.h"
#include "../gui/gui-mouse.h"
#include "../gui/gui-window.h"
@@ -1903,6 +1904,7 @@ command_help_list_plugin_commands (struct t_weechat_plugin *plugin,
struct t_hook *ptr_hook;
struct t_weelist *list;
struct t_weelist_item *item;
+ struct t_gui_buffer *ptr_buffer;
int command_found, length, max_length, list_size;
int cols, lines, col, line, index;
char str_format[64], str_command[256], str_line[2048];
@@ -1943,6 +1945,10 @@ command_help_list_plugin_commands (struct t_weechat_plugin *plugin,
}
else
{
+ ptr_buffer = gui_buffer_search_main ();
+ if (!ptr_buffer)
+ return;
+
max_length = -1;
list = weelist_new ();
@@ -1977,12 +1983,22 @@ command_help_list_plugin_commands (struct t_weechat_plugin *plugin,
plugin_get_name (plugin),
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
- /* auto compute number of columns, max size is 90% of chat width */
- cols = ((gui_current_window->win_chat_width * 90) / 100) / (max_length + 2);
- if (cols == 0)
- cols = 1;
+ /* auto compute number of columns according to current chat width */
+ cols = 1;
+ length = gui_current_window->win_chat_width -
+ (gui_chat_time_length + 1 +
+ ptr_buffer->lines->buffer_max_length + 1 +
+ ptr_buffer->lines->prefix_max_length + 1 +
+ gui_chat_strlen_screen (CONFIG_STRING(config_look_prefix_suffix)) + 1);
+ if (length > 0)
+ {
+ cols = length / (max_length + 2);
+ if (cols == 0)
+ cols = 1;
+ }
lines = ((list_size - 1) / cols) + 1;
+ /* build format according to number of columns */
if (lines == 1)
{
snprintf (str_format, sizeof (str_format), " %%s");
@@ -1993,6 +2009,7 @@ command_help_list_plugin_commands (struct t_weechat_plugin *plugin,
" %%-%ds", max_length);
}
+ /* display lines with commands, in columns */
for (line = 0; line < lines; line++)
{
str_line[0] = '\0';