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 by, int bx)
 instantiate a form popup window
int popup_menu (Init *init, int argc, char **argv, int by, int bx)
 instantiate a menu popup window
int popup_pick (Init *init, int argc, char **argv, int by, int bx)
 instantiate a pick popup window
int popup_view (Init *init, int argc, char **argv, int ilines, int icols, int by, int bx)
 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 by,
int bx )

instantiate a form popup window

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

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

 by, and bx 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 112 of file popups.c.

112 {
113 int rc;
114 zero_opt_args(init);
115 parse_opt_args(init, argc, argv);
116 Form *sav_form = init->form;
117 init->form = nullptr;
118 rc = init_form(init, init->argc, init->argv, by, bx);
119 destroy_form(init);
120 init->form = sav_form;
121 return rc;
122}
int init_form(Init *, int, char **, int, int)
Initialize form data structure and parse description file.
Definition form_engine.c:61
int parse_opt_args(Init *, int, char **)
Parse command-line options and set Init struct values accordingly.
Definition init.c:559
void zero_opt_args(Init *)
Initialize optional arguments in the Init struct to default values.
Definition init.c:574
Form * destroy_form(Init *init)
Destroy Form structure.
Definition mem.c:286
Form * form
Definition common.h:184
int argc
Definition common.h:130
char ** argv
Definition common.h:131
Definition form.h:145

References Init::argc, Init::argv, destroy_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 by,
int bx )

instantiate a menu popup window

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

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

 by, and bx 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;
55 zero_opt_args(init);
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, by, bx);
60 rc = menu_engine(init);
61 destroy_menu(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:145
Menu * destroy_menu(Init *init)
Destroy Menu structure.
Definition mem.c:166
unsigned int menu_engine(Init *)
The main loop of the menu system.
Definition menu_engine.c:38
Menu * menu
Definition common.h:182
The Menu structure is the main data structure for the menu application, containing all the informatio...
Definition menu.h:106

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 by,
int bx )

instantiate a pick popup window

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

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

 by, and bx 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;
85 zero_opt_args(init);
86 parse_opt_args(init, argc, argv);
87 Pick *sav_pick = init->pick;
88 init->pick = nullptr;
89 rc = init_pick(init, init->argc, init->argv, by, bx);
90 destroy_pick(init);
91 init->pick = sav_pick;
92 return rc;
93}
Pick * destroy_pick(Init *init)
Destroy Pick structure.
Definition mem.c:236
int init_pick(Init *, int, char **, int, int)
Initializes pick structure and opens pick input file or pipe.
Definition pick_engine.c:66
Pick * pick
Definition common.h:186
Pick data structure.
Definition pick.h:25

References Init::argc, Init::argv, destroy_pick(), init_pick(), parse_opt_args(), Init::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 ilines,
int icols,
int by,
int bx )

instantiate a view popup window

Parameters
initthe Init struct pointer
argcthe number of command line arguments
argvthe command line arguments
ilinesthe number of lines for the view window
icolsthe number of columns for the view window
bythe y coordinate for the view window
bxthe x coordinate for the view window

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

 ilines, cols, by, and bx 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 144 of file popups.c.

145 {
146 int rc = 0;
147 zero_opt_args(init);
148 parse_opt_args(init, argc, argv);
149 // view_stack_push(&view_stack, *init->view);
150 View *view_sav = init->view;
151 init->view = nullptr;
152 View *view = nullptr;
153 view = nullptr;
154 view = new_view(init);
155
156 if (init->lines > 0 && init->cols > 0) {
157 ilines = init->lines;
158 icols = init->cols;
159 }
160 if (init->begy > 0 || init->begx > 0) {
161 by = init->begy;
162 bx = init->begx;
163 }
164 view->begy = by;
165 view->begx = bx;
166 view->lines = ilines;
167 view->cols = icols;
168 view->f_full_screen = false;
169 if (!init_view_boxwin(init))
170 rc = view_file(init);
171 destroy_view(init);
172 init->view = view_sav;
173 // view_stack_pop(&view_stack, init->view);
174 return rc;
175}
View * view
Definition mem.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
View * new_view(Init *)
Create and initialize View structure.
Definition mem.c:310
int view_file(Init *)
Start view.
int begx
Definition common.h:118
int cols
Definition common.h:116
int begy
Definition common.h:117
View * view
Definition common.h:188
int lines
Definition common.h:115
Definition view.h:42

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(), Init::view, view_file(), 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: