]>
Commit | Line | Data |
---|---|---|
db9ecf05 | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
294bf0c3 ZJS |
2 | #pragma once |
3 | ||
3131c24b LP |
4 | #include "glyph-util.h" |
5 | #include "terminal-util.h" | |
6 | ||
d61a4dbb YW |
7 | #define CYLON_BUFFER_EXTRA (2*STRLEN(ANSI_RED) + STRLEN(ANSI_HIGHLIGHT_RED) + 2*STRLEN(ANSI_NORMAL)) |
8 | ||
9 | void draw_cylon(char buffer[], size_t buflen, unsigned width, unsigned pos); | |
10 | ||
294bf0c3 ZJS |
11 | void print_separator(void); |
12 | ||
62d6a1cc LP |
13 | int file_url_from_path(const char *path, char **ret); |
14 | ||
422c8251 LP |
15 | bool urlify_enabled(void); |
16 | ||
294bf0c3 ZJS |
17 | int terminal_urlify(const char *url, const char *text, char **ret); |
18 | int terminal_urlify_path(const char *path, const char *text, char **ret); | |
19 | int terminal_urlify_man(const char *page, const char *section, char **ret); | |
20 | ||
21 | typedef enum CatFlags { | |
1be6a5db ZJS |
22 | CAT_CONFIG_OFF = 0, |
23 | CAT_CONFIG_ON = 1 << 0, | |
24 | CAT_FORMAT_HAS_SECTIONS = 1 << 1, /* Sections are meaningful for this file format */ | |
25 | CAT_TLDR = 1 << 2, /* Only print comments and relevant section headers */ | |
294bf0c3 ZJS |
26 | } CatFlags; |
27 | ||
28 | int cat_files(const char *file, char **dropins, CatFlags flags); | |
063c8382 | 29 | int conf_files_cat(const char *root, const char *name, CatFlags flags); |
3131c24b LP |
30 | |
31 | #define RED_CROSS_MARK_MAX (STRLEN(ANSI_HIGHLIGHT_RED) + STRLEN("✗") + STRLEN(ANSI_NORMAL) + 1) | |
32 | #define GREEN_CHECK_MARK_MAX (STRLEN(ANSI_HIGHLIGHT_GREEN) + STRLEN("✓") + STRLEN(ANSI_NORMAL) + 1) | |
33 | ||
34 | static inline const char *red_cross_mark_internal(char buffer[static RED_CROSS_MARK_MAX]) { | |
35 | assert(buffer); | |
36 | assert_se(stpcpy(stpcpy(stpcpy(buffer, ansi_highlight_red()), special_glyph(SPECIAL_GLYPH_CROSS_MARK)), ansi_normal()) < buffer + RED_CROSS_MARK_MAX); | |
37 | return buffer; | |
38 | } | |
39 | ||
40 | static inline const char *green_check_mark_internal(char buffer[static GREEN_CHECK_MARK_MAX]) { | |
41 | assert(buffer); | |
42 | assert_se(stpcpy(stpcpy(stpcpy(buffer, ansi_highlight_green()), special_glyph(SPECIAL_GLYPH_CHECK_MARK)), ansi_normal()) < buffer + GREEN_CHECK_MARK_MAX); | |
43 | return buffer; | |
44 | } | |
45 | ||
46 | #define RED_CROSS_MARK() red_cross_mark_internal((char[RED_CROSS_MARK_MAX]) {}) | |
47 | #define GREEN_CHECK_MARK() green_check_mark_internal((char[GREEN_CHECK_MARK_MAX]) {}) | |
48 | ||
49 | #define COLOR_MARK_BOOL(b) ((b) ? GREEN_CHECK_MARK() : RED_CROSS_MARK()) | |
3ef072ee LP |
50 | |
51 | int terminal_tint_color(double hue, char **ret); | |
71cb203a | 52 | |
d4ffb37b LP |
53 | bool shall_tint_background(void); |
54 | ||
71cb203a LP |
55 | void draw_progress_bar(const char *prefix, double percentage); |
56 | void clear_progress_bar(const char *prefix); |