Commit Graph

318 Commits

Author SHA1 Message Date
Karel Zak 19055a25ed libsmartcols: add functions to control terminal usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-13 14:06:01 +02:00
Karel Zak fa4691833a libsmartcols: add application to test library features
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-13 13:08:02 +02:00
Karel Zak ef4a34bbb8 libsmartcols: fix WRAPNL on strings without \n
Addresses: https://github.com/karelzak/util-linux/issues/343
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-12 16:12:22 +02:00
Karel Zak 975ed32fd9 libsmartcols: fix WRAPNL crashes
Addresses: https://github.com/karelzak/util-linux/issues/344
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-12 11:58:34 +02:00
Karel Zak 37948503c9 libsmartcols: support LIBSMARTCOLS_DEBUG_PADDING=on
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>
2016-09-07 12:25:06 +02:00
Karel Zak f1f9b71736 libsmartcols: add fallback for symbols
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-07 11:45:35 +02:00
Karel Zak 64ce7cbbc0 libsmartcols: allow to change cell padding char
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-07 11:07:04 +02:00
Karel Zak a2b8ad291f libsmartcols: extend wrapnl sample
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-06 13:01:45 +02:00
Karel Zak 77a94efb5e libsmartcols: fix padding for non-maxout output
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-06 13:01:09 +02:00
Karel Zak 4f07ff4041 libsmartcols: remove debuging code from sample
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-06 12:24:49 +02:00
Karel Zak 6cd398642b libsmartcols: commit missing file
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-06 11:18:18 +02:00
Karel Zak ff471d89a1 libsmartcols: support multi-line cells based on line breaks
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>
2016-09-06 10:51:25 +02:00
Karel Zak b54439cbad libsmartcols: use SCOLS_FL_RIGHT in sample
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-31 15:51:03 +02:00
Karel Zak 51962c95e3 libsmartcols: add maxout sample
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-31 15:15:28 +02:00
Karel Zak 5e6421ee07 libsmartcols: fix minimal column width calculation
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-31 15:13:06 +02:00
Karel Zak f067de4495 libsmartcols: fix non-tty output for 'maxout' columns
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-31 13:01:48 +02:00
Karel Zak a593128fd0 libsmartcols: fix title output on non-tty
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-31 12:42:38 +02:00
Karel Zak 066779c67b libsmartcols: fix scols_table_enable_colors() usage in samples
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-31 12:05:48 +02:00
Karel Zak d7cda881d5 libsmartcols: don't print title color is colors disabled
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-31 12:05:21 +02:00
Karel Zak 1ca2661bb8 libsmartcols: Corrected JSON escaping
Based on patch set https://github.com/karelzak/util-linux/pull/331
from Fordi.

Addresses: https://github.com/karelzak/util-linux/issues/330
Co-Author: Bryan Elliott <fordiman@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-02 12:05:05 +02:00
Karel Zak c191740c28 misc: cleanup non-widechar compilation
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-06-03 14:46:17 +02:00
Karel Zak 8f0ac57921 lib/ttyutils: use stdout for get_terminal_width()
We use the function to be sure with *output* width. Note that the
current code (with STDIN) is broken because in some situations
libsmartcols is not able to detect terminal width and fall back to
default 80.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-06-02 12:31:45 +02:00
Sebastian Rasmussen 9e93004171 misc: Fix various typos
Fix various typos in error messages, warnings, debug strings,
comments and names of static functions.

Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
2016-05-31 23:40:21 +02:00
Karel Zak 8fcdce8fff libsmartcols remove duplicate code
For petty long time we have strdup_to_struct_member() macro to avoid
duplicate code when strdup() strings in setter functions. Let's use it
for libmount.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-04-22 14:17:21 +02:00
Ruediger Meier 18336d16d9 build-sys: use AC_PROG_MKDIR_P and remove a few gnuisms
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-13 21:48:09 +01:00
Ruediger Meier 58c87bd045 misc: fix icc/clang compiler warnings
clang warning:
libmount/src/tab.c:1833:6: warning: variable 'rc' is used uninitialized whenever
      'if' condition is true [-Wsometimes-uninitialized]
        if (!mpc)
            ^~~~

