[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Ncurses + readline problem
From: |
Sergey I. Sharybin |
Subject: |
Ncurses + readline problem |
Date: |
Sun, 29 Mar 2009 17:38:42 +0600 |
User-agent: |
Thunderbird 2.0.0.12 (X11/20080213) |
Hi,
I'm writting some console program using ncurses for interface. In this
program I want to implement small subshell using readline for command
prompt. I'm switching ncurses to shell mode and call the readline()
function. After this I return ncurses to program mode. But after I
called the readline() function I can't get correct terminal size through
the LINES and COLS variables. The terminal's size before readline() is
stored in this variables and this values isn't changes anyway after
readline() function called.
Is it mine programming error or it is bug of ncurses or readline?
I attached small sample program to this letter.
Thanks,
--
With best regards, Sergey I. Sharybin
#include <ncursesw/ncurses.h>
#include <readline/readline.h>
#include <malloc.h>
#include <signal.h>
static int subshell = 0;
static void
sig_winch (int sig)
{
if (subshell)
{
return;
}
endwin ();
refresh ();
printf ("%d %d\n", LINES, COLS);
fflush (stdout);
}
int
main (int __argc, char **__argv)
{
struct timespec timestruc;
timestruc.tv_sec = 0;
timestruc.tv_nsec = 0.2 * 1000 * 1000;
initscr ();
signal (SIGWINCH, sig_winch);
cbreak (); /* take input chars one at a time, no wait for \n */
noecho (); /* don't echo input */
nodelay (stdscr, TRUE);
start_color ();
for (;;)
{
wchar_t ch;
wget_wch (stdscr, &ch);
if (ch == 'q')
{
break;
}
else if (ch == 's')
{
char *buf;
subshell = 1;
def_prog_mode ();
nodelay (stdscr, FALSE);
endwin ();
buf = readline (">>> ");
if (buf)
{
free (buf);
}
refresh ();
nodelay (stdscr, TRUE);
subshell = 0;
}
nanosleep (×truc, 0);
}
endwin ();
return 0;
}
- Ncurses + readline problem,
Sergey I. Sharybin <=