summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 28d37c9)
raw | patch | inline | side by side (parent: 28d37c9)
author | Max Kellermann <max@duempel.org> | |
Fri, 9 Oct 2009 20:13:53 +0000 (22:13 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Fri, 9 Oct 2009 20:13:53 +0000 (22:13 +0200) |
list_window_set_selected() becomes list_window_move_cursor().
list_window_set_cursor() is the new public function, which sets the
cursor and disables range selection.
list_window_set_cursor() is the new public function, which sets the
cursor and disables range selection.
diff --git a/src/list_window.c b/src/list_window.c
index 3faf437f791a9b305d303c0139a28ec945a4ac5e..e11e75acf986c6d339c349e4d537ebd3dd0a1589 100644 (file)
--- a/src/list_window.c
+++ b/src/list_window.c
}
void
-list_window_set_selected(struct list_window *lw, unsigned n)
+list_window_set_cursor(struct list_window *lw, unsigned i)
+{
+ lw->range_selection = false;
+ lw->selected = i;
+ lw->selected_start = i;
+ lw->selected_end = i;
+}
+
+void
+list_window_move_cursor(struct list_window *lw, unsigned n)
{
lw->selected = n;
if(lw->range_selection)
list_window_next(struct list_window *lw, unsigned length)
{
if (lw->selected + 1 < length)
- list_window_set_selected(lw, lw->selected + 1);
+ list_window_move_cursor(lw, lw->selected + 1);
else if (options.list_wrap)
- list_window_set_selected(lw, 0);
+ list_window_move_cursor(lw, 0);
}
static void
list_window_previous(struct list_window *lw, unsigned length)
{
if (lw->selected > 0)
- list_window_set_selected(lw, lw->selected - 1);
+ list_window_move_cursor(lw, lw->selected - 1);
else if (options.list_wrap)
- list_window_set_selected(lw, length-1);
+ list_window_move_cursor(lw, length-1);
}
static void
list_window_top(struct list_window *lw)
{
if (lw->start == 0)
- list_window_set_selected(lw, lw->start);
+ list_window_move_cursor(lw, lw->start);
else
if ((unsigned) options.scroll_offset * 2 >= lw->rows)
- list_window_set_selected(lw, lw->start + lw->rows / 2);
+ list_window_move_cursor(lw, lw->start + lw->rows / 2);
else
- list_window_set_selected(lw, lw->start + options.scroll_offset);
+ list_window_move_cursor(lw, lw->start + options.scroll_offset);
}
static void
list_window_middle(struct list_window *lw, unsigned length)
{
if (length >= lw->rows)
- list_window_set_selected(lw, lw->start + lw->rows / 2);
+ list_window_move_cursor(lw, lw->start + lw->rows / 2);
else
- list_window_set_selected(lw, length / 2);
+ list_window_move_cursor(lw, length / 2);
}
static void
{
if (length >= lw->rows)
if ((unsigned) options.scroll_offset * 2 >= lw->rows)
- list_window_set_selected(lw, lw->start + lw->rows / 2);
+ list_window_move_cursor(lw, lw->start + lw->rows / 2);
else
if (lw->start + lw->rows == length)
- list_window_set_selected(lw, length - 1);
+ list_window_move_cursor(lw, length - 1);
else
- list_window_set_selected(lw, lw->start + lw->rows - 1 - options.scroll_offset);
+ list_window_move_cursor(lw, lw->start + lw->rows - 1 - options.scroll_offset);
else
- list_window_set_selected(lw, length - 1);
+ list_window_move_cursor(lw, length - 1);
}
static void
list_window_first(struct list_window *lw)
{
- list_window_set_selected(lw, 0);
+ list_window_move_cursor(lw, 0);
}
static void
list_window_last(struct list_window *lw, unsigned length)
{
if (length > 0)
- list_window_set_selected(lw, length - 1);
+ list_window_move_cursor(lw, length - 1);
else
- list_window_set_selected(lw, 0);
+ list_window_move_cursor(lw, 0);
}
static void
if (lw->rows < 2)
return;
if (lw->selected + lw->rows < length)
- list_window_set_selected(lw, lw->selected + lw->rows - 1);
+ list_window_move_cursor(lw, lw->selected + lw->rows - 1);
else
list_window_last(lw, length);
}
if (lw->rows < 2)
return;
if (lw->selected > lw->rows - 1)
- list_window_set_selected(lw, lw->selected - lw->rows + 1);
+ list_window_move_cursor(lw, lw->selected - lw->rows + 1);
else
list_window_first(lw);
}
if(lw->range_selection)
{
screen_status_printf(_("Range selection disabled"));
- lw->range_selection = false;
- list_window_set_selected(lw, lw->selected);
+ list_window_set_cursor(lw, lw->selected);
}
else
{
diff --git a/src/list_window.h b/src/list_window.h
index 68abd4d0d75a18cb7513d86b60b8abf2342aa1bd..7c6a2a71868dc2cfb0a31f651cc14d34301069b3 100644 (file)
--- a/src/list_window.h
+++ b/src/list_window.h
list_window_center(struct list_window *lw, unsigned rows, unsigned n);
/* select functions */
-void list_window_set_selected(struct list_window *lw, unsigned n);
void list_window_check_selected(struct list_window *lw, unsigned length);
+/**
+ * Sets the position of the cursor. Disables range selection.
+ */
+void
+list_window_set_cursor(struct list_window *lw, unsigned i);
+
+/**
+ * Moves the cursor. Modifies the range if range selection is
+ * enabled.
+ */
+void
+list_window_move_cursor(struct list_window *lw, unsigned n);
+
/* find a string in a list window */
bool
list_window_find(struct list_window *lw,
diff --git a/src/screen_artist.c b/src/screen_artist.c
index 996a0b7914d6ebea2889abbcc2e3f005b79d7669..3ffc533021eff02a428811574fe9741902340053 100644 (file)
--- a/src/screen_artist.c
+++ b/src/screen_artist.c
g_free(old);
if (idx >= 0) {
- list_window_set_selected(browser.lw, idx);
+ list_window_set_cursor(browser.lw, idx);
list_window_center(browser.lw,
artist_list->len, idx);
}
if (idx >= 0) {
++idx;
- list_window_set_selected(browser.lw, idx);
+ list_window_set_cursor(browser.lw, idx);
list_window_center(browser.lw,
album_list->len, idx);
}
g_free(old);
if (idx >= 0) {
- list_window_set_selected(browser.lw, idx);
+ list_window_set_cursor(browser.lw, idx);
list_window_center(browser.lw,
artist_list->len, idx);
}
if (idx >= 0) {
++idx;
- list_window_set_selected(browser.lw, idx);
+ list_window_set_cursor(browser.lw, idx);
list_window_center(browser.lw,
album_list->len, idx);
}
diff --git a/src/screen_file.c b/src/screen_file.c
index b087068ea79f717b04093ded2555b3f4e2672f8f..5a37c0c6a1b84b51a2275926974d66550cd9bb08 100644 (file)
--- a/src/screen_file.c
+++ b/src/screen_file.c
if (success && idx >= 0) {
/* set the cursor on the previous working directory */
- list_window_set_selected(browser.lw, idx);
+ list_window_set_cursor(browser.lw, idx);
list_window_center(browser.lw,
filelist_length(browser.filelist), idx);
}
if (i < 0)
i = 0;
- list_window_set_selected(browser.lw, i);
+ list_window_set_cursor(browser.lw, i);
/* finally, switch to the file screen */
screen_switch(&screen_browse, c);
diff --git a/src/screen_play.c b/src/screen_play.c
index 256ea36d2b9e5f03b5d593586cf4637c88e511a9..dd3fccdc2492039864a2e392b8464af53cf3a81c 100644 (file)
--- a/src/screen_play.c
+++ b/src/screen_play.c
if (length < lw->rows)
{
if (center_cursor)
- list_window_set_selected(lw, idx);
+ list_window_set_cursor(lw, idx);
return;
}
list_window_center(lw, length, idx);
if (center_cursor) {
- list_window_set_selected(lw, idx);
+ list_window_set_cursor(lw, idx);
return;
}
playlist_repaint();
return false;
case CMD_SELECT_PLAYING:
- list_window_set_selected(lw, playlist_get_index(&c->playlist,
- c->song));
+ list_window_set_cursor(lw, playlist_get_index(&c->playlist,
+ c->song));
playlist_save_selection();
playlist_repaint();
return true;