icc printf warnings:
    libmount/src/monitor.c(348): warning #2279: printf/scanf format not a string literal and no format arguments
            DBG(MONITOR, ul_debugobj(mn, status == 1 ? " success" : " nothing"));
            ^
    login-utils/vipw.c(348): warning #2279: printf/scanf format not a string literal and no format arguments
                           : _("You are using shadow passwords on this system.\n"));
                                                                                  ^

icc enum warnings:
    disk-utils/fdisk-menu.c(150): warning #188: enumerated type mixed with another type
            .exclude = FDISK_DISKLABEL_GPT | FDISK_DISKLABEL_BSD,
                       ^
    libsmartcols/src/table_print.c(750): warning #188: enumerated type mixed with another type
                            &width, align,
                                    ^

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-13 21:47:27 +01:00
Karel Zak 5bb1d22e8a build-sys: fix if..endif for *_la_LDFLAGS
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-03-10 13:54:15 +01:00
Ruediger Meier dc0495166f build-sys: add and use openat build conditionals
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-07 15:37:25 +01:00
Ruediger Meier beabee7c67 libsmartcols: fix uninitialized variable
This got broken in 2a750b4c.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-29 13:04:54 +01:00
Karel Zak b64dc52a53 Merge branch 'ldadd-cflags-warnings' of https://github.com/rudimeier/util-linux
* 'ldadd-cflags-warnings' of https://github.com/rudimeier/util-linux:
  build-sys: disable unused parameter warnings for some test progs
  misc: fix compiler warnungs (unsigned/signed)
  misc: fix warnings "unused parameter" [-Wunused-parameter]
  libfdisk: fix warnings, "redundant redeclaration" [-Wredundant-decls]
  tests: fix compiler warnings [-Wmissing-prototypes]
  libfdisk: fix compiler warnings [-Wmissing-prototypes]
  libfdisk: fix missing symbol
  libblkid: fix compiler warnings [-Wmissing-prototypes]
  libmount: add mnt_fs_set_priority()
  build-sys: always add AM_CFLAGS
  build-sys: always use global LDADD
2016-02-24 13:51:10 +01:00
Karel Zak 1c3ed5bf17 libsmartcols: fix stupid typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-24 13:42:28 +01:00
Karel Zak cbe3e49535 libsmartcols: fix relative column width for maxout
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-24 12:34:37 +01:00
Ruediger Meier 2013b33f40 build-sys: disable unused parameter warnings for some test progs
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 03:20:22 +01:00
Ruediger Meier b9710f1f08 misc: fix compiler warnungs (unsigned/signed)
These ones should be fixed:
libblkid/src/probe.c:393:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/probe.c:907:25: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libblkid/src/probe.c:1221:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:540:47: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1043:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1056:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1057:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1061:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1199:27: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libblkid/src/partitions/partitions.c:1410:26: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libblkid/src/partitions/partitions.c:1431:25: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libblkid/src/superblocks/linux_raid.c:151:8: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
libblkid/src/superblocks/linux_raid.c:155:2: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
libblkid/src/superblocks/superblocks.c:375:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/superblocks/xfs.c:141:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libsmartcols/src/table.c:333:24: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libsmartcols/src/table.c:344:25: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libsmartcols/src/table_print.c:753:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/ask.c:364:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/utils.c:33:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/context.c:435:56: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/context.c:730:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/script.c:557:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/dos.c:1791:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/gpt.c:813:42: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
disk-utils/partx.c:140:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
disk-utils/partx.c:551:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
disk-utils/partx.c:640:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 03:18:27 +01:00
Ruediger Meier 71177ab8f9 misc: fix warnings "unused parameter" [-Wunused-parameter]
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 03:18:24 +01:00
Ruediger Meier 5fde1d9f06 tests: fix compiler warnings [-Wmissing-prototypes]
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 03:18:09 +01:00
Ruediger Meier b0b54cc582 build-sys: always add AM_CFLAGS
We were missing our nice compliler warnings for many programs
and libs. See next commits how many trivial and non-trival
warnings have to be fixed.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 01:17:29 +01:00
Ruediger Meier b201f1d86c build-sys: always use global LDADD
This was a major showstopper when building on a system where
LTLIBINTL libs are needed (e.g. OSX). Maybe there are a few test
programs which wouldn't need LDADD ... never mind.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 01:16:58 +01:00
Karel Zak 334e5eba9e libsmartcols: fix scols_table_print_range() to print header
References: https://github.com/karelzak/util-linux/issues/287
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-22 10:43:25 +01:00
Igor Gnatenko cfa185721e libsmartcols: implement scols_table_print_range_to_string
Reference: https://github.com/karelzak/util-linux/issues/283
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-02-21 21:13:50 +01:00
Karel Zak 12ca9cb1f5 libsmartcols: add sample-scols-continuous
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-19 16:47:38 +01:00
Karel Zak 2981e0fd0e libsmartcols: support continuous printing
This patch allows to disable line-breaks. This feature is usable when
you want to re-print the same line more than once -- move terminal
cursor to the begin of the line and print again and again (aka
progress bar).

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-19 16:43:28 +01:00
Karel Zak 2a750b4c4e libsmartcols: add scols_table_print_range()
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-19 14:43:06 +01:00
Ruediger Meier b0b24b11f8 lib: rename strmode() and setmode()
On BSD they are part of the standard C library.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-18 12:53:48 +01:00
Ruediger Meier 3719bf8de9 build-sys: check linker support for version scripts
The macro AX_CHECK_VSCRIPT was taken from gnu autoconf archive.
http://www.gnu.org/software/autoconf-archive/

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-18 12:53:48 +01:00
Igor Gnatenko d381f70814 libsmartcols: fill wrapped lines with space instead of 'x'
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-02-16 12:57:55 +01:00
Igor Gnatenko f16f28b0fc libsmartcols: print title only with SCOLS_FMT_HUMAN
Reference: https://github.com/karelzak/util-linux/issues/279
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-02-13 16:13:04 +01:00
Karel Zak 20759a42ec libsmartcols: rewrite ./sample-scols-wrap
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-10 15:37:30 +01:00
Karel Zak d94c519877 libsmartcols: support multi-line cells
The initial implementation has been introduced by SCOLS_FL_WRAP columns,
but this patch clean ups all and makes things more elegant.

