1 /*
2  * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
3  *
4  *     This program is free software; you can redistribute it and/or modify
5  *     it under the terms of the GNU General Public License as published by
6  *     the Free Software Foundation; either version 2 of the License, or
7  *     (at your option) any later version.
8  *
9  *     This program is distributed in the hope that it will be useful,
10  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *     GNU General Public License for more details.
13  *
14  *     You should have received a copy of the GNU General Public License
15  *     along with this program; if not, write to the Free Software
16  *     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18 
19 /*
20  * This file is named mutt_menu.h so it doesn't collide with ncurses menu.h
21  */
22 
23 #ifndef _MUTT_MENU_H_
24 #define _MUTT_MENU_H_ 1
25 
26 #include "keymap.h"
27 #include "mutt_regex.h"
28 
29 #define REDRAW_INDEX		(1)
30 #define REDRAW_MOTION		(1<<1)
31 #define REDRAW_MOTION_RESYNCH	(1<<2)
32 #define REDRAW_CURRENT		(1<<3)
33 #define REDRAW_STATUS		(1<<4)
34 #define REDRAW_FULL		(1<<5)
35 #define REDRAW_BODY		(1<<6)
36 #define REDRAW_SIGWINCH		(1<<7)
37 
38 #define M_MODEFMT "-- Mutt: %s"
39 
40 typedef struct menu_t
41 {
42   char *title;   /* the title of this menu */
43   char *help;    /* quickref for the current menu */
44   void *data;    /* extra data for the current menu */
45   int current;   /* current entry */
46   int max;       /* the number of entries in the menu */
47   int redraw;	/* when to redraw the screen */
48   int menu;	/* menu definition for keymap entries. */
49   int offset;	/* which screen row to start the index */
50   int pagelen;	/* number of entries per screen */
51   int tagprefix;
52 
53   /* Setting dialog != NULL overrides normal menu behaviour.
54    * In dialog mode menubar is hidden and prompt keys are checked before
55    * normal menu movement keys. This can cause problems with scrolling, if
56    * prompt keys override movement keys.
57    */
58   char **dialog;	/* dialog lines themselves */
59   char *prompt;		/* prompt for user, similar to mutt_multi_choice */
60   char *keys;		/* keys used in the prompt */
61 
62   /* callback to generate an index line for the requested element */
63   void (*make_entry) (char *, size_t, struct menu_t *, int);
64 
65   /* how to search the menu */
66   int (*search) (struct menu_t *, regex_t *re, int n);
67 
68   int (*tag) (struct menu_t *, int i, int m);
69 
70   /* color pair to be used for the requested element
71    * (default function returns ColorDefs[MT_COLOR_NORMAL])
72    */
73   int (*color) (int i);
74 
75   /* the following are used only by mutt_menuLoop() */
76   int top;		/* entry that is the top of the current page */
77   int oldcurrent;	/* for driver use only. */
78   int searchDir;	/* direction of search */
79   int tagged;		/* number of tagged entries */
80 } MUTTMENU;
81 
82 void mutt_menu_init (void);
83 void menu_jump (MUTTMENU *);
84 void menu_redraw_full (MUTTMENU *);
85 void menu_redraw_index (MUTTMENU *);
86 void menu_redraw_status (MUTTMENU *);
87 void menu_redraw_motion (MUTTMENU *);
88 void menu_redraw_current (MUTTMENU *);
89 int  menu_redraw (MUTTMENU *);
90 void menu_first_entry (MUTTMENU *);
91 void menu_last_entry (MUTTMENU *);
92 void menu_top_page (MUTTMENU *);
93 void menu_bottom_page (MUTTMENU *);
94 void menu_middle_page (MUTTMENU *);
95 void menu_next_page (MUTTMENU *);
96 void menu_prev_page (MUTTMENU *);
97 void menu_next_line (MUTTMENU *);
98 void menu_prev_line (MUTTMENU *);
99 void menu_half_up (MUTTMENU *);
100 void menu_half_down (MUTTMENU *);
101 void menu_current_top (MUTTMENU *);
102 void menu_current_middle (MUTTMENU *);
103 void menu_current_bottom (MUTTMENU *);
104 void menu_check_recenter (MUTTMENU *);
105 void menu_status_line (char *, size_t, MUTTMENU *, const char *);
106 
107 MUTTMENU *mutt_new_menu (int);
108 void mutt_menuDestroy (MUTTMENU **);
109 int mutt_menuLoop (MUTTMENU *);
110 
111 /* used in both the index and pager index to make an entry. */
112 void index_make_entry (char *, size_t, struct menu_t *, int);
113 int index_color (int);
114 
115 #endif /* _MUTT_MENU_H_ */
116