summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5c75283)
raw | patch | inline | side by side (parent: 5c75283)
author | Max Kellermann <max@duempel.org> | |
Thu, 25 Sep 2008 19:21:29 +0000 (21:21 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Thu, 25 Sep 2008 19:21:29 +0000 (21:21 +0200) |
Everything is now managed with a pointer to the screen_functions
struct.
struct.
src/screen.c | patch | blob | history | |
src/screen.h | patch | blob | history | |
src/screen_list.c | patch | blob | history | |
src/screen_list.h | patch | blob | history |
diff --git a/src/screen.c b/src/screen.c
index 2124a2b7489c81cc0709616a6d5ede22af50b638..9c7ca50a58187c99a98d1e7b3062b0ac79694d69 100644 (file)
--- a/src/screen.c
+++ b/src/screen.c
static void
switch_screen_mode(const struct screen_functions *sf, mpdclient_t *c)
{
- gint new_mode;
+ assert(sf != NULL);
if (sf == mode_fn)
return;
- new_mode = lookup_mode(sf);
- if (new_mode < 0)
- return;
-
/* close the old mode */
if (mode_fn->close != NULL)
mode_fn->close();
/* get functions for the new mode */
mode_fn = sf;
- screen.mode = new_mode;
screen.painted = 0;
/* open the new mode */
{
int max = g_strv_length(options.screen_list);
int current, next;
+ const struct screen_functions *sf;
/* find current screen */
- current = find_configured_screen(screen_get_name(screen.mode));
+ current = find_configured_screen(screen_get_name(mode_fn));
next = current + offset;
if (next<0)
next = max-1;
next = 0;
D("current mode: %d:%d next:%d\n", current, max, next);
- switch_screen_mode(screen_lookup_name(options.screen_list[next]), c);
+ sf = screen_lookup_name(options.screen_list[next]);
+ if (sf != NULL)
+ switch_screen_mode(sf, c);
}
static void
exit(EXIT_FAILURE);
}
- screen.mode = 0;
screen.cols = COLS;
screen.rows = LINES;
diff --git a/src/screen.h b/src/screen.h
index dc7e239ea838661bb1959a6153583838d259d8fc..1eac4d682cbf59f9abc5c795e3154e708ceba747 100644 (file)
--- a/src/screen.h
+++ b/src/screen.h
unsigned cols, rows;
- int mode;
-
char *buf;
size_t buf_size;
diff --git a/src/screen_list.c b/src/screen_list.c
index fddeeb0256fd073ad177cd48e78cc0dd5d389ca1..31e8adaf1f8cf58f20c1e24cc78b38b4f2eb8fbf 100644 (file)
--- a/src/screen_list.c
+++ b/src/screen_list.c
}
const char *
-screen_get_name(unsigned i)
+screen_get_name(const struct screen_functions *sf)
{
- assert(i < NUM_SCREENS);
+ unsigned i;
+
+ for (i = 0; i < NUM_SCREENS; ++i)
+ if (screens[i].functions == sf)
+ return screens[i].name;
- return screens[i].name;
+ return NULL;
}
const struct screen_functions *
return NULL;
}
-
-int
-lookup_mode(const struct screen_functions *sf)
-{
- unsigned i;
-
- for (i = 0; i < NUM_SCREENS; ++i)
- if (screens[i].functions == sf)
- return i;
-
- return -1;
-}
diff --git a/src/screen_list.h b/src/screen_list.h
index 583c225b0e030b4373c79c4bfd7a3b601a7eb4f6..1293b74d95347cef489fe208bae3589bea6f7aec 100644 (file)
--- a/src/screen_list.h
+++ b/src/screen_list.h
screen_list_resize(unsigned cols, unsigned rows);
const char *
-screen_get_name(unsigned i);
+screen_get_name(const struct screen_functions *sf);
const struct screen_functions *
screen_lookup_name(const char *name);
int
screen_get_id(const char *name);
-int
-lookup_mode(const struct screen_functions *sf);
-
#endif