Note that use SCOLS_FL_TREE | SCOLS_FL_WRAP for a column is bad idea
and I don't think we need to fix it.

References: https://github.com/karelzak/util-linux/issues/269
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-10 15:34:21 +01:00
Karel Zak e865838d6d libsmartcols: use libscols_cell for title
References: https://github.com/karelzak/util-linux/issues/270
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-09 11:21:21 +01:00
Ruediger Meier 3fd1f7711e docs: fix typos found by codespell
Using "codespell" from https://github.com/lucasdemarchi/codespell

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-03 15:10:08 +01:00
Karel Zak e85c8c98e6 libsmartcols: make SCOLS_FL_WRAP usable in tree
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-25 15:31:24 +01:00
Karel Zak 5243e4ebc8 libsmartcols: reduce also SCOLS_FL_WRAP columns
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-25 15:17:36 +01:00
Karel Zak e90f4b6715 libsmartcols: add wrap.c sample
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-25 15:17:21 +01:00
Karel Zak 4a51e682bb libsmartcols: fix title sample
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-25 13:45:34 +01:00
Karel Zak 107ca34a4c libsmartcols: fix samples build, add title.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-25 13:42:51 +01:00
Karel Zak 2f09ae9d5d libsmartcols: add samples directory
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-25 13:17:43 +01:00
Karel Zak d372bcf26e Merge branch 'scols_fl_wrap' of https://github.com/ignatenkobrain/util-linux
* 'scols_fl_wrap' of https://github.com/ignatenkobrain/util-linux:
  libsmartcols: add scols_column_is_wrap to docs
  libsmartcols: don't loose colors when wrapping
  libsmartcols: wrap columns correctly with unicode
  libsmartcols: implement SCOLS_FL_WRAP
