summaryrefslogtreecommitdiffstats
path: root/libsmartcols/src/smartcolsP.h
Commit message (Collapse)AuthorAgeFilesLines
* libsmartcols: cleanup and extend padding functionalityKarel Zak2019-07-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | LIBSMARTCOLS_DEBUG_PADDING=on in the next examples forces libsmartcols print '.' as a padding char. See line "ffff" in the exmaples. * default output is to fill all except last cell $ LIBSMARTCOLS_DEBUG_PADDING=on ./sample-scols-fromfile --nlines 10 --width 80 --column tests/ts/libsmartcols/files/col-name --column tests/ts/libsmartcols/files/col-number --column tests/ts/libsmartcols/files/col-string --column tests/ts/libsmartcols/files/col-string tests/ts/libsmartcols/files/data-string tests/ts/libsmartcols/files/data-number tests/ts/libsmartcols/files/data-string-empty tests/ts/libsmartcols/files/data-string-empty 2> /dev/null NAME.. ......NUM STRINGS STRINGS aaaa.. ........0 aaaa... aaaa bbb... ......100 bbb.... bbb ccccc. .......21 ccccc.. ccccc dddddd ........3 dddddd. dddddd ee.... ......411 ee..... ee ffff.. .....5111 ....... gggggg 678993321 gggggg. gggggg hhh... ..7666666 hhh.... hhh * scols_table_enable_minout() minimizes output for tailing empty cells, example: $ LIBSMARTCOLS_DEBUG_PADDING=on ./sample-scols-fromfile --nlines 10 --minout --width 80 --column tests/ts/libsmartcols/files/col-name --column tests/ts/libsmartcols/files/col-number --column tests/ts/libsmartcols/files/col-string --column tests/ts/libsmartcols/files/col-string tests/ts/libsmartcols/files/data-string tests/ts/libsmartcols/files/data-number tests/ts/libsmartcols/files/data-string-empty tests/ts/libsmartcols/files/data-string-empty 2> /dev/null NAME.. ......NUM STRINGS STRINGS aaaa.. ........0 aaaa... aaaa bbb... ......100 bbb.... bbb ccccc. .......21 ccccc.. ccccc dddddd ........3 dddddd. dddddd ee.... ......411 ee..... ee ffff.. .....5111 gggggg 678993321 gggggg. gggggg hhh... ..7666666 hhh.... hhh * cleanup up scols_table_enable_maxout() use, example: $ LIBSMARTCOLS_DEBUG_PADDING=on ./sample-scols-fromfile --nlines 10 --maxout --width 80 --column tests/ts/libsmartcols/files/col-name --column tests/ts/libsmartcols/files/col-number --column tests/ts/libsmartcols/files/col-string --column tests/ts/libsmartcols/files/col-string tests/ts/libsmartcols/files/data-string tests/ts/libsmartcols/files/data-number tests/ts/libsmartcols/files/data-string-empty tests/ts/libsmartcols/files/data-string-empty 2> /dev/null NAME.............. ..................NUM STRINGS............ STRINGS............ aaaa.............. ....................0 aaaa............... aaaa............... bbb............... ..................100 bbb................ bbb................ ccccc............. ...................21 ccccc.............. ccccc.............. dddddd............ ....................3 dddddd............. dddddd............. ee................ ..................411 ee................. ee................. ffff.............. .................5111 ................... ................... gggggg............ ............678993321 gggggg............. gggggg............. hhh............... ..............7666666 hhh................ hhh................ Note that we cannot make scols_table_enable_minout() default because for example "column --table" is pretty commonly used with non-blank columns separator and in this case all cells has to be filled. $ echo -e "aa,b,ccc\na,,\naaa,bbb,ccc" | column --table --separator ',' --output-separator '|' aa |b |ccc a | | aaa|bbb|ccc Addresses: https://github.com/karelzak/util-linux/issues/826 Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: add generic function to walk on treeKarel Zak2019-05-071-1/+42
| | | | | | | Now we implement the same thing on more places. Let's add one set of functions to walk the tree and use it everywhere. Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: cell width calulation cleanupKarel Zak2019-05-031-0/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: (groups) use print functions tp calculate grpsetKarel Zak2019-05-031-1/+1
| | | | | | | Now we have extra code to calculate grpset. It seems better to use only one way how we wall the tree. Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: (groups) print group childrent after regualr treeKarel Zak2019-05-031-0/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: (groups) remove hardcoded const numbersKarel Zak2019-05-021-0/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* docs: fix typos [codespell]Sami Kerola2019-02-181-1/+1
| | | | | Reference: https://github.com/codespell-project/codespell Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libsmartcols: add lines grouping supportKarel Zak2018-12-071-8/+127
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For some use-case we need to describe M:N relation between output lines. The nice examples are RAIDs or multi-path devices in lsblk output. NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT loop0 7:0 0 955.7M 0 loop ┌┈▶ ├─test-thin-metadata 253:0 0 2M 0 dm └┬▶ └─test-thin-data 253:1 0 953.7M 0 dm └┈┈test-thin-pool 253:2 0 953.7M 0 dm In this example two line (test-thin-metadata and test-thin-data) are parents for another line (test-thin-pool). The new API uses term "group" for parental line -- the number of group members is unlimited and every group has at least one child. It's possible that group's child is member of another group: NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT loop0 7:0 0 955.7M 0 loop ┌┈▶ ├─test-thin-metadata 253:0 0 2M 0 dm └┬▶ └─test-thin-data 253:1 0 953.7M 0 dm ┌┈▶ └┈┈test-thin-pool 253:2 0 953.7M 0 dm ┆ └─test-thin 253:3 0 190.8M 0 dm └┬▶ loop1 7:1 0 190.8M 0 loop └┈┈┈┈┈test-thin-extsnap 253:4 0 190.8M 0 dm For now multi-group relation is unsupported and one line can be member of one group only. The library API and printing code is ready to support this feature, but not sure if we really need it. All what is necessary is to create array of groups in the line struct. Note that grouping is independent on standard parent->child relations between lines and grouping can connect arbitrary lines. The restriction is only that group child cannot be child of another line or child of another group. These cross reference are (and probably will be) impossible. The patch is relative large, but easy to review. Changes: * add new UTF symbols * add scols_symbols_set_group_* public API to modify new symbols * add struct libscols_group, used only internally * add "grpset" array to table struct -- the array is used to keep position of the group in the output. Every active group uses three items in the grpset. If there is more overlapping groups than bigger grpset is allocated. Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: split print.c into print.c, put.c and print-api.cKarel Zak2018-12-071-0/+22
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: move width calculation to separate fileKarel Zak2018-12-071-0/+17
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: move buffer stuff to buffer.cKarel Zak2018-12-071-0/+20
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: add is_last_child(), move is_last_column()Karel Zak2018-12-071-0/+22
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: improve JSON support (add types)Karel Zak2018-04-031-0/+2
| | | | | | | This commit add SCOLS_JSON_{NUMBER,STRING,BOOLEAN} to specify column type for JSON output formatting. Signed-off-by: Karel Zak <kzak@redhat.com>
* include/debug: don't print pointer address for SUID programsKarel Zak2018-01-121-0/+3
| | | | | | | | | | | | | | | | * introduce new flag __UL_DEBUG_FL_NOADDR to suppress pointer address printing * use __UL_DEBUG_FL_NOADDR when SUID * move ul_debugobj() to debugobj.h, and require UL_DEBUG_CURRENT_MASK to provide access to the current mask from ul_debugobj(). It's better than modify all ul_debugobj() calls and use the global mask as argument. * remove never used UL_DEBUG_DEFINE_FLAG Reported-by: halfdog <me@halfdog.net> Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: add scols_table_enable_noencoding()Karel Zak2017-07-311-0/+1
| | | | | | | | 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>
* libsmartcols: add header-repeat featureKarel Zak2017-06-131-0/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: add scols_table_{set,get}_termheight()Karel Zak2017-06-121-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: add scols_line_move_cells()Karel Zak2017-04-071-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: custom wrap fixesKarel Zak2016-09-271-1/+1
| | | | | Reported-by: Igor Gnatenko <i.gnatenko.brain@gmail.com Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: support custom wrap and remove SCOLS_FL_WRAPNLKarel Zak2016-09-261-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* libsmartcols: cleanup scols_table_set_symbols() APIKarel Zak2016-09-231-0/+1
| | | | | | | | | | | | 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>
* libsmartcols: use const qualifier where it's possibleIgor Gnatenko2016-09-211-1/+1
| | | | | Closes: https://github.com/karelzak/util-linux/issues/355 Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
* libsmartcols: add functions to control terminal usageKarel Zak2016-09-131-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: support LIBSMARTCOLS_DEBUG_PADDING=onKarel Zak2016-09-071-0/+1
| | | | | | | | | | | | 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>
* libsmartcols: allow to change cell padding charKarel Zak2016-09-071-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: Fix various typosSebastian Rasmussen2016-05-311-1/+1
| | | | | | | Fix various typos in error messages, warnings, debug strings, comments and names of static functions. Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
* libsmartcols remove duplicate codeKarel Zak2016-04-221-0/+1
| | | | | | | | 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>
* libsmartcols: support continuous printingKarel Zak2016-02-191-0/+2
| | | | | | | | | 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>
* libsmartcols: support multi-line cellsKarel Zak2016-02-101-0/+4
| | | | | | | | | | | 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>
* libsmartcols: use libscols_cell for titleKarel Zak2016-02-091-3/+2Star
| | | | | References: https://github.com/karelzak/util-linux/issues/270 Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: support multibyte titles, rename wrap to paddingKarel Zak2016-01-221-1/+1
| | | | | | | | | - 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>
* libsmartcols: use symbols for title wrapIgor Gnatenko2016-01-211-0/+1
| | | | Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
* libsmartcols: implement title of tableIgor Gnatenko2016-01-211-1/+4
| | | | | Reference: https://github.com/karelzak/util-linux/issues/258 Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
* libsmartcols: reflect changinging SCOLS_FL_TREE after adding to tableIgor Gnatenko2016-01-171-0/+2
| | | | | | | | 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>
* libsmartcols: add SCOLS_FL_HIDDENKarel Zak2015-12-101-2/+0Star
| | | | | | Export "don't print this column" functionality by public API. Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: add scols_table_enable_nowrap()Karel Zak2015-12-071-1/+4
| | | | | | | This allows to use libsmartcols in ncurses programs without any additional voodoo. Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: allow to reduce tree columnsKarel Zak2015-11-301-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: add --disable-assertKarel Zak2015-08-041-9/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: don't link with tinfoKarel Zak2015-07-241-1/+1
| | | | | | | 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>
* libsmartcols: add JSON output formatKarel Zak2015-06-041-1/+14
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: clean up debug, add help debug maskKarel Zak2014-11-031-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: add debug messagesKarel Zak2014-06-061-0/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: add scols_sort_table()Karel Zak2014-05-201-0/+6
| | | | | | | | | | | | | | | | | | | * 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>
* libsmartcols: add separator getters/settersOndrej Oprala2014-04-141-0/+3
| | | | Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
* libsmartcols: add debug and version functionsKarel Zak2014-04-071-0/+14
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: clean up flags usageKarel Zak2014-04-031-8/+14
| | | | | | | | | * 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>
* libsmartcols: always deallocate in scols_reset_cell()Karel Zak2014-04-031-2/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: revert the column flags APIOndrej Oprala2014-04-031-6/+1Star
| | | | Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
* libsmartcols: separate flags, add getters/settersOndrej Oprala2014-04-031-3/+15
| | | | Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
* libsmartcols: remove unnecessary codeKarel Zak2014-04-031-1/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>