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.

Functions

int mview (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.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 42 of file menu.c.

42 {
43 int rc;
44 rc = atexit(end_pgm);
45 if (rc != 0) {
46 fprintf(stderr, "\nCannot set exit function\n");
47 exit(EXIT_FAILURE);
48 }
49 char pgm_name[MAXLEN];
51 Init *init = new_init(argc, argv);
52 SIO *sio = init->sio;
53 mapp_initialization(init, argc, argv);
58
59 base_name(pgm_name, argv[0]);
60
61 if (!strcmp(pgm_name, "menu")) {
62 new_menu(init, init->argc, init->argv, LINES / 14, COLS / 14);
63 menu = init->menu;
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")) {
71 if (init->lines > 0 || init->cols > 0)
72 mview(init);
73 else if (!init_view_full_screen(init))
75 } else if (!strcmp(pgm_name, "ckeys")) {
77 }
78 curs_set(1);
79 win_del();
80 // erase();
81 // refresh();
85 exit(EXIT_SUCCESS);
86}
Init * init
Definition common.h:186
Menu * menu
Definition mem.c:45
View * view
Definition mem.c:48
int popup_ckeys()
Display Curses Keys Responds to curses keys and mouse events, displaying the key code and description...
Definition curskeys.c:23
#define MAXLEN
Definition curskeys.c:15
int mview(Init *)
Definition menu.c:88
SIO * sio
Definition dwin.c:77
bool open_curses(SIO *)
Initialize NCurses and color settings.
Definition dwin.c:423
void win_init_attrs()
Initialize window attributes.
Definition dwin.c:162
WINDOW * win_del()
Delete the current window and its associated box window.
Definition dwin.c:902
void destroy_curses()
Gracefully shut down NCurses and restore terminal settings.
Definition dwin.c:738
int init_form(Init *, int, char **, int, int)
Initialize form data structure and parse description file.
Definition form_engine.c:59
bool base_name(char *, char *)
Returns the base name of a file specification.
Definition futil.c:775
void mapp_initialization(Init *, int, char **)
Main initialization function for MAPP - Menu Application.
Definition init.c:324
int init_view_full_screen(Init *)
Initialize C-Menu View in full screen mode.
Definition init_view.c:40
Init * new_init(int, char **)
Create and initialize Init structure.
Definition mem.c:70
Menu * new_menu(Init *, int, char **, int, int)
Create and initialize Menu structure.
Definition mem.c:148
View * new_view(Init *)
Create and initialize View structure.
Definition mem.c:300
unsigned int menu_engine(Init *)
The main loop of the menu system.
Definition menu_engine.c:37
int init_pick(Init *, int, char **, int, int)
Initializes pick structure and opens pick input file or pipe.
Definition pick_engine.c:59
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
bool restore_shell_tioctl()
restore_shell_tioctl() - restore shell terminal settings
Definition scriou.c:56
void sig_dfl_mode()
Set signal handlers to default behavior.
Definition sig.c:42
void sig_prog_mode()
Set up signal handlers for interrupt signals.
Definition sig.c:62
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:107
The SIO structure encapsulates various aspects of the terminal's state and configuration,...
Definition cm.h:626

References Init::argc, Init::argv, base_name(), capture_curses_tioctl(), capture_shell_tioctl(), Init::cols, destroy_curses(), init_form(), init_pick(), init_view_full_screen(), Init::lines, mapp_initialization(), Init::menu, menu, menu_engine(), mview(), new_init(), new_menu(), new_view(), open_curses(), popup_ckeys(), restore_shell_tioctl(), sig_dfl_mode(), sig_prog_mode(), Init::sio, view, view_file(), win_del(), and win_init_attrs().

Here is the call graph for this function:

◆ mview()

int mview ( Init * init)

Definition at line 88 of file menu.c.

88 {
89 view = init->view;
90 if (init->lines != 0 && view->lines == 0)
91 view->lines = init->lines;
92 if (view->lines == 0)
93 view->lines = LINES * 3 / 4;
94 if (view->lines > LINES - 3)
95 view->lines = LINES - 3;
96 if (init->cols != 0 && view->lines == 0)
97 view->cols = init->cols;
98 if (view->cols == 0)
99 view->cols = COLS * 3 / 4;
100 if (view->cols > COLS - 3)
101 view->cols = COLS - 3;
102 if (init->begy != 0 && view->begy == 0)
103 view->begy = init->begy;
104 if (view->begy == 0)
105 view->begy = (LINES - view->lines) / 5;
106 if (view->begy + view->lines > LINES - 2)
107 view->begy = LINES - view->lines - 2;
108 if (init->begx != 0 && view->begx == 0)
109 view->begx = init->begx;
110 if (view->begx == 0)
111 view->begx = (COLS - view->cols) / 5;
112 if (view->begx + view->cols > COLS - 1)
113 view->begx = COLS - view->cols - 1;
114 view->f_full_screen = false;
115 if (!init_view_boxwin(init, init->title)) {
117 win_del();
118 }
120 return 0;
121}
int init_view_boxwin(Init *, char *)
Initialize the C-Menu View in box window mode.
Definition init_view.c:123
View * destroy_view(Init *init)
Destroy View structure.
Definition mem.c:346

References Init::begx, View::begx, Init::begy, View::begy, Init::cols, View::cols, destroy_view(), View::f_full_screen, init_view_boxwin(), Init::lines, View::lines, Init::title, Init::view, view, view_file(), and win_del().

Referenced by main().

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