These functions are to do with being an interactive, terminal-oriented
CLI/TUI, so it would be inappropriate for library code in libflatpak
to call them, and it would also be inappropriate for daemons like the
session and system helpers to call them.
In fact all calls to these were already isolated to app/, so we can
easily move the terminal-related utilities themselves into app/.
As well as shrinking libflatpak, this makes it obvious that the system
helper does not actually need to call flatpak_disable_fancy_output():
it does not link any code that would be affected by that API call.
Signed-off-by: Simon McVittie <smcv@collabora.com>
To make indentation work with less effort. The modeline was copied from
libostree with minor modification and the .editorconfig from GLib.
The advantage of having both a modeline and an editorconfig is we can
work out of the box on more editor setups, and the modeline allows us to
specify the style with a lot more fine grained control.
This allows callers to be checked for mismatches between format string
and arguments, and also means gcc can assume that the format string and
the arguments match up correctly when forwarding them to functions
like g_strdup_vprintf, removing the need to suppress -Wformat-nonliteral
warnings.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Currenly we only list arch in the list of things to install from a
transaction if not all the refs are the same arch. It makes more sense
to show the arch even if its unique if they are not the primary arch.
Avoid shadowing variables that are already declared in a previous scope,
and make such occurrences compile-time errors. These are not functional
changes.
In a few places do related code cleanup.
A similar ostree PR is here:
https://github.com/ostreedev/ostree/pull/2195
Additionally flatpak_table_printer_set_columns now takes a boolean
to say whether the arguments in use are the default.
Closes: #2850
Approved by: matthiasclasen
If a column is marked skip_unique it will be entierly skipped
if all the rows have the same unique value for it. This is
useful for example to skip the arch column if all arches are
the same.
Closes: #2850
Approved by: matthiasclasen
Uncrustify has an option "nl_func_var_def_blk" which is supposed to
ensure there's a newline character between the block of variable
definitions and the rest of the function body, but it gets confused and
thinks that the first instance of "g_autoptr" or "g_auto" being used on
a variable is the start of the function body. So this commit removes
those extra newline characters and removes that option in uncrustify.cfg
so they don't get re-added the next time uncrustify is run.
Here's the command I used:
perl -0777 -i -pe 's/\n(\n\s*g_auto\()/\1/g' `git ls-tree --name-only
-r HEAD | grep \\\.[ch]$ | grep -v common/valgrind-private.h |
grep -v app/flatpak-polkit-agent-text-listener\\\.[ch]`
I ran it again with "g_autoptr" in place of "g_auto", and made a few
manual edits to add back the newline when the g_auto* was in the middle
of a function body rather than at the top.
Closes: #2715
Approved by: matthiasclasen
Move expand and ellipsize to the Column struct,
and change flatpak_table_printer_set_column_titles
to flatpak_table_printer_set_columns that sets up
not just the title, but also expand and ellipsize.
Update all callers.
Closes: #2460
Approved by: alexlarsson
We are allowing Unicode output, so we need to
use g_utf8_strlen whenever we want to count the
number of columns occupied by a string.
Closes: #2502
Approved by: alexlarsson
After ellipsizing nicely, we try to spread the extra
shortfall around, but we need to stop when we've
exhausted the available shrinkage and give up.
Some tables are just too wide.
This was showing up as an infinite loop with
flatpak remote-ls --columns=app,opt flathub
Closes: #2496
Approved by: matthiasclasen
I think this makes a lot more sense than ellipsizing in the middle.
Most app ids start with a common prefix after all.
Closes: #2448
Approved by: alexlarsson
Optionally mark a column as ellipsizing.
Currently, this won't work correctly if more
than one column is ellipsizing.
Closes: #2409
Approved by: alexlarsson
When we are given a with that is larger than the content we have,
expand the space between columns, within reason. We only make the
table at most 1.5 times as wide as it would be unexpanded.
Add a new API for setting individual columns to expand (or not).
For an expanding column, we'll grow the space between it and its
preceding column. The expand flag of the first column is ignored.
By default, columns do not expand.
Make flatpak_table_printer_print_full return not just the table
height, but also the width.
Update all callers.
Closes: #2371
Approved by: alexlarsson
Add a way to change individual cells and a getter for the
current row. Also add a variation of the print() method that
returns the number of terminal rows that was generated
when formatting to given width, while skipping a number
of rows at the beginning. This method will be used in the
following commit to print a part of the table into a terminal
window of a given size.
Closes: #2371
Approved by: alexlarsson
In a table, if some row is wide then *all* rows will be that wide
with spaces at the end. This is not great in e.g. the remote-ls
case where one row has a long EOL message.
This commit strips all the trailing whitespace from each row to avoid
this.
Closes: #2189
Approved by: alexlarsson