Hi Kevin,

I've ported the Sidebar and given your patches a bit of a test-drive.
Looking good.

    https://github.com/neomutt/neomutt/tree/devel/win-sidebar

This simplifies Sidebar noticeably:
    -90 lines in sidebar.c
    -70 lines in other code

I've attached a couple of suggested changes.
    * A patch fix the compile under slang
    * A refactoring of mutt_reflow_windows()

To make the function a bit simpler, I've added some variables tracking
the remaining space.  I've reordered the windows slightly to make the
maths easier.  This also makes it easy to slot in the sidebar window.

For fun, I added a '$sidebar_on_right' variable, which works OK-ish.

Problems encountered so far:
    The pager still uses some clrtoeol()s overwriting my right-Sidebar
    mutt_FormatString() still references COLS

Fixing mutt_FormatString() isn't too hard, but it's used in over 40
places, so it'll be a bit tedious.  Would you like me to look at it?

Rich

diff --git a/curs_lib.c b/curs_lib.c
index d7bc4ce..8af9a81 100644
--- a/curs_lib.c
+++ b/curs_lib.c
@@ -151,7 +151,7 @@ event_t mutt_getch (void)
 int _mutt_get_field (const char *field, char *buf, size_t buflen, int 
complete, int multiple, char ***files, int *numfiles)
 {
   int ret;
-  int x;
+  int x, y;
 
   ENTER_STATE *es = mutt_new_enter_state();
   
@@ -162,7 +162,7 @@ int _mutt_get_field (const char *field, char *buf, size_t 
buflen, int complete,
     addstr ((char *)field); /* cast to get around bad prototypes */
     NORMAL_COLOR;
     mutt_refresh ();
-    x = getcurx (stdscr);
+    getyx (stdscr, y, x);
     ret = _mutt_enter_string (buf, buflen, x, complete, multiple, files, 
numfiles, es);
   }
   while (ret == 1);
@@ -577,7 +577,12 @@ int mutt_window_mvprintw (mutt_window_t *win, int row, int 
col, const char *fmt,
   if ((rv = mutt_window_move (win, row, col) != ERR))
   {
     va_start (ap, fmt);
+#ifdef USE_SLANG_CURSES
+    SLsmg_vprintf (fmt, ap);
+    rv = 0;
+#else
     rv = vw_printw (stdscr, fmt, ap);
+#endif
     va_end (ap);
   }
 
void mutt_reflow_windows (void)
{
  if (option (OPTNOCURSES))
    return;

  dprint (2, (debugfile, "In mutt_reflow_windows\n"));

  /* Remaining space */
  int x = 0;
  int y = 0;
  int w = COLS;
  int h = LINES;

  MuttMessageWindow->rows = 1;
  MuttMessageWindow->cols = w;
  MuttMessageWindow->row_offset = h - 1;
  MuttMessageWindow->col_offset = 0;

  h -= MuttMessageWindow->rows;

  if (option (OPTHELP))
    MuttHelpWindow->rows = 1;
  else
    MuttHelpWindow->rows = 0;
  MuttHelpWindow->cols = w;
  MuttHelpWindow->col_offset = x;
  if (option (OPTSTATUSONTOP)) {
    MuttHelpWindow->row_offset = y + h - 1;
  } else {
    MuttHelpWindow->row_offset = y;
    y += MuttHelpWindow->rows;
  }
  h -= MuttHelpWindow->rows;

  MuttStatusWindow->rows = 1;
  MuttStatusWindow->cols = w;
  MuttStatusWindow->col_offset = x;
  if (option (OPTSTATUSONTOP)) {
    MuttStatusWindow->row_offset = y;
    y += MuttStatusWindow->rows;
  } else {
    MuttStatusWindow->row_offset = y + h - 1;
  }
  h -= MuttStatusWindow->rows;


  MuttIndexWindow->rows = h;
  MuttIndexWindow->cols = w;
  MuttIndexWindow->row_offset = y;
  MuttIndexWindow->col_offset = x;
}

Reply via email to