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(); }
static int luabox_getcell( lua_State *L ) { uint16_t x = luaL_checknumber( L, 1 ); uint16_t y = luaL_checknumber( L, 2 ); if ( x >= 0 && x < tb_width() && y >= 0 && y < tb_height()) { struct tb_cell *cell = (tb_cell_buffer() + y * tb_width() + x); lua_pushnumber( L, cell->ch ); lua_pushnumber( L, cell->fg ); lua_pushnumber( L, cell->bg ); return 3; } else { luaL_error( L, "coordinates out of bounds" ); return 0; } }