13515Sache/*
23515Sache *  dialog.h -- common declarations for all dialog modules
33515Sache *
43515Sache *  AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
53515Sache *
63515Sache *  This program is free software; you can redistribute it and/or
73515Sache *  modify it under the terms of the GNU General Public License
83515Sache *  as published by the Free Software Foundation; either version 2
93515Sache *  of the License, or (at your option) any later version.
103515Sache *
113515Sache *  This program is distributed in the hope that it will be useful,
123515Sache *  but WITHOUT ANY WARRANTY; without even the implied warranty of
133515Sache *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
143515Sache *  GNU General Public License for more details.
153515Sache *
163515Sache *  You should have received a copy of the GNU General Public License
173515Sache *  along with this program; if not, write to the Free Software
183515Sache *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
193515Sache */
203515Sache
213515Sache
223515Sache#include <sys/types.h>
233515Sache#include <fcntl.h>
243515Sache#include <unistd.h>
253515Sache#include <ctype.h>
263515Sache#include <stdlib.h>
273515Sache#include <string.h>
2850631Speter#include <termios.h>
293515Sache
303515Sache#if defined(LOCALE)
313515Sache#include <locale.h>
323515Sache#endif
333515Sache
3412983Sjkh
353515Sache/*
363515Sache * Change these if you want
373515Sache */
383515Sache#define USE_SHADOW TRUE
393515Sache#define USE_COLORS TRUE
403515Sache
413515Sache#define ESC 27
423515Sache#define TAB 9
433515Sache#define BUF_SIZE (10*1024)
446458Sache
456458Sache#ifndef MIN
463515Sache#define MIN(x,y) (x < y ? x : y)
476458Sache#endif
486458Sache#ifndef MAX
493515Sache#define MAX(x,y) (x > y ? x : y)
506458Sache#endif
513515Sache
526458Sache#ifndef ctrl
536458Sache#define ctrl(a)          ((a) - 'a' + 1)
548858Srgrimes#endif
556458Sache
563515Sache#ifndef HAVE_NCURSES
573515Sache#ifndef ACS_ULCORNER
583515Sache#define ACS_ULCORNER '+'
593515Sache#endif
603515Sache#ifndef ACS_LLCORNER
613515Sache#define ACS_LLCORNER '+'
623515Sache#endif
633515Sache#ifndef ACS_URCORNER
643515Sache#define ACS_URCORNER '+'
653515Sache#endif
663515Sache#ifndef ACS_LRCORNER
673515Sache#define ACS_LRCORNER '+'
683515Sache#endif
693515Sache#ifndef ACS_HLINE
703515Sache#define ACS_HLINE '-'
713515Sache#endif
723515Sache#ifndef ACS_VLINE
733515Sache#define ACS_VLINE '|'
743515Sache#endif
753515Sache#ifndef ACS_LTEE
763515Sache#define ACS_LTEE '+'
773515Sache#endif
783515Sache#ifndef ACS_RTEE
793515Sache#define ACS_RTEE '+'
803515Sache#endif
813515Sache#ifndef ACS_UARROW
823515Sache#define ACS_UARROW '^'
833515Sache#endif
843515Sache#ifndef ACS_DARROW
853515Sache#define ACS_DARROW 'v'
863515Sache#endif
873515Sache#endif    /* HAVE_NCURSES */
883515Sache
8921790Sjkh/* Travel key conventions */
9021790Sjkh#define KEY_IS_UP(key)		((key) == KEY_UP || (key) == '-' || key == '\020' /* ^P */)
9121790Sjkh#define KEY_IS_DOWN(key)	((key) == KEY_DOWN || (key) == '+' || key == '\016' /* ^N */)
9221790Sjkh
933515Sache/*
943515Sache * Global variables
953515Sache */
963515Sache#ifdef __DIALOG_MAIN__
973515Sache
983515Sache#ifdef HAVE_NCURSES
993515Sache
1003515Sache/* use colors by default? */
1013515Sachebool use_colors = USE_COLORS;
1023515Sache
1033515Sache/* shadow dialog boxes by default?
1043515Sache   Note that 'use_shadow' implies 'use_colors' */
1053515Sachebool use_shadow = USE_SHADOW;
1063515Sache
1073515Sache#endif
1083515Sache
1093515Sache
1108858Srgrimes/*
1113515Sache * Attribute values, default is for mono display
1123515Sache */
1133515Sachechtype attributes[] = {
1143515Sache  A_NORMAL,       /* screen_attr */
1153515Sache  A_NORMAL,       /* shadow_attr */
1163515Sache  A_REVERSE,      /* dialog_attr */
1173515Sache  A_REVERSE,      /* title_attr */
1183515Sache  A_REVERSE,      /* border_attr */
1193515Sache  A_BOLD,         /* button_active_attr */
1203515Sache  A_DIM,          /* button_inactive_attr */
1213515Sache  A_UNDERLINE,    /* button_key_active_attr */
1223515Sache  A_UNDERLINE,    /* button_key_inactive_attr */
1233515Sache  A_NORMAL,       /* button_label_active_attr */
1243515Sache  A_NORMAL,       /* button_label_inactive_attr */
1253515Sache  A_REVERSE,      /* inputbox_attr */
1263515Sache  A_REVERSE,      /* inputbox_border_attr */
1273515Sache  A_REVERSE,      /* searchbox_attr */
1283515Sache  A_REVERSE,      /* searchbox_title_attr */
1293515Sache  A_REVERSE,      /* searchbox_border_attr */
1303515Sache  A_REVERSE,      /* position_indicator_attr */
1313515Sache  A_REVERSE,      /* menubox_attr */
1323515Sache  A_REVERSE,      /* menubox_border_attr */
1333515Sache  A_REVERSE,      /* item_attr */
1343515Sache  A_NORMAL,       /* item_selected_attr */
1353515Sache  A_REVERSE,      /* tag_attr */
1363515Sache  A_REVERSE,      /* tag_selected_attr */
1373515Sache  A_NORMAL,       /* tag_key_attr */
1383515Sache  A_BOLD,         /* tag_key_selected_attr */
1393515Sache  A_REVERSE,      /* check_attr */
1403515Sache  A_REVERSE,      /* check_selected_attr */
1413515Sache  A_REVERSE,      /* uarrow_attr */
1423515Sache  A_REVERSE       /* darrow_attr */
1433515Sache};
1443515Sache
1453515Sache#else
1463515Sache
1473515Sache#ifdef HAVE_NCURSES
1483515Sacheextern bool use_colors;
1493515Sache#endif
1503515Sache
1513515Sache#endif    /* __DIALOG_MAIN__ */
1523515Sache
1533515Sache
1543515Sache
1553515Sache#ifdef HAVE_NCURSES
1563515Sache
1573515Sache/*
1583515Sache * Function prototypes
1593515Sache */
1603515Sache#ifdef __DIALOG_MAIN__
1613515Sache
1623515Sacheextern int parse_rc(void);
1633515Sache
1643515Sache#endif    /* __DIALOG_MAIN__ */
1653515Sache
1663515Sache#endif
1673515Sache
1683515Sache
1693515Sache#ifdef HAVE_NCURSES
1703515Sachevoid color_setup(void);
1713515Sache#endif
17212983Sjkh
1733515Sachevoid attr_clear(WINDOW *win, int height, int width, chtype attr);
17412983Sjkhvoid print_autowrap(WINDOW *win, unsigned char *prompt, int height, int width, int maxwidth,
17512983Sjkh		    int y, int x, int center, int rawmode);
1763515Sachevoid print_button(WINDOW *win, unsigned char *label, int y, int x, int selected);
1773950SacheFILE *raw_popen(const char *program, char * const *argv, const char *type);
1783950Sacheint raw_pclose(FILE *iop);
1796458Sachevoid display_helpfile(void);
1806458Sachevoid display_helpline(WINDOW *w, int y, int width);
18112983Sjkhvoid print_arrows(WINDOW *dialog, int scroll, int menu_height, int item_no, int box_x,
18212983Sjkh		  int box_y, int tag_x, int cur_x, int cur_y);
1836818Sache
184