C-Menu 0.2.9
A User Interface Toolkit
Loading...
Searching...
No Matches
cm.h File Reference

Headder for C-Menu API library, libcm.so. More...

#include "version.h"
#include <argp.h>
#include <signal.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include <time.h>
#include <wait.h>
#include <wchar.h>
#include <stdio.h>
Include dependency graph for cm.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Arg
struct  Argv
struct  Chyron
struct  ChyronKey
struct  CmField
struct  ColorPair
struct  Date
struct  SIO
 The SIO structure encapsulates various aspects of the terminal's state and configuration, including color management, file pointers, and terminal device information. More...
struct  String
struct  Time
struct  WCStr

Macros

#define __atexit
 This macro registers the end_pgm function to be called when the program exits.
#define _GNU_SOURCE
#define _XOPEN_SOURCE_EXTENDED   1
#define ABS(x)
 ABS macro for absolute value, which evaluates the expression once and returns the absolute value.
#define BG_COLOR   0
#define BO_COLOR   1
#define CHYRON_KEY_MAXLEN   64
#define CHYRON_KEYS   20
#define COLOR_LEN   8
#define Ctrl(c)
#define DEFAULTSHELL   "/bin/bash"
#define DIV_ROUND_UP(n, d)
#define F_NO_STDERR   1
#define FG_COLOR   2
#define KEY_ALTDEL   0x20e
#define KEY_ALTDOWN   0x214
#define KEY_ALTEND   0x219
#define KEY_ALTF(n)
#define KEY_ALTF0   0x138
#define KEY_ALTHOME   0x21e
#define KEY_ALTINS   0x223
#define KEY_ALTLEFT   0x228
#define KEY_ALTPGDN   0x22d
#define KEY_ALTPGUP   0x232
#define KEY_ALTRIGHT   0x237
#define KEY_ALTUP   0x23d
#define LN_BG_COLOR   7
#define LN_COLOR   4
#define MAX(a, b)
 MIN macro for compatibility with code that uses the same name, while avoiding multiple evaluations of the arguments.
#define max(a, b)
 max macro evaluates two expressions, returning greatest result.
#define MAX_ARGS   64
#define MAX_DEPTH   3
#define MAXARGS   64
#define MAXLEN   256
#define MAXWIN   30
#define MAXWIN   30
#define MIN(x, y)
 MAX macro for compatibility with code that uses the same name, while avoiding multiple evaluations of the arguments.
#define min(x, y)
 min macro evaluates two expressions, returning least result
#define NCURSES_WIDECHAR   1
#define nullptr   NULL
#define S_QUIET   0x2000
#define S_TOLOWER(c)
#define S_TOUPPER(c)
#define S_WCOK   0x1000
#define SCR_COLS   1024
#define SCREEN_MAX_LINES   100
#define to_lowercase(c)
#define to_uppercase(c)
#define to_uppercase(c)
#define XTERM_256COLOR

Typedefs

typedef unsigned char uchar

Enumerations

enum  ColorsEnum {
  CLR_BLACK , CLR_RED , CLR_GREEN , CLR_YELLOW ,
  CLR_BLUE , CLR_MAGENTA , CLR_CYAN , CLR_WHITE ,
  CLR_BBLACK , CLR_BRED , CLR_BGREEN , CLR_BYELLOW ,
  CLR_BBLUE , CLR_BMAGENTA , CLR_BCYAN , CLR_BWHITE ,
  CLR_BORANGE , CLR_FG , CLR_BG , CLR_BOX_FG ,
  CLR_BOX_BG , CLR_IND_FG , CLR_IND_BG , CLR_BRACKETS_FG ,
  CLR_BRACKETS_BG , CLR_FILL_CHAR_FG , CLR_FILL_CHAR_BG , CLR_LN_FG ,
  CLR_LN_BG , CLR_CMDLN_FG , CLR_CMDLN_BG , CLR_NT_FG ,
  CLR_NT_BG , CLR_NT_REV_FG , CLR_NT_REV_BG , CLR_NT_HL_FG ,
  CLR_NT_HL_BG , CLR_NT_HL_REV_FG , CLR_NT_HL_REV_BG , CLR_TITLE_FG ,
  CLR_TITLE_BG , CLR_NCOLORS
}
 Used for xterm256 color conversions. More...
enum  F_Type {
  F_F0 , F_FIFO , F_CHR , F_F1 ,
  F_DIR , F_F2 , F_BLK , F_F3 ,
  F_REG , F_F4 , F_LNK , F_F5 ,
  F_SOCK , F_F6 , F_UNKNOWN
}
enum  LFFlags {
  LF_HIDE = 0b00000001 , LF_ICASE = 0b00000010 , LF_EXC_REGEX = 0b00000100 , LF_REGEX = 0b00001000 ,
  LF_EXEC = 0b00010000 , LF_USER = 0b00100000 , LF_IXUSR = 0b00000001 , LF_IWUSR = 0b00000010 ,
  LF_IRUSR = 0b00000100 , LF_ISGID = 0b00010000 , LF_ISUID = 0b00100000
}
enum  LFTypes {
  LF_FIFO = 0b00000001 , LF_CHR = 0b00000010 , LF_DIR = 0b00000100 , LF_BLK = 0b00001000 ,
  LF_REG = 0b00010000 , LF_LNK = 0b00100000 , LF_SOCK = 0b01000000 , LF_UNKNOWN = 0b10000000
}

Functions

unsigned long a_to_ul (const char *)
 Converts a string to an unsigned long long integer, with support for suffixes K, M, and G for kilobytes, megabytes, and gigabytes respectively.
int a_toi (char *, bool *)
 a safer alternative to atoi() for converting ASCII strings to integers.
void abend (int, char *)
 Abnormal program termination.
bool action_disposition (char *eitle, char *action_str)
 Display a simple action disposition message window or print to stderr.
void activate_all_chyron_keys (Chyron *)
 Deactivate chyron key.
void activate_chyron_key (Chyron *, uint)
 Activate chyron key.
int answer_yn (char *, char *, char *, char *)
 Accept a single letter answer.
void apply_gamma (RGB *)
 Apply gamma correction to RGB color.
int assign_chyron_win (Chyron *chyron, UiSurface *s, uint w, char *)
int bare_box_new (uint, uint, uint, uint, char *)
bool base_name (char *, char *)
 Returns the base name of a file specification.
int border_draw (UiSurface *sfc)
int border_title (UiSurface *sfc, char *title)
 Draw a box with a title around the specified window.
int border_ysplit (UiSurface *, uint)
 Draw a box with a separator line around the specified window.
int border_ysplit_text (UiSurface *, char *, uint)
 Draw a box with a separator line and text around the specified window.
size_t canonicalize_file_spec (char *)
 Removes quotes and trims at first space.
bool capture_curses_tioctl ()
 capture_curses_tioctl() - capture curses terminal settings
bool capture_shell_tioctl ()
 capture_shell_tioctl() - capture shell terminal settings
int cf_accept (UiSurface *, uint w, char *, uint, uint, uint)
 Accepts input for a field in a C-Menu window.
void check_panels (uint)
bool chrep (char *, char, char)
 Replaces all occurrences of old_chr in s with new_chr in place.
int cm_surface_destroy (UiSurface *sfc)
 Destroy the most recently created surface.
size_t codepoint_to_utf8 (uint32_t codepoint, uint8_t *utf8)
void compile_chyron (Chyron *)
 construct the chyron string from the chyron structure
bool construct_file_spec (char *, char *, char *, char *, char *, uint)
void deactivate_all_chyron_keys (Chyron *)
 Deactivate all chyron keys.
void deactivate_chyron_key (Chyron *, uint)
 Deactivate chyron key.
int destroy_argv (uint argc, char **argv)
 Deallocates memory allocated for argument strings in argv.
Chyrondestroy_chyron (Chyron *chyron)
 Destroy Chyron structure.
void destroy_curses ()
 Gracefully shut down NCurses and restore terminal settings.
char di_getch ()
 get single character from terminal in raw mode
bool dir_name (char *, char *)
 Returns the directory name of a file specification.
void display_argv_error_msg (char *, char **)
void display_chyron (UiSurface *, uint n, Chyron *, uint, uint)
 Display chyron on the specified line and column of the surface.
int display_curses_keys ()
int display_error (char *, char *, char *, char *)
 Display an error message window or print to stderr.
int display_ok_message (char *)
void dump_opts ()
void dump_opts_by_use (char *, char *)
uint enter_option ()
bool expand_tilde (char *, uint)
 Replaces "~/" in string with the user's home directory.
char * fdname (int, char *)
 Retrieves the file path associated with a given file descriptor.
bool file_spec_name (char *, char *)
 extracts the file name component of a file specification
bool file_spec_path (char *, char *)
 extracts the path component of a file specification
char * fill_field (char *, char *, char, uint)
int fork_detach_execvp (char **)
 Fork, set new session ID, close files, and execute detached command.
int fork_exec (char **)
 Fork and exec a command.
char * format_local_timestamp (time_t, char *, size_t)
 Formats a time_t as an ISO 8601 string in local time.
String free_string (String)
 Free the dynamically allocated String.
int full_screen_fork_exec (char **)
 Execute a command in full screen mode.
int full_screen_shell (char *)
 Execute a shell command in full screen mode.
bool get_argp_doc_by_name (char *comment, const struct argp_option *, const char *)
 Retrieves the documentation string for a given key name from an argp options array.
int get_chyron_key (Chyron *, uint)
 Get keycode from chyron.
char * get_ip_addresses (char *, uint)
 Retrieves the IP addresses of the local machine and formats them into a string.
char * get_local_timestamp ()
 Returns the current local time as an ISO 8601 formatted string.
void get_rfc3339_s (char *, size_t)
char * get_user_str (char *, size_t)
 Retrieves the current user's name and UID, and formats it into a string.
bool handle_signal (sig_atomic_t)
bool init_clr_palette (SIO *)
 Initialize color palette based on SIO settings.
void init_stdscr ()
void initialize_cells (SIO *sio)
 Initialize local color variables and color pairs based on SIO settings.
void initialize_styles (SIO *)
bool is_directory (const char *)
 Checks if the given path is a directory.
bool is_hex_str (char *, uint)
 Validates that a string consists of exactly len hexadecimal digits.
bool is_newer (char *, char *)
 Checks if the file specified by "fut" is newer than the file specified by "control".
bool is_set_chyron_key (Chyron *, uint)
 Check if function key label is set.
bool is_symlink_to_dir (const char *)
 Checks if the given path is a symbolic link to a directory.
bool is_valid_date (uint yyyy, uint mm, uint dd)
 Check if a given date is valid, including leap years.
bool is_valid_regex (const char *)
 Checks if the given regular expression pattern is valid.
bool is_valid_time (uint hh, uint mm, uint ss)
 Check if a given time is valid.
char * iso8601_time (char *, uint, time_t *, bool)
 Formats a struct tm as an ISO 8601 string.
void left_justify (char *s)
 Left justify string by removing leading spaces.
bool locate_file_in_path (char *, char *)
 Locates a file in the system PATH.
void mbc_to_wc (wchar_t wc[2], const char mbc)
wchar_t * mbstr_to_wcstr (const char *mb_str)
bool mk_dir (char *dir)
 If directory doesn't exist, make it.
bool mk_raw_tioctl (struct termios *)
 mk_raw_tioctl() - set terminal to raw mode
