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

Command line start-up for C-Menu components. More...

#include "common.h"
#include <string.h>
Include dependency graph for menu.c:

Go to the source code of this file.

Macros

#define _GNU_SOURCE

Functions

int main (int argc, char **argv)

Detailed Description

Command line start-up for C-Menu components.

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

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 9 of file menu.c.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 42 of file menu.c.

42 {
43 int rc;
44 char pgm_name[MAXLEN];
46 Init *init = new_init(argc, argv);
47 mapp_initialization(init, argc, argv);
48 SIO *sio = init->sio;
49 UiConfig *ui_config = calloc(1, sizeof(UiConfig));
50 ui_config->enable_mouse = true;
51 ui_config->enable_alt_screen = false;
52 ui_config->cursor_visible = true;
53 ui_config->border_style = sio->border;
56 rc = atexit(end_pgm);
57 if (rc != 0) {
58 fprintf(stderr, "\nCannot set exit function\n");
59 exit(EXIT_FAILURE);
60 }
63 base_name(pgm_name, argv[0]);
64 if (!strcmp(pgm_name, "menu")) {
65 new_menu(init, init->argc, init->argv, LINES / 14, COLS / 14);
66 menu_engine(init);
67 } else if (!strcmp(pgm_name, "form")) {
68 init_form(init, init->argc, init->argv, LINES / 14, COLS / 14);
69 } else if (!strcmp(pgm_name, "pick")) {
70 init_pick(init, init->argc, init->argv, 0, 0);
71 } else if (!strcmp(pgm_name, "view")) {
72 View *view = new_view(init);
73 if (init->lines > 0 || init->cols > 0) {
74 if (init->h_shift == 0)
75 init->h_shift = view->cols / 3;
76 if (!init_view_boxwin(init)) {
77 view_file(init);
78 }
79 } else if (!init_view_full_screen(init)) {
80 view_file(init);
81 }
82 } else if (!strcmp(pgm_name, "ckeys"))
84 destroy_view(init);
86 destroy_init(init);
87 exit(EXIT_SUCCESS);
88}
UiRuntime * ui_init(const UiConfig *config)
Definition ui_ncurses.c:261
uint COLS
Definition ui_backend.h:266
uint LINES
UiConfig * ui_config
View * view
Definition mem.c:38
int popup_ckeys()
Definition curskeys.c:31
#define MAXLEN
Definition curskeys.c:15
void initialize_cells(SIO *sio)
Initialize local color variables and color pairs based on SIO settings.
Definition dwin.c:177
void destroy_curses()
Gracefully shut down NCurses and restore terminal settings.
Definition dwin.c:384
int init_form(Init *, int, char **, uint, uint)
Initialize form data structure and parse description file.
Definition form_engine.c:61
bool base_name(char *, char *)
Returns the base name of a file specification.
Definition futil.c:1106
void mapp_initialization(Init *, int, char **)
Main initialization function for MAPP - Menu Application.
Definition init.c:474
int init_view_full_screen(Init *init)
Initialize C-Menu View in full screen mode.
Definition init_view.c:47
int init_view_boxwin(Init *init)
Initialize the C-Menu View in box window mode.
Definition init_view.c:147
View * destroy_view(Init *init)
Destroy View structure.
Definition mem.c:345
Menu * new_menu(Init *init, int argc, char **argv, uint begy, uint begx)
Create and initialize Menu structure.
Definition mem.c:134
Init * new_init(int argc, char **argv)
Create and initialize Init structure.
Definition mem.c:60
View * new_view(Init *init)
Create and initialize View structure.
Definition mem.c:299
Init * destroy_init(Init *init)
Destroy Init structure.
Definition mem.c:95
unsigned int menu_engine(Init *)
The main loop of the menu system.
Definition menu_engine.c:36
int init_pick(Init *, int, char **, uint, uint)
Initializes pick structure and opens pick input file or pipe.
Definition pick_engine.c:66
bool capture_shell_tioctl()
capture_shell_tioctl() - capture shell terminal settings
Definition scriou.c:43
bool capture_curses_tioctl()
capture_curses_tioctl() - capture curses terminal settings
Definition scriou.c:70
void sig_prog_mode()
Set up signal handlers for interrupt signals.
Definition sig.c:62
int view_file(Init *)
Start view.
Structure representing the configuration options for the UI runtime.
Definition ui_backend.h:142
The SIO structure encapsulates various aspects of the terminal's state and configuration,...
Definition cm.h:688
char border
Definition cm.h:752
Gathers runtime information for C-Menu Menu, Form, Pick, and View components, used for passing common...
Definition common.h:113
SIO * sio
Definition common.h:114
int argc
Definition common.h:130
int cols
Definition common.h:116
int h_shift
Definition common.h:182
char ** argv
Definition common.h:131
int lines
Definition common.h:115
Definition view.h:61

References Init::argc, Init::argv, base_name(), SIO::border, UiConfig::border_style, capture_curses_tioctl(), capture_shell_tioctl(), COLS, Init::cols, View::cols, UiConfig::cursor_visible, destroy_curses(), destroy_init(), destroy_view(), UiConfig::enable_alt_screen, UiConfig::enable_mouse, Init::h_shift, init_form(), init_pick(), init_view_boxwin(), init_view_full_screen(), initialize_cells(), LINES, Init::lines, mapp_initialization(), menu_engine(), new_init(), new_menu(), new_view(), popup_ckeys(), sig_prog_mode(), Init::sio, ui_init(), and view_file().

Here is the call graph for this function: