Code

screen_{play,keydef,text}: use list_window_set_cursor()
authorMax Kellermann <max@duempel.org>
Fri, 9 Oct 2009 20:34:04 +0000 (22:34 +0200)
committerMax Kellermann <max@duempel.org>
Fri, 9 Oct 2009 20:34:04 +0000 (22:34 +0200)
Don't write list_window.selected directly.

src/screen_browser.c
src/screen_help.c
src/screen_keydef.c
src/screen_play.c
src/screen_text.c

index 6375ee955325c13b7206b0003b568834b62c2b53..492fdd44b8e2bb21259d56bfe46d62649b3e059f 100644 (file)
@@ -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 ) {
index 0ce3bd8dc375c1c01492ee59caab89a152392575..4d501742bb0f2cf533382d361a680af92affe46e 100644 (file)
@@ -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 */
index bc3115c65b827604db76527ac1da9c32dc37b0fd..44e08384e5165a4aaa4f0f6314647800e06f58c4 100644 (file)
@@ -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();
index 7d079bdc5615a6cd4724169adf93a8b45fb82909..784667b0bdbf143fb1202295e76e7db6a484e5ed 100644 (file)
@@ -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:
index ffa81cdb00990799ec9073ae304d171216855647..56e41d3e07bba2b60cb565ca62f0b06f8882eb77 100644 (file)
@@ -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 */