static int check_buf(char *buf, t_win *win, int position, t_ios *term) { int select; select = 0; if (buf[0] == 32) selection(win->arg, position, &select); else if (buf[0] == 4) { if (tcsetattr(0, TCSADRAIN, term) == -1) leave_term(); } else if (buf[0] == 10) print_selected(win->arg); else if (buf[0] == 114) select_reverse(win->arg); else if (buf[0] == 97) select_all(win->arg); else if ((buf[0] == 126 || buf[0] == 127)) { clr_screen(); win->arg = delete_link(win, position); } return (select); }
/* SIGINTシグナルハンドラ */ void Sigint_Handler(void) { system("tput cnorm"); system("stty echo icanon"); color_default(); property_default(); clr_screen(); pos(0,0); exit(0); }
/* reset terminal to original state */ void settty(char *s) { clr_screen(); end_screen(); if(s) printf("%s", s); (void) fflush(stdout); if(tcsetattr(0, TCSADRAIN, &inittyb) < 0) perror("Hack (settty)"); flags.echo = (inittyb.c_lflag & ECHO) ? ON : OFF; flags.cbreak = (inittyb.c_lflag & ICANON) ? OFF : ON; setioctls(); }
void main() { init_uart(); clr_screen(); while(1) { home_screen(); tx('H'); delay(2); tx('E'); delay(2); } }
int __start() { printf("-- boot complete -- \r\n"); refresh = 0; old_img_addr = SRAM_BASEADDR; new_img_addr = SRAM_BASEADDR + 0x80000; clr_screen(old_img_addr); clr_screen(new_img_addr); draw_gun(0, 30); /* blinker */ set_pixel(old_img_addr, 20, 10, 1); set_pixel(old_img_addr, 20, 11, 1); set_pixel(old_img_addr, 20, 12, 1); /* another blinker */ set_pixel(old_img_addr, 30, 10, 1); set_pixel(old_img_addr, 31, 10, 1); set_pixel(old_img_addr, 32, 10, 1); /* pixel alone, will die after the first iteration */ set_pixel(old_img_addr, 32, 30, 1); /* start vga */ write_mem(VGA_BASEADDR + VGA_CFG_OFFSET, old_img_addr); /* program timer: 0x01000000 / (50MHz) = 0.33554432 seconds */ write_mem(TIMER_BASEADDR + TIMER_0_TLR_OFFSET, 0x04000000); write_mem(TIMER_BASEADDR + TIMER_0_CSR_OFFSET, TIMER_RELOAD); write_mem(TIMER_BASEADDR + TIMER_0_CSR_OFFSET, TIMER_START); /* program gpio to input */ write_mem(GPIO_BASEADDR + GPIO_TRI_OFFSET, GPIO_INPUT); while (1) { /* glider */ set_pixel(old_img_addr, 11, 10, 1); set_pixel(old_img_addr, 12, 11, 1); set_pixel(old_img_addr, 10, 12, 1); set_pixel(old_img_addr, 11, 12, 1); set_pixel(old_img_addr, 12, 12, 1); /* another glider */ set_pixel(old_img_addr, 51, 10, 1); set_pixel(old_img_addr, 50, 11, 1); set_pixel(old_img_addr, 52, 12, 1); set_pixel(old_img_addr, 51, 12, 1); set_pixel(old_img_addr, 50, 12, 1); while (1) { uint32_t d = read_mem(GPIO_BASEADDR + GPIO_DATA_OFFSET); if (TEST_BIT(d, GPIO_BTN0)) { break; } // put cpu in a lower consumption state while waiting for an int wait_for_irq(); //cpu_relax(); } } return 0; }
void resize(void) { get_window_size(); clr_screen(); }