projects
/
apps
/
madmutt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Andreas Krennmair:
[apps/madmutt.git]
/
menu.c
diff --git
a/menu.c
b/menu.c
index
ecb8117
..
15eccce
100644
(file)
--- a/
menu.c
+++ b/
menu.c
@@
-16,10
+16,15
@@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*/
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*/
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include "mutt.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
#include "mbyte.h"
#include "mutt.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
#include "mbyte.h"
+#include "sidebar.h"
#ifdef USE_IMAP
#include "imap.h"
#ifdef USE_IMAP
#include "imap.h"
@@
-38,7
+43,6
@@
static void print_enriched_string (int attr, unsigned char *s, int do_color)
size_t k;
size_t n = mutt_strlen ((char *)s);
mbstate_t mbstate;
size_t k;
size_t n = mutt_strlen ((char *)s);
mbstate_t mbstate;
- short f1, f2, b1, b2;
memset (&mbstate, 0, sizeof (mbstate));
while (*s)
memset (&mbstate, 0, sizeof (mbstate));
while (*s)
@@
-46,12
+50,7
@@
static void print_enriched_string (int attr, unsigned char *s, int do_color)
if (*s < M_TREE_MAX)
{
if (do_color)
if (*s < M_TREE_MAX)
{
if (do_color)
- {
- pair_content(PAIR_NUMBER(ColorDefs[MT_COLOR_TREE]), &f1, &b1);
- pair_content(PAIR_NUMBER(attr), &f2, &b2);
- if (b1 == b2)
- SETCOLOR (MT_COLOR_TREE);
- }
+ SETCOLOR (MT_COLOR_TREE);
while (*s && *s < M_TREE_MAX)
{
switch (*s)
while (*s && *s < M_TREE_MAX)
{
switch (*s)
@@
-159,10
+158,14
@@
static void menu_make_entry (char *s, int l, MUTTMENU *menu, int i)
void menu_pad_string (char *s, size_t n)
{
int shift = option (OPTARROWCURSOR) ? 3 : 0;
void menu_pad_string (char *s, size_t n)
{
int shift = option (OPTARROWCURSOR) ? 3 : 0;
- int cols = COLS - shift;
+ int cols = COLS - shift - SidebarWidth;
+
+ char tmpbuf[n];
- mutt_format_string (s, n, cols, cols, 0, ' ', s, strlen (s), 1);
- s[n - 1] = 0;
+ mutt_format_string (tmpbuf, n, cols, cols, 0, ' ', s, strlen (s), 1);
+ tmpbuf[n - 1] = 0;
+
+ snprintf(s,n,"%s",tmpbuf); /* overkill */
}
void menu_redraw_full (MUTTMENU *menu)
}
void menu_redraw_full (MUTTMENU *menu)
@@
-209,6
+212,7
@@
void menu_redraw_index (MUTTMENU *menu)
char buf[STRING];
int i;
char buf[STRING];
int i;
+ draw_sidebar(1);
for (i = menu->top; i < menu->top + menu->pagelen; i++)
{
if (i < menu->max)
for (i = menu->top; i < menu->top + menu->pagelen; i++)
{
if (i < menu->max)
@@
-219,7
+223,7
@@
void menu_redraw_index (MUTTMENU *menu)
if (option (OPTARROWCURSOR))
{
attrset (menu->color (i));
if (option (OPTARROWCURSOR))
{
attrset (menu->color (i));
- CLEARLINE (i - menu->top + menu->offset);
+ CLEARLINE
_WIN
(i - menu->top + menu->offset);
if (i == menu->current)
{
if (i == menu->current)
{
@@
-230,7
+234,7
@@
void menu_redraw_index (MUTTMENU *menu)
addch (' ');
}
else
addch (' ');
}
else
- move (i - menu->top + menu->offset, 3);
+ move (i - menu->top + menu->offset,
SidebarWidth +
3);
print_enriched_string (menu->color(i), (unsigned char *) buf, 1);
SETCOLOR (MT_COLOR_NORMAL);
print_enriched_string (menu->color(i), (unsigned char *) buf, 1);
SETCOLOR (MT_COLOR_NORMAL);
@@
-245,14
+249,14
@@
void menu_redraw_index (MUTTMENU *menu)
BKGDSET (MT_COLOR_INDICATOR);
}
BKGDSET (MT_COLOR_INDICATOR);
}
- CLEARLINE (i - menu->top + menu->offset);
+ CLEARLINE
_WIN
(i - menu->top + menu->offset);
print_enriched_string (menu->color(i), (unsigned char *) buf, i != menu->current);
SETCOLOR (MT_COLOR_NORMAL);
BKGDSET (MT_COLOR_NORMAL);
}
}
else
print_enriched_string (menu->color(i), (unsigned char *) buf, i != menu->current);
SETCOLOR (MT_COLOR_NORMAL);
BKGDSET (MT_COLOR_NORMAL);
}
}
else
- CLEARLINE (i - menu->top + menu->offset);
+ CLEARLINE
_WIN
(i - menu->top + menu->offset);
}
menu->redraw = 0;
}
}
menu->redraw = 0;
}
@@
-267,7
+271,7
@@
void menu_redraw_motion (MUTTMENU *menu)
return;
}
return;
}
- move (menu->oldcurrent + menu->offset - menu->top,
0
);
+ move (menu->oldcurrent + menu->offset - menu->top,
SidebarWidth
);
SETCOLOR (MT_COLOR_NORMAL);
BKGDSET (MT_COLOR_NORMAL);
SETCOLOR (MT_COLOR_NORMAL);
BKGDSET (MT_COLOR_NORMAL);
@@
-282,13
+286,13
@@
void menu_redraw_motion (MUTTMENU *menu)
clrtoeol ();
menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
menu_pad_string (buf, sizeof (buf));
clrtoeol ();
menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
menu_pad_string (buf, sizeof (buf));
- move (menu->oldcurrent + menu->offset - menu->top, 3);
+ move (menu->oldcurrent + menu->offset - menu->top,
SidebarWidth +
3);
print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
SETCOLOR (MT_COLOR_NORMAL);
}
/* now draw it in the new location */
print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
SETCOLOR (MT_COLOR_NORMAL);
}
/* now draw it in the new location */
- move (menu->current + menu->offset - menu->top,
0
);
+ move (menu->current + menu->offset - menu->top,
SidebarWidth
);
attrset (menu->color (menu->current));
ADDCOLOR (MT_COLOR_INDICATOR);
addstr ("->");
attrset (menu->color (menu->current));
ADDCOLOR (MT_COLOR_INDICATOR);
addstr ("->");
@@
-309,7
+313,7
@@
void menu_redraw_motion (MUTTMENU *menu)
attrset (menu->color (menu->current));
ADDCOLOR (MT_COLOR_INDICATOR);
BKGDSET (MT_COLOR_INDICATOR);
attrset (menu->color (menu->current));
ADDCOLOR (MT_COLOR_INDICATOR);
BKGDSET (MT_COLOR_INDICATOR);
- CLEARLINE (menu->current - menu->top + menu->offset);
+ CLEARLINE
_WIN
(menu->current - menu->top + menu->offset);
print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
SETCOLOR (MT_COLOR_NORMAL);
BKGDSET (MT_COLOR_NORMAL);
print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
SETCOLOR (MT_COLOR_NORMAL);
BKGDSET (MT_COLOR_NORMAL);
@@
-321,7
+325,7
@@
void menu_redraw_current (MUTTMENU *menu)
{
char buf[STRING];
{
char buf[STRING];
- move (menu->current + menu->offset - menu->top,
0
);
+ move (menu->current + menu->offset - menu->top,
SidebarWidth
);
menu_make_entry (buf, sizeof (buf), menu, menu->current);
menu_pad_string (buf, sizeof (buf));
menu_make_entry (buf, sizeof (buf), menu, menu->current);
menu_pad_string (buf, sizeof (buf));
@@
-373,32
+377,37
@@
void menu_redraw_prompt (MUTTMENU *menu)
void menu_check_recenter (MUTTMENU *menu)
{
void menu_check_recenter (MUTTMENU *menu)
{
- if (menu->max <= menu->pagelen && menu->top != 0)
+ int c = MIN (MenuContext, menu->pagelen / 2);
+ int old_top = menu->top;
+
+ if (menu->max <= menu->pagelen) /* less entries than lines */
{
{
- menu->top = 0;
- set_option (OPTNEEDREDRAW);
- menu->redraw |= REDRAW_INDEX;
+ if (menu->top != 0) {
+ menu->top = 0;
+ set_option (OPTNEEDREDRAW);
+ }
}
}
- else if (menu->current >= menu->top + menu->pagelen
)
+ else if (menu->current >= menu->top + menu->pagelen
- c) /* indicator below bottom threshold */
{
if (option (OPTMENUSCROLL) || (menu->pagelen <= 0))
{
if (option (OPTMENUSCROLL) || (menu->pagelen <= 0))
- menu->top = menu->current - menu->pagelen + 1;
+ menu->top = menu->current - menu->pagelen +
c +
1;
else
else
- menu->top += menu->pagelen * ((menu->current - menu->top) / menu->pagelen);
- menu->redraw |= REDRAW_INDEX;
+ menu->top += (menu->pagelen - c) * ((menu->current - menu->top) / (menu->pagelen - c)) - c;
}
}
- else if (menu->current < menu->top
)
+ else if (menu->current < menu->top
+ c) /* indicator above top threshold */
{
if (option (OPTMENUSCROLL) || (menu->pagelen <= 0))
{
if (option (OPTMENUSCROLL) || (menu->pagelen <= 0))
- menu->top = menu->current;
+ menu->top = menu->current
- c
;
else
else
- {
- menu->top -= menu->pagelen * ((menu->top + menu->pagelen - 1 - menu->current) / menu->pagelen);
- if (menu->top < 0)
- menu->top = 0;
- }
- menu->redraw |= REDRAW_INDEX;
+ menu->top -= (menu->pagelen - c) * ((menu->top + menu->pagelen - 1 - menu->current) / (menu->pagelen - c)) - c;
}
}
+
+ /* make entries stick to bottom */
+ menu->top = MIN (menu->top, menu->max - menu->pagelen);
+ menu->top = MAX (menu->top, 0);
+
+ if (menu->top != old_top)
+ menu->redraw |= REDRAW_INDEX;
}
void menu_jump (MUTTMENU *menu)
}
void menu_jump (MUTTMENU *menu)
@@
-482,7
+491,9
@@
void menu_next_page (MUTTMENU *menu)
void menu_prev_page (MUTTMENU *menu)
{
void menu_prev_page (MUTTMENU *menu)
{
- if (menu->top > 0)
+ int c = MIN (MenuContext, menu->pagelen / 2);
+
+ if (menu->top > c)
{
if ((menu->top -= menu->pagelen) < 0)
menu->top = 0;
{
if ((menu->top -= menu->pagelen) < 0)
menu->top = 0;
@@
-698,7
+709,7
@@
void mutt_menuDestroy (MUTTMENU **p)
for (i=0; i < (*p)->max; i++)
FREE (&(*p)->dialog[i]);
for (i=0; i < (*p)->max; i++)
FREE (&(*p)->dialog[i]);
- FREE ((*p)->dialog);
+ FREE (
&
(*p)->dialog);
}
FREE (p);
}
FREE (p);