2016-01-25 13:03:29 +01:00
Karel Zak 982034c3d1 libsmartcols: document v2.27 symbols
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-25 12:57:14 +01:00
Igor Gnatenko db307d8e96 libsmartcols: add 'Since' tag for gtkdoc for some functions
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-25 00:12:14 +01:00
Igor Gnatenko 703d0196ee libsmartcols: add few methods to get information about title
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-25 00:12:14 +01:00
Igor Gnatenko bfc3d8b48e libsmartcols: position of title in fact unsigned
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-25 00:12:14 +01:00
Karel Zak 57867795aa libsmartcols: support multibyte titles, rename wrap to padding
- let's support multibyte table titles
- use lib/mbalign.c to align the title
- rename title_wrap to title_padding (we already use "wrap" on another
  places for another things)

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-22 16:51:59 +01:00
Igor Gnatenko ad13ab8d66 libsmartcols: add scols_column_is_wrap to docs
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-22 14:48:46 +01:00
Igor Gnatenko 57c7b2a1a5 libsmartcols: don't loose colors when wrapping
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-22 14:30:39 +01:00
Igor Gnatenko e6f89163be libsmartcols: wrap columns correctly with unicode
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-22 14:29:16 +01:00
Karel Zak fd5cbf57e0 libsmartcols: add title to the test application
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-22 13:50:02 +01:00
Karel Zak 6f2737964d libsmartcols: add JSON to the test application
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-22 13:46:29 +01:00
Karel Zak 500a229f51 libsmartcols: add new functions to docs
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-22 13:40:19 +01:00
Igor Gnatenko 0a69e647fc libsmartcols: set everything once in scols_table_set_title()
Reported-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-22 12:54:02 +01:00
Igor Gnatenko a640409309 libsmartcols: implement SCOLS_FL_WRAP
Reference: https://github.com/karelzak/util-linux/issues/257
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-22 12:51:45 +01:00
Igor Gnatenko 2f62d9fe3e libsmartcols: put new line after title
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-21 17:37:21 +01:00
Igor Gnatenko 7bc451694f libsmartcols: fix title aligning to center
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-21 17:36:53 +01:00
Igor Gnatenko 284ee2a9a4 libsmartcols: don't try to align title if it's more that term
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-21 17:25:15 +01:00
Igor Gnatenko cd32dc248c libsmartcols: use symbols for title wrap
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-21 17:09:16 +01:00
Igor Gnatenko b3256efff2 libsmartcols: implement title of table
Reference: https://github.com/karelzak/util-linux/issues/258
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-21 16:41:12 +01:00
Karel Zak 8afabdb1fa libsmartcols: don't sort if cmpfunc() is not set
Reported-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-18 10:47:22 +01:00
Karel Zak 7ad4b8503c libsmartcols: be sure column is unused
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-18 10:36:31 +01:00
Karel Zak 1bb767f54c Merge branch 'gh/254' of https://github.com/ignatenkobrain/util-linux 2016-01-18 10:24:39 +01:00
Igor Gnatenko d10fa7e6dd libsmartcols: reflect changinging SCOLS_FL_TREE after adding to table
When scols_column_set_flags() is called we will compare before & after
status of SCOLS_FL_TREE flag and appropriately handle tb->ntreecols.

Reference: https://github.com/karelzak/util-linux/issues/254
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-17 09:44:09 +01:00
Igor Gnatenko a229e20478 libsmartcols: add scols_column_is_hidden into sym file
In commit 6d6b6d185e we forgot to
add this function to sym file and now we are getting
undefined symbol: scols_column_is_hidden

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-15 23:27:52 +01:00
Karel Zak 7837186515 libsmartcols: allow to set data by reference to libscols_column
References: https://github.com/karelzak/util-linux/issues/251
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-12 11:39:03 +01:00
Karel Zak 19981b07d9 libsmartcols: make output buffer size estimation more robust and elegant
Reported-by: Andreas Henriksson <andreas@fatal.se>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-07 17:36:44 +01:00
Boris Egorov 43b4f7ea5f lib/tty: Pass default width to get_terminal_width()
Almost any code calling get_terminal_width() checks returned width for
non-positive values and sets it to some default value (say, 80). So,
let's pass this default value directly to the function.

