Rocco Rutte:
authorpdmef <pdmef@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Mon, 27 Feb 2006 12:39:19 +0000 (12:39 +0000)
committerpdmef <pdmef@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Mon, 27 Feb 2006 12:39:19 +0000 (12:39 +0000)
- align (hopefully ;-) all status and help lines to start next to sidebar (if visible)

git-svn-id: svn://svn.berlios.de/mutt-ng/trunk@790 e385b8ad-14ed-0310-8656-cc95a2468c6d

VERSION.svn
compose.c
curs_main.c
menu.c
pager.c
recvattach.c
remailer.c
sidebar.c
sidebar.h
status.c

index 0c2b781..1797364 100644 (file)
@@ -1 +1 @@
-789
+790
index c061c5f..9e0ebcc 100644 (file)
--- a/compose.c
+++ b/compose.c
@@ -131,33 +131,13 @@ static struct mapping_t ComposeNewsHelp[] = {
 };
 #endif
 
-static void snd_entry (char *b, size_t blen, MUTTMENU * menu, int num)
-{
-  int old1=DrawFullLine,old2=option(OPTSTATUSONTOP);
-
-  /*
-   * XXX
-   * mutt_FormatString is totally broken as it tries to determine
-   * the max. width of the output string itself which may fail
-   * (for example, for $status_on_top, many of the format strings
-   * are as wide as screen but $attach_format is not, etc.)
-   *
-   * When $status_on_top is unset, mutt_FormatString() will respect
-   * sidebar so unset it for compose menu entries by force... ;-(
-   */
-  DrawFullLine=0;
-  unset_option(OPTSTATUSONTOP);
-
-  mutt_FormatString (b, blen, NONULL (AttachFormat), mutt_attach_fmt,
+static void snd_entry (char *b, size_t blen, MUTTMENU * menu, int num) {
+  int w=(COLS-SW)>blen?blen:COLS-SW;
+  mutt_FormatString (b, w, NONULL (AttachFormat), mutt_attach_fmt,
                      (unsigned long) (((ATTACHPTR **) menu->data)[num]),
                      M_FORMAT_STAT_FILE | M_FORMAT_ARROWCURSOR);
-
-  DrawFullLine=old1;
-  if (old2) set_option(OPTSTATUSONTOP);
 }
 
-
-
 #include "mutt_crypt.h"
 
 static void redraw_crypt_lines (HEADER * msg)
@@ -521,7 +501,8 @@ static const char *compose_format_str (char *buf, size_t buflen, char op,
 static void compose_status_line (char *buf, size_t buflen, MUTTMENU * menu,
                                  const char *p)
 {
-  mutt_FormatString (buf, buflen, p, compose_format_str,
+  int w=(COLS-SW)>buflen?buflen:(COLS-SW);
+  mutt_FormatString (buf, w, p, compose_format_str,
                      (unsigned long) menu, 0);
 }
 
@@ -1426,7 +1407,8 @@ int mutt_compose_menu (HEADER * msg,    /* structure for new message */
       compose_status_line (buf, sizeof (buf), menu, NONULL (ComposeFormat));
       CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES - 2);
       SETCOLOR (MT_COLOR_STATUS);
-      printw ("%-*.*s", COLS, COLS, buf);
+      move (option (OPTSTATUSONTOP) ? 0 : LINES - 2, SW);
+      printw ("%-*.*s", COLS-SW, COLS-SW, buf);
       SETCOLOR (MT_COLOR_NORMAL);
       menu->redraw &= ~REDRAW_STATUS;
     }
index 4d58326..0278069 100644 (file)
@@ -110,6 +110,7 @@ static const char *No_visible = N_("No visible messages.");
 #define CURHDR Context->hdrs[Context->v2r[menu->current]]
 #define OLDHDR Context->hdrs[Context->v2r[menu->oldcurrent]]
 #define UNREAD(h) mutt_thread_contains_unread (Context, h)
+#define SW              (option(OPTMBOXPANE)?SidebarWidth:0)
 
 extern const char *ReleaseDate;
 extern size_t UngetCount;
@@ -561,13 +562,13 @@ int mutt_index_menu (void)
       }
 
       if (menu->redraw & REDRAW_STATUS) {
-        DrawFullLine = 1;
         menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
-        DrawFullLine = 0;
         CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES - 2);
+        sidebar_draw_frames();
         SETCOLOR (MT_COLOR_STATUS);
         BKGDSET (MT_COLOR_STATUS);
-        mutt_paddstr (COLS, buf);
+        move(option (OPTSTATUSONTOP) ? 0 : LINES - 2,SW);
+        mutt_paddstr (COLS-SW, buf);
         SETCOLOR (MT_COLOR_NORMAL);
         BKGDSET (MT_COLOR_NORMAL);
         sidebar_set_buffystats (Context);
diff --git a/menu.c b/menu.c
index f8ea243..95d4f47 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -173,8 +173,8 @@ void menu_redraw_full (MUTTMENU * menu)
 
   if (option (OPTHELP)) {
     SETCOLOR (MT_COLOR_STATUS);
-    move (option (OPTSTATUSONTOP) ? LINES - 2 : 0, 0);
-    mutt_paddstr (COLS, menu->help);
+    move (option (OPTSTATUSONTOP) ? LINES - 2 : 0, SW);
+    mutt_paddstr (COLS-SW, menu->help);
     SETCOLOR (MT_COLOR_NORMAL);
     menu->offset = 1;
     menu->pagelen = LINES - 3;
@@ -184,6 +184,8 @@ void menu_redraw_full (MUTTMENU * menu)
     menu->pagelen = LINES - 2;
   }
 
+  sidebar_draw_frames();
+
   mutt_show_error ();
 
   menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
@@ -195,10 +197,11 @@ void menu_redraw_status (MUTTMENU * menu)
 
   snprintf (buf, sizeof (buf), M_MODEFMT, menu->title);
   SETCOLOR (MT_COLOR_STATUS);
-  move (option (OPTSTATUSONTOP) ? 0 : LINES - 2, 0);
-  mutt_paddstr (COLS, buf);
+  move (option (OPTSTATUSONTOP) ? 0 : LINES - 2, SW);
+  mutt_paddstr (COLS-SW, buf);
   SETCOLOR (MT_COLOR_NORMAL);
   menu->redraw &= ~REDRAW_STATUS;
+  sidebar_draw_frames();
 }
 
 void menu_redraw_index (MUTTMENU * menu)
@@ -206,7 +209,6 @@ void menu_redraw_index (MUTTMENU * menu)
   char buf[STRING];
   int i;
 
-  sidebar_draw (1);
   for (i = menu->top; i < menu->top + menu->pagelen; i++) {
     if (i < menu->max) {
       menu_make_entry (buf, sizeof (buf), menu, i);
@@ -254,6 +256,9 @@ void menu_redraw_index (MUTTMENU * menu)
     else
       CLEARLINE_WIN (i - menu->top + menu->offset);
   }
+  sidebar_draw (1);
+/*  sidebar_draw_frames(); */
+
   menu->redraw = 0;
 }
 
diff --git a/pager.c b/pager.c
index dfd4cbe..9cc94a1 100644 (file)
--- a/pager.c
+++ b/pager.c
@@ -1540,8 +1540,8 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra)
 
       if (option (OPTHELP)) {
         SETCOLOR (MT_COLOR_STATUS);
-        move (helpoffset, 0);
-        mutt_paddstr (COLS, helpstr);
+        move (helpoffset, SW);
+        mutt_paddstr (COLS-SW, helpstr);
         SETCOLOR (MT_COLOR_NORMAL);
       }
 
