162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (C) 2008 Nir Tzachar <nir.tzachar@gmail.com> 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Derived from menuconfig. 662306a36Sopenharmony_ci */ 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#include <ctype.h> 962306a36Sopenharmony_ci#include <errno.h> 1062306a36Sopenharmony_ci#include <fcntl.h> 1162306a36Sopenharmony_ci#include <limits.h> 1262306a36Sopenharmony_ci#include <stdarg.h> 1362306a36Sopenharmony_ci#include <stdlib.h> 1462306a36Sopenharmony_ci#include <string.h> 1562306a36Sopenharmony_ci#include <unistd.h> 1662306a36Sopenharmony_ci#include <ncurses.h> 1762306a36Sopenharmony_ci#include <menu.h> 1862306a36Sopenharmony_ci#include <panel.h> 1962306a36Sopenharmony_ci#include <form.h> 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci#include <stdio.h> 2262306a36Sopenharmony_ci#include <time.h> 2362306a36Sopenharmony_ci#include <sys/time.h> 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci#define max(a, b) ({\ 2662306a36Sopenharmony_ci typeof(a) _a = a;\ 2762306a36Sopenharmony_ci typeof(b) _b = b;\ 2862306a36Sopenharmony_ci _a > _b ? _a : _b; }) 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci#define min(a, b) ({\ 3162306a36Sopenharmony_ci typeof(a) _a = a;\ 3262306a36Sopenharmony_ci typeof(b) _b = b;\ 3362306a36Sopenharmony_ci _a < _b ? _a : _b; }) 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ciextern int attr_normal; 3662306a36Sopenharmony_ciextern int attr_main_heading; 3762306a36Sopenharmony_ciextern int attr_main_menu_box; 3862306a36Sopenharmony_ciextern int attr_main_menu_fore; 3962306a36Sopenharmony_ciextern int attr_main_menu_back; 4062306a36Sopenharmony_ciextern int attr_main_menu_grey; 4162306a36Sopenharmony_ciextern int attr_main_menu_heading; 4262306a36Sopenharmony_ciextern int attr_scrollwin_text; 4362306a36Sopenharmony_ciextern int attr_scrollwin_heading; 4462306a36Sopenharmony_ciextern int attr_scrollwin_box; 4562306a36Sopenharmony_ciextern int attr_dialog_text; 4662306a36Sopenharmony_ciextern int attr_dialog_menu_fore; 4762306a36Sopenharmony_ciextern int attr_dialog_menu_back; 4862306a36Sopenharmony_ciextern int attr_dialog_box; 4962306a36Sopenharmony_ciextern int attr_input_box; 5062306a36Sopenharmony_ciextern int attr_input_heading; 5162306a36Sopenharmony_ciextern int attr_input_text; 5262306a36Sopenharmony_ciextern int attr_input_field; 5362306a36Sopenharmony_ciextern int attr_function_text; 5462306a36Sopenharmony_ciextern int attr_function_highlight; 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_citypedef enum { 5762306a36Sopenharmony_ci F_HELP = 1, 5862306a36Sopenharmony_ci F_SYMBOL = 2, 5962306a36Sopenharmony_ci F_INSTS = 3, 6062306a36Sopenharmony_ci F_CONF = 4, 6162306a36Sopenharmony_ci F_BACK = 5, 6262306a36Sopenharmony_ci F_SAVE = 6, 6362306a36Sopenharmony_ci F_LOAD = 7, 6462306a36Sopenharmony_ci F_SEARCH = 8, 6562306a36Sopenharmony_ci F_EXIT = 9, 6662306a36Sopenharmony_ci} function_key; 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_civoid set_colors(void); 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_citypedef int (*extra_key_cb_fn)(int, size_t, size_t, void *); 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci/* this changes the windows attributes !!! */ 7362306a36Sopenharmony_civoid print_in_middle(WINDOW *win, int y, int width, const char *str, int attrs); 7462306a36Sopenharmony_ciint get_line_length(const char *line); 7562306a36Sopenharmony_ciint get_line_no(const char *text); 7662306a36Sopenharmony_ciconst char *get_line(const char *text, int line_no); 7762306a36Sopenharmony_civoid fill_window(WINDOW *win, const char *text); 7862306a36Sopenharmony_ciint btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...); 7962306a36Sopenharmony_ciint dialog_inputbox(WINDOW *main_window, 8062306a36Sopenharmony_ci const char *title, const char *prompt, 8162306a36Sopenharmony_ci const char *init, char **resultp, int *result_len); 8262306a36Sopenharmony_civoid refresh_all_windows(WINDOW *main_window); 8362306a36Sopenharmony_ciint show_scroll_win_ext(WINDOW *main_window, const char *title, char *text, 8462306a36Sopenharmony_ci int *vscroll, int *hscroll, 8562306a36Sopenharmony_ci extra_key_cb_fn extra_key_cb, void *data); 8662306a36Sopenharmony_civoid show_scroll_win(WINDOW *main_window, 8762306a36Sopenharmony_ci const char *title, 8862306a36Sopenharmony_ci const char *text); 89