blob: 6f925bc74eb3d0d05283f7bb4b9f9ee8eb25d033 [file] [log] [blame]
Masahiro Yamada0c874102018-12-18 21:13:35 +09001/* SPDX-License-Identifier: GPL-2.0 */
nir.tzachar@gmail.com692d97c2009-11-25 12:28:43 +02002/*
Masahiro Yamada0c874102018-12-18 21:13:35 +09003 * Copyright (C) 2008 Nir Tzachar <nir.tzachar@gmail.com>
nir.tzachar@gmail.com692d97c2009-11-25 12:28:43 +02004 *
5 * Derived from menuconfig.
nir.tzachar@gmail.com692d97c2009-11-25 12:28:43 +02006 */
7
8#include <ctype.h>
9#include <errno.h>
10#include <fcntl.h>
11#include <limits.h>
12#include <stdarg.h>
13#include <stdlib.h>
14#include <string.h>
15#include <unistd.h>
Masahiro Yamada26561512018-03-15 15:25:27 +090016#include <ncurses.h>
nir.tzachar@gmail.com692d97c2009-11-25 12:28:43 +020017#include <menu.h>
18#include <panel.h>
19#include <form.h>
20
21#include <stdio.h>
22#include <time.h>
23#include <sys/time.h>
24
nir.tzachar@gmail.com692d97c2009-11-25 12:28:43 +020025#define max(a, b) ({\
26 typeof(a) _a = a;\
27 typeof(b) _b = b;\
28 _a > _b ? _a : _b; })
29
30#define min(a, b) ({\
31 typeof(a) _a = a;\
32 typeof(b) _b = b;\
33 _a < _b ? _a : _b; })
34
Masahiro Yamada93487b12021-04-11 04:45:34 +090035extern int attr_normal;
36extern int attr_main_heading;
37extern int attr_main_menu_box;
38extern int attr_main_menu_fore;
39extern int attr_main_menu_back;
40extern int attr_main_menu_grey;
41extern int attr_main_menu_heading;
42extern int attr_scrollwin_text;
43extern int attr_scrollwin_heading;
44extern int attr_scrollwin_box;
45extern int attr_dialog_text;
46extern int attr_dialog_menu_fore;
47extern int attr_dialog_menu_back;
48extern int attr_dialog_box;
49extern int attr_input_box;
50extern int attr_input_heading;
51extern int attr_input_text;
52extern int attr_input_field;
53extern int attr_function_text;
54extern int attr_function_highlight;
nir.tzachar@gmail.com692d97c2009-11-25 12:28:43 +020055
56typedef enum {
57 F_HELP = 1,
58 F_SYMBOL = 2,
59 F_INSTS = 3,
60 F_CONF = 4,
61 F_BACK = 5,
62 F_SAVE = 6,
63 F_LOAD = 7,
Nir Tzachara72f3e22010-08-08 16:50:06 +030064 F_SEARCH = 8,
65 F_EXIT = 9,
nir.tzachar@gmail.com692d97c2009-11-25 12:28:43 +020066} function_key;
67
68void set_colors(void);
69
70/* this changes the windows attributes !!! */
Masahiro Yamada08718742021-04-12 10:12:27 +090071void print_in_middle(WINDOW *win, int y, int width, const char *str, int attrs);
nir.tzachar@gmail.com692d97c2009-11-25 12:28:43 +020072int get_line_length(const char *line);
73int get_line_no(const char *text);
74const char *get_line(const char *text, int line_no);
75void fill_window(WINDOW *win, const char *text);
76int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...);
77int dialog_inputbox(WINDOW *main_window,
78 const char *title, const char *prompt,
Cheng Renquan5ea9f642011-09-01 10:52:20 -070079 const char *init, char **resultp, int *result_len);
nir.tzachar@gmail.com692d97c2009-11-25 12:28:43 +020080void refresh_all_windows(WINDOW *main_window);
81void show_scroll_win(WINDOW *main_window,
82 const char *title,
83 const char *text);