projects
/
apps
/
madmutt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Rocco Rutte:
[apps/madmutt.git]
/
menu.c
diff --git
a/menu.c
b/menu.c
index
f892f27
..
8ff8ace
100644
(file)
--- a/
menu.c
+++ b/
menu.c
@@
-39,9
+39,12
@@
extern size_t UngetCount;
static void print_enriched_string (int attr, unsigned char *s, int do_color)
{
static void print_enriched_string (int attr, unsigned char *s, int do_color)
{
+ wchar_t wc;
size_t k;
size_t n = mutt_strlen ((char *)s);
size_t k;
size_t n = mutt_strlen ((char *)s);
+ mbstate_t mbstate;
+ memset (&mbstate, 0, sizeof (mbstate));
while (*s)
{
if (*s < M_TREE_MAX)
while (*s)
{
if (*s < M_TREE_MAX)
@@
-131,10
+134,10
@@
static void print_enriched_string (int attr, unsigned char *s, int do_color)
}
if (do_color) attrset(attr);
}
}
if (do_color) attrset(attr);
}
- else if (
*s
> 0)
+ else if (
(k = mbrtowc (&wc, (char *)s, n, &mbstate))
> 0)
{
{
- addnstr ((char *)s,
1
);
- s +=
1, n-= 1
;
+ addnstr ((char *)s,
k
);
+ s +=
k, n-= k
;
}
else
break;
}
else
break;
@@
-155,14
+158,16
@@
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 - SidebarWidth;
-
- char tmpbuf[n];
-
+ int cols;
+ char* tmpbuf = safe_malloc (n);
+ if (option(OPTMBOXPANE))
+ cols = COLS - shift - SidebarWidth;
+ else
+ cols = COLS - shift;
mutt_format_string (tmpbuf, n, cols, cols, 0, ' ', s, strlen (s), 1);
tmpbuf[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 */
snprintf(s,n,"%s",tmpbuf); /* overkill */
+ FREE(&tmpbuf);
}
void menu_redraw_full (MUTTMENU *menu)
}
void menu_redraw_full (MUTTMENU *menu)
@@
-377,7
+382,7
@@
void menu_check_recenter (MUTTMENU *menu)
int c = MIN (MenuContext, menu->pagelen / 2);
int old_top = menu->top;
int c = MIN (MenuContext, menu->pagelen / 2);
int old_top = menu->top;
- if (menu->max <= menu->pagelen) /* less entries than lines */
+ if (
!option (OPTMENUMOVEOFF) &&
menu->max <= menu->pagelen) /* less entries than lines */
{
if (menu->top != 0) {
menu->top = 0;
{
if (menu->top != 0) {
menu->top = 0;
@@
-399,8
+404,8
@@
void menu_check_recenter (MUTTMENU *menu)
menu->top -= (menu->pagelen - c) * ((menu->top + menu->pagelen - 1 - menu->current) / (menu->pagelen - c)) - c;
}
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);
+
if (!option (OPTMENUMOVEOFF))
/* 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->top = MAX (menu->top, 0);
if (menu->top != old_top)
@@
-436,10
+441,13
@@
void menu_next_line (MUTTMENU *menu)
{
if (menu->max)
{
{
if (menu->max)
{
- if (menu->top + 1 < menu->max)
+ int c = MIN (MenuContext, menu->pagelen / 2);
+
+ if (menu->top + 1 < menu->max - c
+ && (option(OPTMENUMOVEOFF) || (menu->max > menu->pagelen && menu->top < menu->max - menu->pagelen)))
{
menu->top++;
{
menu->top++;
- if (menu->current < menu->top)
+ if (menu->current < menu->top
+ c && menu->current < menu->max - 1
)
menu->current++;
menu->redraw = REDRAW_INDEX;
}
menu->current++;
menu->redraw = REDRAW_INDEX;
}
@@
-454,8
+462,10
@@
void menu_prev_line (MUTTMENU *menu)
{
if (menu->top > 0)
{
{
if (menu->top > 0)
{
+ int c = MIN (MenuContext, menu->pagelen / 2);
+
menu->top--;
menu->top--;
- if (menu->current >= menu->top + menu->pagelen)
+ if (menu->current >= menu->top + menu->pagelen
- c && menu->current > 1
)
menu->current--;
menu->redraw = REDRAW_INDEX;
}
menu->current--;
menu->redraw = REDRAW_INDEX;
}