C-Menu 0.2.9
A User Interface Toolkit
Loading...
Searching...
No Matches
popups.c
Go to the documentation of this file.
1#include "common.h"
2
3int popup_menu(Init *, int, char **, int, int);
4int popup_form(Init *, int, char **, int, int);
5int popup_pick(Init *, int, char **, int, int);
6int popup_view(Init *, int, char **, int, int, int, int);
7
8int popup_menu(Init *init, int argc, char **argv, int begy, int begx) {
9 int rc;
11 parse_opt_args(init, argc, argv);
12 Menu *sav_menu = init->menu;
13 init->menu = NULL;
14 new_menu(init, init->argc, init->argv, begy, begx);
15 rc = menu_engine(init);
17 init->menu = sav_menu;
18 return rc;
19}
20
21int popup_pick(Init *init, int argc, char **argv, int begy, int begx) {
22 int rc;
24 parse_opt_args(init, argc, argv);
25 Pick *sav_pick = init->pick;
26 init->pick = NULL;
27 new_pick(init, init->argc, init->argv, begy, begx);
28 rc = init_pick(init, init->argc, init->argv, begy, begx);
30 init->pick = sav_pick;
31 return rc;
32}
33
34int popup_form(Init *init, int argc, char **argv, int begy, int begx) {
35 int rc;
37 parse_opt_args(init, argc, argv);
38 Form *sav_form = init->form;
39 init->form = NULL;
40 new_form(init, init->argc, init->argv, begy, begx);
41 rc = init_form(init, init->argc, init->argv, begy, begx);
43 init->form = sav_form;
44 return rc;
45}
46
47int popup_view(Init *init, int argc, char **argv, int lines, int cols, int begy,
48 int begx) {
49 int rc = 0;
51 parse_opt_args(init, argc, argv);
52 View *sav_view = init->view;
53 init->view = NULL;
54 view = NULL;
55 if (!view)
56 view = new_view(init);
57 else
58 view = init->view;
59 if (lines > 0)
60 view->lines = lines;
61 if (cols > 0)
62 view->cols = cols;
63 if (begy > 0)
64 view->begy = begy;
65 if (begx > 0)
66 view->begx = begx;
67 if (init->lines != 0 && view->lines == 0)
68 view->lines = init->lines;
69 if (view->lines == 0)
70 view->lines = LINES * 3 / 4;
71 if (view->lines > LINES - 3)
72 view->lines = LINES - 3;
73 if (init->cols != 0 && view->lines == 0)
74 view->cols = init->cols;
75 if (view->cols == 0)
76 view->cols = COLS * 3 / 4;
77 if (view->cols > COLS - 3)
78 view->cols = COLS - 3;
79 if (init->begy != 0 && view->begy == 0)
80 view->begy = init->begy;
81 if (view->begy == 0)
82 view->begy = (LINES - view->lines) / 5;
83 if (view->begy + view->lines > LINES - 2)
84 view->begy = LINES - view->lines - 2;
85 if (init->begx != 0 && view->begx == 0)
86 view->begx = init->begx;
87 if (view->begx == 0)
88 view->begx = (COLS - view->cols) / 5;
89 if (view->begx + view->cols > COLS - 1)
90 view->begx = COLS - view->cols - 1;
91 view->f_full_screen = false;
92 if (!init_view_boxwin(init, init->title)) {
93 rc = view_file(init);
95 }
97 init->view = sav_view;
98 return rc;
99}
int popup_form(Init *, int, char **, int, int)
Definition popups.c:34
int popup_menu(Init *, int, char **, int, int)
Definition popups.c:8
int popup_view(Init *, int, char **, int, int, int, int)
Definition popups.c:47
int parse_opt_args(Init *, int, char **)
Definition init.c:393
int popup_pick(Init *, int, char **, int, int)
Definition popups.c:21
View * view
Definition mem.c:48
WINDOW * win_del()
Delete the current window and its associated box window.
Definition dwin.c:902
int init_form(Init *, int, char **, int, int)
Initialize form data structure and parse description file.
Definition form_engine.c:59
void zero_opt_args(Init *)
Initialize optional arguments in the Init struct to default values.
Definition init.c:408
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
Form * new_form(Init *, int, char **, int, int)
Create and initialize Form structure.
Definition mem.c:253
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
Form * destroy_form(Init *init)
Destroy Form structure.
Definition mem.c:276
View * new_view(Init *)
Create and initialize View structure.
Definition mem.c:300
Pick * new_pick(Init *, int, char **, int, int)
Create and initialize Pick structure.
Definition mem.c:200
Pick * destroy_pick(Init *init)
Destroy Pick structure.
Definition mem.c:230
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
int view_file(Init *)
Start view.
char title[MAXLEN]
Definition common.h:123
int begx
Definition common.h:112
Form * form
Definition common.h:174
int argc
Definition common.h:124
int cols
Definition common.h:110
int begy
Definition common.h:111
View * view
Definition common.h:178
Menu * menu
Definition common.h:172
char ** argv
Definition common.h:125
int lines
Definition common.h:109
Pick * pick
Definition common.h:176
int cols
Definition view.h:49
bool f_full_screen
Definition view.h:86
int lines
Definition view.h:48
int begy
Definition view.h:50
int begx
Definition view.h:51