String mk_string (size_t)
 Create a String struct with a dynamically allocated string.
Chyronnew_chyron ()
 Create and initialize Chyron structure.
bool normalize_file_spec (char *)
 replace backslashes with forward lashes
void numeric (char *d, char *s)
 Extract numeric characters from source string to destination string.
void open_cmenu_log ()
 Open new C-Menu log file.
bool open_curses (SIO *)
int open_log (char *)
bool parse_local_timestamp (const char *, time_t *)
 Parses an ISO 8601 timestamp string in local time and converts it to time_t.
int Perror (char *)
 Display a simple error message window or print to stderr.
char * rep_substring (const char *, const char *, const char *)
 Replace all occurrences of "tgt_s" in "org_s" with "rep_s".
bool restore_curses_tioctl ()
 restore_curses_tioctl() - restore curses terminal settings
bool restore_shell_tioctl ()
 restore_shell_tioctl() - restore shell terminal settings
void restore_wins ()
uint rgb_clr_to_cube (uint)
uint rgb_to_curses_clr (RGB *)
uint rgb_to_xterm256_idx (RGB *)
 Convert RGB color to XTerm 256 color index.
void right_justify (char *, uint)
 Right justify string by removing trailing spaces and adding leadingspaces.
size_t rtrim (char *)
 Trims trailing spaces from string s in place.
int segmentation_fault ()
 Function to intentionally cause a segmentation fault for testing purposes.
void set_chyron_key (Chyron *, uint, char *, uint)
 Set chyron key with default color pair (cp_nt_rev).
void set_chyron_key_cb (Chyron *, uint, char *, uint, UiCell)
 Set chyron key with color pair (cp).
bool set_sane_tioctl (struct termios *)
 set_sane_tioctl() - set terminal to sane settings for C-MENU
int shell (char *)
 Execute a shell command.
void sig_dfl_mode ()
 Set signal handlers to default behavior.
void sig_prog_mode ()
 Set up signal handlers for interrupt signals.
void sig_shell_mode ()
void signal_handler (int)
 Signal handler for interrupt signals.
size_t ssnprintf (char *, size_t, const char *,...)
 ssnprintf was designed to be a safer alternative to snprintf.
char * stdio_fdnames (char *, char *)
char * stdio_names (char *, char *)
bool str_subc (char *, char *, char, char *, uint)
 Replaces "ReplaceChr" in "s" with "Withstr" in "d" won't copy more than "l" bytes to "d" Replaces all occurrences of a character in a string with another string, copying the result to a destination buffer.
int str_to_args (char **, char *, uint)
 Converts a string into an array of argument strings.
bool str_to_bool (const char *)
 Converts String to boolean true or false.
double str_to_double (char *)
 converts string to double
bool str_to_lower (char *)
 Converts a string to lowercase.
bool str_to_upper (char *)
 Converts a string to uppercase.
size_t string_cat (String *, const String *)
 Concatenates src String to dest String, allocating additional memory for dest String if necessary.
size_t string_cpy (String *, const String *)
 Copy src String to dest String, allocating additional memory for dest String if necessary.
size_t string_ncat (String *, const String *, size_t)
 Concatenates up to n characters from src String to dest String, allocating additional memory for dest String if necessary.
size_t string_ncpy (String *, const String *, size_t)
 copies up to n characters from src String to dest String, allocating additional memory for dest String if necessary
size_t strip_ansi (char *, char *)
 Strips ANSI SGR escape sequences (ending in 'm') from string s to d.
bool strip_quotes (char *)
 removes leading and trailing double quotes if present
bool stripz_quotes (char *)
 removes leading and trailing double quotes if present
bool strnfill (char *, char, uint)
size_t strnlf (char *, size_t)
 terminates string with line feed
size_t strnz (char *, size_t)
 terminates string at New Line, Carriage Return, or max_len
size_t strnz__cat (char *, const char *, size_t)
 safer alternative to strncat
size_t strnz__cpy (char *, const char *, size_t)
 safer alternative to strncpy
char * strnz_dup (char *, size_t)
 Allocates memory for and duplicates string s up to length l or until line feed or carriage return.
int surface_box_win_new (uint, uint, uint, uint, char *)
int surface_split_box_win_new (uint, uint, uint, uint, uint, uint, char *)
String to_string (const char *)
 String functions provide a simple string library to facilitate string manipulation in C, allowing developers to easily create, copy, concatenate, and free strings without having to manage memory manually.
size_t trim (char *)
 Trims leading and trailing spaces from string s in place.
bool trim_ext (char *, char *)
 trims the file extension from "filename" and copies the result to "buf"
bool trim_path (char *)
 Trims trailing spaces and slashes from directory path in place.
void unset_chyron_key (Chyron *, uint)
 Unset chyron key.
bool unstr_hex_clr (char *, char *)
 Validates that a string is a hex color code in the format "#RRGGBB".
void user_end ()
bool verify_dir (char *, uint)
 Verifies that the directory specified by "spec" exists and is accessible with the permissions specified by "imode".
bool verify_dir_q (char *, uint)
bool verify_file (char *, uint)
 Verifies that the file specified by "in_spec" exists and is accessible with the permissions specified by "imode".
bool verify_file_q (char *, uint)
bool verify_spec_arg (char *, char *, char *, char *, uint)
 Verify file specification argument.
bool wait_destroy (Chyron *)
Chyronwait_mk_chyron ()
bool waitpid_with_timeout (pid_t, uint)
int wccp_to_str (wchar_t, uint8_t *)
int win2_box_new (uint, uint, uint, uint, char *)
void win_del ()
void win_init_attrs ()
void win_resize (uint, uint, char *)
void win_Toggle_Attrs ()
void write_cmenu_log (char *)
 Write message to C-Menu log file without timestamp.
void write_cmenu_log_ts (char *)
 Write message to C-Menu log file with timestamp.
void write_log (char *)
RGB xterm256_idx_to_rgb (uint)
 Convert XTerm 256 color index to RGB.

Variables

UiCell cell_bl
UiCell cell_box
UiCell cell_br
UiCell cell_brktl
UiCell cell_brktr
UiCell cell_bs
UiCell cell_bt
UiCell cell_chk
UiCell cell_cmdln
UiCell cell_cr
UiCell cell_default
UiCell cell_fill_char
UiCell cell_ho
UiCell cell_ind
UiCell cell_ln
UiCell cell_ls
UiCell cell_lt
UiCell cell_nt
UiCell cell_nt_hl
UiCell cell_nt_hl_rev
UiCell cell_nt_rev
UiCell cell_ran
UiCell cell_rs
UiCell cell_rt
UiCell cell_sp
UiCell cell_title
UiCell cell_tl
UiCell cell_tr
UiCell cell_ts
UiCell cell_tt
UiCell cell_ve
int click_x
int click_y
uint clr_cnt
uint clr_idx
uint clr_pair_cnt
uint clr_pair_idx
int cmenu_log_fd
FILE * cmenu_log_fp
char const colors_text [][10]
 Color names for .minitrc overrides.
ushort cp_blue
ushort cp_bold
ushort cp_box
ushort cp_brackets
ushort cp_cmdln_bg
ushort cp_cmdln_fg
ushort cp_default
ushort cp_fill_char
ushort cp_green
ushort cp_highlight
ushort cp_ind
ushort cp_ln_bg
ushort cp_ln_fg
ushort cp_nt
ushort cp_nt_hl
ushort cp_nt_hl_rev
ushort cp_nt_rev
ushort cp_red
ushort cp_title
ushort cp_yellow
struct termios shell_err_tioctl curses_err_tioctl
struct termios shell_in_tioctl curses_in_tioctl
struct termios shell_out_tioctl curses_out_tioctl
struct termios shell_tioctl curses_tioctl
uint dbgfd
char em0 [MAXLEN]
char em1 [MAXLEN]
char em2 [MAXLEN]
char em3 [MAXLEN]
char errmsg []
int exit_code
bool f_curses_open = false
bool f_debug
bool f_have_curses_tioctl = false
bool f_have_shell_tioctl = false
bool f_restore_screen
char fn [MAXLEN]
uint mbegx
uint mbegy
uint mcols
uint mg_action
uint mg_col
uint mg_line
uint mlines
uint n_cols
uint n_lines
volatile sig_atomic_t sig_received = 0
uint src_line
char * src_name
int stderr_fd
int stdin_fd
char stdio_names_str [4096]
int stdout_fd
FILE * tty_fp
int wait_timeout
uint16_t win_attr

Detailed Description

Headder for C-Menu API library, libcm.so.

Author
Bill Waller Copyright (c) 2025 MIT License billx.nosp@m.wall.nosp@m.er@gm.nosp@m.ail..nosp@m.com
Date
2026-02-09

Definition in file cm.h.

Macro Definition Documentation

◆ __atexit

#define __atexit
Value:
{ \
int rc; \
rc = atexit(end_pgm); \
if (rc != 0) { \
fprintf(stderr, "\nCannot set exit function\n"); \
exit(EXIT_FAILURE); \
} \
}

This macro registers the end_pgm function to be called when the program exits.

It checks the return value of atexit() to ensure that the registration was successful, and if not, it prints an error message and exits with a failure status. Programs using libcm should call __atexit in their main function to ensure that the end_pgm function is registered to be called on program exit. This will help ensure that the terminal is properly restored to its original state, even if the program encounters an error or is terminated unexpectedly.

Definition at line 339 of file cm.h.

339#define __atexit \
340 { \
341 int rc; \
342 rc = atexit(end_pgm); \
343 if (rc != 0) { \
344 fprintf(stderr, "\nCannot set exit function\n"); \
345 exit(EXIT_FAILURE); \
346 } \
347 }

◆ _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 12 of file cm.h.

◆ _XOPEN_SOURCE_EXTENDED

#define _XOPEN_SOURCE_EXTENDED   1

Enable wide character support

Definition at line 13 of file cm.h.

◆ ABS

#define ABS ( x)
Value:
({ \
__typeof__(x) _a = (x); \
_a < 0 ? -_a : _a; \
})

ABS macro for absolute value, which evaluates the expression once and returns the absolute value.

This macro uses a compound statement to create a local scope for the temporary variable _a, which stores the value of x. This ensures that if x has side effects (such as being incremented), it will only be evaluated once when the macro is expanded. The use of typeof allows the macro to work with any data type that supports comparison with zero and negation.

Definition at line 139 of file cm.h.

139#define ABS(x) \
140 ({ \
141 __typeof__(x) _a = (x); \
142 _a < 0 ? -_a : _a; \
143 })

◆ BG_COLOR

#define BG_COLOR   0

default background color

Definition at line 417 of file cm.h.

◆ BO_COLOR

#define BO_COLOR   1

default bold foreground color

Definition at line 418 of file cm.h.

◆ CHYRON_KEY_MAXLEN

#define CHYRON_KEY_MAXLEN   64

maximum length of the command text for a key \ binding in the chyron

Definition at line 372 of file cm.h.

372#define CHYRON_KEY_MAXLEN \
373 64

◆ CHYRON_KEYS

#define CHYRON_KEYS   20

maximum number of key bindings for the chyron

Definition at line 375 of file cm.h.

◆ COLOR_LEN

#define COLOR_LEN   8
              Include     Exclude
             ----------  ----------

