sys.nanosleep(0, 48000000)
# Keyboard input
- while stdin.as(Stdin).poll_in do
+ while stdin.poll_in do
if stdin.eof then return
var c = stdin.read_char
if c == 'q'.ascii then
fun delwin is extern
fun endwin is extern
end
-
-redef class Stdin
- # Is these something to read? (non blocking)
- # FIXME: should not be in the curses module
- fun poll_in: Bool is extern
-end
*/
#include "curses.nit.h"
-#include <poll.h>
/*
C implementation of curses::Window::init
{
endwin();
}
-
-/*
-C implementation of curses::Stdin::poll_in
-*/
-int Stdin_poll_in___impl( Stdin recv ) {
- struct pollfd fd = {0, POLLIN, 0};
- int res = poll(&fd, 1, 0);
- if (res == -1) {
- endwin();
- perror("Error poll stdin");
- exit(EXIT_FAILURE);
- }
- return res > 0;
-}
void Window_wclear___impl( Window recv );
void Window_delwin___impl( Window recv );
void Window_endwin___impl( Window recv );
-int Stdin_poll_in___impl( Stdin recv );
#endif
_path = "/dev/stdin"
prepare_buffer(1)
end
+
+ # Is these something to read? (non blocking)
+ # FIXME: should be generalized
+ fun poll_in: Bool is extern "file_stdin_poll_in"
end
class Stdout
end
# Standard input.
-fun stdin: IFStream do return once new Stdin
+fun stdin: Stdin do return once new Stdin
# Standard output.
fun stdout: OFStream do return once new Stdout
#include <sys/types.h>
#include <string.h>
#include <dirent.h>
+#include <poll.h>
#include "file_nit.h"
extern int string_NativeString_NativeString_file_delete_0(char *f){
return (remove(f) == 0);
}
+
+int file_stdin_poll_in_(void) {
+ struct pollfd fd = {0, POLLIN, 0};
+ int res = poll(&fd, 1, 0);
+ if (res == -1) {
+ perror("Error poll stdin");
+ exit(EXIT_FAILURE);
+ }
+ return res > 0;
+}
#define file_FileStat_FileStat_size_0(self) (((struct stat*)self)->st_size)
#define string_NativeString_NativeString_file_mkdir_0(p) (mkdir(p, 0777))
+
+#define file_stdin_poll_in(self) file_stdin_poll_in_()
+int file_stdin_poll_in_(void);
#endif