MCPcopy Create free account
hub / github.com/Entware/Entware / dialog_textbox

Function dialog_textbox

scripts/config/lxdialog/textbox.c:151–358  ·  view source on GitHub ↗

* Display text from a file in a dialog box. * * keys is a null-terminated array */

Source from the content-addressed store, hash-verified

149 * keys is a null-terminated array
150 */
151int dialog_textbox(const char *title, const char *tbuf, int initial_height,
152 int initial_width, int *_vscroll, int *_hscroll,
153 int (*extra_key_cb)(int, size_t, size_t, void *), void *data)
154{
155 int i, x, y, cur_x, cur_y, key = 0;
156 int height, width, boxh, boxw;
157 WINDOW *dialog, *box;
158 bool done = false;
159
160 begin_reached = 1;
161 end_reached = 0;
162 page_length = 0;
163 hscroll = 0;
164 buf = tbuf;
165 page = buf; /* page is pointer to start of page to be displayed */
166
167 if (_vscroll && *_vscroll) {
168 begin_reached = 0;
169
170 for (i = 0; i < *_vscroll; i++)
171 get_line();
172 }
173 if (_hscroll)
174 hscroll = *_hscroll;
175
176do_resize:
177 getmaxyx(stdscr, height, width);
178 if (height < TEXTBOX_HEIGTH_MIN || width < TEXTBOX_WIDTH_MIN)
179 return -ERRDISPLAYTOOSMALL;
180 if (initial_height != 0)
181 height = initial_height;
182 else
183 if (height > 4)
184 height -= 4;
185 else
186 height = 0;
187 if (initial_width != 0)
188 width = initial_width;
189 else
190 if (width > 5)
191 width -= 5;
192 else
193 width = 0;
194
195 /* center dialog box on screen */
196 x = (getmaxx(stdscr) - width) / 2;
197 y = (getmaxy(stdscr) - height) / 2;
198
199 draw_shadow(stdscr, y, x, height, width);
200
201 dialog = newwin(height, width, y, x);
202 keypad(dialog, TRUE);
203
204 /* Create window for box region, used for scrolling text */
205 boxh = height - 4;
206 boxw = width - 2;
207 box = subwin(dialog, boxh, boxw, y + 1, x + 1);
208 wattrset(box, dlg.dialog.atr);

Callers 1

show_textbox_extFunction · 0.85

Calls 10

draw_shadowFunction · 0.85
draw_boxFunction · 0.85
print_titleFunction · 0.85
print_buttonFunction · 0.85
attr_clearFunction · 0.85
refresh_text_boxFunction · 0.85
back_linesFunction · 0.85
on_key_escFunction · 0.85
on_key_resizeFunction · 0.85
get_lineFunction · 0.70

Tested by

no test coverage detected