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