1 /* ncmpc (Ncurses MPD Client)
2 * (c) 2004-2010 The Music Player Daemon Project
3 * Project homepage: http://musicpd.org
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "screen_utils.h"
22 #include "mpdclient.h"
29 #include <mpd/client.h>
35 if (options
.audible_bell
)
37 if (options
.visible_bell
)
42 screen_getch(const char *prompt
)
44 WINDOW
*w
= screen
.status_bar
.window
.w
;
46 colors_use(w
, COLOR_STATUS_ALERT
);
55 while ((key
= wgetch(w
)) == ERR
)
59 /* ignore mouse events */
61 return screen_getch(prompt
);
71 screen_get_yesno(const char *prompt
, bool def
)
73 /* NOTE: if one day a translator decides to use a multi-byte character
74 for one of the yes/no keys, we'll have to parse it properly */
76 int key
= tolower(screen_getch(prompt
));
79 else if (key
== NO
[0])
86 screen_readln(const char *prompt
,
91 struct window
*window
= &screen
.status_bar
.window
;
92 WINDOW
*w
= window
->w
;
97 colors_use(w
, COLOR_STATUS_ALERT
);
98 line
= wreadln(w
, prompt
, value
, window
->cols
, history
, gcmp
);
104 screen_read_password(const char *prompt
)
106 struct window
*window
= &screen
.status_bar
.window
;
107 WINDOW
*w
= window
->w
;
111 colors_use(w
, COLOR_STATUS_ALERT
);
114 prompt
= _("Password");
115 char *ret
= wreadln_masked(w
, prompt
, NULL
, window
->cols
, NULL
, NULL
);
122 screen_display_completion_list(GList
*list
)
124 static GList
*prev_list
= NULL
;
125 static guint prev_length
= 0;
126 static guint offset
= 0;
127 WINDOW
*w
= screen
.main_window
.w
;
129 unsigned length
= g_list_length(list
);
130 if (list
== prev_list
&& length
== prev_length
) {
131 offset
+= screen
.main_window
.rows
;
132 if (offset
>= length
)
136 prev_length
= length
;
140 colors_use(w
, COLOR_STATUS_ALERT
);
143 while (y
< screen
.main_window
.rows
) {
144 GList
*item
= g_list_nth(list
, y
+offset
);
149 gchar
*tmp
= g_strdup(item
->data
);
150 waddstr(w
, g_basename(tmp
));
157 colors_use(w
, COLOR_LIST
);
162 set_xterm_title(const char *format
, ...)
164 /* the current xterm title exists under the WM_NAME property */
165 /* and can be retrieved with xprop -id $WINDOWID */
167 if (options
.enable_xterm_title
) {
168 if (g_getenv("WINDOWID")) {
171 char *msg
= g_strdup_vprintf(format
,ap
);
173 printf("\033]0;%s\033\\", msg
);
177 options
.enable_xterm_title
= FALSE
;