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

void cmenu_abend (Init *init, int ec, char *s)
void cmenu_shutdown (Init *init)
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

◆ cmenu_abend()

void cmenu_abend ( Init * init,
int ec,
char * s )

Definition at line 94 of file menu.c.

94 {
95 cmenu_shutdown(init);
98 fprintf(stderr, _("\n\nABEND: %s (code: %d)\n"), s, ec);
99 exit(EXIT_FAILURE);
100}
void cmenu_shutdown(Init *init)
Definition menu.c:88
#define _(String)
Definition amort.c:23
bool restore_shell_tioctl()
restore_shell_tioctl() - restore shell terminal settings
Definition scriou.c:57
void sig_dfl_mode()
Set signal handlers to default behavior.
Definition sig.c:41

References cmenu_shutdown(), restore_shell_tioctl(), and sig_dfl_mode().

Referenced by view_init_input().

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

◆ cmenu_shutdown()

void cmenu_shutdown ( Init * init)

Definition at line 88 of file menu.c.

88 {
89 destroy_view(init);
91 destroy_init(init);
92}
void ui_shutdown()
Shutdown the UI runtime, cleaning up resources and freeing memory.
Definition ui_ncurses.c:418
View * destroy_view(Init *init)
Destroy View structure.
Definition mem.c:337
Init * destroy_init(Init *init)
Destroy Init structure.
Definition mem.c:91

References destroy_init(), destroy_view(), and ui_shutdown().

Referenced by cmenu_abend().

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

◆ 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 mapp_initialization(init, argc, argv);
48 .border_style = UI_BORDER_ROUNDED,
49 .log_file = "/tmp/mylog.log",
50 .log_level = INFO};
51 ui_init(&ui_config, init->sio);
52 rc = atexit(end_pgm);
53 if (rc != 0) {
54 fprintf(stderr, "\n");
55 fprintf(stderr, _("Cannot set exit function"));
56 fprintf(stderr, "\n");
57 exit(EXIT_FAILURE);
58 }
61 base_name(pgm_name, argv[0]);
62 if (!strcmp(pgm_name, "menu")) {
63 new_menu(init, init->argc, init->argv, LINES / 14, COLS / 14);
64 menu_engine(init);
65 } else if (!strcmp(pgm_name, "form")) {
66 init_form(init, init->argc, init->argv, LINES / 14, COLS / 14);
67 } else if (!strcmp(pgm_name, "pick")) {
68 init_pick(init, init->argc, init->argv, 0, 0);
69 } else if (!strcmp(pgm_name, "view")) {
70 View *view = new_view(init);
71 if (init->lines > 0 || init->cols > 0) {
72 if (init->h_shift == 0)
73 init->h_shift = view->cols / 3;
74 if (!init_view_boxwin(init)) {
75 view_file(init);
76 }
77 } else if (!init_view_full_screen(init)) {
78 view_file(init);
79 }
80 } else if (!strcmp(pgm_name, "ckeys"))
82 destroy_view(init);
84 destroy_init(init);
85 exit(EXIT_SUCCESS);
86}
UiRuntime * ui_init(const UiConfig *config, SIO *sio)
Initialize the UI runtime with the given configuration and SIO.
Definition ui_ncurses.c:129
uint COLS
Definition ui_backend.h:426
uint LINES
UiConfig * ui_config
View * view
Definition mem.c:38
int popup_ckeys()
Definition curskeys.c:31
#define MAXLEN
Definition curskeys.c:15
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:1132
void mapp_initialization(Init *, int, char **)
Main initialization function for MAPP - Menu Application.
Definition init.c:498
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:162
Menu * new_menu(Init *init, int argc, char **argv, uint begy, uint begx)
Create and initialize Menu structure.
Definition mem.c:126
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:291
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:68
bool capture_shell_tioctl()
capture_shell_tioctl() - capture shell terminal settings
Definition scriou.c:43
bool capture_program_tioctl()
capture_program_tioctl() - capture program terminal settings
Definition scriou.c:70
void sig_prog_mode()
Set up signal handlers for interrupt signals.
Definition sig.c:61
int view_file(Init *)
Start view.
Gathers runtime information for C-Menu Menu, Form, Pick, and View components, used for passing common...
Definition common.h:116
SIO * sio
Definition common.h:117
int argc
Definition common.h:133
int cols
Definition common.h:119
int h_shift
Definition common.h:186
char ** argv
Definition common.h:134
int lines
Definition common.h:118
Definition view.h:59

References Init::argc, Init::argv, base_name(), UiConfig::border_style, capture_program_tioctl(), capture_shell_tioctl(), Init::cols, View::cols, destroy_init(), destroy_view(), Init::h_shift, init_form(), init_pick(), init_view_boxwin(), init_view_full_screen(), Init::lines, UiConfig::log_file, UiConfig::log_level, mapp_initialization(), menu_engine(), new_init(), new_menu(), new_view(), popup_ckeys(), sig_prog_mode(), Init::sio, ui_init(), ui_shutdown(), and view_file().

Here is the call graph for this function: