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>
34 if (options
.audible_bell
)
36 if (options
.visible_bell
)
41 screen_getch(const char *prompt
)
43 WINDOW
*w
= screen
.status_bar
.window
.w
;
46 colors_use(w
, COLOR_STATUS_ALERT
);
54 while ((key
= wgetch(w
)) == ERR
)
58 /* ignore mouse events */
60 return screen_getch(prompt
);
70 screen_readln(const char *prompt
,
75 struct window
*window
= &screen
.status_bar
.window
;
76 WINDOW
*w
= window
->w
;
81 colors_use(w
, COLOR_STATUS_ALERT
);
82 line
= wreadln(w
, prompt
, value
, window
->cols
, history
, gcmp
);
88 screen_read_password(const char *prompt
)
90 struct window
*window
= &screen
.status_bar
.window
;
91 WINDOW
*w
= window
->w
;
96 colors_use(w
, COLOR_STATUS_ALERT
);
99 prompt
= _("Password");
100 ret
= wreadln_masked(w
, prompt
, NULL
, window
->cols
, NULL
, NULL
);
107 screen_display_completion_list(GList
*list
)
109 static GList
*prev_list
= NULL
;
110 static guint prev_length
= 0;
111 static guint offset
= 0;
112 WINDOW
*w
= screen
.main_window
.w
;
115 length
= g_list_length(list
);
116 if (list
== prev_list
&& length
== prev_length
) {
117 offset
+= screen
.main_window
.rows
;
118 if (offset
>= length
)
122 prev_length
= length
;
126 colors_use(w
, COLOR_STATUS_ALERT
);
127 while (y
< screen
.main_window
.rows
) {
128 GList
*item
= g_list_nth(list
, y
+offset
);
133 gchar
*tmp
= g_strdup(item
->data
);
134 waddstr(w
, g_basename(tmp
));
141 colors_use(w
, COLOR_LIST
);
146 set_xterm_title(const char *format
, ...)
148 /* the current xterm title exists under the WM_NAME property */
149 /* and can be retrieved with xprop -id $WINDOWID */
151 if (options
.enable_xterm_title
) {
152 if (g_getenv("WINDOWID")) {
157 msg
= g_strdup_vprintf(format
,ap
);
159 printf("%c]0;%s%c", '\033', msg
, '\007');
162 options
.enable_xterm_title
= FALSE
;