using stls should not enable new CAPAs
[apps/madmutt.git] / lib-ui / menu.h
1 /*
2  * Copyright notice from original mutt:
3  * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
4  *
5  * This file is part of mutt-ng, see http://www.muttng.org/.
6  * It's licensed under the GNU General Public License,
7  * please see the file GPL in the top level source directory.
8  */
9 #ifndef _MUTT_MENU_H
10 #define _MUTT_MENU_H
11
12 #include <lib-lib/lib-lib.h>
13
14 #include "keymap.h"
15
16 #define REDRAW_INDEX            (1)
17 #define REDRAW_MOTION           (1<<1)
18 #define REDRAW_MOTION_RESYNCH   (1<<2)
19 #define REDRAW_CURRENT          (1<<3)
20 #define REDRAW_STATUS           (1<<4)
21 #define REDRAW_FULL             (1<<5)
22 #define REDRAW_BODY             (1<<6)
23 #define REDRAW_SIGWINCH         (1<<7)
24 #define REDRAW_SIDEBAR          (1<<8)
25
26 #define M_MODEFMT "-- Madmutt: %s"
27
28 typedef struct menu_t {
29   const char *title;            /* the title of this menu */
30   void *data;                   /* extra data for the current menu */
31   int current;                  /* current entry */
32   int max;                      /* the number of entries in the menu */
33   int redraw;                   /* when to redraw the screen */
34   int menu;                     /* menu definition for keymap entries. */
35   int offset;                   /* which screen row to start the index */
36   int pagelen;                  /* number of entries per screen */
37   int tagprefix;
38
39   /* Setting dialog != NULL overrides normal menu behaviour. 
40    * In dialog mode menubar is hidden and prompt keys are checked before
41    * normal menu movement keys. This can cause problems with scrolling, if 
42    * prompt keys override movement keys.
43    */
44   char **dialog;                /* dialog lines themselves */
45   const char *prompt;           /* prompt for user, similar to mutt_multi_choice */
46   const char *keys;             /* keys used in the prompt */
47
48   /* callback to generate an index line for the requested element */
49   void (*make_entry) (char *, ssize_t, struct menu_t *, int);
50
51   /* how to search the menu */
52   int (*search) (struct menu_t *, regex_t * re, int n);
53
54   int (*tag) (struct menu_t *, int i, int m);
55
56   /* color pair to be used for the requested element 
57    * (default function returns ColorDefs[MT_COLOR_NORMAL])
58    */
59   int (*color) (int i);
60
61   /* the following are used only by mutt_menuLoop() */
62   int top;                      /* entry that is the top of the current page */
63   int oldcurrent;               /* for driver use only. */
64   char *searchBuf;              /* last search pattern */
65   int searchDir;                /* direction of search */
66   int tagged;                   /* number of tagged entries */
67 } MUTTMENU;
68
69 void menu_jump (MUTTMENU *);
70 void menu_redraw_full (MUTTMENU *);
71 void menu_redraw_index (MUTTMENU *);
72 void menu_redraw_status (MUTTMENU *);
73 void menu_redraw_motion (MUTTMENU *);
74 void menu_redraw_current (MUTTMENU *);
75 int menu_redraw (MUTTMENU *);
76 void menu_first_entry (MUTTMENU *);
77 void menu_last_entry (MUTTMENU *);
78 void menu_top_page (MUTTMENU *);
79 void menu_bottom_page (MUTTMENU *);
80 void menu_middle_page (MUTTMENU *);
81 void menu_next_page (MUTTMENU *);
82 void menu_prev_page (MUTTMENU *);
83 void menu_next_line (MUTTMENU *);
84 void menu_prev_line (MUTTMENU *);
85 void menu_half_up (MUTTMENU *);
86 void menu_half_down (MUTTMENU *);
87 void menu_current_top (MUTTMENU *);
88 void menu_current_middle (MUTTMENU *);
89 void menu_current_bottom (MUTTMENU *);
90 void menu_check_recenter (MUTTMENU *);
91 void menu_status_line (char *, ssize_t, MUTTMENU *, const char *);
92
93 MUTTMENU *mutt_new_menu (void);
94 void mutt_menuDestroy (MUTTMENU **);
95 int mutt_menuLoop (MUTTMENU *);
96
97 /* used in both the index and pager index to make an entry. */
98 void index_make_entry (char *, ssize_t, struct menu_t *, int);
99 int index_color (int);
100
101 #endif /* !_MUTT_MENU_H */