LF_FIFO 1 0 00000001 7 11111110 named pipe LF_CHR 2 1 00000010 6 11111101 character device LF_DIR 4 2 00000100 5 11111011 directory LF_BLK 8 3 00001000 4 11110111 block device LF_REG 16 4 00010000 3 11101111 regular file LF_LNK 32 5 00100000 2 11011111 link LF_SOCK 64 6 01000000 1 10111111 socket LF_UNKNOWN 128 7 10000000 0 01111111 unknown length of color code strings

Definition at line 325 of file cm.h.

◆ Ctrl

#define Ctrl ( c)
Value:

Definition at line 54 of file cm.h.

◆ DEFAULTSHELL

#define DEFAULTSHELL   "/bin/bash"

Definition at line 326 of file cm.h.

◆ DIV_ROUND_UP

#define DIV_ROUND_UP ( n,
d )
Value:

Definition at line 69 of file cm.h.

◆ F_NO_STDERR

#define F_NO_STDERR   1

Definition at line 310 of file cm.h.

◆ FG_COLOR

#define FG_COLOR   2

default foreground color

Definition at line 416 of file cm.h.

◆ KEY_ALTDEL

#define KEY_ALTDEL   0x20e

Definition at line 559 of file cm.h.

◆ KEY_ALTDOWN

#define KEY_ALTDOWN   0x214

Definition at line 564 of file cm.h.

◆ KEY_ALTEND

#define KEY_ALTEND   0x219

Definition at line 560 of file cm.h.

◆ KEY_ALTF

#define KEY_ALTF ( n)
Value:

define alt function keys

Definition at line 503 of file cm.h.

◆ KEY_ALTF0

#define KEY_ALTF0   0x138

Definition at line 502 of file cm.h.

◆ KEY_ALTHOME

#define KEY_ALTHOME   0x21e

Definition at line 557 of file cm.h.

◆ KEY_ALTINS

#define KEY_ALTINS   0x223

EXTENDED NCURSES KEYS

Key code bindings are customarily defined in terminfo. xterm-256color tends to be the most complete, and indeed, it seems to work with Ghostty, Kitty, and Alacritty. If you want to use the altkey bindings, you may need to set your terminal's TERM environment variable to xterm-256color. Here's why:

Ghostty, Kitty, and Alacritty all come with their own terminfo files:

Ghostty with xterm-ghostty, Kitty with xterm-kitty, and Alacritty with alacritty

None of the three produced the correct extended altkey bindings when paired with the terminfo provided in their distribution, yet all three worked with xterm-256color.

The extended altkeys were not defined in any of the terminfo files, not even xterm-256color. Yet, xterm-256color produced consistent keycode bindings with all three emulators. The standard key bindings, ins, delete, up, down arrows, etc., were the same for all three terminfos, and all three emulators produced the correct key bindings for those keys.

The fact that xterm-256color produced consistent keycode bindings for the altkeys, while the other three terminfos did not, is likely due to the fact that xterm-256color is more widely used and has better support for extended key bindings, even if they are not explicitly defined in the terminfo file. It's possible that xterm-256color has some default behavior or fallback mechanism that allows it to recognize and produce key codes for the altkeys, while the other terminfos do not have such a mechanism in place. This could explain why xterm-256color produced consistent keycode bindings for the altkeys across all three emulators, while the other terminfos did not.

Definition at line 556 of file cm.h.

◆ KEY_ALTLEFT

#define KEY_ALTLEFT   0x228

Definition at line 563 of file cm.h.

◆ KEY_ALTPGDN

#define KEY_ALTPGDN   0x22d

Definition at line 561 of file cm.h.

◆ KEY_ALTPGUP

#define KEY_ALTPGUP   0x232

Definition at line 558 of file cm.h.

◆ KEY_ALTRIGHT

#define KEY_ALTRIGHT   0x237

Definition at line 565 of file cm.h.

◆ KEY_ALTUP

#define KEY_ALTUP   0x23d

Definition at line 562 of file cm.h.

◆ LN_BG_COLOR

#define LN_BG_COLOR   7

default line number background

Definition at line 420 of file cm.h.

◆ LN_COLOR

#define LN_COLOR   4

default line number color

Definition at line 419 of file cm.h.

◆ MAX

#define MAX ( a,
b )
Value:

MIN macro for compatibility with code that uses the same name, while avoiding multiple evaluations of the arguments.

/usr/include/sys/param.h contains implementations of the MIN and MAX macros, which are simple but can lead to issues with multiple evaluations of the arguments if they have side effects. These macros provides a safer alternative to param.h Here are the macros from /usr/include/sys/param.h. You may comment out the macros defined herein and use the macros in param.h if you prefer.

Note
The following macro provides a safer alternative to param.h

Definition at line 114 of file cm.h.

◆ max

#define max ( a,
b )
Value:

max macro evaluates two expressions, returning greatest result.

These macros use compound statements to create local scopes for the temporary variables _x and _y, which store the values of x and y, respectively. This ensures that if x or y have side effects (such as being incremented), they will only be evaluated once when the macro is expanded. The use of typeof allows the macro to work with any data type. The line (void)(&_x == &_y) is a compile-time check to ensure that the types of the arguments are compatible. This implementation of the min and max macros provides a safer and more robust way to determine the minimum and maximum values between two expressions without risking unintended consequences from multiple evaluations.

Definition at line 84 of file cm.h.

◆ MAX_ARGS

#define MAX_ARGS   64

maximum number of arguments for external commands

Definition at line 48 of file cm.h.

◆ MAX_DEPTH

#define MAX_DEPTH   3

default depth for recursive file searching

Definition at line 52 of file cm.h.

◆ MAXARGS

#define MAXARGS   64

maximum number of arguments

Definition at line 50 of file cm.h.

◆ MAXLEN

#define MAXLEN   256

maximum length for strings and buffers

Definition at line 49 of file cm.h.

◆ MAXWIN [1/2]

#define MAXWIN   30

maximum number of windows that can be created

Definition at line 42 of file cm.h.

◆ MAXWIN [2/2]

#define MAXWIN   30

maximum number of windows that can be created

Definition at line 42 of file cm.h.

◆ MIN

#define MIN ( x,
y )
Value:

MAX macro for compatibility with code that uses the same name, while avoiding multiple evaluations of the arguments.

Note
The following macro provides a safer alternative to param.h

Definition at line 124 of file cm.h.

◆ min

#define min ( x,
y )
Value:

min macro evaluates two expressions, returning least result

Definition at line 91 of file cm.h.

◆ NCURSES_WIDECHAR

#define NCURSES_WIDECHAR   1

Enable wide character support

Definition at line 14 of file cm.h.

◆ nullptr

#define nullptr   NULL

Definition at line 39 of file cm.h.

◆ S_QUIET

#define S_QUIET   0x2000

quiet mode flag for file validation

Definition at line 328 of file cm.h.

◆ S_TOLOWER

#define S_TOLOWER ( c)
Value:

Definition at line 144 of file cm.h.

◆ S_TOUPPER

#define S_TOUPPER ( c)
Value:

Definition at line 149 of file cm.h.

◆ S_WCOK

#define S_WCOK   0x1000

write or create permitted

Definition at line 327 of file cm.h.

◆ SCR_COLS

#define SCR_COLS   1024

maximum number of columns in the terminal screen

Definition at line 51 of file cm.h.

◆ SCREEN_MAX_LINES

#define SCREEN_MAX_LINES   100

Definition at line 53 of file cm.h.

◆ to_lowercase

#define to_lowercase ( c)
Value:

to_lowercase(c) - convert an uppercase letter to lowercase

Definition at line 160 of file cm.h.

◆ to_uppercase [1/2]

#define to_uppercase ( c)
Value:

to_uppercase(c) - convert a lowercase letter to uppercase

simple macro to convert a character to uppercase

Definition at line 156 of file cm.h.

◆ to_uppercase [2/2]

#define to_uppercase ( c)
Value:

to_uppercase(c) - convert a lowercase letter to uppercase

simple macro to convert a character to uppercase

Definition at line 156 of file cm.h.

◆ XTERM_256COLOR

#define XTERM_256COLOR

use xterm-256color terminfo for altkey bindings

Definition at line 504 of file cm.h.

Typedef Documentation

◆ uchar

typedef unsigned char uchar

Definition at line 594 of file cm.h.

Enumeration Type Documentation

◆ ColorsEnum

enum ColorsEnum

Used for xterm256 color conversions.

Enumerator
CLR_BLACK 
CLR_RED 
CLR_GREEN 
CLR_YELLOW 
CLR_BLUE 
CLR_MAGENTA 
CLR_CYAN 
CLR_WHITE 
CLR_BBLACK 
CLR_BRED 
CLR_BGREEN 
CLR_BYELLOW 
CLR_BBLUE 
CLR_BMAGENTA 
CLR_BCYAN 
CLR_BWHITE 
CLR_BORANGE 
CLR_FG 
CLR_BG 
CLR_BOX_FG 
CLR_BOX_BG 
CLR_IND_FG 
CLR_IND_BG 
CLR_BRACKETS_FG 
CLR_BRACKETS_BG 
CLR_FILL_CHAR_FG 
CLR_FILL_CHAR_BG 
CLR_LN_FG 
CLR_LN_BG 
CLR_CMDLN_FG 
CLR_CMDLN_BG 
CLR_NT_FG 
CLR_NT_BG 
CLR_NT_REV_FG 
CLR_NT_REV_BG 
CLR_NT_HL_FG 
CLR_NT_HL_BG 
CLR_NT_HL_REV_FG 
CLR_NT_HL_REV_BG 
CLR_TITLE_FG 
CLR_TITLE_BG 
CLR_NCOLORS 

Definition at line 166 of file cm.h.

◆ F_Type

enum F_Type
Enumerator
F_F0 
F_FIFO 
F_CHR 
F_F1 
F_DIR 
F_F2 
F_BLK 
F_F3 
F_REG 
F_F4 
F_LNK 
F_F5 
F_SOCK 
F_F6 
F_UNKNOWN 

Definition at line 272 of file cm.h.

◆ LFFlags

enum LFFlags
Enumerator
LF_HIDE 

byte 0 - bits 0-7 Selection Flags 1 Don't list hidden files

LF_ICASE 

2 Ignore case in search

LF_EXC_REGEX 

4 Exclude files matching regex

LF_REGEX 

8 Include files matching regex

LF_EXEC 

16 Execute command each file

LF_USER 

32 Select User Name

LF_IXUSR 

<< 16 byte 1 - bits 8-15 1 Select Files with Execute Permission

LF_IWUSR 

2 Select Files with Write Permission

LF_IRUSR 

4 Select Files with Read Permission

LF_ISGID 

16 Select Setgid Files

LF_ISUID 

32 Select Setuid Files

Definition at line 243 of file cm.h.

245 LF_HIDE = 0b00000001,
246 LF_ICASE = 0b00000010,
247 LF_EXC_REGEX = 0b00000100,
248 LF_REGEX = 0b00001000,
249 LF_EXEC = 0b00010000,
250 LF_USER = 0b00100000,
253 LF_IXUSR = 0b00000001,
254 LF_IWUSR = 0b00000010,
255 LF_IRUSR = 0b00000100,
256 LF_ISGID = 0b00010000,
257 LF_ISUID = 0b00100000,
258} LFFlags;
LFFlags
Definition cm.h:243
@ LF_EXC_REGEX
Definition cm.h:247
@ LF_HIDE
Definition cm.h:245
@ LF_ISUID
Definition cm.h:257
@ LF_IRUSR
Definition cm.h:255
@ LF_ICASE
Definition cm.h:246
@ LF_ISGID
Definition cm.h:256
@ LF_EXEC
Definition cm.h:249
@ LF_REGEX
Definition cm.h:248
@ LF_USER
Definition cm.h:250
@ LF_IXUSR
Definition cm.h:253
@ LF_IWUSR
Definition cm.h:254

