aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKalle Wallin <kaw@linux.se>2004-06-18 14:21:53 +0000
committerKalle Wallin <kaw@linux.se>2004-06-18 14:21:53 +0000
commit0a40624443576a8929d9f2370d52248cab9245fe (patch)
treea4b8a0dc778f58131edba0aeda6e6e9100ebe1a4
parent5661324c51dd3af2bd3e3695b09502b65222f3db (diff)
downloadmpd-0a40624443576a8929d9f2370d52248cab9245fe.tar.gz
mpd-0a40624443576a8929d9f2370d52248cab9245fe.tar.xz
mpd-0a40624443576a8929d9f2370d52248cab9245fe.zip
Added completion stuff
git-svn-id: https://svn.musicpd.org/ncmpc/trunk@1556 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/screen_utils.c22
-rw-r--r--src/screen_utils.h9
-rw-r--r--src/wreadln.c8
-rw-r--r--src/wreadln.h8
4 files changed, 44 insertions, 3 deletions
diff --git a/src/screen_utils.c b/src/screen_utils.c
index 398fdd9fe..16359c6ea 100644
--- a/src/screen_utils.c
+++ b/src/screen_utils.c
@@ -159,4 +159,26 @@ screen_find(screen_t *screen,
return 0;
}
+void
+screen_display_completion_list(screen_t *screen, GList *list)
+{
+ WINDOW *w = screen->main_window.w;
+ gint y=0;
+ colors_use(w, COLOR_STATUS_ALERT);
+ while( y<screen->main_window.rows )
+ {
+ wmove(w, y++, 0);
+ wclrtoeol(w);
+ if( list )
+ {
+ gchar *tmp = g_strdup(list->data);
+ waddstr(w, basename(tmp));
+ g_free(tmp);
+ list = list->next;
+ }
+ }
+ wrefresh(w);
+ doupdate();
+ colors_use(w, COLOR_LIST);
+}
diff --git a/src/screen_utils.h b/src/screen_utils.h
index b6e8d1171..d60a33824 100644
--- a/src/screen_utils.h
+++ b/src/screen_utils.h
@@ -1,9 +1,13 @@
+#ifndef SCREEN_UTILS_H
+#define SCREEN_UTILS_H
/* read a characher from the status window */
int screen_getch(WINDOW *w, char *prompt);
/* read a string from the status window */
char *screen_getstr(WINDOW *w, char *prompt);
+char *screen_readln(WINDOW *w, char *prompt, char *value,
+ GList **history, GCompletion *gcmp);
/* query user for a string and find it in a list window */
int screen_find(screen_t *screen,
@@ -14,5 +18,6 @@ int screen_find(screen_t *screen,
list_window_callback_fn_t callback_fn);
-int my_waddstr(WINDOW *, const char *, int);
-int my_mvwaddstr(WINDOW *, int, int, const char *, int);
+void screen_display_completion_list(screen_t *screen, GList *list);
+
+#endif
diff --git a/src/wreadln.c b/src/wreadln.c
index 6ac94b7dc..b5caef7dd 100644
--- a/src/wreadln.c
+++ b/src/wreadln.c
@@ -39,6 +39,8 @@
unsigned int wrln_max_line_size = WRLN_MAX_LINE_SIZE;
unsigned int wrln_max_history_length = WRLN_MAX_HISTORY_LENGTH;
GVoidFunc wrln_resize_callback = NULL;
+wrln_gcmp_pre_cb_t wrln_pre_completion_callback = NULL;
+wrln_gcmp_post_cb_t wrln_post_completion_callback = NULL;
char *
@@ -183,7 +185,9 @@ wreadln(WINDOW *w,
char *prefix = NULL;
GList *list;
- list = g_completion_complete(gcmp, line, &prefix);
+ if(wrln_pre_completion_callback)
+ wrln_pre_completion_callback(gcmp, line);
+ list = g_completion_complete(gcmp, line, &prefix);
if( prefix )
{
int len = strlen(prefix);
@@ -193,6 +197,8 @@ wreadln(WINDOW *w,
}
else
beep();
+ if( wrln_post_completion_callback )
+ wrln_post_completion_callback(gcmp, line, list);
}
break;
diff --git a/src/wreadln.h b/src/wreadln.h
index 270d73fb1..520ba2a6a 100644
--- a/src/wreadln.h
+++ b/src/wreadln.h
@@ -10,6 +10,14 @@ extern unsigned int wrln_max_history_length;
/* a callback function for KEY_RESIZE */
extern GVoidFunc wrln_resize_callback;
+/* called after TAB is pressed but before g_completion_complete */
+typedef void (*wrln_gcmp_pre_cb_t) (GCompletion *gcmp, gchar *buf);
+extern wrln_gcmp_pre_cb_t wrln_pre_completion_callback;
+
+/* post completion callback */
+typedef void (*wrln_gcmp_post_cb_t) (GCompletion *gcmp, gchar *s, GList *l);
+extern wrln_gcmp_post_cb_t wrln_post_completion_callback;
+
/* Note, wreadln calls curs_set() and noecho(), to enable cursor and
* disable echo. wreadln will not restore these settings when exiting! */
char *wreadln(WINDOW *w, /* the curses window to use */