summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bcae179)
raw | patch | inline | side by side (parent: bcae179)
author | Max Kellermann <max@duempel.org> | |
Wed, 30 Sep 2009 14:30:18 +0000 (16:30 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Wed, 30 Sep 2009 14:30:18 +0000 (16:30 +0200) |
Callers shouldn't care which window will be used; we're going to use
the global variable screen.status_window.
the global variable screen.status_window.
diff --git a/src/screen_client.c b/src/screen_client.c
index 51b10df9c7661795ad46590f5bab0d5cbca0e746..3916304801d8f00cb700ff878866468d20b4cf21 100644 (file)
--- a/src/screen_client.c
+++ b/src/screen_client.c
if (recursion > 2)
return false;
- password = screen_read_password(NULL, NULL);
+ password = screen_read_password(NULL);
if (password == NULL)
return false;
diff --git a/src/screen_file.c b/src/screen_file.c
index a9d5e6a7ad3346e6939c3aae61345a1b2efc1237..78052100c9aeede306e7ad290a63b857c1de8970 100644 (file)
--- a/src/screen_file.c
+++ b/src/screen_file.c
str = utf8_to_locale(g_basename(mpd_playlist_get_path(playlist)));
buf = g_strdup_printf(_("Delete playlist %s [%s/%s] ? "), str, YES, NO);
g_free(str);
- key = tolower(screen_getch(screen.status_window.w, buf));
+ key = tolower(screen_getch(buf));
g_free(buf);
if( key != YES[0] ) {
/* translators: a dialog was aborted by the user */
diff --git a/src/screen_keydef.c b/src/screen_keydef.c
index 16cc95710585982a1cc6636b01da382e9069e47b..b92ebe39d584453f7fa6d61d3a3bdc6f96ad230c 100644 (file)
--- a/src/screen_keydef.c
+++ b/src/screen_keydef.c
}
static void
-assign_new_key(WINDOW *w, int cmd_index, int key_index)
+assign_new_key(int cmd_index, int key_index)
{
int key;
char *buf;
command_t cmd;
buf = g_strdup_printf(_("Enter new key for %s: "), cmds[cmd_index].name);
- key = screen_getch(w, buf);
+ key = screen_getch(buf);
g_free(buf);
if (key==ERR) {
keydef_repaint();
} else
- assign_new_key(screen.status_window.w,
- subcmd,
+ assign_new_key(subcmd,
lw->selected - STATIC_SUB_ITEMS);
}
return true;
diff --git a/src/screen_play.c b/src/screen_play.c
index 3e4f05ada50ec563d0d993c1f32496d237930b96..f3a0804903155f4906a5a0928bebdfb20958bb9c 100644 (file)
--- a/src/screen_play.c
+++ b/src/screen_play.c
/* query the user for a filename */
- filename = screen_readln(screen.status_window.w,
- _("Save playlist as"),
+ filename = screen_readln(_("Save playlist as"),
defaultname,
NULL,
gcmp);
buf = g_strdup_printf(_("Replace %s [%s/%s] ? "),
filename, YES, NO);
- key = tolower(screen_getch(screen.status_window.w,
- buf));
+ key = tolower(screen_getch(buf));
g_free(buf);
if (key != YES[0]) {
#endif
/* get path */
- path = screen_readln(screen.status_window.w,
- _("Add"),
+ path = screen_readln(_("Add"),
NULL,
NULL,
#ifdef NCMPC_MINI
diff --git a/src/screen_search.c b/src/screen_search.c
index 11ffd619f134bcbe50b3ef16ad3fcd6c6d0a52ec..5c7cdeafd0edd2668ed3bd15b5ea2b23889372a4 100644 (file)
--- a/src/screen_search.c
+++ b/src/screen_search.c
search_clear(c, TRUE);
g_free(pattern);
- pattern = screen_readln(screen.status_window.w,
- _("Search"),
+ pattern = screen_readln(_("Search"),
NULL,
&search_history,
NULL);
diff --git a/src/screen_utils.c b/src/screen_utils.c
index 3c9ccfe9cbe6e6b800c07cb93261f22d9918b42d..7a3f04b78bdd154d77b507cc3c79b3586cb80e44 100644 (file)
--- a/src/screen_utils.c
+++ b/src/screen_utils.c
}
int
-screen_getch(WINDOW *w, const char *prompt)
+screen_getch(const char *prompt)
{
+ WINDOW *w = screen.status_window.w;
int key = -1;
colors_use(w, COLOR_STATUS_ALERT);
#ifdef HAVE_GETMOUSE
/* ignore mouse events */
if (key == KEY_MOUSE)
- return screen_getch(w, prompt);
+ return screen_getch(prompt);
#endif
noecho();
}
char *
-screen_readln(WINDOW *w,
- const char *prompt,
+screen_readln(const char *prompt,
const char *value,
GList **history,
GCompletion *gcmp)
{
+ struct window *window = &screen.status_window;
+ WINDOW *w = window->w;
char *line = NULL;
wmove(w, 0,0);
curs_set(1);
colors_use(w, COLOR_STATUS_ALERT);
- line = wreadln(w, prompt, value, COLS, history, gcmp);
+ line = wreadln(w, prompt, value, window->cols, history, gcmp);
curs_set(0);
return line;
}
char *
-screen_read_password(WINDOW *w, const char *prompt)
+screen_read_password(const char *prompt)
{
+ struct window *window = &screen.status_window;
+ WINDOW *w = window->w;
char *ret;
- if (w == NULL) {
- int rows, cols;
- getmaxyx(stdscr, rows, cols);
- /* create window for input */
- w = newwin(1, cols, rows-1, 0);
- leaveok(w, FALSE);
- keypad(w, TRUE);
- }
-
wmove(w, 0,0);
curs_set(1);
colors_use(w, COLOR_STATUS_ALERT);
if (prompt == NULL)
prompt = _("Password");
- ret = wreadln_masked(w, prompt, NULL, COLS, NULL, NULL);
+ ret = wreadln_masked(w, prompt, NULL, window->cols, NULL, NULL);
curs_set(0);
return ret;
case CMD_LIST_FIND_NEXT:
case CMD_LIST_RFIND_NEXT:
if (!screen.findbuf)
- screen.findbuf=screen_readln(screen.status_window.w,
- prompt,
+ screen.findbuf=screen_readln(prompt,
value,
&screen.find_history,
NULL);
/* unfortunately wgetch returns "next/previous-page" not as an ascii-char */
while(!g_ascii_iscntrl(key) && key != KEY_NPAGE && key != KEY_PPAGE) {
- key = screen_getch(screen.status_window.w, screen.findbuf);
+ key = screen_getch(screen.findbuf);
/* if backspace or delete was pressed */
if (key == KEY_BACKSPACE || key == 330) {
int i;
diff --git a/src/screen_utils.h b/src/screen_utils.h
index 5b133fcec5387986a803169d90e4bef185aadb31..bbcdbf282238b51a5a01a0725dc47362c8a07202 100644 (file)
--- a/src/screen_utils.h
+++ b/src/screen_utils.h
#include "list_window.h"
#include "command.h"
-#ifdef HAVE_NCURSESW_NCURSES_H
-#include <ncursesw/ncurses.h>
-#else
-#include <ncurses.h>
-#endif
-
struct mpdclient;
/* sound an audible and/or visible bell */
void screen_bell(void);
/* read a character from the status window */
-int screen_getch(WINDOW *w, const char *prompt);
+int screen_getch(const char *prompt);
char *
-screen_read_password(WINDOW *w, const char *prompt);
+screen_read_password(const char *prompt);
-char *screen_readln(WINDOW *w, const char *prompt, const char *value,
+char *screen_readln(const char *prompt, const char *value,
GList **history, GCompletion *gcmp);
/* query user for a string and find it in a list window */