[kzak@redhat.com: - get_terminal_width() refactoring]

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-06 12:22:07 +01:00
Igor Gnatenko 5e8461a53a scols/table_print: restore old stream after printing to str
Reference: https://github.com/karelzak/util-linux/issues/240
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2015-12-13 15:02:05 +01:00
Karel Zak 6d6b6d185e libsmartcols: add SCOLS_FL_HIDDEN
Export "don't print this column" functionality by public API.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-12-10 13:02:03 +01:00
Karel Zak 96561604e2 libsmartcols: fix right-aligned logic for last column
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-12-07 15:10:23 +01:00
Karel Zak 05c1123bc3 libsmartcols: don't use fprintf() when count cells
fprintf("%*s") is based on bytes, no cells.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-12-07 12:22:29 +01:00
Karel Zak df73852b6e libsmartcols: add scols_table_enable_nowrap()
This allows to use libsmartcols in ncurses programs without any
additional voodoo.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-12-07 12:03:52 +01:00
Karel Zak c600d82a3a libsmartcols: make sure we have space for ascii art
* more verbose output about columns width counting
* strlen_line() does not care about space between columns and extra
  tree ASCII art. Let's assume that all termwith is possible to use
  for this extra stuff, it means that maximal buffer size is
  biggest_line + termwidth.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-11-30 12:53:42 +01:00
Karel Zak 440f73b7bc libsmartcols: allow to reduce tree columns
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-11-30 11:43:05 +01:00
Karel Zak 2c6567799d build-sys: add --disable-assert
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-04 13:40:44 +02:00
Karel Zak fdd68e25b5 libsmartcols: make child-parent reference more robust [clang analyze]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-29 14:44:27 +02:00
Karel Zak 5627fcec0e libsmartcols: reduce relative columns more aggressively
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-27 14:29:38 +02:00
Karel Zak 0bef6f759b libsmartcols: don't link with tinfo
Let's move color names to sequence translation to separate file to
make it usable without all the stuff in lib/colors.c.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-24 12:57:46 +02:00
Karel Zak 6a768b5516 libsmartcols: keep JSON field names lower-case
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-05 11:58:42 +02:00
Karel Zak 4827093d4b losetup: add --json
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-05 10:30:52 +02:00
Karel Zak 2a6cfc1361 libsmartcols: add JSON output format
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-04 15:47:21 +02:00
Karel Zak d5dbd57b22 docs: fix gtk-docs related warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-28 12:28:23 +02:00
Karel Zak 4310faf950 lib/colors: use libtinfo to check terminal capability
The current implementation assumes that all terminals supports colors
and users are forcet to use terminal-colors.d/ to disable colors for
some terminals.

This patch checks for maximal supported colors for the current
terminal and colors are automatically disabled for terminals like
vt100.

