C-Menu 0.2.9
A User Interface Toolkit
Loading...
Searching...
No Matches
pick_engine.c File Reference

pick from a list of choices More...

#include "include/common.h"
#include <fcntl.h>
#include <stdbool.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <termios.h>
#include <unistd.h>
Include dependency graph for pick_engine.c:

Go to the source code of this file.

Functions

void deselect_object (Pick *pick)
 Deselects the currently selected object in pick window.
void destroy_pick_view (Init *init)
 Destroys pick view, unmaps file buffer, and cleans up resources.
void display_pick_help (Init *init)
 Displays the help screen for the pick interface using view.
void display_pick_page (Pick *pick)
 Displays current page of objects in pick window.
void end_pick_view (Init *)
int exec_objects (Init *init)
 Executes specified command with selected objects as arguments.
int init_pick (Init *init, int argc, char **argv, int by, int bx)
 Initializes pick structure and opens pick input file or pipe.
int match_objects (Pick *pick, char *s)
 Displays current page of objects in pick window.
int new_pick_view (Init *init)
 Initializes a new view for displaying file contents in the pick interface.
void new_view_file (Init *init, char *file)
 Initializes a new view for displaying the contents of a specified file in the pick interface.
int open_pick_win (Init *init)
 Initializes the pick window based on the parameters specified in the Pick structure.
int output_objects (Pick *pick)
 Outputs selected objects to specified output file.
int pick_engine (Init *init)
 Initializes pick interface, calculates window size and position, and enters picker loop.
void pick_std_chyron (Pick *pick)
 Sets standard chyron key states based on pick structure.
int picker (Init *init, char *field)
 Main loop for handling user input and interactions in the pick interface.
int read_pick_input (Init *init)
 Reads pick input from file pointer and saves objects into pick structure.
int read_theme (Init *)
void remove_right_angle (Pick *)
void reverse_object (Pick *pick)
 Reverses the display of the currently selected object in pick window.
void save_object (Pick *pick, char *s)
 Saves a string as an object in the pick structure.
void toggle_object (Pick *pick)
 Toggles the selection state of the currently selected object in pick window.
void unreverse_object (Pick *pick)
 Unreverses the display of the currently selected object in pick window.

Variables

int calculated_idx
int obj_idx
char const pagers_editors [12][10]
int pg_lines
int pipe_fd [2]
int tbl_col
int tbl_cols
int tbl_line
int tbl_page
int tbl_pages

Detailed Description

pick from a list of choices

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 pick_engine.c.

Function Documentation

◆ end_pick_view()

void end_pick_view ( Init * )

◆ read_theme()

int read_theme ( Init * init)

Definition at line 587 of file pick_engine.c.

587 {
588 int rc;
589 expand_tilde(init->mapp_theme, MAXLEN - 1);
590 rc = process_config_file(init->mapp_theme, init);
591 if (rc)
592 return rc;
593 SIO *sio = init->sio;
595 update_panels();
596 doupdate();
597 return 0;
598}
int process_config_file(char *, Init *)
Definition init.c:631
#define MAXLEN
Definition curskeys.c:15
void initialize_local_colors(SIO *)
Initialize local color variables and color pairs based on SIO settings.
Definition dwin.c:320
bool expand_tilde(char *, int)
Replaces "~/" in string with the user's home directory.
Definition futil.c:970
SIO * sio
Definition common.h:114
char mapp_theme[MAXLEN]
Definition common.h:151
The SIO structure encapsulates various aspects of the terminal's state and configuration,...
Definition cm.h:805

References expand_tilde(), initialize_local_colors(), Init::mapp_theme, process_config_file(), and Init::sio.

Referenced by pick_engine().

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

◆ remove_right_angle()

void remove_right_angle ( Pick * pick)

Definition at line 539 of file pick_engine.c.

539 {
540 if (pick->d_idx >= pick->d_cnt)
541 pick->d_idx = pick->d_cnt - 1;
542 pick->tbl_line = (pick->d_idx / pick->tbl_cols) % pick->lines;
543 pick->y = pick->tbl_line + pick->y_offset;
544 pick->d_idx = pick->tbl_page * pick->lines * pick->tbl_cols + pick->tbl_col * pick->lines + pick->tbl_line;
545 if (pick->f_selected[pick->d_idx])
546 mvwadd_wchnstr(pick->win, pick->y, 0, &chk, 1);
547 else
548 mvwadd_wchnstr(pick->win, pick->y, 0, &sp, 1); // space
549 wmove(pick->win, pick->y, 0);
550}
cchar_t chk
Definition cm.h:631
cchar_t sp
Definition cm.h:631
Pick * pick
Definition mem.c:47

References chk, Pick::d_cnt, Pick::d_idx, Pick::f_selected, Pick::lines, sp, Pick::tbl_col, Pick::tbl_cols, Pick::tbl_line, Pick::tbl_page, Pick::win, Pick::y, and Pick::y_offset.

Referenced by picker().

Here is the caller graph for this function:

Variable Documentation

◆ calculated_idx

int calculated_idx

Definition at line 24 of file pick_engine.c.

◆ obj_idx

int obj_idx

Definition at line 24 of file pick_engine.c.

◆ pagers_editors

char const pagers_editors[12][10]
Initial value:
= {"view", "view", "less", "more",
"vi", "vim", "nano", "nvim",
"pico", "emacs", "edit", ""}

Definition at line 48 of file pick_engine.c.

48 {"view", "view", "less", "more",
49 "vi", "vim", "nano", "nvim",
50 "pico", "emacs", "edit", ""};

◆ pg_lines

int pg_lines

Definition at line 23 of file pick_engine.c.

◆ pipe_fd

int pipe_fd[2]

Definition at line 46 of file pick_engine.c.

Referenced by init_pick().

◆ tbl_col

int tbl_col

Definition at line 23 of file pick_engine.c.

◆ tbl_cols

int tbl_cols

Definition at line 23 of file pick_engine.c.

◆ tbl_line

int tbl_line

Definition at line 23 of file pick_engine.c.

◆ tbl_page

int tbl_page

Definition at line 23 of file pick_engine.c.

◆ tbl_pages

int tbl_pages

Definition at line 23 of file pick_engine.c.