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

113 {
114 int rc;
115 zero_opt_args(init);
116 parse_opt_args(init, argc, argv);
117 Form *sav_form = init->form;
118 init->form = nullptr;
119 rc = init_form(init, init->argc, init->argv, by, bx);
120 destroy_form(init);
121 init->form = sav_form;
122 return rc;
123}
int init_form(Init *, int, char **, uint, uint)
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:591
void zero_opt_args(Init *)
Initialize optional arguments in the Init struct to default values.
Definition init.c:606
Form * destroy_form(Init *init)
Destroy Form structure.
Definition mem.c:275
Form * form
Definition common.h:185
int argc
Definition common.h:130
char ** argv
Definition common.h:131
Definition form.h:146

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,
uint by,
uint 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 *init, int argc, char **argv, uint begy, uint begx)
Create and initialize Menu structure.
Definition mem.c:134
Menu * destroy_menu(Init *init)
Destroy Menu structure.
Definition mem.c:155
unsigned int menu_engine(Init *)
The main loop of the menu system.
Definition menu_engine.c:36
Menu * menu
Definition common.h:183
The Menu structure is the main data structure for the menu application, containing all the informatio...
Definition menu.h:105

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,
uint by,
uint 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
90 rc = init_pick(init, init->argc, init->argv, by, bx);
91 destroy_pick(init);
92 init->pick = sav_pick;
93 return rc;
94}
Pick * destroy_pick(Init *init)
Destroy Pick structure.
Definition mem.c:225
int init_pick(Init *, int, char **, uint, uint)
Initializes pick structure and opens pick input file or pipe.
Definition pick_engine.c:66
Pick * pick
Definition common.h:187
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,
uint ilines,
uint icols,
uint by,
uint 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 145 of file popups.c.

146 {
147 int rc = 0;
148 zero_opt_args(init);
149 parse_opt_args(init, argc, argv);
150 // view_stack_push(&view_stack, *init->view);
151 View *view_sav = init->view;
152 init->view = nullptr;
153 View *view = nullptr;
154 view = nullptr;
155 view = new_view(init);
156
157 if (init->lines > 0 && init->cols > 0) {
158 ilines = init->lines;
159 icols = init->cols;
160 }
161 if (init->begy > 0 || init->begx > 0) {
162 by = init->begy;
163 bx = init->begx;
164 }
165 view->begy = by;
166 view->begx = bx;
167 view->lines = ilines;
168 view->cols = icols;
169 view->f_full_screen = false;
170 if (!init_view_boxwin(init))
171 rc = view_file(init);
172 destroy_view(init);
173 init->view = view_sav;
174 // view_stack_pop(&view_stack, init->view);
175 return rc;
176}
View * view
Definition mem.c:38
int init_view_boxwin(Init *init)
Initialize the C-Menu View in box window mode.
Definition init_view.c:147
View * destroy_view(Init *init)
Destroy View structure.
Definition mem.c:345
View * new_view(Init *init)
Create and initialize View structure.
Definition mem.c:299
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:189
int lines
Definition common.h:115
Definition view.h:61

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: