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

functions to create popup windows More...

#include "common.h"
Include dependency graph for popups.c:

Go to the source code of this file.

Functions

int popup_form (Init *init, int argc, char **argv, int begy, int begx)
 instantiate a form popup window
int popup_menu (Init *init, int argc, char **argv, int begy, int begx)
 instantiate a menu popup window
int popup_pick (Init *init, int argc, char **argv, int begy, int begx)
 instantiate a pick popup window
int popup_view (Init *init, int argc, char **argv, int lines, int cols, int begy, int begx)
 instantiate a view popup window

Detailed Description

functions to create popup windows

Author
Bill Waller
Date
2026-03

This file contains functions to create popup windows for menu, form, pick, and view. The functions in this file are called by the main function in main.c when the user selects a menu option that requires a popup window. The functions in this file also handle command line arguments that may be passed to the popup windows, such as the number of lines and columns for the view window, and the y and x coordinates for the popup windows. The functions in this file also save the current state of the popup windows before creating a new one, and restore the state after the popup window is closed. The functions in this file also call the appropriate functions to initialize and destroy the popup windows, and to handle the user input for the popup windows. The functions in this file also return the appropriate return codes to the main function in main.c, which will determine how to proceed based on the return codes. The functions in this file also handle any errors that may occur during the creation and handling of the popup windows, and will return appropriate error codes to the main function in main.c, which will determine how to proceed based on the error codes. The functions in this file also handle any cleanup that may be necessary after the popup windows are closed, such as freeing memory and resetting variables. The functions in this file also handle any necessary updates to the main window after the popup windows are closed, such as refreshing the main window and updating any relevant data.

Definition in file popups.c.

Function Documentation

◆ popup_form()

int popup_form ( Init * init,
int argc,
char ** argv,
int begy,
int begx )

instantiate a form popup window

Parameters
initthe Init struct pointer
argcthe number of command line arguments
argvthe command line arguments
begythe y coordinate for the form window
begxthe x coordinate for the form window

begy and begx may be set as command line option arguments, in which case, they will take precedence over arguments passed in the function arguments.

 begy, and begx may be set by
    1. the calling function
       or
    2. command line arguments
 Non-zero command line arguments will override the calling function's
arguments.

Definition at line 113 of file popups.c.

113 {
114 int rc;
116 parse_opt_args(init, argc, argv);
117 Form *sav_form = init->form;
118 init->form = nullptr;
119 form = nullptr;
120 rc = init_form(init, init->argc, init->argv, begy, begx);
122 init->form = sav_form;
123 return rc;
124}
Form * form
Definition mem.c:47
Init * init
Definition init.c:74
int begx
int begy
int init_form(Init *, int, char **, int, int)
Initialize form data structure and parse description file.
Definition form_engine.c:60
int parse_opt_args(Init *, int, char **)
Parse command-line options and set Init struct values accordingly.
Definition init.c:427
void zero_opt_args(Init *)
Initialize optional arguments in the Init struct to default values.
Definition init.c:442
Form * destroy_form(Init *init)
Destroy Form structure.
Definition mem.c:289
Definition form.h:145

References Init::argc, Init::argv, destroy_form(), form, Init::form, init_form(), parse_opt_args(), and zero_opt_args().

Referenced by enter_file_spec(), and menu_cmd_processor().

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

◆ popup_menu()

int popup_menu ( Init * init,
int argc,
char ** argv,
int begy,
int begx )

instantiate a menu popup window

Parameters
initthe Init struct pointer
argcthe number of command line arguments
argvthe command line arguments
begythe y coordinate for the menu window
begxthe x coordinate for the menu window

begy and begx may be set as command line option arguments, in which case, they will take precedence over arguments passed in the function arguments.

 begy, and begx may be set by
    1. the calling function
       or
    2. command line arguments
 Non-zero command line arguments will override the calling function's
arguments.

Definition at line 53 of file popups.c.

53 {
54 int rc;
56 parse_opt_args(init, argc, argv);
57 Menu *sav_menu = init->menu;
58 init->menu = nullptr;
59 init->menu = new_menu(init, init->argc, init->argv, begy, begx);
60 rc = menu_engine(init);
62 init->menu = sav_menu;
63 return rc;
64}
Menu * new_menu(Init *, int, char **, int, int)
Create and initialize Menu structure.
Definition mem.c:148
Menu * destroy_menu(Init *init)
Destroy Menu structure.
Definition mem.c:169
unsigned int menu_engine(Init *)
The main loop of the menu system.
Definition menu_engine.c:38
The Menu structure is the main data structure for the menu application, containing all the informatio...
Definition menu.h:90

