I've been amusing myself recently playing with Curses in perl and now I want to play with multiple terminals (ala screen). If I'm reading the documentation for curses correctly, I want to use the newterm function to facilitate this. The problem is, newterm() either errors with complaints about my arguments or segfaults.
My latest segfault looks like this:
my $o = IO::File->new("/dev/tty", "w");
my $i = IO::File->new("/dev/tty", "r");
newterm(undef, $o, $i);
endwin()
I should note that roughly the same code in C works:
#include <curses.h>
#include <stdlib.h>
int main()
{
FILE *i, *o;
i = fopen( "/dev/tty", "r" );
o = fopen( "/dev/tty", "w" );
SCREEN *s = newterm(0, o, i);
addch('a');
addch('b');
addch('c');
refresh();
endwin();
}
I'll reproduce the XS code for newterm for your viewing pleasure:
XS(XS_Curses_newterm)
{
dXSARGS;
#ifdef C_NEWTERM
c_exactargs("newterm", items, 3);
{
char * type = ST(0) != &PL_sv_undef ? (char *)SvPV(ST(0),PL_na) :
+NULL;
FILE * outfd = IoIFP(sv_2io(ST(1)));
FILE * infd = IoIFP(sv_2io(ST(2)));
SCREEN * ret = newterm(type, outfd, infd);
ST(0) = sv_newmortal();
c_screen2sv(ST(0), ret);
}
XSRETURN(1);
#else
c_fun_not_there("newterm");
XSRETURN(0);
#endif
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.