blob: fa5245eb93a75358b3427f5d5224020fbe1e1fd9 [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
35typedef enum {
36 NORMAL = 1,
37 MAIN_HEADING,
38 MAIN_MENU_BOX,
39 MAIN_MENU_FORE,
40 MAIN_MENU_BACK,
41 MAIN_MENU_GREY,
42 MAIN_MENU_HEADING,
43 SCROLLWIN_TEXT,
44 SCROLLWIN_HEADING,
45 SCROLLWIN_BOX,
46 DIALOG_TEXT,
47 DIALOG_MENU_FORE,
48 DIALOG_MENU_BACK,
49 DIALOG_BOX,
50 INPUT_BOX,
51 INPUT_HEADING,
52 INPUT_TEXT,
53 INPUT_FIELD,
54 FUNCTION_TEXT,
55 FUNCTION_HIGHLIGHT,
56 ATTR_MAX
57} attributes_t;
58extern attributes_t attributes[];
59
60typedef enum {
61 F_HELP = 1,
62 F_SYMBOL = 2,
63 F_INSTS = 3,
64 F_CONF = 4,
65 F_BACK = 5,
66 F_SAVE = 6,
67 F_LOAD = 7,
Nir Tzachara72f3e22010-08-08 16:50:06 +030068 F_SEARCH = 8,
69 F_EXIT = 9,
nir.tzachar@gmail.com692d97c2009-11-25 12:28:43 +020070} function_key;
71
72void set_colors(void);
73
74/* this changes the windows attributes !!! */
75void print_in_middle(WINDOW *win,
76 int starty,
77 int startx,
78 int width,
79 const char *string,
80 chtype color);
81int get_line_length(const char *line);
82int get_line_no(const char *text);
83const char *get_line(const char *text, int line_no);
84void fill_window(WINDOW *win, const char *text);
85int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...);
86int dialog_inputbox(WINDOW *main_window,
87 const char *title, const char *prompt,
Cheng Renquan5ea9f642011-09-01 10:52:20 -070088 const char *init, char **resultp, int *result_len);
nir.tzachar@gmail.com692d97c2009-11-25 12:28:43 +020089void refresh_all_windows(WINDOW *main_window);
90void show_scroll_win(WINDOW *main_window,
91 const char *title,
92 const char *text);