// // Open_IO: C // DEVICE_CMD Open_IO(REBREQ *req) { REBDEV *dev; dev = Devices[req->device]; // Avoid opening the console twice (compare dev and req flags): if (GET_FLAG(dev->flags, RDF_OPEN)) { // Device was opened earlier as null, so req must have that flag: if (GET_FLAG(dev->flags, SF_DEV_NULL)) SET_FLAG(req->modes, RDM_NULL); SET_FLAG(req->flags, RRF_OPEN); return DR_DONE; // Do not do it again } Init_Signals(); if (!GET_FLAG(req->modes, RDM_NULL)) { #ifndef HAS_SMART_CONSOLE if (isatty(Std_Inp)) Term_IO = Init_Terminal(); #endif //printf("%x\r\n", req->requestee.handle); } else SET_FLAG(dev->flags, SF_DEV_NULL); SET_FLAG(req->flags, RRF_OPEN); SET_FLAG(dev->flags, RDF_OPEN); return DR_DONE; }
main() { int i; char buf[1024]; STD_TERM *term; term = Init_Terminal(); Write_Char('-', 50); WRITE_STR("\r\n"); #ifdef WIN32 test(term, "text\010\010st\n"); //bs bs test(term, "test\001xxxx\n"); // home test(term, "test\001\005xxxx\n"); // home test(term, "\033[A\n"); // up arrow #endif do { WRITE_STR(">> "); i = Read_Line(term, buf, 1000); printf("len: %d %s\r\n", i, term->out); } while (i > 0); Quit_Terminal(term); }