Hye,
I'm playing with the readline binding and the GLib mainloop:
-----------------------
using GLib;
static MainLoop loop;
void parse_line (string? line_read) {
if (line_read == null) {
Readline.callback_handler_remove ();
loop.quit ();
return;
}
stdout.printf (@"$line_read\n");
}
bool io_read_event (IOChannel source, IOCondition cond)
{
if (cond == IOCondition.IN) {
Readline.callback_read_char();
return true;
}
warning ("io_read_event unable to handle IOCondition than
IOCondition.IN");
return false;
}
void main () {
loop = new MainLoop ();
var io_stdin = new IOChannel.unix_new (stdin.fileno());
io_stdin.add_watch (IOCondition.IN, io_read_event);
Readline.VcpFunc func = parse_line;
Readline.callback_handler_install ("-> ", func);
loop.run ();
stdout.printf ("\nGoodbye!\n");
}
-----------------------
I have a problem using the delegate VcpFunc.
With the correction of the bug 656146 (thanks to Luca):
user@localhost:/tmp$ valac main.vala --pkg gio-2.0 --pkg readline -X -lreadline
/tmp/main.vala.c: In function ‘_vala_main’:
/tmp/main.vala.c:102:2: error: lvalue required as left operand of assignment
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)
Replacing the lines:
Readline.VcpFunc func = parse_line;
Readline.callback_handler_install ("-> ", func);
with:
Readline.callback_handler_install ("-> ", parse_line);
works fine.
Did I misunderstand delegation or is there a bug here?
--
Jérôme
_______________________________________________
vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list