◆ LFTypes

enum LFTypes

byte 2 - bits 16-23 File types

Enumerator
LF_FIFO 

1 named pipe

LF_CHR 

2 character device

LF_DIR 

4 directory

LF_BLK 

8 block

LF_REG 

16 regular file

LF_LNK 

32 link

LF_SOCK 

64 socket

LF_UNKNOWN 

128 unknown

Definition at line 261 of file cm.h.

261 {
262 LF_FIFO = 0b00000001,
263 LF_CHR = 0b00000010,
264 LF_DIR = 0b00000100,
265 LF_BLK = 0b00001000,
266 LF_REG = 0b00010000,
267 LF_LNK = 0b00100000,
268 LF_SOCK = 0b01000000,
269 LF_UNKNOWN = 0b10000000
270} LFTypes;
LFTypes
Definition cm.h:261
@ LF_FIFO
Definition cm.h:262
@ LF_UNKNOWN
Definition cm.h:269
@ LF_SOCK
Definition cm.h:268
@ LF_BLK
Definition cm.h:265
@ LF_CHR
Definition cm.h:263
#define LF_DIR
Definition futil.c:44
#define LF_REG
Definition futil.c:45
#define LF_LNK
Definition futil.c:43

Function Documentation

◆ apply_gamma()

void apply_gamma ( RGB * rgb)
extern

Apply gamma correction to RGB color.

apply_gamma

Parameters
rgbPointer to RGB color

This function modifies the RGB color in place. It applies gamma correction to the RGB color based on the gamma values set in the SIO struct. If the color is a shade of gray, it applies the gray gamma correction. Otherwise, it applies the individual red, green, and blue gamma corrections.

Definition at line 307 of file dwin.c.

307 {
308 if (rgb->r == rgb->g && rgb->r == rgb->b) {
309 if (GRAY_GAMMA > 0.0f && GRAY_GAMMA != 1.0f) {
310 rgb->r = (int)(pow((rgb->r / 255.0f), 1.0f / GRAY_GAMMA) * 255.0f);
311 rgb->g = rgb->r;
312 rgb->b = rgb->r;
313 }
314 return;
315 }
316 if (rgb->r != 0 && RED_GAMMA > 0.0f && RED_GAMMA != 1.0f)
317 rgb->r = (int)(pow((rgb->r / 255.0f), 1.0f / RED_GAMMA) * 255.0f);
318 if (rgb->g != 0 && GREEN_GAMMA > 0.0f && GREEN_GAMMA != 1.0f)
319 rgb->g = (int)(pow((rgb->g / 255.0f), 1.0f / GREEN_GAMMA) * 255.0f);
320 if (rgb->b != 0 && BLUE_GAMMA > 0.0f && BLUE_GAMMA != 1.0f)
321 rgb->b = (int)(pow((rgb->b / 255.0f), 1.0f / BLUE_GAMMA) * 255.0f);
322}
double BLUE_GAMMA
Definition dwin.c:125
double GRAY_GAMMA
Definition dwin.c:122
double RED_GAMMA
Definition dwin.c:123
double GREEN_GAMMA
Definition dwin.c:124

References BLUE_GAMMA, GRAY_GAMMA, GREEN_GAMMA, and RED_GAMMA.

Referenced by ui_add_color_rgb(), ui_chg_color(), and ui_init_color_hex().

Here is the caller graph for this function:

◆ assign_chyron_win()

int assign_chyron_win ( Chyron * chyron,
UiSurface * s,
uint w,
char *  )
extern

Definition at line 962 of file dwin.c.

962 {
963 bool a_toi_error = false;
964 if (!sfc)
965 return -1;
966 chyron->sfc = sfc;
967 chyron->win = win;
968 if (*y == '-')
969 chyron->y = ui_getmaxy(sfc, win) - 1;
970 else {
971 chyron->y = a_toi(y, &a_toi_error);
972 if (a_toi_error)
973 return -1;
974 chyron->y = min(chyron->y, ui_getmaxy(sfc, win) - 1);
975 }
976 return 0;
977}
#define min(x, y)
min macro evaluates two expressions, returning least result
Definition cm.h:91
int ui_getmaxy(UiSurface *s, uint w)
Definition ui_ncurses.c:681
int a_toi(char *, bool *)
a safer alternative to atoi() for converting ASCII strings to integers.
Definition futil.c:762
uint y
Definition cm.h:394
UiSurface * sfc
Definition cm.h:392
uint win
Definition cm.h:393

References a_toi(), Chyron::sfc, ui_getmaxy(), Chyron::win, and Chyron::y.

Referenced by open_pick_win().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bare_box_new()

int bare_box_new ( uint ,
uint ,
uint ,
uint ,
char *  )
extern

◆ border_draw()

int border_draw ( UiSurface * sfc)
extern

Definition at line 581 of file dwin.c.

581 {
582 uint maxy = ui_getmaxy(sfc, BOX);
583 uint maxx = ui_getmaxx(sfc, BOX);
584 uint y = 0;
585 uint x = 0;
586 ui_mvwadd_wchnstr(sfc, BOX, y, x++, &cell_tl, 1);
587 ui_render();
588 for (x = 1; x < maxx - 1; x++)
589 ui_mvwadd_wchnstr(sfc, BOX, y, x, &cell_ho, 1);
590 ui_render();
591 ui_mvwadd_wchnstr(sfc, BOX, y, maxx - 1, &cell_tr, 1);
592 ui_render();
593 for (y = 1; y < maxy - 1; y++) {
594 ui_mvwadd_wchnstr(sfc, BOX, y, 0, &cell_ve, 1);
595 ui_render();
596 ui_mvwadd_wchnstr(sfc, BOX, y, maxx - 1, &cell_ve, 1);
597 ui_render();
598 }
599 ui_mvwadd_wchnstr(sfc, BOX, y, 0, &cell_bl, 1);
600 for (x = 1; x < maxx - 1; x++)
601 ui_mvwadd_wchnstr(sfc, BOX, y, x, &cell_ho, 1);
602 ui_mvwadd_wchnstr(sfc, BOX, y, maxx - 1, &cell_br, 1);
603 ui_render();
604 return 0;
605}
int ui_getmaxx(UiSurface *s, uint w)
Definition ui_ncurses.c:686
void ui_render()
Definition ui_ncurses.c:800
int ui_mvwadd_wchnstr(UiSurface *s, uint w, uint y, uint x, const UiCell *cell, uint m)
UiCell cell_ve
Definition dwin.c:112
UiCell cell_tr
Definition dwin.c:110
UiCell cell_br
Definition dwin.c:114
UiCell cell_tl
Definition dwin.c:109
UiCell cell_ho
Definition dwin.c:111
UiCell cell_bl
Definition dwin.c:113

References BOX, cell_bl, cell_br, cell_ho, cell_tl, cell_tr, cell_ve, ui_getmaxx(), ui_getmaxy(), ui_mvwadd_wchnstr(), and ui_render().

Referenced by ui_box_surface_new(), and ui_box_surface_new().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cf_accept()

int cf_accept ( UiSurface * sfc,
uint w,
char * accept_s,
uint flin,
uint fcol,
uint flen )
extern

Accepts input for a field in a C-Menu window.

Parameters
UiSurface*sfc The surface to accept input from
winThe window to accept input from
accept_sThe string to accept input into
flinThe line number of the field
fcolThe column number of the field
flenThe length of the field
Returns
The key pressed to exit the field (KEY_ENTER, KEY_F09, etc.)

< Enter accepts the field and moves to the next field if f_erase_remainder is set, it will clear the remaining characters above and after the current cursor location

KEY_IC toggles insert mode

KEY_DC deletes character at cursor

KEY_HOME moves cursor to start of field

KEY_BACKSPACE deletes character before cursor

KEY_LEFT moves cursor left one character

KEY_RIGHT moves cursor right one character

Handles mouse events for field editing

Definition at line 41 of file cm_fields.c.

41 {
42 bool f_insert = false;
43 int in_key = 0;
44 char *s, *d;
45 char *fstart;
46 UiEvent event;
47
48 click_x = click_y = -1;
49 char *p = fstart = accept_s;
50 char *fend = fstart + flen;
51 int x = fcol;
52 char *str_end = p + strlen(p);
53 while (1) {
54 if (in_key == 0) {
55 ui_mvwaddstr(sfc, w, flin, fcol, accept_s);
56 ui_wclrtoeol(sfc, w);
57 ui_cursor_move(sfc, w, flin, x);
58 ui_render();
59 in_key = ui_get_event(sfc, WIN, &event, -1);
60 }
61 ui_curs_set(0);
62 switch (in_key) {
63 case KEY_F09:
64 in_key = KEY_F09;
65 return (in_key);
66 case '\t':
67 case KEY_END:
68 case Ctrl('e'):
69 while (*p != '\0')
70 p++;
71 x = fcol + (p - fstart);
72 in_key = 0;
73 continue;
77 case '\n':
78 case KEY_ENTER:
80 *p = '\0';
81 in_key = KEY_ENTER;
82 return (in_key);
84 case KEY_IC:
85 f_insert = !f_insert;
86 in_key = 0;
87 continue;
89 case KEY_DC:
90 s = p + 1;
91 d = p;
92 while (*s != '\0')
93 *d++ = *s++;
94 *d = '\0';
95 str_end = d;
96 f_insert = false;
97 in_key = 0;
98 continue;
100 case KEY_HOME:
101 case Ctrl('a'):
102 p = fstart;
103 x = fcol;
104 in_key = 0;
105 continue;
107 case KEY_BACKSPACE:
108 if (p > fstart) {
109 p--;
110 x--;
111 }
112 s = p + 1;
113 d = p;
114 while (*s != '\0')
115 *d++ = *s++;
116 *d = '\0';
117 str_end = d;
118 in_key = 0;
119 continue;
121 case KEY_LEFT:
122 if (p > fstart) {
123 p--;
124 x--;
125 }
126 in_key = 0;
127 continue;
129 case KEY_RIGHT:
130 if (p < fend && p < str_end) {
131 p++;
132 x++;
133 }
134 in_key = 0;
135 continue;
137 case KEY_MOUSE:
138 x = click_x;
139 flin = click_y;
140 fstart = accept_s;
141 fend = fstart + flen;
142 str_end = fstart + strlen(fstart);
143 p = fstart + (x - fcol);
144 if (p > str_end)
145 x -= p - str_end;
146 p = min(p, str_end);
147 in_key = 0;
148 continue;
149 default:
150 if (p >= fend) {
151 in_key = 0;
152 continue;
153 }
154 if (in_key < ' ' || in_key > '~') {
155 in_key = 0;
156 continue;
157 }
158 if (f_insert) {
159 if (str_end < fend) {
160 s = str_end - 1;
161 d = str_end;
162 while (s >= p)
163 *d-- = *s--;
164 *p++ = in_key;
165 str_end++;
166 x++;
167 }
168 } else {
169 if (p < fend) {
170 if (p < str_end) {
171 if (p == accept_s && in_key == ' ') {
172 d = accept_s;
173 s = accept_s + 1;
174 while (*s != '\0')
175 *d++ = *s++;
176 *d = '\0';
177 in_key = 0;
178 continue;
179 }
180 *p++ = in_key;
181 x++;
182 } else if (p == str_end) {
183 *p++ = in_key;
184 *p = '\0';
185 str_end = p;
186 x++;
187 }
188 }
189 }
190 in_key = 0;
191 continue;
192 }
193 }
194}
#define Ctrl(c)
Definition cm.h:54
int ui_cursor_move(UiSurface *s, uint w, uint y, uint x)
Definition ui_ncurses.c:727
int ui_mvwaddstr(UiSurface *s, uint w, uint y, uint x, const char *text)
int ui_get_event(UiSurface *s, uint w, UiEvent *ev, int timeout_ms)
Wait for an input event on target (or stdscr if NULL).
int ui_wclrtoeol(UiSurface *s, uint w)
int ui_curs_set(int visibility)
Definition ui_ncurses.c:737
#define KEY_F09
#define KEY_RIGHT
#define KEY_DC
#define KEY_BACKSPACE
#define KEY_END
#define KEY_ENTER
#define KEY_MOUSE
#define KEY_IC
#define KEY_LEFT
#define KEY_HOME
bool f_erase_remainder
Structure to hold field information for C-Menu.
Definition cm_fields.c:30
int click_x
Definition dwin.c:45
int click_y
Definition dwin.c:44

