Let's use the same semantic for the title as for the last column in
the table. If aligned on left, table is not "maxout" and title padding
symbol is undefined (or blank) then keep title as short as possible.
Addresses: https://github.com/karelzak/util-linux/issues/549
Signed-off-by: Karel Zak <kzak@redhat.com>
* add comment to explain when nolinesep flag is necessary
* force to print \n before switch to the next line to support
./sample-scols-continuous > file
use case.
Addresses: https://github.com/ignatenkobrain/python-smartcols/issues/18
Signed-off-by: Karel Zak <kzak@redhat.com>
Now the library encode all output. It seems too strict and difficult
to use the library for some use-cases -- for example if you want to
use the library for already colorized output (by esc.sequences).
Signed-off-by: Karel Zak <kzak@redhat.com>
We got some errors on Alpine Linux where $LTLIBINTL is non-empty:
./.libs/libcommon.a(libcommon_la-blkdev.o): In function `open_blkdev_or_file':
lib/blkdev.c:282: undefined reference to `libintl_gettext
collect2: error: ld returned 1 exit status
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
libsmartcols/samples/fromfile.c:57:16: warning: declaration of 'flags'
shadows a global declaration [-Wshadow]
libsmartcols/samples/fromfile.c:29:33: note: shadowed declaration is here
libsmartcols/samples/fromfile.c:101:8: warning: declaration of 'flags'
shadows a global declaration [-Wshadow]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Now it's impossible to add new column if the table already contains
lines with data. This patch forces library to realloc cell array in
the lines to accept a new column.
Signed-off-by: Karel Zak <kzak@redhat.com>
Just to hide that we use cell flags (bitwise operations) to define
cell content alignment. The patch also more explicitly specifies the
flags in the header file.
The alignment is evaluated in the order: right, center, left. The
default is left.
Note that SCOLS_CELL_FL_* are used for for table title only.
Signed-off-by: Karel Zak <kzak@redhat.com>
libsmartcols/samples/fromfile.c:59:2: warning: passing argument 3 of 'string_to_bitmask' from incompatible pointer type
text-utils/pg.c:79:0: warning: "TABSIZE" redefined
libblkid/src/read.c:455:13: warning: 'debug_dump_dev' defined but not used [-Wunused-function]
libblkid/src/probe.c:769:13: warning: unused function 'cdrom_size_correction' [-Wunused-function]
/usr/include/sys/termios.h:3:2: warning: "this file includes <sys/termios.h> which is deprecated, use <termios.h> instead" [-W#warnings]
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
This new API provides full control on multi-line cells, you can wrap
text by new lines (build-in support) or by another way (after words,
commas, etc.) Changes:
* new scols_column_set_wrapfunc() sets pointers to two callback functions
1/ chunksize() - returns largest data chunk size; used when we
calculate columns width
2/ nextchunk() - terminate the current chunk and returns pointer to
the next; used when we print data
* remove SCOLS_FL_WRAPNL and add new functions scols_wrapnl_chunksize()
and scols_wrapnl_nextchunk() to provide build-in functionality to
wrap cells on \n
* remove scols_column_is_wrapnl() add scols_column_is_customwrap()
(returns true if custom wrap functions are defined)
* add scols_column_set_safechars() and scols_column_get_safechars() to
allow to control output encoding, safe chars are not encoded by \xFOO
* modify "fromfile" test code to use build-in scols_wrapnl_* callbacks
for "wrapnl" tests
* add new function scols_column_get_table()
Signed-off-by: Karel Zak <kzak@redhat.com>
Change behavior:
* scols_table_set_symbols(tb, NULL) remove reference to the current symbols setting
and does not set default symbols at all
Add new functions:
* scols_table_get_symbols()
* scols_table_set_default_symbols()
Signed-off-by: Karel Zak <kzak@redhat.com>
* 'api_const' of https://github.com/ignatenkobrain/util-linux:
libsmartcols: use const qualifier where it's possible
debug: use const void * for ul_debugobj()
libsmartcols: make get_line/column_separator() return const
We don't modify data it's pointing out and we should not modify it.
Also remove casting to void * as gcc will do it automatically (before
we had to cast it explicitly to avoid warning on discarding 'const'
qualifier).
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
The patch introduces tiny API changes (char * -> const char *) for
scols_table_get_line_separator
scols_table_get_column_separator
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
The patch introduces tiny API changes (int -> size_t) for
scols_table_get_ncols
scols_table_get_nlines
Addresses: https://github.com/karelzak/util-linux/issues/349
Signed-off-by: Karel Zak <kzak@redhat.com>
* use line separator only to separate lines, not after last line
* explicitly print \n after table in scols_print_table()
* don't terminate table by \n or line separator in scols_print_table_to_string()
Note that the patch is little bit trick due to impact to the trees
printing. Now print_tree_line() should be more readable.
Signed-off-by: Karel Zak <kzak@redhat.com>
This env.variable forces libsmartcols to use visible padding chars.
The standard debug has to be enabled (to minimize overhead for
non-debug execution).
For example:
$ LIBSMARTCOLS_DEBUG=all LIBSMARTCOLS_DEBUG_PADDING=on findmnt 2> ~/log
Signed-off-by: Karel Zak <kzak@redhat.com>
Now libsmartcols completely control when and how wrap long
lines/cells. This is sometimes user unfriendly and it would be nice to
support multi-line cells where wrap is based on \n (new line char).
This patch add new column flag SCOLS_FL_WRAPNL.
Signed-off-by: Karel Zak <kzak@redhat.com>