Example #1
0
void start_ex_cmd(char symbol, int state)
{
  log_msg("EXCMD", "start");
  ex.ex_state = state;
  ex.state_symbol = symbol;
  window_refresh();

  pos_T max = layout_size();
  ex.curpos = 0;
  ex.curofs = 0;
  ex.maxpos = max.col - 2;
  ex.state = 0;
  ex.col_text = opt_color(COMPL_TEXT);
  ex.col_symb = opt_color(BUF_TEXT);

  switch (state) {
    case EX_CMD_STATE:
      menu_start(ex.menu);
      break;
    case EX_REG_STATE:
      ex.lm = window_get_focus()->matches;
      regex_mk_pivot(ex.lm);
      break;
    case EX_FIL_STATE:
      ex.fil = window_get_focus()->filter;
      //swap exline with filter string
      break;
  }
  ex.line = calloc(max.col, sizeof(char*));
  ex.cmd.cmds = NULL;
  ex.cmd.line = NULL;
  hist_push(state);
  cmdline_build(&ex.cmd, ex.line);
}
Example #2
0
void cmdline_resize()
{
  pos_T max = layout_size();
  delwin(ex.nc_win);
  ex.nc_win = newwin(1, 0, max.lnum - 1, 0);
  menu_resize(ex.menu);
}
Example #3
0
blob encode_omdl(const model& mdl
	, const allocator& file_alloc
	, const allocator& temp_alloc)
{
	const auto& info = mdl.info();

	uint32_t nslots = info.num_slots;
	const auto subsets_bytes = info.num_subsets * (uint32_t)sizeof(subset_t);
	const auto indices_bytes = info.num_indices * (uint32_t)sizeof(uint16_t);
	const auto vertices_bytes = info.num_vertices * layout_size(info.layout);

	const auto bytes = sizeof(file_header) 
		+ sizeof(file_chunk) + sizeof(info_t) 
		+ sizeof(file_chunk) + subsets_bytes
		+ sizeof(file_chunk) + indices_bytes
		+ sizeof(file_chunk) * nslots + vertices_bytes;

	auto mem = file_alloc.scoped_allocate(bytes, "encoded model");
	auto hdr = (file_header*)mem;

	hdr->fourcc = omdl_signature;
	hdr->num_chunks = 4;
	hdr->compression = compression_type::none; // not yet implemented, though here's where it gets done
	hdr->reserved = 0;
	hdr->version_hash = 0; // not yet implemented

	auto chk = hdr->first_chunk();
	chk->fourcc = omdl_info_signature;
	chk->chunk_bytes = sizeof(info_t);
	chk->uncompressed_bytes = chk->chunk_bytes;
	memcpy(chk->data<info_t>(), &info, sizeof(info_t));

	chk = chk->next();
	chk->fourcc = omdl_subsets_signature;
	chk->chunk_bytes = subsets_bytes;
	chk->uncompressed_bytes = chk->chunk_bytes;
	memcpy(chk->data<subset_t>(), mdl.subsets(), chk->chunk_bytes);

	chk = chk->next();
	chk->fourcc = omdl_indices_signature;
	chk->chunk_bytes = indices_bytes;
	chk->uncompressed_bytes = chk->chunk_bytes;
	memcpy(chk->data<uint16_t>(), mdl.indices(), chk->chunk_bytes);

	for (uint32_t slot = 0; slot < nslots; slot++)
	{
		chk = chk->next();
		chk->fourcc = omdl_vertex_slot_signature;
		chk->chunk_bytes = vertices_bytes;
		chk->uncompressed_bytes = chk->chunk_bytes;
		memcpy(chk->data<void>(), mdl.vertices(slot), chk->chunk_bytes);
	}

	return mem;
}
Example #4
0
static void ex_draw()
{
  log_msg("EXCMD", "ex_draw");
  werase(ex.nc_win);

  if (ex.ex_state == EX_CMD_STATE)
    menu_draw(ex.menu);

  pos_T max = layout_size();
  wchar_t *wline = str2wide(ex.line);
  int len = 2 + wcswidth(wline, -1);
  int offset = MAX(len - (max.col - 1), 0);

  mvwaddch(ex.nc_win, 0, 0, ex.state_symbol);
  mvwaddwstr(ex.nc_win, 0, 1, &wline[offset]);
  mvwchgat(ex.nc_win, 0, 0, 1, A_NORMAL, ex.col_symb, NULL);
  mvwchgat(ex.nc_win, 0, 1, -1, A_NORMAL, ex.col_text, NULL);

  doupdate();
  curs_set(1);
  wmove(ex.nc_win, 0, (ex.curpos + 1) - offset);
  wnoutrefresh(ex.nc_win);
  free(wline);
}
Example #5
0
#define layout_entry_size (sizeof ((dht_layout_t *)NULL)->list[0])

#define layout_size(cnt) (layout_base_size + (cnt * layout_entry_size))

dht_layout_t *
dht_layout_new (xlator_t *this, int cnt)
{
        dht_layout_t *layout = NULL;
        dht_conf_t   *conf = NULL;

        REQUIRE(NULL != this);
        REQUIRE(cnt >= 0);

        conf = this->private;

        layout = GF_CALLOC (1, layout_size (cnt),
                            gf_dht_mt_dht_layout_t);
        if (!layout) {
                goto out;
        }

        layout->type = DHT_HASH_TYPE_DM;
        layout->cnt = cnt;

        if (conf) {
                layout->spread_cnt = conf->dir_spread_cnt;
                layout->gen = conf->gen;
        }

        layout->ref = 1;
Example #6
0
VALUE _miyako_layout_size(VALUE self)
{
  return layout_size(self);
}
Example #7
0
#define layout_entry_size (sizeof((dht_layout_t *)NULL)->list[0])

#define layout_size(cnt) (layout_base_size + (cnt * layout_entry_size))

dht_layout_t *
dht_layout_new(xlator_t *this, int cnt)
{
    dht_layout_t *layout = NULL;
    dht_conf_t *conf = NULL;

    REQUIRE(NULL != this);
    REQUIRE(cnt >= 0);

    conf = this->private;

    layout = GF_CALLOC(1, layout_size(cnt), gf_dht_mt_dht_layout_t);
    if (!layout) {
        goto out;
    }

    layout->type = DHT_HASH_TYPE_DM;
    layout->cnt = cnt;

    if (conf) {
        layout->spread_cnt = conf->dir_spread_cnt;
        layout->gen = conf->gen;
    }

    GF_ATOMIC_INIT(layout->ref, 1);

    ENSURE(NULL != layout);