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 "ui/ui_ncurses_internal.h"
#include "ui_backend.h"
#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 41 of file menu.c.

41 {
42 int rc;
43 char pgm_name[MAXLEN];
45 Init *init = new_init(argc, argv);
46 SIO *sio = init->sio;
47 mapp_initialization(init, argc, argv);
48 rc = atexit(end_pgm);
49 if (rc != 0) {
50 fprintf(stderr, "\nCannot set exit function\n");
51 exit(EXIT_FAILURE);
52 }
53#ifdef UAL_UI
54 UiConfig *ui_config = calloc(1, sizeof(UiConfig));
55 ui_config->enable_mouse = true;
56 ui_config->enable_alt_screen = false;
57 ui_config->cursor_visible = true;
59#else
60 open_curses(sio);
61#endif
65 base_name(pgm_name, argv[0]);
66 if (!strcmp(pgm_name, "menu")) {
67 new_menu(init, init->argc, init->argv, LINES / 14, COLS / 14);
68 menu_engine(init);
69 } else if (!strcmp(pgm_name, "form")) {
70 init_form(init, init->argc, init->argv, LINES / 14, COLS / 14);
71 } else if (!strcmp(pgm_name, "pick")) {
72 init_pick(init, init->argc, init->argv, 0, 0);
73 } else if (!strcmp(pgm_name, "view")) {
74 View *view = new_view(init);
75 if (init->lines > 0 || init->cols > 0) {
76 if (init->h_shift == 0)
77 init->h_shift = view->cols / 3;
78 if (!init_view_boxwin(init)) {
79 view_file(init);
80 }
81 } else if (!init_view_full_screen(init)) {
82 view_file(init);
83 }
84 } else if (!strcmp(pgm_name, "ckeys"))
86 destroy_view(init);
88 destroy_init(init);
89 exit(EXIT_SUCCESS);
90}
int popup_ckeys()
Display Curses Keys Responds to curses keys and mouse events, displaying the key code and description...
Definition curskeys.c:23
View * view
Definition mem.c:49
#define MAXLEN
Definition curskeys.c:15
UiRuntime * ui_runtime
Definition dwin.c:44
UiConfig * ui_config
Definition dwin.c:45
bool open_curses(SIO *)
Initialize NCurses and color settings.
Definition dwin.c:244
void destroy_curses()
Gracefully shut down NCurses and restore terminal settings.
Definition dwin.c:670
void initialize_local_colors(SIO *)
Initialize local color variables and color pairs based on SIO settings.
Definition dwin.c:320
int init_form(Init *, int, char **, int, int)
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:1123
void mapp_initialization(Init *, int, char **)
Main initialization function for MAPP - Menu Application.
Definition init.c:441
int init_view_full_screen(Init *)
Initialize C-Menu View in full screen mode.
Definition init_view.c:49
int init_view_boxwin(Init *)
Initialize the C-Menu View in box window mode.
Definition init_view.c:194
View * destroy_view(Init *init)
Destroy View structure.
Definition mem.c:356
Init * new_init(int, char **)
Create and initialize Init structure.
Definition mem.c:71
Menu * new_menu(Init *, int, char **, int, int)
Create and initialize Menu structure.
Definition mem.c:145
View * new_view(Init *)
Create and initialize View structure.
Definition mem.c:310
Init * destroy_init(Init *init)
Destroy Init structure.
Definition mem.c:106
unsigned int menu_engine(Init *)
The main loop of the menu system.
Definition menu_engine.c:38
int init_pick(Init *, int, char **, int, int)
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:68
void sig_prog_mode()
Set up signal handlers for interrupt signals.
Definition sig.c:62
int view_file(Init *)
Start view.
UiRuntime * ui_init(const UiConfig *cfg)
Initialize NCUrses.
Definition ui_ncurses.c:180
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:181
char ** argv
Definition common.h:131
int lines
Definition common.h:115
The SIO structure encapsulates various aspects of the terminal's state and configuration,...
Definition cm.h:805
Definition view.h:42
Structure representing the configuration options for the UI runtime.
Definition ui_backend.h:211

References Init::argc, Init::argv, base_name(), capture_curses_tioctl(), capture_shell_tioctl(), Init::cols, View::cols, destroy_curses(), destroy_init(), destroy_view(), Init::h_shift, init_form(), init_pick(), init_view_boxwin(), init_view_full_screen(), initialize_local_colors(), Init::lines, mapp_initialization(), menu_engine(), new_init(), new_menu(), new_view(), open_curses(), popup_ckeys(), sig_prog_mode(), Init::sio, and view_file().

Here is the call graph for this function: