diff options
author | pgen <p.gen.progs@gmail.com> | 2018-01-18 23:57:03 +0100 |
---|---|---|
committer | pgen <p.gen.progs@gmail.com> | 2018-01-18 23:57:03 +0100 |
commit | a093e61fef68c40c0efa39cd479f70a0fff970db (patch) | |
tree | d9ae5079a767af8fca7978f25c827127e8cddcc9 | |
parent | 968a0d7cf28b7c52e4e7465489bcb81c96075f99 (diff) |
Fix the wide option when in column or tabulation mode
- utf-8 encoding is now correctly managed
- in tabulation mode the case of a word larger than its column is now
taken into account and the manual has been updated accordingly
-rw-r--r-- | smenu.1 | 7 | ||||
-rw-r--r-- | smenu.c | 32 |
2 files changed, 30 insertions, 9 deletions
@@ -268,13 +268,16 @@ By default five lines at most are displayed and the other ones, if any, need you to scroll the window. .IP "\fB-t\fP [\fIcolumns\fP]" This option sets the tabulation mode and, if a number is specified, -limits the number of displayed columns to that number. +attents to set the number of displayed columns to that number. In this mode, embedded line separators are ignored. The options \fB-A\fP and \fB-Z\fP can nevertheless be used to force words to appear in the first (respectively last) position of the displayed line. .P .RS -Note that in this mode each column has the same width. +Note that the number of requested columns will be automatically reduced +if a word does not fit in the calculated column size. +.P +In this mode each column has the same width. .RE .IP \fB-k\fP By default, the spaces surrounding the output string will be deleted. @@ -5779,6 +5779,11 @@ main(int argc, char * argv[]) if (win.tab_mode && !win.max_cols) win.wide = 1; + /* Disable the wide mode if not in column mode and not in tab mode */ + /* """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" */ + if (!win.tab_mode && !win.col_mode) + win.wide = 0; + win.start = 0; void sig_handler(int s); @@ -6956,7 +6961,7 @@ main(int argc, char * argv[]) } /* Update the size of the longest expanded word */ /* """""""""""""""""""""""""""""""""""""""""""" */ - word_real_max_size = cols_max_size; + word_real_max_size = cols_real_max_size; } else if (win.tab_mode) { @@ -7014,15 +7019,28 @@ main(int argc, char * argv[]) } } - /* Set the minimum width of a column (-t option) */ - /* """"""""""""""""""""""""""""""""""""""""""""" */ + /* Set the minimum width of a column (-w and -t or -c option) */ + /* """""""""""""""""""""""""""""""""""""""""""""""""""""""""" */ if (win.wide) { - if (win.max_cols > 0) - min_size = (term.ncolumns - 2) / win.max_cols - 1; + if (win.tab_mode) + { + if (win.max_cols > 0) + min_size = (term.ncolumns - 2) / win.max_cols - 1; - if (min_size < 0) - min_size = term.ncolumns - 2; + if (min_size < tab_max_size) + min_size = tab_max_size; + + word_real_max_size = min_size + tab_real_max_size - tab_max_size; + } + else /* column mode */ + { + min_size = (term.ncolumns - 2) / cols_number; + if (min_size < cols_max_size) + min_size = cols_max_size; + + word_real_max_size = cols_real_max_size; + } } /* Third (compress) pass: remove all empty word and words containing */ |