diff --git a/src/list_window.c b/src/list_window.c
index e02d92babc0a64b61804497c97a35fcb4e351622..ca857b8a06ec60185e3d9d334c318d084b881b55 100644 (file)
--- a/src/list_window.c
+++ b/src/list_window.c
#include "match.h"
#include "command.h"
#include "colors.h"
-#include "screen.h"
+#include "screen_message.h"
#include "i18n.h"
#include <assert.h>
lw->selected_end = 0;
lw->range_selection = false;
lw->range_base = 0;
- lw->xoffset = 0;
lw->start = 0;
}
if(lw->range_selection)
{
+ if (length == 0) {
+ lw->selected_start = 0;
+ lw->selected_end = 0;
+ lw->range_base = 0;
+ } else {
+ if (lw->selected_start >= length)
+ lw->selected_start = length - 1;
+ if (lw->selected_end >= length)
+ lw->selected_end = length - 1;
+ if (lw->range_base >= length)
+ lw->range_base = length - 1;
+ }
+
if(lw->range_base > lw->selected_end)
lw->selected_end = lw->selected;
if(lw->range_base < lw->selected_start)
static void
list_window_first(struct list_window *lw)
{
- lw->xoffset = 0;
list_window_set_selected(lw, 0);
}
static void
list_window_last(struct list_window *lw, unsigned length)
{
- lw->xoffset = 0;
if (length > 0)
list_window_set_selected(lw, length - 1);
else
lw->start = 0;
else
{
- while ( start > 0 && callback(start + lw->rows - 1, &highlight, callback_data) == NULL)
+ while ( start > 0 && callback(start + lw->rows - 1, &highlight, NULL, callback_data) == NULL)
start--;
lw->start = start;
}
for (i = 0; i < lw->rows; i++) {
const char *label;
+ char *second_column = NULL;
highlight = false;
- label = callback(lw->start + i, &highlight, callback_data);
+ label = callback(lw->start + i, &highlight, &second_column, callback_data);
wmove(lw->w, i, 0);
if (label) {
else
colors_use(lw->w, COLOR_LIST);
- if (show_cursor && selected)
+ if (show_cursor && selected &&
+ (!options.hardware_cursor || lw->range_selection))
wattron(lw->w, A_REVERSE);
//waddnstr(lw->w, label, lw->cols);
if (fill && len < lw->cols)
whline(lw->w, ' ', lw->cols-len);
+ if(second_column)
+ {
+ unsigned sc_len = utf8_width(second_column) + 1;
+ if(lw->cols > sc_len)
+ {
+ wmove(lw->w, i, lw->cols - sc_len);
+ waddstr(lw->w, " ");
+ wmove(lw->w, i, lw->cols - sc_len + 1);
+ waddstr(lw->w, second_column);
+ }
+ g_free(second_column);
+ }
+
if (selected)
wattroff(lw->w, A_REVERSE);
} else
wclrtoeol(lw->w);
}
+
+ if (options.hardware_cursor && lw->selected >= lw->start &&
+ lw->selected < lw->start + lw->rows) {
+ curs_set(1);
+ wmove(lw->w, lw->selected - lw->start, 0);
+ }
}
bool
const char *label;
do {
- while ((label = callback(i,&h,callback_data))) {
+ while ((label = callback(i,&h,NULL,callback_data))) {
if (str && label && match_line(label, str)) {
lw->selected = i;
if(!lw->range_selection || i > lw->selected_end)
return false;
do {
- while (i >= 0 && (label = callback(i,&h,callback_data))) {
+ while (i >= 0 && (label = callback(i,&h,NULL,callback_data))) {
if( str && label && match_line(label, str) ) {
lw->selected = i;
if(!lw->range_selection || i > (int)lw->selected_end)
unsigned i = 0;
const char *label;
- while ((label = callback(i,&h,callback_data))) {
+ while ((label = callback(i,&h,NULL,callback_data))) {
if (label && label[0] == '[')
label++;
#ifndef NCMPC_MINI