References click_x, click_y, f_erase_remainder, ui_curs_set(), ui_cursor_move(), ui_get_event(), ui_mvwaddstr(), ui_render(), ui_wclrtoeol(), and WIN.

Referenced by get_cmd_arg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_panels()

void check_panels ( uint )
extern

◆ codepoint_to_utf8()

size_t codepoint_to_utf8 ( uint32_t codepoint,
uint8_t * utf8 )
extern

◆ construct_file_spec()

bool construct_file_spec ( char * ,
char * ,
char * ,
char * ,
char * ,
uint  )
extern

◆ display_argv_error_msg()

void display_argv_error_msg ( char * ,
char **  )
extern

◆ display_curses_keys()

int display_curses_keys ( )
extern

◆ display_ok_message()

int display_ok_message ( char * )
extern

◆ dump_opts()

void dump_opts ( )
extern

dump options to stdout

◆ dump_opts_by_use()

void dump_opts_by_use ( char * ,
char *  )
extern

dump options to stdout

◆ enter_option()

uint enter_option ( )
extern

◆ fill_field()

char * fill_field ( char * accept_s,
char * display_s,
char fill_char,
uint flen )
extern

Definition at line 1731 of file futil.c.

1732 {
1733 char *s = accept_s;
1734 char *d = display_s;
1735 char *e = d + flen;
1736 while (*s != '\0' && d < e)
1737 *d++ = *s++;
1738 while (d < e)
1739 *d++ = fill_char;
1740 *d = '\0';
1741 return display_s;

◆ get_rfc3339_s()

void get_rfc3339_s ( char * ,
size_t  )
extern

◆ handle_signal()

bool handle_signal ( sig_atomic_t )
extern

Referenced by notcurses_input().

Here is the caller graph for this function:

◆ init_clr_palette()

bool init_clr_palette ( SIO * sio)
extern

Initialize color palette based on SIO settings.

init_clr_palette

Parameters
sioPointer to SIO struct with color settings
Returns
true if successful, false if error

This function initializes the xterm256 color cube and applies any color overrides specified in the SIO struct. The color strings in the SIO struct are expected to be six-digit HTML style hex color codes (e.g., "#RRGGBB"). If a color override is specified for any of the standard colors, it is applied using the ui_add_color_hex function.

Definition at line 333 of file dwin.c.

333 {
335 ui_chg_color(CLR_RED, &sio->red);
338 ui_chg_color(CLR_BLUE, &sio->blue);
340 ui_chg_color(CLR_CYAN, &sio->cyan);
343 ui_chg_color(CLR_BRED, &sio->bred);
351 ui_chg_color(CLR_FG, &sio->fg);
352 ui_chg_color(CLR_BG, &sio->bg);
373 return true;
374}
uint ui_color_cnt
Definition ui_ncurses.c:33
int ui_chg_color(uint16_t color_idx, uint32_t *color)
Definition ui_ncurses.c:206
uint32_t ln_bg
Definition cm.h:723
uint32_t magenta
Definition cm.h:698
uint32_t nt_hl_rev_fg
Definition cm.h:732
uint32_t bgreen
Definition cm.h:704
uint32_t green
Definition cm.h:695
uint32_t nt_fg
Definition cm.h:726
uint32_t yellow
Definition cm.h:696
uint32_t fill_char_fg
Definition cm.h:720
uint32_t box_fg
Definition cm.h:714
uint32_t ln_fg
Definition cm.h:722
uint32_t ind_bg
Definition cm.h:717
uint32_t bmagenta
Definition cm.h:707
uint32_t ind_fg
Definition cm.h:716
uint32_t byellow
Definition cm.h:705
uint32_t bblue
Definition cm.h:706
uint32_t borange
Definition cm.h:710
uint32_t title_bg
Definition cm.h:735
uint32_t fg
Definition cm.h:712
uint32_t cyan
Definition cm.h:699
uint32_t bblack
Definition cm.h:702
uint32_t red
Definition cm.h:694
uint32_t nt_hl_rev_bg
Definition cm.h:733
uint32_t bred
Definition cm.h:703
uint32_t fill_char_bg
Definition cm.h:721
uint32_t black
Definition cm.h:693
uint32_t nt_rev_bg
Definition cm.h:729
uint32_t brackets_bg
Definition cm.h:719
uint32_t bcyan
Definition cm.h:708
uint32_t nt_bg
Definition cm.h:727
uint32_t blue
Definition cm.h:697
uint32_t brackets_fg
Definition cm.h:718
uint32_t white
Definition cm.h:700
uint32_t box_bg
Definition cm.h:715
uint32_t nt_hl_fg
Definition cm.h:730
uint32_t bwhite
Definition cm.h:709
uint32_t nt_rev_fg
Definition cm.h:728
uint32_t nt_hl_bg
Definition cm.h:731
uint32_t bg
Definition cm.h:713

References SIO::bblack, SIO::bblue, SIO::bcyan, SIO::bg, SIO::bgreen, SIO::black, SIO::blue, SIO::bmagenta, SIO::borange, SIO::box_bg, SIO::box_fg, SIO::brackets_bg, SIO::brackets_fg, SIO::bred, SIO::bwhite, SIO::byellow, CLR_BBLACK, CLR_BBLUE, CLR_BCYAN, CLR_BG, CLR_BGREEN, CLR_BLACK, CLR_BLUE, CLR_BMAGENTA, CLR_BORANGE, CLR_BOX_BG, CLR_BOX_FG, CLR_BRACKETS_BG, CLR_BRACKETS_FG, CLR_BRED, CLR_BWHITE, CLR_BYELLOW, CLR_CYAN, CLR_FG, CLR_FILL_CHAR_BG, CLR_FILL_CHAR_FG, CLR_GREEN, CLR_IND_BG, CLR_IND_FG, CLR_LN_BG, CLR_LN_FG, CLR_MAGENTA, CLR_NCOLORS, CLR_NT_BG, CLR_NT_FG, CLR_NT_HL_BG, CLR_NT_HL_FG, CLR_NT_HL_REV_BG, CLR_NT_HL_REV_FG, CLR_NT_REV_BG, CLR_NT_REV_FG, CLR_RED, CLR_TITLE_BG, CLR_WHITE, CLR_YELLOW, SIO::cyan, SIO::fg, SIO::fill_char_bg, SIO::fill_char_fg, SIO::green, SIO::ind_bg, SIO::ind_fg, SIO::ln_bg, SIO::ln_fg, SIO::magenta, SIO::nt_bg, SIO::nt_fg, SIO::nt_hl_bg, SIO::nt_hl_fg, SIO::nt_hl_rev_bg, SIO::nt_hl_rev_fg, SIO::nt_rev_bg, SIO::nt_rev_fg, SIO::red, SIO::title_bg, ui_chg_color(), ui_color_cnt, SIO::white, and SIO::yellow.

Referenced by initialize_cells().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_stdscr()

void init_stdscr ( )
extern

◆ initialize_cells()

void initialize_cells ( SIO * sio)
extern

Initialize local color variables and color pairs based on SIO settings.

Parameters
sioPointer to SIO struct with color settings

This function initializes local color variables and color pairs based on the settings in the SIO struct. It applies gamma correction to colors and sets up cchar_t variables for use in NCurses functions. The color pair indices are stored in global variables for easy reference throughout the code when applying colors to various parts of the interface using NCurses functions that accept color pair indices.

gamma correction values

These are read from ~/.minitrc

used when initializing colors

Definition at line 177 of file dwin.c.

177 {
181 RED_GAMMA = sio->red_gamma;
183 BLUE_GAMMA = sio->blue_gamma;
184 GRAY_GAMMA = sio->gray_gamma;
185 init_clr_palette(sio);
186 //
187 // Standardized color pairs
188 //
189 // strcpy(sio->nt_bg, "#0000ff");
190 // strcpy(sio->box_bg, "#00ff00");
207 //
208 // Standardized UiCells
209 //
212
213 mbstate_t mbstate;
214 memset(&mbstate, 0, sizeof(mbstate));
215 wchar_t brktl = sio->brackets[0];
216 cell_brktl = ui_cell_from_ucp(&brktl, &sio->brackets_fg, &sio->brackets_bg);
217 wchar_t brktr = sio->brackets[1];
218 cell_brktr = ui_cell_from_ucp(&brktr, &sio->brackets_fg, &sio->brackets_bg);
219 cell_nt = ui_cell_from_ucp(bw_sp, &sio->nt_fg, &sio->nt_bg);
226 cell_ln = ui_cell_from_ucp(bw_sp, &sio->ln_fg, &sio->ln_bg);
230 cell_tl = ui_cell_from_ucp(&bw_tl, &sio->box_fg, &sio->box_bg);
231 cell_tr = ui_cell_from_ucp(&bw_tr, &sio->box_fg, &sio->box_bg);
232 cell_bl = ui_cell_from_ucp(&bw_bl, &sio->box_fg, &sio->box_bg);
233 cell_br = ui_cell_from_ucp(&bw_br, &sio->box_fg, &sio->box_bg);
234 cell_ho = ui_cell_from_ucp(&bw_ho, &sio->box_fg, &sio->box_bg);
235 cell_ve = ui_cell_from_ucp(&bw_ve, &sio->box_fg, &sio->box_bg);
236 cell_lt = ui_cell_from_ucp(&bw_lt, &sio->box_fg, &sio->box_bg);
237 cell_rt = ui_cell_from_ucp(&bw_rt, &sio->box_fg, &sio->box_bg);
238 cell_tt = ui_cell_from_ucp(&bw_tt, &sio->box_fg, &sio->box_bg);
239 cell_bt = ui_cell_from_ucp(&bw_bt, &sio->box_fg, &sio->box_bg);
240 cell_cr = ui_cell_from_ucp(&bw_cr, &sio->box_fg, &sio->box_bg);
241 cell_sp = ui_cell_from_ucp(bw_sp, &sio->box_fg, &sio->box_bg);
242}
#define bw_ho
Definition ui_backend.h:213
const wchar_t * bw_sp
Definition ui_ncurses.c:52
const wchar_t * bw_ran
Definition ui_ncurses.c:57
#define bw_tr
Definition ui_backend.h:221
const wchar_t * bw_chk
Definition ui_ncurses.c:59
#define bw_lt
Definition ui_backend.h:215
#define bw_br
Definition ui_backend.h:223
uint ui_add_pair(uint fg, uint bg)
Definition ui_ncurses.c:105
#define bw_bl
Definition ui_backend.h:222
UiCell ui_cell_from_ucp(const wchar_t *ucp, const uint32_t *fg, const uint32_t *bg)
Definition ui_ncurses.c:239
#define bw_tt
Definition ui_backend.h:217
#define bw_cr
Definition ui_backend.h:219
#define bw_bt
Definition ui_backend.h:218
#define bw_ve
Definition ui_backend.h:214
#define bw_rt
Definition ui_backend.h:216
#define bw_tl
Definition ui_backend.h:220
UiCell cell_sp
Definition dwin.c:120
ushort cp_nt
Definition dwin.c:151
UiCell cell_nt
Definition dwin.c:94
UiCell cell_nt_hl_rev
Definition dwin.c:97
UiCell cell_bt
Definition dwin.c:118
ushort cp_green
Definition dwin.c:160
ushort cp_red
Definition dwin.c:159
ushort cp_box
Definition dwin.c:147
ushort cp_blue
Definition dwin.c:162
UiCell cell_ln
Definition dwin.c:102
ushort cp_nt_hl
Definition dwin.c:153
ushort cp_cmdln
Definition dwin.c:149
ushort cp_fill_char
Definition dwin.c:157
UiCell cell_tt
Definition dwin.c:117
ushort cp_brackets
Definition dwin.c:158
ushort cp_yellow
Definition dwin.c:161
bool init_clr_palette(SIO *sio)
Initialize color palette based on SIO settings.
Definition dwin.c:333
UiCell cell_default
Definition dwin.c:90
ushort cp_nt_hl_rev
Definition dwin.c:154
ushort cp_default
Definition dwin.c:156
UiCell cell_nt_hl
Definition dwin.c:96
ushort cp_nt_rev
Definition dwin.c:152
ushort cp_ln
Definition dwin.c:155
ushort cp_title
Definition dwin.c:150
UiCell cell_lt
Definition dwin.c:115
UiCell cell_brktl
Definition dwin.c:92
UiCell cell_cr
Definition dwin.c:119
UiCell cell_title
Definition dwin.c:101
UiCell cell_ind
Definition dwin.c:99
UiCell cell_ran
Definition dwin.c:103
UiCell cell_cmdln
Definition dwin.c:100
UiCell cell_brktr
Definition dwin.c:93
ushort cp_ind
Definition dwin.c:148
UiCell cell_fill_char
Definition dwin.c:91
UiCell cell_box
Definition dwin.c:98
UiCell cell_rt
Definition dwin.c:116
UiCell cell_chk
Definition dwin.c:104
UiCell cell_nt_rev
Definition dwin.c:95
uint32_t ran_bg
Definition cm.h:737
double green_gamma
Definition cm.h:690
double blue_gamma
Definition cm.h:691
char brackets[3]
Definition cm.h:750
uint32_t cmdln_bg
Definition cm.h:725
uint32_t cmdln_fg
Definition cm.h:724
uint32_t ran_fg
Definition cm.h:736
double red_gamma
Definition cm.h:689
uint32_t title_fg
Definition cm.h:734
double gray_gamma
Definition cm.h:692

References BLUE_GAMMA, SIO::blue_gamma, SIO::box_bg, SIO::box_fg, SIO::brackets, SIO::brackets_bg, SIO::brackets_fg, bw_chk, bw_ran, bw_sp, cell_bl, cell_box, cell_br, cell_brktl, cell_brktr, cell_bt, cell_chk, cell_cmdln, cell_cr, cell_default, cell_fill_char, cell_ho, cell_ind, cell_ln, cell_lt, cell_nt, cell_nt_hl, cell_nt_hl_rev, cell_nt_rev, cell_ran, cell_rt, cell_sp, cell_title, cell_tl, cell_tr, cell_tt, cell_ve, CLR_BG, CLR_BLUE, CLR_BOX_BG, CLR_BOX_FG, CLR_BRACKETS_BG, CLR_BRACKETS_FG, CLR_CMDLN_BG, CLR_CMDLN_FG, CLR_FG, CLR_FILL_CHAR_BG, CLR_FILL_CHAR_FG, CLR_GREEN, CLR_IND_BG, CLR_IND_FG, CLR_LN_BG, CLR_LN_FG, CLR_NT_BG, CLR_NT_FG, CLR_NT_HL_BG, CLR_NT_HL_FG, CLR_NT_HL_REV_BG, CLR_NT_HL_REV_FG, CLR_NT_REV_BG, CLR_NT_REV_FG, CLR_RED, CLR_TITLE_BG, CLR_TITLE_FG, CLR_YELLOW, SIO::cmdln_bg, SIO::cmdln_fg, cp_blue, cp_box, cp_brackets, cp_cmdln, cp_default, cp_fill_char, cp_green, cp_ind, cp_ln, cp_nt, cp_nt_hl, cp_nt_hl_rev, cp_nt_rev, cp_red, cp_title, cp_yellow, SIO::fill_char_bg, SIO::fill_char_fg, GRAY_GAMMA, SIO::gray_gamma, GREEN_GAMMA, SIO::green_gamma, SIO::ind_bg, SIO::ind_fg, init_clr_palette(), SIO::ln_bg, SIO::ln_fg, SIO::nt_bg, SIO::nt_fg, SIO::nt_hl_bg, SIO::nt_hl_fg, SIO::nt_hl_rev_bg, SIO::nt_hl_rev_fg, SIO::nt_rev_bg, SIO::nt_rev_fg, SIO::ran_bg, SIO::ran_fg, RED_GAMMA, SIO::red_gamma, SIO::title_bg, SIO::title_fg, ui_add_pair(), and ui_cell_from_ucp().

Referenced by main(), and read_theme().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialize_styles()

void initialize_styles ( SIO * )
extern

◆ mbc_to_wc()

void mbc_to_wc ( wchar_t wc[2],
const char mbc )
extern

Definition at line 393 of file dwin.c.

393 {
394 wc[0] = wc[1] = L'\0';
395 mbstate_t state = {0};
396 size_t len = mbrtowc(wc, &mbc, MB_CUR_MAX, &state);
397 if (len <= 0) {
398 wc[0] = L'?';
399 wc[1] = L'\0';
400 len = 1;
401 }
402}

◆ mbstr_to_wcstr()

wchar_t * mbstr_to_wcstr ( const char * mb_str)
extern

Definition at line 404 of file dwin.c.

404 {
405 const char *src_ptr = mb_str;
406 mbstate_t state = {0};
407 size_t wc_count = mbsrtowcs(NULL, &src_ptr, 0, &state);
408 if (wc_count == (size_t)-1)
409 return nullptr;
410 src_ptr = mb_str;
411 wmemset((wchar_t *)&state, 0, sizeof(state) / sizeof(wchar_t));
412 wchar_t *wc_str = malloc((wc_count + 1) * sizeof(wchar_t));
413 if (!wc_str)
414 return nullptr;
415 mbsrtowcs(wc_str, &src_ptr, wc_count + 1, &state);
416 return wc_str;
417}

Referenced by border_title(), and border_ysplit_text().

Here is the caller graph for this function:

◆ mk_string()

String mk_string ( size_t l)
extern

Create a String struct with a dynamically allocated string.

Parameters
llength of string to create including null terminator
Returns
String struct

The returned String struct contains a dynamically allocated string of he specified length

Note
the caller is responsible for calling free_string to free the allocated memory.

Definition at line 1526 of file futil.c.

1527 {
1528 if (l == 0) {
1529 String str;
1530 str.l = 0;
1531 str.s = nullptr;
1532 return str;
1533 }
1534 String str;
1535 str.l = l + 1;
1536 str.s = (char *)malloc(str.l);
1537 str.s[0] = '\0';
1538 return str;
Definition cm.h:662
size_t l
Definition cm.h:664
char * s
Definition cm.h:663

References String::l, and String::s.

◆ open_curses()

bool open_curses ( SIO * )
extern

◆ open_log()

int open_log ( char * )
extern

◆ restore_wins()

void restore_wins ( )
extern

◆ rgb_clr_to_cube()

uint rgb_clr_to_cube ( uint )
extern

◆ rgb_to_curses_clr()

uint rgb_to_curses_clr ( RGB * )
extern

◆ rgb_to_xterm256_idx()

uint rgb_to_xterm256_idx ( RGB * rgb)
extern

Convert RGB color to XTerm 256 color index.

rgb_to_xterm256_idx

Parameters
rgbRGB color
Returns
XTerm 256 color index

This function converts an RGB color to the nearest XTerm 256 color index. It first checks if the color is a shade of gray, and if so, it uses the gray ramp. Otherwise, it calculates the nearest color in the 6x6x6 color cube.

Definition at line 252 of file dwin.c.

252 {
253 if (rgb->r == rgb->g && rgb->g == rgb->b) {
254 if (rgb->r < 8)
255 return 16;
256 if (rgb->r > 248)
257 return 231;
258 return ((rgb->r - 8) / 10) + 231;
259 } else {
260 uint r_index = (rgb->r < 45) ? 0 : (rgb->r - 60) / 40 + 1;
261 uint g_index = (rgb->g < 45) ? 0 : (rgb->g - 60) / 40 + 1;
262 uint b_index = (rgb->b < 45) ? 0 : (rgb->b - 60) / 40 + 1;
263 return 16 + (36 * r_index) + (6 * g_index) + b_index;
264 }
265}

◆ rtrim()

size_t rtrim ( char * s)
extern

Trims trailing spaces from string s in place.

Parameters
s- string to trim
Returns
length of trimmed string

Definition at line 331 of file futil.c.

331 {
332 if (s == nullptr || *s == '\0')
333 return (size_t)0;
334 char *p = s + strlen(s) - 1;
335 while (p >= s && *p == ' ')
336 p--;
337 *(p + 1) = '\0';
338 return (size_t)(p - s + 1);
339}

Referenced by fmt_line(), and picker().

Here is the caller graph for this function:

◆ sig_shell_mode()

void sig_shell_mode ( )
extern

◆ stdio_fdnames()

char * stdio_fdnames ( char * stdio_str,
char * id )
extern

Definition at line 1082 of file futil.c.

1083 {
1084 if (!stdio_str)
1085 return nullptr;
1086 char buf[MAXLEN] = {'\0'};
1087 char buf0[MAXLEN] = {'\0'};
1088 ssnprintf(buf, MAXLEN - 1, "%s: ", id);
1089 strnz__cpy(stdio_str, buf, MAXLEN - 1);
1090 for (int i = 0; i < 16; i++) {
1091 if (fdname(i, buf0) != nullptr) {
1092 ssnprintf(buf, 4095, " fd%d=%s", i, buf0);
1093 strnz__cat(stdio_str, buf, MAXLEN - 1);
1094 strnz__cat(stdio_str, ",", MAXLEN - 1);
1095 }
1096 }
1097 return stdio_str;
#define MAXLEN
Definition curskeys.c:15
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
Definition futil.c:537
size_t ssnprintf(char *, size_t, const char *,...)
ssnprintf was designed to be a safer alternative to snprintf.
Definition futil.c:413
size_t strnz__cat(char *, const char *, size_t)
safer alternative to strncat
Definition futil.c:566
char * fdname(int fd, char *out_path)
Retrieves the file path associated with a given file descriptor.
Definition futil.c:1047

References fdname(), ssnprintf(), strnz__cat(), and strnz__cpy().

Referenced by form_process(), init_pick(), and view_init_input().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stdio_names()

char * stdio_names ( char * stdio_str,
char * id )
extern

Definition at line 1057 of file futil.c.

1058 {
1059 if (!stdio_str)
1060 return nullptr;
1061 char buf[MAXLEN] = {'\0'};
1062 char err_str[MAXLEN] = {'\0'};
1063 errno = 0;
1064 ssnprintf(buf, MAXLEN - 1, "%s - ", id);
1065 strnz__cpy(stdio_str, buf, MAXLEN - 1);
1066 strnz__cat(stdio_str, ttyname(0), MAXLEN - 1);
1067 strnz__cat(stdio_str, ", ", MAXLEN - 1);
1068 if (errno)
1069 ssnprintf(err_str, MAXLEN - 1, "Error fd %d: %s\n", 0, strerror(errno));
1070
1071 strnz__cat(stdio_str, ttyname(1), MAXLEN - 1);
1072 strnz__cat(stdio_str, ", ", MAXLEN - 1);
1073 if (errno)
1074 ssnprintf(err_str, MAXLEN - 1, "Error fd %d: %s\n", 1, strerror(errno));
1075
1076 strnz__cat(stdio_str, ttyname(2), MAXLEN - 1);
1077 strnz__cat(stdio_str, ", ", MAXLEN - 1);
1078 if (errno)
1079 ssnprintf(err_str, MAXLEN - 1, "Error fd %d: %s\n", 2, strerror(errno));
1080
1081 return stdio_str;

References ssnprintf(), strnz__cat(), and strnz__cpy().

Referenced by fork_exec(), and menu_cmd_processor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ str_to_bool()

bool str_to_bool ( const char * s)
extern

Converts String to boolean true or false.

Parameters
s- string to convert
Returns
boolean true or false

Definition at line 934 of file futil.c.

935 {
936 if (s == nullptr || *s == '\0')
937 return false;
938 switch (s[0]) {
939 case 't':
940 case 'T':
941 case 'y':
942 case 'Y':
943 case '1':
944 return true;
945 case 'o':
946 case 'O':
947 switch (s[1]) {
948 case 'n':
949 case 'N':
950 return true;
951 default:
952 break;
953 }
954 default:
955 break;
956 }
957 return false;

Referenced by process_config_file().

Here is the caller graph for this function:

◆ strnfill()

bool strnfill ( char * ,
char ,
uint  )
extern

◆ surface_box_win_new()

int surface_box_win_new ( uint ,
uint ,
uint ,
uint ,
char *  )
extern

Definition at line 521 of file dwin.c.

521 {
522 if (sfc_ptr >= SFC_MAX) {
523 Perror("Maximum number of surfaces (%d) exceeded");
524 exit(EXIT_FAILURE);
525 }
526 uint maxy, maxx;
527 ui_get_screen_size(&maxy, &maxx);
528 wlines = min(wlines, maxy - 2);
529 wcols = min(wcols, maxx - 2);
530 sfc_ptr++;
531 // -------------------> UAL_win_box <-------------------
532 ui_surface[sfc_ptr] = ui_box_surface_new(nullptr, 0, wlines, wcols, wbegy, wbegx, wtitle);
534 ui_surface_addwin(sfc, WIN, BOX, wlines, wcols, 1, 1);
535 ui_render();
536 return 0;
537}
UiSurface * ui_surface[UI_SFC_MAX]
Definition ui_ncurses.c:28
void ui_get_screen_size(uint *lines, uint *cols)
Definition ui_ncurses.c:692
int sfc_ptr
Definition nckeys.c:47
UiSurface * ui_box_surface_new(UiSurface *parent, uint p, uint lines, uint cols, uint y, uint x, char *title)
Definition ui_ncurses.c:453
#define SFC_MAX
Definition ui_backend.h:25
int ui_surface_addwin(UiSurface *s, uint w, uint p, uint lines, uint cols, uint y, uint x)
Definition ui_ncurses.c:523
int Perror(char *emsg_str)
Display a simple error message window or print to stderr.
Definition dwin.c:841
A drawable surface in the NotCurses backend.

References BOX, Perror(), sfc_ptr, ui_box_surface_new(), ui_get_screen_size(), ui_render(), ui_surface, ui_surface_addwin(), and WIN.

Referenced by action_disposition(), answer_yn(), display_error(), display_form(), menu_engine(), Perror(), and popup_ckeys().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ surface_split_box_win_new()

int surface_split_box_win_new ( uint ,
uint ,
uint ,
uint ,
uint ,
uint ,
char *  )
extern

Definition at line 539 of file dwin.c.

539 {
540 if (sfc_ptr >= SFC_MAX) {
541 Perror("Maximum number of surfaces (%d) exceeded");
542 exit(EXIT_FAILURE);
543 }
544 if (sfc_ptr >= SFC_MAX) {
545 Perror("Maximum number of surfaces (%d) exceeded");
546 exit(EXIT_FAILURE);
547 }
548 uint maxy, maxx;
549 ui_get_screen_size(&maxy, &maxx);
550 wlines = min(wlines, maxy - 2);
551 wcols = min(wcols, maxx - 2);
552 split_x = min(split_x, maxx - 2); // not implemented yet
553 uint split_wlines = min(wlines + split_y + 1, maxy - 2);
554 wcols = min(wcols, maxx - 2);
555 sfc_ptr++;
556 // -------------------> surface_new <-------------------
557 ui_surface[sfc_ptr] = ui_box_surface_new(nullptr, 0, split_wlines, wcols, wbegy, wbegx, wtitle);
559
560 ui_surface_addwin(sfc, WIN, BOX, wlines, wcols, 1, 1);
561 ui_render();
562
563 border_ysplit(sfc, wlines + 1);
564 ui_render();
565 ui_surface_addwin(sfc, WIN2, BOX, 2, wcols, wlines + 2, 1);
566 ui_curs_set(0);
567 return 0;
568}
int border_ysplit(UiSurface *sfc, uint y)
Draw a box with a separator line around the specified window.
Definition dwin.c:617

References border_ysplit(), BOX, Perror(), sfc_ptr, ui_box_surface_new(), ui_curs_set(), ui_get_screen_size(), ui_render(), ui_surface, ui_surface_addwin(), WIN, and WIN2.

Referenced by open_pick_win().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ user_end()

void user_end ( )
extern

◆ verify_dir_q()

bool verify_dir_q ( char * ,
uint  )
extern

◆ verify_file_q()

bool verify_file_q ( char * ,
uint  )
extern

◆ wait_destroy()

bool wait_destroy ( Chyron * )
extern

◆ wait_mk_chyron()

Chyron * wait_mk_chyron ( )
extern

◆ waitpid_with_timeout()

bool waitpid_with_timeout ( pid_t ,
uint  )
extern

◆ wccp_to_str()

int wccp_to_str ( wchar_t ,
uint8_t *  )
extern

◆ win2_box_new()

int win2_box_new ( uint ,
uint ,
uint ,
uint ,
char *  )
extern

◆ win_del()

void win_del ( )
extern

◆ win_init_attrs()

void win_init_attrs ( )
extern

◆ win_resize()

void win_resize ( uint ,
uint ,
char *  )
extern

◆ win_Toggle_Attrs()

void win_Toggle_Attrs ( )
extern

◆ write_log()

void write_log ( char * )
extern

◆ xterm256_idx_to_rgb()

RGB xterm256_idx_to_rgb ( uint idx)
extern

Convert XTerm 256 color index to RGB.

xterm256_idx_to_rgb

Parameters
idxXTerm 256 color index
Returns
RGB color

This function converts an XTerm 256 color index to an RGB color. It first checks if the index is in the standard 16 colors, then checks if it's in the 6x6x6 color cube, and finally checks if it's in the gray ramp.

Convert XTerm 256 color index to RGB

Parameters
idx- XTerm 256 color index
Returns
RGB struct

Definition at line 274 of file dwin.c.

274 {
278 RGB rgb;
279 if (idx > 255)
280 idx = 255;
281 rgb.r = rgb.g = rgb.b = 0;
282 if (idx < 16) {
283 rgb.r = std_color[idx].r;
284 rgb.g = std_color[idx].g;
285 rgb.b = std_color[idx].b;
286 } else if (idx >= 16 && idx <= 231) {
287 idx -= 16;
288 rgb.r = (idx / 36) % 6 * 51;
289 rgb.g = (idx / 6) % 6 * 51;
290 rgb.b = (idx % 6) * 51;
291 } else if (idx >= 232 && idx <= 255) {
292 uint gray = (idx - 232) * 11;
293 rgb.r = rgb.g = rgb.b = gray;
294 }
295 return rgb;
296}
STDRGB std_color[]
Definition ui_ncurses.c:62

References STDRGB::b, STDRGB::g, STDRGB::r, and std_color.

Referenced by parse_ansi(), and parse_ansi_str().

Here is the caller graph for this function:

Variable Documentation

◆ cell_bl

UiCell cell_bl
extern

Definition at line 113 of file dwin.c.

Referenced by border_draw(), and initialize_cells().

◆ cell_box

UiCell cell_box
extern

Definition at line 98 of file dwin.c.

Referenced by border_title(), initialize_cells(), ui_bkgd(), and ui_box_surface_new().

◆ cell_br

UiCell cell_br
extern

Definition at line 114 of file dwin.c.

Referenced by border_draw(), and initialize_cells().

◆ cell_brktl

UiCell cell_brktl
extern

Definition at line 92 of file dwin.c.

Referenced by display_form(), and initialize_cells().

◆ cell_brktr

UiCell cell_brktr
extern

Definition at line 93 of file dwin.c.

Referenced by display_form(), and initialize_cells().

◆ cell_bs

UiCell cell_bs
extern

Definition at line 108 of file dwin.c.

◆ cell_bt

UiCell cell_bt
extern

Definition at line 118 of file dwin.c.

Referenced by initialize_cells().

◆ cell_chk

UiCell cell_chk
extern

◆ cell_cmdln

UiCell cell_cmdln
extern

Definition at line 100 of file dwin.c.

Referenced by initialize_cells().

◆ cell_cr

UiCell cell_cr
extern

Definition at line 119 of file dwin.c.

Referenced by initialize_cells().

◆ cell_default

UiCell cell_default
extern

Definition at line 90 of file dwin.c.

Referenced by initialize_cells().

◆ cell_fill_char

UiCell cell_fill_char
extern

Definition at line 91 of file dwin.c.

Referenced by form_display_fields(), and initialize_cells().

◆ cell_ho

UiCell cell_ho
extern

◆ cell_ind

UiCell cell_ind
extern

Definition at line 99 of file dwin.c.

Referenced by initialize_cells().

◆ cell_ln

UiCell cell_ln
extern

Definition at line 102 of file dwin.c.

Referenced by init_view_boxwin(), init_view_full_screen(), and initialize_cells().

◆ cell_ls

UiCell cell_ls
extern

Definition at line 105 of file dwin.c.

◆ cell_lt

UiCell cell_lt
extern

Definition at line 115 of file dwin.c.

Referenced by border_title(), border_ysplit(), border_ysplit_text(), and initialize_cells().

◆ cell_nt

◆ cell_nt_hl

UiCell cell_nt_hl
extern

Definition at line 96 of file dwin.c.

Referenced by border_ysplit_text(), initialize_cells(), menu_cmd_processor(), and menu_engine().

◆ cell_nt_hl_rev

UiCell cell_nt_hl_rev
extern

Definition at line 97 of file dwin.c.

Referenced by field_editor(), form_engine(), initialize_cells(), menu_cmd_processor(), and picker().

◆ cell_nt_rev

◆ cell_ran

UiCell cell_ran
extern

Definition at line 103 of file dwin.c.

Referenced by get_cmd_arg(), get_cmd_char(), initialize_cells(), and picker().

◆ cell_rs

UiCell cell_rs
extern

Definition at line 106 of file dwin.c.

◆ cell_rt

UiCell cell_rt
extern

Definition at line 116 of file dwin.c.

Referenced by border_title(), border_ysplit(), border_ysplit_text(), and initialize_cells().

◆ cell_sp

◆ cell_title

UiCell cell_title
extern

Definition at line 101 of file dwin.c.

Referenced by border_title(), and initialize_cells().

◆ cell_tl

UiCell cell_tl
extern

Definition at line 109 of file dwin.c.

Referenced by border_draw(), border_title(), and initialize_cells().

◆ cell_tr

UiCell cell_tr
extern

Definition at line 110 of file dwin.c.

Referenced by border_draw(), and initialize_cells().

◆ cell_ts

UiCell cell_ts
extern

Definition at line 107 of file dwin.c.

◆ cell_tt

UiCell cell_tt
extern

Definition at line 117 of file dwin.c.

Referenced by initialize_cells().

◆ cell_ve

UiCell cell_ve
extern

Definition at line 112 of file dwin.c.

Referenced by border_draw(), and initialize_cells().

◆ click_x

int click_x
extern

the x coordinate of a mouse click

Definition at line 45 of file dwin.c.

Referenced by cf_accept(), field_editor(), form_post(), and form_process().

◆ click_y

int click_y
extern

the y coordinate of a mouse click

Definition at line 44 of file dwin.c.

Referenced by cf_accept(), field_editor(), form_post(), and form_process().

◆ clr_cnt

uint clr_cnt
extern

number of colors used

◆ clr_idx

uint clr_idx
extern

current color index

◆ clr_pair_cnt

uint clr_pair_cnt
extern

number of color pairs supported by the terminal

◆ clr_pair_idx

uint clr_pair_idx
extern

current color pair index

◆ cmenu_log_fd

int cmenu_log_fd
extern

Definition at line 47 of file futil.c.

Referenced by open_cmenu_log(), write_cmenu_log(), and write_cmenu_log_ts().

◆ cmenu_log_fp

FILE* cmenu_log_fp
extern

◆ colors_text

char const colors_text[][10]
extern

Color names for .minitrc overrides.

color codes for the 16 basic colors

colors_text

These names are used in .minitrc to specify color overrides The order of these names corresponds to the ColorsEnum values

Definition at line 51 of file dwin.c.

51 {
52 "black", "red", "green", "yellow", "blue", "magenta", "cyan",
53 "white", "orange", "bg", "abg", "bblack", "bred", "bgreen",
54 "byellow", "bblue", "bcyan", "bmagenta", "bwhite", "borange", ""};

◆ cp_blue

ushort cp_blue
extern

blue background color pair index

Definition at line 162 of file dwin.c.

Referenced by initialize_cells().

◆ cp_bold

ushort cp_bold
extern

bold color pair index

◆ cp_box

ushort cp_box
extern

box color pair index

Definition at line 147 of file dwin.c.

Referenced by initialize_cells().

◆ cp_brackets

ushort cp_brackets
extern

color pair index for field brackets

Definition at line 158 of file dwin.c.

Referenced by initialize_cells().

◆ cp_cmdln_bg

ushort cp_cmdln_bg
extern

command line number background color pair index

◆ cp_cmdln_fg

ushort cp_cmdln_fg
extern

command line number color pair index

◆ cp_default

ushort cp_default
extern

default color pair index

Definition at line 156 of file dwin.c.

Referenced by initialize_cells().

◆ cp_fill_char

ushort cp_fill_char
extern

fill character color pair index

Definition at line 157 of file dwin.c.

Referenced by initialize_cells().

◆ cp_green

ushort cp_green
extern

green background color pair index

Definition at line 160 of file dwin.c.

Referenced by initialize_cells().

◆ cp_highlight

ushort cp_highlight
extern

highlight color pair index

◆ cp_ind

ushort cp_ind
extern

indicator color pair index

Definition at line 148 of file dwin.c.

Referenced by initialize_cells().

◆ cp_ln_bg

ushort cp_ln_bg
extern

line number background color pair index

◆ cp_ln_fg

ushort cp_ln_fg
extern

line number color pair index

◆ cp_nt

ushort cp_nt
extern

normal color pair index

Definition at line 151 of file dwin.c.

Referenced by fmt_line(), initialize_cells(), and mbstr_to_cc().

◆ cp_nt_hl

ushort cp_nt_hl
extern

highlight color pair index

Definition at line 153 of file dwin.c.

Referenced by initialize_cells().

◆ cp_nt_hl_rev

ushort cp_nt_hl_rev
extern

highlight reverse color pair index

Definition at line 154 of file dwin.c.

Referenced by initialize_cells().

◆ cp_nt_rev

ushort cp_nt_rev
extern

reverse color pair index

Definition at line 152 of file dwin.c.

Referenced by initialize_cells().

◆ cp_red

ushort cp_red
extern

red background color pair index

Definition at line 159 of file dwin.c.

Referenced by initialize_cells().

◆ cp_title

ushort cp_title
extern

title color pair index

Definition at line 150 of file dwin.c.

Referenced by initialize_cells().

◆ cp_yellow

ushort cp_yellow
extern

yellow background color pair index

Definition at line 161 of file dwin.c.

Referenced by initialize_cells().

◆ curses_err_tioctl

struct termios shell_err_tioctl curses_err_tioctl
extern

Definition at line 37 of file scriou.c.

Referenced by capture_curses_tioctl(), and restore_curses_tioctl().

◆ curses_in_tioctl

struct termios shell_in_tioctl curses_in_tioctl
extern

Definition at line 35 of file scriou.c.

Referenced by capture_curses_tioctl(), and restore_curses_tioctl().

◆ curses_out_tioctl

struct termios shell_out_tioctl curses_out_tioctl
extern

Definition at line 36 of file scriou.c.

Referenced by capture_curses_tioctl(), and restore_curses_tioctl().

◆ curses_tioctl

struct termios shell_tioctl curses_tioctl
extern

Definition at line 34 of file scriou.c.

◆ dbgfd

uint dbgfd
extern

the file descriptor for debug output, for debugging purposes

◆ em0

◆ em1

◆ em2

◆ em3

char em3[MAXLEN]
extern

error message string for error messages

Definition at line 145 of file dwin.c.

Referenced by verify_dir(), and verify_file().

◆ errmsg

char errmsg
extern

Global variables for error reporting

Definition at line 131 of file futil.c.

◆ exit_code

int exit_code
extern

the exit code for the program, for error messages and other output

Definition at line 127 of file dwin.c.

◆ f_curses_open

bool f_curses_open = false
extern

curses mode is active

Definition at line 33 of file sig.c.

Referenced by action_disposition(), answer_yn(), destroy_curses(), display_error(), handle_signal(), Perror(), ui_init(), ui_init(), and ui_shutdown().

◆ f_debug

bool f_debug
extern

a flag to indicate whether debug output should be printed, for debugging purposes

◆ f_have_curses_tioctl

bool f_have_curses_tioctl = false
extern

curses tioctl captured

Definition at line 25 of file scriou.c.

Referenced by capture_curses_tioctl(), and restore_curses_tioctl().

◆ f_have_shell_tioctl

bool f_have_shell_tioctl = false
extern

shell tioctl captured

Definition at line 24 of file scriou.c.

Referenced by capture_shell_tioctl(), and restore_shell_tioctl().

◆ f_restore_screen

bool f_restore_screen
extern

whether to restore the screen

◆ fn

char fn[MAXLEN]
extern

function name for error messages

Definition at line 141 of file dwin.c.

Referenced by verify_dir(), and verify_file().

◆ mbegx

uint mbegx
extern

beginning x coordinate of the current window, which can be used to determine the position of the window on the terminal screen.

◆ mbegy

uint mbegy
extern

beginning y coordinate of the current window, which can be used to determine the position of the window on the terminal screen.

◆ mcols

uint mcols
extern

number of columns in the current window, which may be less than the total number of columns in the terminal if the window is resized or if multiple windows are being used.

◆ mg_action

uint mg_action
extern

action in progress, which can be used to keep track of the current state of the program and determine how to respond to user input or other events.

◆ mg_col

uint mg_col
extern

window column, which can be used to determine the current column position in the window for displaying text or other content.

◆ mg_line

uint mg_line
extern

window line, which can be used to determine the current line position in the window for displaying text or other content.

◆ mlines

uint mlines
extern

number of lines in the current window, which may be less than the total number of lines in the terminal if the window is resized or if multiple windows are being used.

◆ n_cols

uint n_cols
extern

number of columns in the terminal

◆ n_lines

uint n_lines
extern

number of lines in the terminal

◆ sig_received

volatile sig_atomic_t sig_received = 0
extern

Definition at line 31 of file sig.c.

Referenced by handle_signal(), notcurses_input(), and signal_handler().

◆ src_line

uint src_line
extern

the line number of the source file being processed, for error messages

Definition at line 139 of file dwin.c.

Referenced by verify_dir(), and verify_file().

◆ src_name

char* src_name
extern

the name of the source file being processed, for error messages

Definition at line 140 of file dwin.c.

Referenced by verify_dir(), and verify_file().

◆ stderr_fd

int stderr_fd
extern

the file descriptor for the terminal, for error messages and other output

Definition at line 164 of file dwin.c.

◆ stdin_fd

int stdin_fd
extern

the file descriptor for the terminal, for error messages

Definition at line 137 of file dwin.c.

◆ stdio_names_str

char stdio_names_str
extern

Definition at line 127 of file futil.c.

Referenced by fork_exec(), form_process(), init_pick(), menu_cmd_processor(), and view_init_input().

◆ stdout_fd

int stdout_fd
extern

the file descriptor for the terminal, for error messages

Definition at line 138 of file dwin.c.

◆ tty_fp

FILE* tty_fp
extern

◆ wait_timeout

int wait_timeout
extern

Definition at line 145 of file futil.c.

◆ win_attr

uint16_t win_attr
extern

Ncurses attributes for the current window, such as color pair, bold, etc.

Definition at line 130 of file dwin.c.