The patch moves lib/colors.c from libcommon.la to libtcolors.la to
avoid collisions with another utils.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-27 13:57:34 +01:00
Karel Zak 323da9ce47 libsmartcols: remove assert(arg) from public functions
Reported-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-16 13:49:29 +01:00
Karel Zak 78ad5aaaa9 libsmartcols: remove unnecessary check [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-29 11:07:37 +01:00
Benno Schulenberg b295bdb1b5 docs: fix two "maybe be" duplications in program comments
Also improve the grammar of the comments and some neighbours.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-26 11:22:15 +01:00
Karel Zak 2473b71182 libsmartcols: (docs) improve section descriptions
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-13 12:23:40 +01:00
Karel Zak 2b6c532e17 docs: update API docs years
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-13 12:03:17 +01:00
Karel Zak fed9b1775d libsmartcols: cleanup gtk-docs warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-13 11:56:57 +01:00
Karel Zak 8501d9befe libsmartcols: use ASCII art for trees rather than padding
Based on patch from  Roman Odaisky.

References: https://launchpad.net/bugs/1406133
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-07 15:20:22 +01:00
Sami Kerola 7ee26cbf02 maint: fix shadow declaration
This change fixes all shadow declarations.  The worth while to mention
fix is with libfdisk sun geometry.  It comes from bitops.h cpu_to_be16
macro that further expands from include/bits/byteswap.h that has the
shadowing.

libfdisk/src/sun.c:961:173: warning: declaration of '__v' shadows a previous local [-Wshadow]
libfdisk/src/sun.c:961:69: warning: shadowed declaration is here [-Wshadow]
libfdisk/src/sun.c:961:178: warning: declaration of '__x' shadows a previous local [-Wshadow]
libfdisk/src/sun.c:961:74: warning: shadowed declaration is here [-Wshadow]

That could have caused earlier some unexpected results.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-07 10:08:21 +01:00
Karel Zak 5bc118c3c2 libsmartcols: fix docs namespace
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-26 16:53:48 +01:00
Karel Zak adc9f78cfc build-sys: cleanup library symbol files
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-20 14:01:03 +01:00
Karel Zak 2deb7cc347 libsmartcols: clean up debug, add help debug mask
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-03 13:13:22 +01:00
Sami Kerola 1bcf491a78 textual: fix couple typos in comments
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:15 +02:00
Ondrej Oprala 14ad2353cc libs/debug: accept human readable names for _DEBUG=
For example
	$ LIBMOUNT_DEBUG=tab,cache findmnt

to debug only TAB and CACHE subsystem.

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-13 12:33:47 +02:00
Sami Kerola b697fc994a libsmartcols: avoid variable dereference after release
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-13 18:35:39 +01:00
Sami Kerola 0e65dcde88 textual: fix some typos
Found with misspell-check version 2.0d.

Reference: https://github.com/lyda/misspell-check
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-13 17:21:02 +01:00
Karel Zak 3175f03552 libsmartcols: add note about deallocations
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-30 14:14:34 +02:00
Karel Zak 8675a3503d build-sys: move libsmartcols.so to /lib if they exists
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-16 15:00:33 +02:00
Karel Zak 710ed55dcd libsmartcols: add debug messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-06 13:47:06 +02:00
Karel Zak 36e4bdf018 libsmartcols: fix docs
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-03 12:41:58 +02:00
Karel Zak 7a1c36ab38 docs: rename libs xml/version.xml to xml/version-utils.xml
It seems that gtk-docs stuff is confused when we use version.xml
(package version) and xml/version.xml (library version functions).

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-03 12:37:33 +02:00
Karel Zak f92b26c184 libsmartcols: clean up test.c example
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-30 14:17:29 +02:00
Karel Zak 57a86f9bff libsmartcols: add scols_sort_table()
* add pointer to column cmp() function [scols_column_set_cmpfunc()]

 * allow to store per-cell application private data
   (to make it possible to sort tables on data independent on cell
    output data) [scols_cell_set_userdata() ...]

 * make it possible to access line cell by column
   [scols_line_get_column_cell()]

Sort and cmp() stuff based on patches from Shakur Shams Mullick.

Co-Author: Shakur Shams Mullick <shakursmullick@gmail.com>
Signed-off-by: Shakur Shams Mullick <shakursmullick@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-20 15:04:11 +02:00
Karel Zak 3eb482d027 libsmartcols: use new colors API
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-13 12:09:03 +02:00
Karel Zak c60329b33f libsmartcols: (docs) reorder functions in version section
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-07 11:48:53 +02:00
Karel Zak 140b006172 libsmartcols: check recount_widths() return value
Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-06 10:21:24 +02:00
Karel Zak 2dc0c6283b libsmartcols: fix buffer usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-18 12:01:59 +02:00
Karel Zak ee75308c31 libsmartcols: don't colorize tree ascii art
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-15 15:25:45 +02:00
Karel Zak 47329bbcf9 libsmartcols: don't mix width (in cells) and size (in bytes)
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-15 14:23:34 +02:00
Karel Zak d6303e28ec libsmartcols: resuse buffer for encoded data
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-15 13:59:46 +02:00
Karel Zak ae0abae283 libsmartcols: fix padding
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-14 16:59:44 +02:00
Karel Zak b233dcb6ff libsmartcols: use buffer struct in table_print.c
* consolidate code in table_print.c
 * make the code easy to extend
 * use return codes everywhere

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-14 16:41:20 +02:00
Karel Zak 4baab7dfd3 libsmartcols: improve line and cell separators
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-14 13:44:23 +02:00
Ondrej Oprala d1b4d14f4d libsmartcols: add separator getters/setters
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-04-14 12:37:21 +02:00
Karel Zak d9554c97e8 libsmartcols: rewrite test code to tree(1)-like util
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-08 12:13:02 +02:00
Karel Zak e2310281c7 libsmartcols: improve docs
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-07 14:07:49 +02:00
Karel Zak 4418714f47 libsmartcols: add debug and version functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-07 13:43:50 +02:00
Karel Zak c830206931 libsmartcols: add missing COPYING file
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-04 13:53:50 +02:00
Karel Zak 71dbc865f8 libsmartcols: fix test
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-04 13:51:47 +02:00
Karel Zak 2a49c0165d build-sys: small fixes to libsmartcols
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-04 11:25:08 +02:00
Karel Zak 0925a9dd6c libsmartcols: clean up flags usage
* rename flags functions to scols_table_enable_*
 * rename *_no_foo() functions to _nofoo()
 * output formats are mutually exclusive, so don't use flags there
 * don't assume symbols in scols_new_table(), use scols_table_set_symbols()

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 16:09:57 +02:00
Karel Zak 1424fe8c86 libsmartcols: init symbols when necessary
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:20 +02:00
Karel Zak dc36586085 libsmartcols: clean up flags
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:20 +02:00
Karel Zak 92e0d69c73 libsmartcols: always deallocate in scols_reset_cell()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:19 +02:00
Ondrej Oprala ce44112b10 libsmartcols: include stdio
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-04-03 12:29:18 +02:00
Ondrej Oprala c0070f8187 libsmartcols: add scols_table_is_empty()
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-04-03 12:29:18 +02:00
Ondrej Oprala 6e792bb6c0 libsmartcols: fix a usage example
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-04-03 12:29:18 +02:00
Ondrej Oprala 1d90bcb1a8 libsmartcols: documentation
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-04-03 12:29:18 +02:00
Ondrej Oprala b72b824d06 libsmartcols: move some code around
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-04-03 12:29:18 +02:00
Ondrej Oprala 8b992cb571 libsmartcols: revert the column flags API
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-04-03 12:29:17 +02:00
Ondrej Oprala 35958d0c61 libsmartcols: colors may now be specified as human-readable strings
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-04-03 12:29:17 +02:00
Ondrej Oprala 8a38a8d31e libsmartcols: separate flags, add getters/setters
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-04-03 12:29:17 +02:00
Ondrej Oprala 9fd9b99f4f libsmartcols: add missing copyright notifications
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-04-03 12:29:17 +02:00
Ondrej Oprala bc8cb33a72 libsmartcols: fill the symbol version file
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-04-03 12:29:17 +02:00
Karel Zak 7e8fe02941 libsmartcols: allow to read lines as tree
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:17 +02:00
Karel Zak 2a965b804a libsmartcols: add function to convert table to string
Note that open_memstream() is POSIX-1.2008, so it's possible than not
all libc have already implemented this function.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:17 +02:00
Karel Zak b28e886463 libsmartcols: remove unnecessary code
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:17 +02:00
Karel Zak e906be066e libsmartcols: add reduce term width functionality
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:16 +02:00
Karel Zak 62d2e2e538 libsmartcols: add SCOLS_FL_MAX
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:16 +02:00
Karel Zak 571441e291 libsmartcols: support alternative streams
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:16 +02:00
Ondrej Oprala 3a29e909f7 libsmartcols: add test
[kzak@redhat.com: - refresh according to previous API changes]

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:16 +02:00
Karel Zak 3e542c7654 libsmartcols: add table code
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:16 +02:00
Karel Zak c638c57ac3 libsmartcols: add table struct, cleanup refcounting
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:16 +02:00
Karel Zak 74bd28ad6e libsmartcols: add lines
Co-Author: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:16 +02:00
Karel Zak 1577b2592e libsmartcols: add columns
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:16 +02:00
Ondrej Oprala 6d1072696c libsmartcols: add cells
[kzak@redhat.com: - remove copy, free -- all have to be handled by lines]

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:16 +02:00
Ondrej Oprala b36992fb2a libsmartcols: add symbols
[kzak@redhat.com: - split scols_new_symbols() to regular getters functions]

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:16 +02:00
Ondrej Oprala 0b0ab9ff96 libsmartcols: add iterator
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:15 +02:00
Ondrej Oprala 1a4d989e22 libsmartcols: add basic files
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:15 +02:00