@@ -1663,13 +1663,9 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra)
         _mutt_make_string (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt),
                            Context, extra->bdy->hdr, M_FORMAT_MAKEPRINT);
       }
-      if (option(OPTSTATUSONTOP)) {
-        move(0,0);
-      } else {
-        move(LINES-2,SW);
-      }
-      mutt_paddstr (COLS - 10 - (option(OPTSTATUSONTOP)?0:SW), IsHeader (extra)
-                    || IsMsgAttach (extra) ? buffer : banner);
+      move(statusoffset,SW);
+      mutt_paddstr (COLS - 10 - SW, IsHeader (extra) || 
+                    IsMsgAttach (extra) ? buffer : banner);
 
       addstr (" -- (");
       if (last_pos < sb.st_size - 1)
@@ -1690,12 +1686,10 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra)
       sidebar_draw (MENU_PAGER);
       /* print out the index status bar */
       menu_status_line (buffer, sizeof (buffer), index, NONULL (Status));
-      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)),
-            option (OPTSTATUSONTOP) ? 0 : SW);
+      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), SW);
       SETCOLOR (MT_COLOR_STATUS);
       BKGDSET (MT_COLOR_STATUS);
-      mutt_paddstr (COLS - (option (OPTSTATUSONTOP) ? 0 : SW),
-                    buffer);
+      mutt_paddstr (COLS-SW, buffer);
       SETCOLOR (MT_COLOR_NORMAL);
       BKGDSET (MT_COLOR_NORMAL);
     }
