diff --git a/list_window.c b/list_window.c
index d976ce05c351372b1f87efea8427f4f31dc3d89b..b251310be228bbfa397dcf5c8a9224ebca81dd5b 100644 (file)
--- a/list_window.c
+++ b/list_window.c
+/*
+ * (c) 2004 by Kalle Wallin (kaw@linux.se)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <ncurses.h>
#include "config.h"
+#include "options.h"
#include "support.h"
#include "command.h"
#include "list_window.h"
{
list_window_t *lw;
- lw = malloc(sizeof(list_window_t));
+ lw = g_malloc(sizeof(list_window_t));
memset(lw, 0, sizeof(list_window_t));
lw->w = w;
lw->cols = width;
if( lw )
{
memset(lw, 0, sizeof(list_window_t));
- free(lw);
+ g_free(lw);
}
return NULL;
}
void
list_window_check_selected(list_window_t *lw, int length)
{
+ while( lw->start && lw->start+lw->rows>length)
+ lw->start--;
+
if( lw->selected<0 )
lw->selected=0;
+ while( lw->selected<lw->start )
+ lw->selected++;
+
while( lw->selected>0 && length>0 && lw->selected>=length )
lw->selected--;
}
void *callback_data)
{
int i;
+ int fill = options.wide_cursor;
while( lw->selected < lw->start )
{
lw->start++;
lw->clear=1;
}
- if( lw->clear )
- {
- wclear(lw->w);
- lw->clear=0;
- }
for(i=0; i<lw->rows; i++)
{
- int highlight;
+ int highlight = 0;
char *label;
label = (callback) (lw->start+i, &highlight, callback_data);
+ wmove(lw->w, i, 0);
+ if( lw->clear && (!fill || !label) )
+ wclrtoeol(lw->w);
if( label )
{
- wmove(lw->w, i, 0);
if( highlight )
wattron(lw->w, A_BOLD);
if( lw->start+i == lw->selected )
wattron(lw->w, A_REVERSE);
- waddnstr(lw->w, label, lw->cols);
+ waddnstr(lw->w, label, lw->cols-1);
+ if( fill )
+ mvwhline(lw->w, i, strlen(label), ' ', lw->cols-1);
if( highlight )
wattroff(lw->w, A_BOLD);
if( lw->start+i == lw->selected )
wattroff(lw->w, A_REVERSE);
}
+
}
+ lw->clear=0;
}