Description
Introduction
As requested in #453, we have several modules prints only a few characters (for example, Processes
module prints only an integer), it will be nice to merge them into one line.
With the introduction of JSON config, the configuration part for this is possible. I plan to implement Line merging / concatenation in 2.0.
Configuration
Expected result:
OS: Arch Linux x86_64
Host: Windows Subsystem for Linux (1.3.11.0)
Shell: fish 3.6.1 | Terminal: Windows Terminal
CPU Usage: 8% (processes: 302)
Design
Principle: line merging should not invade module implementations; that's to say, a module implementation should not care if it's merged or not.
- Line endings should be handled outside of modules. We print
\n
everywhere, this requires major code refactoring. - Logo (cursor moving) should be handled outside of modules. No
ffPrintLogoAndKey
There are modules prints multiple lines (Display, GPU, Disk, LocalIP, etc). This is what I want to discuss. My basic ideas:
- Add option
--compact
or--compact-type
to force them to print in one line, like--display-compact-type
and--localip-compact
. - In general these modules still print multi lines. However since we are moving
logo
andline ending
handling outside of modules, it will be problematic when printing second line. Therefore a module should not print anything, but generates a list of strings, so that they don't need to take care of other works between printing two lines.
void ffGenerateGPUOutput(FFGPUOptions* options, FFlist output)
{
FFlist gpus;
FF_LIST_FOR_EACH(FFGPUResult, gpu, gpus)
{
appendGPUResult(options, index, gpu, (FFstrbuf*) FFListAdd(output));
}
}
To be honest this requires much more code changes and is what I want to avoid. Any easier-to-do ideas?
- If we get multiple lines in
~
(line merging) module, just concat them normally.
{
"modules": [
{
"type": "~",
"separator": " | "
"modules": [
"gpu"
]
}
]
}
Expected result:
GPU 1: Intel(R) Iris(R) Xe Graphics (1.00 GiB) [Integrated] | GPU 2: NVIDIA GeForce RTX 3070 Ti Laptop GPU (8.00 GiB) [Discrete]
The line may be trancated with --disable-linewrap
enabled.