index f770915..30bcb49 100644 (file)
@@ -49,6 +49,8 @@ static char LastSaveFolder[_POSIX_PATH_MAX] = "";
     break; \
 }
 
+#define SW              (option(OPTMBOXPANE)?SidebarWidth:0)
+
 static struct mapping_t AttachHelp[] = {
   {N_("Exit"), OP_EXIT},
   {N_("Save"), OP_SAVE},
@@ -367,7 +369,8 @@ const char *mutt_attach_fmt (char *dest,
 
 static void attach_entry (char *b, size_t blen, MUTTMENU * menu, int num)
 {
-  mutt_FormatString (b, blen, NONULL (AttachFormat), mutt_attach_fmt,
+  int w=(COLS-SW)>blen?blen:(COLS-SW);
+  mutt_FormatString (b, w, NONULL (AttachFormat), mutt_attach_fmt,
                      (unsigned long) (((ATTACHPTR **) menu->data)[num]),
                      M_FORMAT_ARROWCURSOR);
 }
index 70b31ac..8f934b4 100644 (file)
@@ -36,6 +36,8 @@
 #include <sys/file.h>
 #include <fcntl.h>
 
+#define SW              (option(OPTMBOXPANE)?SidebarWidth:0)
+
 #ifdef MIXMASTER
 
 struct coord {
@@ -419,8 +421,9 @@ static const char *mix_entry_fmt (char *dest,
 static void mix_entry (char *b, size_t blen, MUTTMENU * menu, int num)
 {
   REMAILER **type2_list = (REMAILER **) menu->data;
+  int w=(COLS-SW)>blen?blen:(COLS-SW);
 
-  mutt_FormatString (b, blen, NONULL (MixEntryFormat), mix_entry_fmt,
+  mutt_FormatString (b, w, NONULL (MixEntryFormat), mix_entry_fmt,
                      (unsigned long) type2_list[num], M_FORMAT_ARROWCURSOR);
 }
 
index 4742101..48ec9df 100644 (file)
--- a/sidebar.c
+++ b/sidebar.c
@@ -274,32 +274,67 @@ void sidebar_set_buffystats (CONTEXT* Context) {
   tmp->msg_flagged = Context->flagged;
 }
 
+void sidebar_draw_frames (void) {
+  size_t i,delim_len;
+
+  if (!option(OPTMBOXPANE) || SidebarWidth==0) 
+    return;
+
+  delim_len=str_len(NONULL(SidebarDelim));
+
+  /* draw vertical delimiter */
+  SETCOLOR (MT_COLOR_SIDEBAR);
+  for (i = 0; i < LINES-1; i++) {
+    move (i, SidebarWidth - delim_len);
+    if (option (OPTASCIICHARS))
+      addstr (NONULL (SidebarDelim));
+    else if (!option (OPTASCIICHARS) && !str_cmp (SidebarDelim, "|"))
+      addch (ACS_VLINE);
+    else if ((Charset_is_utf8) && !str_cmp (SidebarDelim, "|"))
+      addstr ("\342\224\202");
+    else
+      addstr (NONULL (SidebarDelim));
+  }
+
+  /* fill "gaps" at top+bottom */
+  SETCOLOR(MT_COLOR_STATUS);
+  for (i=0; i<SidebarWidth; i++) {
+    /*
+     * if we don't have $status_on_top and have $help, fill top
+     * gap with spaces to get bg color
+     */
+    if (option(OPTSTATUSONTOP) || option(OPTHELP)) {
+      move(0,i);
+      addch(' ');
+    }
+    /*
+      * if we don't have $status_on_top or we have $help, fill bottom
+      * gap with spaces to get bg color
+      */
+    if (!option(OPTSTATUSONTOP) || option(OPTHELP)) {
+      move(LINES-2,i);
+      addch(' ');
+    }
+  }
+  SETCOLOR (MT_COLOR_NORMAL);
+}
+
 /* actually draws something
  * FIXME this needs some clue when to do it
  */
-int sidebar_draw (int menu)
-{
-  int first_line = option (OPTSTATUSONTOP) ? 1 : option (OPTHELP) ? 1 : 0;
-  int last_line = LINES-1;
-  int draw_devider = 1, i = 0;
-  int line;
+int sidebar_draw (int menu) {
+  int first_line = option (OPTSTATUSONTOP) ? 1 : option (OPTHELP) ? 1 : 0,
+      last_line = LINES - 2 + (option (OPTSTATUSONTOP) && !option (OPTHELP) ? 1 : 0),
+      i = 0,line;
   BUFFY *tmp;
-  short delim_len = str_len (SidebarDelim);
+  size_t delim_len = str_len (SidebarDelim);
   char blank[SHORT_STRING];
 
-  if (option (OPTSTATUSONTOP)) {
-    last_line -= option (OPTHELP) ? 1 : 0;
-  } else {
-    last_line -= 1-(menu==MENU_PAGER);
-  }
-
   known_lines=last_line-first_line;
 
   /* initialize first time */
   if (!initialized) {
     prev_show_value = option (OPTMBOXPANE);
-    if (!option (OPTMBOXPANE))
-      draw_devider = 1;
     initialized = 1;
   }
 
@@ -325,23 +360,8 @@ int sidebar_draw (int menu)
 
   if (SidebarWidth == 0 || !option (OPTMBOXPANE))
     return 0;
-  /* draw devider only if necessary (if the sidebar becomes visible e.g.)*/
-  if (draw_devider == 1){
-    /* draw the divider */
-    SETCOLOR (MT_COLOR_SIDEBAR);
-    for (line = first_line; line < last_line; line++) {
-      move (line, SidebarWidth - delim_len);
-      if (option (OPTASCIICHARS))
-        addstr (NONULL (SidebarDelim));
-      else if (!option (OPTASCIICHARS) && !str_cmp (SidebarDelim, "|"))
-        addch (ACS_VLINE);
-      else if ((Charset_is_utf8) && !str_cmp (SidebarDelim, "|"))
-        addstr ("\342\224\202");
-      else
-        addstr (NONULL (SidebarDelim));
-    }
-  }
-  SETCOLOR (MT_COLOR_NORMAL);
+
+  sidebar_draw_frames();
 
   if (list_empty(Incoming))
     return 0;
@@ -363,9 +383,10 @@ int sidebar_draw (int menu)
     line += make_sidebar_entry (tmp->path, i, SidebarWidth-delim_len);
   }
 
+  SETCOLOR (MT_COLOR_NORMAL);
+
   /* fill with blanks to bottom */
   memset (&blank, ' ', sizeof (blank));
-  SETCOLOR (MT_COLOR_NORMAL);
   for (; line < last_line; line++) {
     move (line, 0);
     addnstr (blank, SidebarWidth-delim_len);
index 005092c..9aba9a3 100644 (file)
--- a/sidebar.h
+++ b/sidebar.h
@@ -12,6 +12,7 @@
 #define _SIDEBAR_H
 
 int sidebar_draw (int);
+void sidebar_draw_frames (void);
 void sidebar_scroll (int, int);
 void sidebar_set_buffystats (CONTEXT *);
 const char* sidebar_get_current (void);
index 212b007..099157d 100644 (file)
--- a/status.c
+++ b/status.c
@@ -27,6 +27,8 @@
 #include <ctype.h>
 #include <unistd.h>
 
+#define SW              (option(OPTMBOXPANE)?SidebarWidth:0)
+
 static char *get_sort_str (char *buf, size_t buflen, int method)
 {
   snprintf (buf, buflen, "%s%s%s",
@@ -309,9 +311,11 @@ static const char *status_format_str (char *buf, size_t buflen, char op,
   return (src);
 }
 
-void menu_status_line (char *buf, size_t buflen, MUTTMENU * menu,
-                       const char *p)
-{
-  mutt_FormatString (buf, buflen, p, status_format_str, (unsigned long) menu,
-                     0);
+void menu_status_line (char* buf, size_t len, MUTTMENU* menu, const char* p) {
+  /*
+   * if we have enough space for buffer, format lines to $COLS-$SidebarWidth
+   * only to not wrap past end of screen
+   */
+  mutt_FormatString (buf, (COLS-SW)>len?len:(COLS-SW), p, status_format_str,
+                     (unsigned long) menu, 0);
 }