aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-25 17:40:29 +0200
committerMax Kellermann <max@duempel.org>2008-09-25 17:40:29 +0200
commit9e27391e321912878f7cddaa92f2c8201c6e91de (patch)
treed4177ec184712f13cdf4d3276a03c981c073e225
parent0fd4d0c99d31b69356c289d3bb1dcd791b898028 (diff)
downloadmpd-9e27391e321912878f7cddaa92f2c8201c6e91de.tar.gz
mpd-9e27391e321912878f7cddaa92f2c8201c6e91de.tar.xz
mpd-9e27391e321912878f7cddaa92f2c8201c6e91de.zip
list_window: removed property "clear"
Without clearing previous screen contents, there may be corruptions, make this mandatory and optimize screen clearing.
-rw-r--r--src/list_window.c24
-rw-r--r--src/list_window.h3
-rw-r--r--src/screen_artist.c4
-rw-r--r--src/screen_file.c2
-rw-r--r--src/screen_help.c1
-rw-r--r--src/screen_keydef.c3
-rw-r--r--src/screen_lyrics.c2
-rw-r--r--src/screen_play.c13
-rw-r--r--src/screen_search.c2
9 files changed, 13 insertions, 41 deletions
diff --git a/src/list_window.c b/src/list_window.c
index 5a4ccf36d..e69f6ac04 100644
--- a/src/list_window.c
+++ b/src/list_window.c
@@ -41,7 +41,6 @@ list_window_init(WINDOW *w, unsigned width, unsigned height)
lw->w = w;
lw->cols = width;
lw->rows = height;
- lw->clear = 1;
return lw;
}
@@ -60,7 +59,6 @@ list_window_reset(struct list_window *lw)
lw->selected = 0;
lw->xoffset = 0;
lw->start = 0;
- lw->clear = 1;
}
void
@@ -95,7 +93,7 @@ list_window_center(struct list_window *lw, unsigned rows, unsigned n)
lw->start = 0;
}
- lw->repaint = lw->clear = 1;
+ lw->repaint = 1;
}
void
@@ -172,15 +170,11 @@ list_window_paint(struct list_window *lw,
int show_cursor = !(lw->flags & LW_HIDE_CURSOR);
if (show_cursor) {
- if (lw->selected < lw->start) {
+ if (lw->selected < lw->start)
lw->start = lw->selected;
- lw->clear=1;
- }
- if (lw->selected >= lw->start + lw->rows) {
+ if (lw->selected >= lw->start + lw->rows)
lw->start = lw->selected - lw->rows + 1;
- lw->clear=1;
- }
}
for (i = 0; i < lw->rows; i++) {
@@ -189,8 +183,6 @@ list_window_paint(struct list_window *lw,
label = callback(lw->start + i, &highlight, callback_data);
wmove(lw->w, i, 0);
- if( lw->clear && (!fill || !label) )
- wclrtoeol(lw->w);
if (label) {
int selected = lw->start + i == lw->selected;
@@ -211,10 +203,12 @@ list_window_paint(struct list_window *lw,
if (selected)
wattroff(lw->w, A_REVERSE);
- }
- }
- lw->clear=0;
+ if (!fill && len < lw->cols)
+ wclrtoeol(lw->w);
+ } else
+ wclrtoeol(lw->w);
+ }
}
int
@@ -359,7 +353,7 @@ list_window_scroll_cmd(struct list_window *lw, unsigned rows, command_t cmd)
return 0;
}
- lw->repaint = lw->clear = 1;
+ lw->repaint = 1;
return 1;
}
diff --git a/src/list_window.h b/src/list_window.h
index 25f5362f9..9a348a26a 100644
--- a/src/list_window.h
+++ b/src/list_window.h
@@ -22,7 +22,6 @@ typedef struct list_window {
unsigned start;
unsigned selected;
unsigned xoffset;
- int clear;
int repaint;
int flags;
} list_window_t;
@@ -39,7 +38,7 @@ struct list_window *list_window_init(WINDOW *w,
/* destroy a list window (returns NULL) */
void list_window_free(struct list_window *lw);
-/* reset a list window (selected=0, start=0, clear=1) */
+/* reset a list window (selected=0, start=0) */
void list_window_reset(struct list_window *lw);
/* paint a list window */
diff --git a/src/screen_artist.c b/src/screen_artist.c
index 4abd585c0..bf7e54df0 100644
--- a/src/screen_artist.c
+++ b/src/screen_artist.c
@@ -150,7 +150,6 @@ update_metalist(mpdclient_t *c, char *m_artist, char *m_album)
mode = LIST_ARTISTS;
}
metalist_length = g_list_length(metalist);
- browser.lw->clear = TRUE;
}
/* db updated */
@@ -160,7 +159,6 @@ browse_callback(mpdclient_t *c, int event, mpd_unused gpointer data)
switch(event) {
case BROWSE_DB_UPDATED:
D("screen_artist.c> browse_callback() [BROWSE_DB_UPDATED]\n");
- browser.lw->clear = 1;
update_metalist(c, g_strdup(artist), g_strdup(album));
break;
default:
@@ -215,8 +213,6 @@ resize(int cols, int rows)
static void
paint(mpd_unused screen_t *screen, mpd_unused mpdclient_t *c)
{
- browser.lw->clear = 1;
-
if (browser.filelist) {
list_window_paint(browser.lw, browser_lw_callback,
browser.filelist);
diff --git a/src/screen_file.c b/src/screen_file.c
index f2384ecb7..8f9c6c897 100644
--- a/src/screen_file.c
+++ b/src/screen_file.c
@@ -177,8 +177,6 @@ browse_title(char *str, size_t size)
static void
browse_paint(mpd_unused screen_t *screen, mpd_unused mpdclient_t *c)
{
- browser.lw->clear = 1;
-
list_window_paint(browser.lw, browser_lw_callback, browser.filelist);
wnoutrefresh(browser.lw->w);
}
diff --git a/src/screen_help.c b/src/screen_help.c
index e440672d2..eec76d18a 100644
--- a/src/screen_help.c
+++ b/src/screen_help.c
@@ -210,7 +210,6 @@ help_title(mpd_unused char *str, mpd_unused size_t size)
static void
help_paint(mpd_unused screen_t *screen, mpd_unused mpdclient_t *c)
{
- lw->clear = 1;
list_window_paint(lw, list_callback, NULL);
wrefresh(lw->w);
}
diff --git a/src/screen_keydef.c b/src/screen_keydef.c
index 3dda0ec72..38ba315c3 100644
--- a/src/screen_keydef.c
+++ b/src/screen_keydef.c
@@ -134,7 +134,6 @@ delete_key(int cmd_index, int key_index)
cmds[cmd_index].keys[key_index] = 0;
cmds[cmd_index].flags |= COMMAND_KEY_MODIFIED;
check_subcmd_length();
- lw->clear = 1;
lw->repaint = 1;
/* update key conflict flags */
check_key_bindings(cmds, NULL, 0);
@@ -281,7 +280,6 @@ keydef_title(char *str, size_t size)
static void
keydef_paint(mpd_unused screen_t *screen, mpd_unused mpdclient_t *c)
{
- lw->clear = 1;
list_window_paint(lw, list_callback, NULL);
wrefresh(lw->w);
}
@@ -327,7 +325,6 @@ keydef_cmd(screen_t *screen, mpd_unused mpdclient_t *c, command_t cmd)
lw->selected - STATIC_SUB_ITEMS);
}
lw->repaint = 1;
- lw->clear = 1;
return 1;
case CMD_DELETE:
if (subcmd >= 0 && lw->selected >= STATIC_SUB_ITEMS)
diff --git a/src/screen_lyrics.c b/src/screen_lyrics.c
index 9b9ea03a2..152580092 100644
--- a/src/screen_lyrics.c
+++ b/src/screen_lyrics.c
@@ -126,7 +126,6 @@ screen_lyrics_set(const GString *str)
/* paint new data */
if (get_cur_mode_id() == 104) { /* XXX don't use the literal number */
- lw->clear = 1;
list_window_paint(lw, list_callback, NULL);
wrefresh(lw->w);
@@ -265,7 +264,6 @@ lyrics_title(char *str, size_t size)
static void
lyrics_paint(mpd_unused screen_t *screen, mpd_unused mpdclient_t *c)
{
- lw->clear = 1;
list_window_paint(lw, list_callback, NULL);
wrefresh(lw->w);
}
diff --git a/src/screen_play.c b/src/screen_play.c
index 6df8c9f81..579d4f4ca 100644
--- a/src/screen_play.c
+++ b/src/screen_play.c
@@ -67,8 +67,7 @@ playlist_changed_callback(mpdclient_t *c, int event, gpointer data)
default:
break;
}
- /* make shure the playlist is repainted */
- lw->clear = 1;
+
list_window_check_selected(lw, c->playlist.list->len);
}
@@ -139,10 +138,8 @@ save_post_completion_cb(mpd_unused GCompletion *gcmp, mpd_unused gchar *line,
completion_callback_data_t *tmp = (completion_callback_data_t *)data;
screen_t *screen = tmp->screen;
- if (g_list_length(items) >= 1) {
+ if (g_list_length(items) >= 1)
screen_display_completion_list(screen, items);
- lw->clear = 1;
- }
}
int
@@ -266,10 +263,8 @@ static void add_post_completion_cb(GCompletion *gcmp, gchar *line,
screen_t *screen = tmp->screen;
D("post_completion()...\n");
- if (g_list_length(items) >= 1) {
+ if (g_list_length(items) >= 1)
screen_display_completion_list(screen, items);
- lw->clear = 1;
- }
if (line && line[0] && line[strlen(line) - 1] == '/' &&
string_list_find(*dir_list, line) == NULL) {
@@ -366,8 +361,6 @@ play_title(char *str, size_t size)
static void
play_paint(mpd_unused screen_t *screen, mpdclient_t *c)
{
- lw->clear = 1;
-
list_window_paint(lw, list_callback, (void *) c);
wnoutrefresh(lw->w);
}
diff --git a/src/screen_search.c b/src/screen_search.c
index 8242f1350..5995b7976 100644
--- a/src/screen_search.c
+++ b/src/screen_search.c
@@ -389,8 +389,6 @@ resize(int cols, int rows)
static void
paint(mpd_unused screen_t *screen, mpdclient_t *c)
{
- browser.lw->clear = 1;
-
if (browser.filelist) {
browser.lw->flags = 0;
list_window_paint(browser.lw, browser_lw_callback, browser.filelist);