References Init::argc, Init::argv, destroy_menu(), Init::menu, menu_engine(), new_menu(), parse_opt_args(), and zero_opt_args().

Referenced by menu_cmd_processor().

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

◆ popup_pick()

int popup_pick ( Init * init,
int argc,
char ** argv,
int begy,
int begx )

instantiate a pick popup window

Parameters
initthe Init struct pointer
argcthe number of command line arguments
argvthe command line arguments
begythe y coordinate for the pick window
begxthe x coordinate for the pick window

begy and begx may be set as command line option arguments, in which case, they will take precedence over arguments passed in the function arguments.

 begy, and begx may be set by
    1. the calling function
       or
    2. command line arguments
 Non-zero command line arguments will override the calling function's
arguments.

Definition at line 83 of file popups.c.

83 {
84 int rc;
86 parse_opt_args(init, argc, argv);
87 Pick *sav_pick = init->pick;
88 init->pick = nullptr;
89 pick = nullptr;
90 rc = init_pick(init, init->argc, init->argv, begy, begx);
92 init->pick = sav_pick;
93 return rc;
94}
Pick * pick
Definition mem.c:46
Pick * destroy_pick(Init *init)
Destroy Pick structure.
Definition mem.c:239
int init_pick(Init *, int, char **, int, int)
Initializes pick structure and opens pick input file or pipe.
Definition pick_engine.c:60
Pick data structure.
Definition pick.h:25

References Init::argc, Init::argv, destroy_pick(), init_pick(), parse_opt_args(), Init::pick, pick, and zero_opt_args().

Referenced by menu_cmd_processor().

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

◆ popup_view()

int popup_view ( Init * init,
int argc,
char ** argv,
int lines,
int cols,
int begy,
int begx )

instantiate a view popup window

Parameters
initthe Init struct pointer
argcthe number of command line arguments
argvthe command line arguments
linesthe number of lines for the view window
colsthe number of columns for the view window
begythe y coordinate for the view window
begxthe x coordinate for the view window

lines, cols, begy, and begx may also be set as command line option arguments, in which case, they will take precedence over arguments passed in the function arguments.

 lines, cols, begy, and begx may be set by
    1. the calling function
       or
    2. command line arguments
 Non-zero command line arguments will override the calling function's
arguments.

Definition at line 146 of file popups.c.

147 {
148 int rc = 0;
150 parse_opt_args(init, argc, argv);
151 View *sav_view = init->view;
152 init->view = nullptr;
153 view = nullptr;
154 view = new_view(init);
155
156 if (init->lines > 0 && init->cols > 0) {
157 lines = init->lines;
158 cols = init->cols;
159 }
160 if (init->begy > 0 || init->begx > 0) {
161 begy = init->begy;
162 begx = init->begx;
163 }
164 view->lines = lines;
165 view->cols = cols;
166 view->begy = begy;
167 view->begx = begx;
169 view->f_full_screen = false;
170 if (!init_view_boxwin(init, view->title)) {
171 rc = view_file(init);
172 win_del();
173 }
175 init->view = sav_view;
176 return rc;
177}
int cols
int lines
View * view
Definition mem.c:48
WINDOW * win_del()
Delete the current window and its associated box window.
Definition dwin.c:893
void view_calc_win_dimensions(Init *, char *title)
Calculate the dimensions and position of the box window for C-Menu View.
Definition init_view.c:367
int init_view_boxwin(Init *, char *)
Initialize the C-Menu View in box window mode.
Definition init_view.c:172
View * destroy_view(Init *init)
Destroy View structure.
Definition mem.c:359
View * new_view(Init *)
Create and initialize View structure.
Definition mem.c:313
int view_file(Init *)
Start view.
Definition view.h:37

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, new_view(), parse_opt_args(), View::title, Init::view, view, view_calc_win_dimensions(), view_file(), win_del(), and zero_opt_args().

Referenced by display_pick_help(), exec_objects(), form_engine(), form_exec_receiver(), menu_cmd_processor(), and view_display_help().

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