From: Max Kellermann Date: Fri, 9 Oct 2009 20:34:04 +0000 (+0200) Subject: screen_{play,keydef,text}: use list_window_set_cursor() X-Git-Tag: release-0.16~150 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=87ab0f79a5672cc5680462183beb8d514cdbc6e3;p=ncmpc.git screen_{play,keydef,text}: use list_window_set_cursor() Don't write list_window.selected directly. --- diff --git a/src/screen_browser.c b/src/screen_browser.c index 6375ee9..492fdd4 100644 --- a/src/screen_browser.c +++ b/src/screen_browser.c @@ -383,7 +383,7 @@ browser_handle_mouse_event(struct screen_browser *browser, struct mpdclient *c) list_window_mouse(browser->lw, length, bstate, row)) return 1; - browser->lw->selected = browser->lw->start + row; + list_window_set_cursor(browser->lw, browser->lw->start + row); list_window_check_selected(browser->lw, length); if( bstate & BUTTON1_CLICKED ) { diff --git a/src/screen_help.c b/src/screen_help.c index 0ce3bd8..4d50174 100644 --- a/src/screen_help.c +++ b/src/screen_help.c @@ -261,7 +261,7 @@ help_cmd(G_GNUC_UNUSED struct mpdclient *c, command_t cmd) return true; } - lw->selected = lw->start; + list_window_set_cursor(lw, lw->start); if (screen_find(lw, help_text_rows, cmd, list_callback, NULL)) { /* center the row */ diff --git a/src/screen_keydef.c b/src/screen_keydef.c index bc3115c..44e0838 100644 --- a/src/screen_keydef.c +++ b/src/screen_keydef.c @@ -327,9 +327,7 @@ keydef_cmd(G_GNUC_UNUSED struct mpdclient *c, command_t cmd) } } else { if (lw->selected == 0) { /* up */ - lw->selected = subcmd; - lw->selected_start = lw->selected; - lw->selected_end = lw->selected; + list_window_set_cursor(lw, subcmd); subcmd = -1; keydef_repaint(); @@ -340,9 +338,7 @@ keydef_cmd(G_GNUC_UNUSED struct mpdclient *c, command_t cmd) return true; case CMD_GO_PARENT_DIRECTORY: if (subcmd >=0) { - lw->selected = subcmd; - lw->selected_start = lw->selected; - lw->selected_end = lw->selected; + list_window_set_cursor(lw, subcmd); subcmd = -1; keydef_repaint(); diff --git a/src/screen_play.c b/src/screen_play.c index 7d079bd..784667b 100644 --- a/src/screen_play.c +++ b/src/screen_play.c @@ -111,7 +111,7 @@ playlist_restore_selection(void) pos = playlist_get_index_from_id(playlist, selected_song_id); if (pos >= 0) - lw->selected = pos; + list_window_set_cursor(lw, pos); list_window_check_selected(lw, playlist_length(playlist)); playlist_save_selection(); @@ -608,7 +608,7 @@ handle_mouse_event(struct mpdclient *c) mpdclient_cmd_delete(c, lw->selected); } - lw->selected = selected; + list_window_set_cursor(lw, selected); list_window_check_selected(lw, playlist_length(playlist)); playlist_save_selection(); playlist_repaint(); @@ -723,8 +723,7 @@ screen_playlist_cmd(struct mpdclient *c, command_t cmd) mpdclient_cmd_delete(c, lw->selected); } - lw->selected = lw->selected_end = lw->selected_start; - lw->range_selection = false; + list_window_set_cursor(lw, lw->selected_start); return true; case CMD_SAVE_PLAYLIST: diff --git a/src/screen_text.c b/src/screen_text.c index ffa81cd..56e41d3 100644 --- a/src/screen_text.c +++ b/src/screen_text.c @@ -103,7 +103,7 @@ screen_text_cmd(struct screen_text *text, return true; } - text->lw->selected = text->lw->start; + list_window_set_cursor(text->lw, text->lw->start); if (screen_find(text->lw, text->lines->len, cmd, screen_text_list_callback, text)) { /* center the row */