summaryrefslogtreecommitdiff
path: root/src/basic/terminal-util.h
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: fix typo and comment style updateYu Watanabe2023-02-151-1/+1
|
* terminal-util: get_color_mode checks COLORTERMSonali Srivastava2022-05-051-4/+7
|
* exec: Add TTYRows and TTYColumns properties to set TTY dimensionsDaan De Meyer2021-11-051-0/+2
|
* util: add helpers for generating colored check mark glyphs from boolsLennart Poettering2021-03-031-0/+4
|
* tree-wide: use -EINVAL for enum invalid valuesZbigniew Jędrzejewski-Szmek2021-02-101-1/+1
| | | | | | | | | As suggested in https://github.com/systemd/systemd/pull/11484#issuecomment-775288617. This does not touch anything exposed in src/systemd. Changing the defines there would be a compatibility break. Note that tests are broken after this commit. They will be fixed in the next one.
* basic/term-util: inline colors_enabled functionrnhmjoj2020-12-151-1/+6
| | | | | There is no need to cache colors_enabled because the function is now simply calling get_color_mode, which is already cached.
* tree-wide: avoid direct use of color macrosrnhmjoj2020-12-151-0/+1
|
* basic/term-util: extend $SYSTEMD_COLORSrnhmjoj2020-12-151-23/+64
| | | | | | | This commit extends $SYSTEMD_COLORS to an enum variable (compared to a simple boolean) which specifies the "colors mode". This means that, in addition to disabling colors altogether, it's now possible to restrict the console output to 16 or 256 colors only.
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* basic/terminal-util: rename our replacement highlight-yellow and test both ↵Zbigniew Jędrzejewski-Szmek2020-07-301-10/+17
| | | | | | | | | | | | | | the original and replacement The fact that we cannot use the "real" yellow color and need to use some other color is essentially a bug. In this particular case the issue is in urxvt, see a9009769de43b7f29d05017f4219e18c1e42a273. While we work around this by using a different color, let's not forget that this is just a (hopefullly temporary) workaround. https://bugzilla.redhat.com/show_bug.cgi?id=1859886 https://bugzilla.redhat.com/show_bug.cgi?id=1859889 https://bugzilla.redhat.com/show_bug.cgi?id=1859894
* basic/terminal-util: define all foreground colorsZbigniew Jędrzejewski-Szmek2020-07-231-0/+33
| | | | | | We would add and remove definitions based on which colors were used by other code. Let's just define all of them to simplify tests and allow easy comparisons which colors look good.
* systemctl: ensure underline for "list-unit-files" empty cellsLennart Poettering2020-05-061-0/+2
|
* terminal-util: fixate underlined yellow color tooLennart Poettering2020-04-081-1/+1
| | | | | | | non-underlined yellow uses RGB ANSI sequences while the underlined version uses the paletted ANSI sequences. Let's unify that and use the RGB sequence for both cases, so that underlined or not doesn't alter the color.
* Revert "Move verify_vc_kbmode() to terminal-util.c as vt_verify_kbmode()"Lennart Poettering2019-07-181-1/+0
| | | | This reverts commit bb5ac84d79ac3aef606a4a9eeaafef94a1f199be.
* basic/log: put location in a dark shade of yellowZbigniew Jędrzejewski-Szmek2019-07-021-6/+7
| | | | | It is different then the other colors we use. Tested on gnome-terminal, urxvt, urxvt -rv, xterm, linux console.
* terminal-util: introduce openpt_allocate()Franck Bui2019-06-181-2/+2
| | | | | | | | | | | | | | | | Allocating a pty is done in a couple of places so let's introduce a new helper which does the job. Also the new function, as well as openpt_in_namespace(), returns both pty master and slave so the callers don't need to know about the pty slave allocation details. For the same reasons machine_openpt() prototype has also been changed to return both pty master and slave so callers don't need to allocate a pty slave which might be in a different namespace. Finally openpt_in_namespace() has been renamed into openpt_allocate_in_namespace().
* terminal-util: reset access mode in vt_restore(), tooLennart Poettering2019-05-241-0/+3
| | | | | | Only changing ownership back to root is not enough we also need to change the access mode, otherwise the user might have set 666 first, and thus allow everyone access before and after the chown().
* terminal-util: define yellow as "Khaki3"Zbigniew Jędrzejewski-Szmek2019-05-171-1/+1
| | | | | | | | | | | | Previously used "highlight yellow" was not visible on urxvt, because it was too light. This color is shown as bold black by urxvt, but at least it is readable. On other terminals it is shown as various hues of yellow, pleasant on the eyes and not too bright. The color shown on linux console could be called orange rather than yellow, but it is still readable. (I also tried non-highlight "yellow", but it is not as readable.) This is a follow-up for bb40c12569d017f75774ff9f4b6fb0ac64f9eee0.
* Merge pull request #12535 from poettering/color-greyZbigniew Jędrzejewski-Szmek2019-05-161-25/+26
|\ | | | | redefine how we select the ANSI color grey
| * terminal-util: add complete set of inline functions for all colors we defineLennart Poettering2019-05-101-15/+23
| | | | | | | | | | | | We don#t actually use all combinations, but it's kinda nice if we can output all combinations in a test, and this is preparation so that we can do so nicely.
| * terminal-util: reduce colors we define a bitLennart Poettering2019-05-101-9/+2
| | | | | | | | | | | | three of these colors we never use, so let's drop them. Let's however add a highlight version of grey, so that at least for all colors we do define we have all possible styles defined.
| * terminal-util: define grey as 256color ANSI sequenceLennart Poettering2019-05-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Apparently all relevant terminals implement these sequences, including the Linux kernel, rxvt, xterm, and of course gnome terminal. Hence it should be OK to use them, and fixate the grey color in a way that maps to the same color in all terminals. Ideally we'd stick to the more symbolic colors that allow terminal emulators to implement color styles, but this apparently doesn#t work, since rxvt maps grey to something unreadable by default. Note that this change has negative effects besides the non-themability of the palette: the midrange grey this uses maps to regular white on the linux console. However, that's probably not too bad: allowing things to be unreadable on some terminals is probably worse than showing no color on some terminals. Fixes: #12482
* | Merge pull request #12378 from rbalint/vt-kbd-reset-checkLennart Poettering2019-05-161-0/+1
|\ \ | |/ |/| VT kbd reset check
| * Move verify_vc_kbmode() to terminal-util.c as vt_verify_kbmode()Balint Reczey2019-04-241-0/+1
| |
* | basic/log: use colors to highlight messages like journalctlZbigniew Jędrzejewski-Szmek2019-05-081-0/+3
|/
* resolvectl: color "comment" output greyLennart Poettering2018-12-051-0/+2
| | | | Let's de-emphasize the "comment" output a bit, by making it grey.
* terminal-util: introduce vt_release() helperFranck Bui2018-11-211-0/+1
|
* terminal-util: introduce vt_restore() helperFranck Bui2018-11-211-0/+1
|
* Split out pretty-print.c and move pager.c and main-func.h to shared/Zbigniew Jędrzejewski-Szmek2018-11-201-12/+0
| | | | | This is high-level functionality, and fits better in shared/ (which is for our executables), than in basic/ (which is also for libraries).
* tree-wide: add clickable man page link to all --help textsLennart Poettering2018-08-201-0/+1
| | | | | | | | | | This is a bit like the info link in most of GNU's --help texts, but we don't do info but man pages, and we make them properly clickable on terminal supporting that, because awesome. I think it's generally advisable to link up our (brief) --help texts and our (more comprehensive) man pages a bit, so this should be an easy and straight-forward way to do it.
* show-status: add newline to ephemeral messagesTomsod M2018-07-061-0/+3
| | | | Fixes #6712. The newline is later reversed, naturally.
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-4/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* tree-wide: unify how we define bit mak enumsLennart Poettering2018-06-121-5/+5
| | | | | | Let's always write "1 << 0", "1 << 1" and so on, except where we need more than 31 flag bits, where we write "UINT64(1) << 0", and so on to force 64bit values.
* terminal-util: add a function that shows a pretty separator lineLennart Poettering2018-05-111-0/+2
| | | | Follow-up for #8824
* analyze: add 'cat-config' verbZbigniew Jędrzejewski-Szmek2018-04-271-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | This is used as 'systemd-analyze show-config systemd/logind.conf', which will dump /etc/systemd/system/user@.service /etc/systemd/system/user@.service.d/*.conf /run/systemd/system/user@.service.d/*.conf /usr/local/lib/systemd/system/user@.service.d/*.conf /usr/lib/systemd/system/user@.service.d/*.conf The idea is to make it easy to dump the configuration using the same locations and order that systemd programs use themselves (including masking, in the right order, etc.). This is the generic variant that works with any configuration scheme that follows the same general rules: $ systemd-analyze cat-config systemd/system.conf $ systemd-analyze cat-config systemd/user.conf $ systemd-analyze cat-config systemd/logind.conf $ systemd-analyze cat-config systemd/sleep.conf $ systemd-analyze cat-config systemd/journald.conf $ systemd-analyze cat-config systemd/journal-remote.conf $ systemd-analyze cat-config systemd/journal-upload.conf $ systemd-analyze cat-config systemd/coredump.conf $ systemd-analyze cat-config systemd/resolved.conf $ systemd-analyze cat-config systemd/timesyncd.conf $ systemd-analyze cat-config udev/udev.conf
* Move function to cat file & dropins into basic/Zbigniew Jędrzejewski-Szmek2018-04-261-0/+2
| | | | | This fixes a buglet where the second and later drop-in would not be seperated properly by a newline.
* terminal: add internal API to format URLs for display in capable terminalsLennart Poettering2018-04-191-0/+3
| | | | | | | | | | | | | | | | Newer terminals (in particular gnome-terminal) understand special escape sequence for formatting clickable links. Let's support that to make our tool output more clickable where that's appropriate. For details see this: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda The one big issue is that 'less' currently doesn't grok this, and doesn't ignore sequence like regular terminal implementations do if they don't support it. Hence for now, let's disable URL output if a pager is used. We should revisit that though as soon as less added support for it and enough time passed for it to enter various distributions.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* core: drop unnecessary __useless_struct_to_allow_trailing_semicolon__Zbigniew Jędrzejewski-Szmek2018-03-061-5/+2
| | | | | | | | | | | | | | ISO C does not allow empty statements outside of functions, and gcc will warn the trailing semicolons when compiling with -pedantic: warning: ISO C does not allow extra ‘;’ outside of a function [-Wpedantic] But our code cannot compile with -pedantic anyway, at least because warning: ISO C does not support ‘__PRETTY_FUNCTION__’ predefined identifier [-Wpedantic] Without -pedatnic, clang and even old gcc (3.4) generate no warnings about those semicolons, so let's just drop __useless_struct_to_allow_trailing_semicolon__.
* Merge pull request #8314 from poettering/rearrange-stdioLennart Poettering2018-03-021-2/+0
|\ | | | | refactor how we rearrange fds for stdin/stdout/stderr
| * terminal-util: port some generic code over to rearrange_stdio()Lennart Poettering2018-03-021-2/+0
| |
* | Organize the ANSI codes and add missing colorsAlexander F Rødseth2018-03-021-10/+34
|/ | | | For consistency.
* terminal-util: make resolve_dev_console() less weirdLennart Poettering2018-02-141-1/+1
| | | | | Let's normalize the behaviour: return a negative errno style error code, and return the resolved string directly as argument.
* terminal-util: modernize get_kernel_consoles() a bitLennart Poettering2018-02-141-1/+1
| | | | | Also, make sure when we run in a container, we don't use the data from /sys at all, but immediately fall back to /dev/console itself.
* tty-ask-password-agent: reenable color for boot-time password promptLennart Poettering2018-02-141-0/+1
| | | | | | | The password prompt used to be highlighted, and that was a good thing. Let's fix things to make the prompt highlighted again. Fixes: #3853
* terminal-util: when making /dev/null or the console stdio, forget cached ↵Lennart Poettering2018-02-131-0/+2
| | | | | | | | | | | | | terminal features Let's forget all relevant terminal features we learnt when we make a console or /dev/null stdin/stdout/stderr. Also, while we are at it, let's drop the various _unlikely_ and _likely_ annotiations around the terminal feature caches. In many cases we call the relevant functions only once in which cases the annotations are likely to do just harm and no good. After all we can't know if the specific code will call us just once or many times...
* terminal-util: rework acquire_terminal()Lennart Poettering2018-02-131-1/+17
| | | | | | | | | | | | | | This modernizes acquire_terminal() in a couple of ways: 1. The three boolean arguments are replaced by a flags parameter, that should be more descriptive in what it does. 2. We now properly handle inotify queue overruns 3. We use _cleanup_ for closing the fds now, to shorten the code quite a bit. Behaviour should not be altered by this.
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* systemctl: don't do ANSI underlining on TERM=linux (#6778)Lennart Poettering2017-09-091-6/+16
| | | | | | The linux console apparently can't do underlining, hence let's not do it on the console. Also see: #6601