aboutsummaryrefslogtreecommitdiffstats
path: root/screen_utils.c
blob: 49bd6692a2682c3e14bd53940203af0c99cc3f93 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <glib.h>
#include <ncurses.h>

#include "libmpdclient.h"
#include "mpc.h"
#include "support.h"
#include "command.h"
#include "screen.h"

char *
screen_readln(WINDOW *w, char *prompt)
{
  char buf[256], *line = NULL;
  int prompt_len = strlen(prompt);

  wclear(w);  
  wmove(w, 0, 0);
  waddstr(w, prompt);
  wmove(w, 0, prompt_len);
  
  echo();
  curs_set(1);

  if( wgetnstr(w, buf, 256) == OK )
    line = strdup(buf);

  noecho();
  curs_set(0);

  return line;
}