/* * The ctor calls the init function to initialize the termbox library, which * returns * -1 if unsupported terminal, * -2 if failed to open tty, * -3 unix pipe error. */ Window::Window() { // TODO: ignored ret code for now int ret = tb_init(); // input = {}; // tb_clear(); tb_select_output_mode(TB_OUTPUT_NORMAL); tb_present(); }
void ui_draw(state_t *state) { tb_clear(); ui_draw_input_line(state->input); ui_draw_status_line(); ui_draw_output(&state->log); tb_present(); usleep(50000); }
void updateAndRedrawAll(int mx, int my) { tb_clear(); if (mx != -1 && my != -1) { backbuf[bbw*my+mx].ch = runes[curRune]; backbuf[bbw*my+mx].fg = colors[curCol]; } memcpy(tb_cell_buffer(), backbuf, sizeof(struct tb_cell)*bbw*bbh); int h = tb_height(); updateAndDrawButtons(&curRune, 0, 0, mx, my, len(runes), runeAttrFunc); updateAndDrawButtons(&curCol, 0, h-3, mx, my, len(colors), colorAttrFunc); tb_present(); }
/* * Starting from (x,y) we print the string character by character. */ void Window::print(int x, int y, const std::string& s, uint16_t fg, uint16_t bg) { // We work with the underlying C string auto str = s.c_str(); for(int i = 0; i < s.size(); ++i) { uint32_t uni; tb_utf8_char_to_unicode(&uni, &str[i]); tb_change_cell(x, y, uni, fg, bg); ++x; } tb_present(); }
int main(int argc, char const *argv[]) { tb_init(); Player player; while (1) { g_input.update(); if (g_input.getKey() == KeyEsc) { tb_shutdown(); return 0; } player.update(); tb_clear(); player.render(); tb_present(); } tb_shutdown(); return 0; }
/** * Render widgets to the screen. */ inline void render() { if (root) root->render(); tb_present(); }
void Window::print(int x, int y, char c, uint16_t fg, uint16_t bg) { uint32_t uni; tb_utf8_char_to_unicode(&uni, &c); tb_change_cell(x, y, uni, fg, bg); tb_present(); }
static int lua_tb_present( lua_State *L ) { tb_present(); return 0; }
static void draw() { tb_clear(); tb_change_cell(0, 0, 'A', 0, 1); tb_present(); }
/*! \brief Synchronizes the internal back buffer with the terminal. */ void present(){ Q_ASSERT_X(QTermboxCorePrivate::wasInitialized(), "present", "Termbox was not initialized."); tb_present(); }