Code

Added a find buffer and a function for formated status messages.
authorKalle Wallin <kaw@linux.se>
Mon, 22 Mar 2004 18:09:23 +0000 (18:09 +0000)
committerKalle Wallin <kaw@linux.se>
Mon, 22 Mar 2004 18:09:23 +0000 (18:09 +0000)
git-svn-id: https://svn.musicpd.org/ncmpc/trunk@368 09075e82-0dd4-0310-85a5-a0d7c8717e4f

screen.c
screen.h

index 98c08eb66027c601bf186a9678d74e916bfd4ff9..2d61122fd91cfe08d988bab76080f93a0124a0c6 100644 (file)
--- a/screen.c
+++ b/screen.c
@@ -5,6 +5,7 @@
 
 #include <stdlib.h>
 #include <unistd.h>
+#include <stdarg.h>
 #include <string.h>
 #include <time.h>
 #include <glib.h>
@@ -20,6 +21,7 @@
 #include "screen_search.h"
 
 #define STATUS_MESSAGE_TIMEOUT 3
+#define STATUS_LINE_MAX_SIZE   512
 
 static screen_t *screen = NULL;
 
@@ -203,6 +205,7 @@ screen_exit(void)
       screen->filelist = list_window_free(screen->filelist);
       screen->helplist = list_window_free(screen->helplist);
       free(screen->buf);
+      free(screen->findbuf);
       free(screen);
       screen = NULL;
     }
@@ -235,6 +238,18 @@ screen_status_message(mpd_client_t *c, char *msg)
   screen->status_timestamp = time(NULL);
 }
 
+void 
+screen_status_printf(mpd_client_t *c, char *format, ...)
+{
+  char buffer[STATUS_LINE_MAX_SIZE];
+  va_list ap;
+  
+  va_start(ap,format);
+  vsnprintf(buffer,sizeof(buffer),format,ap);
+  va_end(ap);
+  screen_status_message(c, buffer);
+}
+
 int
 screen_init(void)
 {
@@ -269,6 +284,7 @@ screen_init(void)
   screen->rows = LINES;
   screen->buf  = malloc(screen->cols);
   screen->buf_size = screen->cols;
+  screen->findbuf = NULL;
   screen->painted = 0;
 
   /* create top window */
@@ -503,6 +519,8 @@ screen_cmd(mpd_client_t *c, command_t cmd)
       break;
     case CMD_QUIT:
       exit(EXIT_SUCCESS);
+    case CMD_LIST_FIND:
+    case CMD_LIST_FIND_NEXT:
     case CMD_NONE:
     case CMD_DELETE: 
     case CMD_SELECT:
index 35124240b002f56d46b48b14a9ceca1cc0a2200a..4681319c391d646c39e14aff07b4a832fd0337d5 100644 (file)
--- a/screen.h
+++ b/screen.h
@@ -53,6 +53,8 @@ typedef struct
   char *buf;
   size_t buf_size;
 
+  char *findbuf;
+
   int painted;
 
 } screen_t;
@@ -63,6 +65,7 @@ int screen_init(void);
 int screen_exit(void);
 void screen_resized(int sig);
 void screen_status_message(mpd_client_t *c, char *msg);
+void screen_status_printf(mpd_client_t *c, char *format, ...);
 char *screen_error(void);
 void screen_paint(mpd_client_t *c);
 void screen_update(mpd_client_t *c);