Example #1
0
static Container *_ht_list_container(QSP_ARG_DECL  Hash_Tbl *htp)
{
	Container *cnt_p;

	cnt_p = new_container(LIST_CONTAINER);
	cnt_p->cnt_lp = ht_list(htp);
	return cnt_p;
}
Example #2
0
Container * _create_container(QSP_ARG_DECL  const char *name, container_type_code type)
{
	Container *cnt_p;

	if( type == 0 ) type=HASH_TBL_CONTAINER;	// default
	cnt_p = new_container(type);
	cnt_p->name = savestr(name);
	return cnt_p;
}
Example #3
0
int main(void)
{
  gui *g;
  widget *w, *c1, *c2, *l, *plot, *tl;
  int tlcol;

  g = gui_init();

  c1 = new_container(g, VERTICAL);
  c2 = new_container(g, HORIZONTAL);

  l = new_label(g, "this is a good label");
  widget_add_child(g, c2, l, 0);
  l = new_label(g, "this is another good label");
  widget_add_child(g, c2, l, -1);

  l = new_label(g, "OH! WHAT A LABEL!");
  widget_add_child(g, c1, l, -1);

  widget_add_child(g, c1, c2, 0);

  plot = new_xy_plot(g, 100, 100, "xy plot test", 30);
#if 0
  c2 = new_container(g, HORIZONTAL);
  widget_add_child(g, c2, plot, -1);
  widget_add_child(g, c1, c2, -1);
#else
  widget_add_child(g, c1, plot, -1);
#endif

  tlcol = new_color(g, "#ddf");
  tl = new_textlist(g, 300, 10, tlcol);
  widget_add_child(g, c1, tl, -1);

  textlist_add(g, tl, "hello", -1, FOREGROUND_COLOR);
  textlist_add(g, tl, "world", -1, FOREGROUND_COLOR);

  w = new_toplevel_window(g, 500, 400, "test window");
  widget_add_child(g, w, c1, 0);

  gui_loop(g);

  return 0;
}
Example #4
0
void	*create_io_number(void const *lex_value)
{
	t_token const		*token;

	token = lex_value;
	if (token != NULL && token->value != NULL)
		return (new_container(token->value,
					&ft_memdel,
					ft_strlen(token->value) + 1,
					e_ast_container_label_io_number));
	else
		return (NULL);
}
Example #5
0
void	*create_io_redirect(void const *lex_value)
{
	struct s_container		*container;
	struct s_sh_io_redirect	io_redirect;

	(void)lex_value;
	io_redirect.ionum = NULL;
	io_redirect.type = e_sh_io_type_none;
	io_redirect.target = NULL;
	io_redirect.flags = 0;
	io_redirect.mode = 0;
	io_redirect.variant = 0;
	container = new_container(&io_redirect, &destroy_io_redirect,
			sizeof(io_redirect), e_ast_container_label_io_redirect);
	return (container);
}
Example #6
0
static void vcd_main_gui(gui *g, event_handler *h, void *database)
{
  int i, j;
  int n;
  int nb_functions = 0;
  char **ids;
  widget *win;
  widget *container;
  widget *w;
  view *timeview;
  view *subview;
  logger *timelog;

  /* get number of vcd functions - look for all events VCD_FUNCTION_xxx */
  n = database_get_ids(database, &ids);
  for (i = 0; i < n; i++) {
    if (strncmp(ids[i], "VCD_FUNCTION_", 13) != 0) continue;
    nb_functions++;
  }

  win = new_toplevel_window(g, 1000, 5 * nb_functions, "VCD tracer");
  container = new_container(g, VERTICAL);
  widget_add_child(g, win, container, -1);

  w = new_timeline(g, 1000, nb_functions, 5);
  widget_add_child(g, container, w, -1);
  for (i = 0; i < nb_functions; i++)
    timeline_set_subline_background_color(g, w, i,
        new_color(g, i & 1 ? "#ddd" : "#eee"));
  timeview = new_view_time(3600, 10, g, w);
  i = 0;
  for (j = 0; j < n; j++) {
    if (strncmp(ids[j], "VCD_FUNCTION_", 13) != 0) continue;
    timelog = new_timelog(h, database, ids[j]);
    subview = new_subview_time(timeview, i, FOREGROUND_COLOR, 3600*1000);
    logger_add_view(timelog, subview);
    i++;
  }

  free(ids);
}
Example #7
0
File: layout.c Project: thuck/sway
void move_container(swayc_t *container, enum movement_direction dir) {
	enum swayc_layouts layout;
	if (container->is_floating
			|| (container->type != C_VIEW && container->type != C_CONTAINER)) {
		return;
	}
	if (dir == MOVE_UP || dir == MOVE_DOWN) {
		layout = L_VERT;
	} else if (dir == MOVE_LEFT || dir == MOVE_RIGHT) {
		layout = L_HORIZ;
	} else {
		return;
	}
	swayc_t *parent = container->parent;
	swayc_t *child = container;
	bool ascended = false;
	while (true) {
		sway_log(L_DEBUG, "container:%p, parent:%p, child %p,",
				container,parent,child);
		if (parent->layout == layout
			|| (parent->layout == L_TABBED && layout == L_HORIZ)
			|| (parent->layout == L_STACKED && layout == L_VERT)) {
			int diff;
			// If it has ascended (parent has moved up), no container is removed
			// so insert it at index, or index+1.
			// if it has not, the moved container is removed, so it needs to be
			// inserted at index-1, or index+1
			if (ascended) {
				diff = dir == MOVE_LEFT || dir == MOVE_UP ? 0 : 1;
			} else {
				diff = dir == MOVE_LEFT || dir == MOVE_UP ? -1 : 1;
			}
			int desired = index_child(child) + diff;
			// when it has ascended, legal insertion position is 0:len
			// when it has not, legal insertion position is 0:len-1
			if (desired >= 0 && desired - ascended < parent->children->length) {
				if (!ascended) {
					child = parent->children->items[desired];
					// Move container into sibling container
					if (child->type == C_CONTAINER) {
						parent = child;
						// Insert it in first/last if matching layout, otherwise
						// inesrt it next to focused container
						if (parent->layout == layout
							|| (parent->layout == L_TABBED && layout == L_HORIZ)
							|| (parent->layout == L_STACKED && layout == L_VERT)) {
							desired = (diff < 0) * parent->children->length;
						} else {
							desired = index_child(child->focused);
						}
						//reset geometry
						container->width = container->height = 0;
					}
				}
				swayc_t *old_parent = remove_child(container);
				insert_child(parent, container, desired);
				destroy_container(old_parent);
				sway_log(L_DEBUG,"Moving to %p %d",parent, desired);
				break;
			}
		}
		// Change parent layout if we need to
		if (parent->children->length == 1 && parent->layout != layout) {
			parent->layout = layout;
			continue;
		}
		if (parent->type == C_WORKSPACE) {
			// We simply cannot move any further.
			if (parent->layout == layout) {
				break;
			}
			// Create container around workspace to insert child into
			parent = new_container(parent, layout);
		}
		ascended = true;
		child = parent;
		parent = child->parent;
	}
	arrange_windows(parent->parent, -1, -1);
	set_focused_container_for(parent->parent, container);
}
Example #8
0
struct cmd_results *cmd_layout(int argc, char **argv) {
	struct cmd_results *error = NULL;
	if (config->reading) return cmd_results_new(CMD_FAILURE, "layout", "Can't be used in config file.");
	if (!config->active) return cmd_results_new(CMD_FAILURE, "layout", "Can only be used when sway is running.");
	if ((error = checkarg(argc, "layout", EXPECTED_MORE_THAN, 0))) {
		return error;
	}
	swayc_t *parent = get_focused_container(&root_container);
	if (parent->is_floating) {
		return cmd_results_new(CMD_FAILURE, "layout", "Unable to change layout of floating windows");
	}

	while (parent->type == C_VIEW) {
		parent = parent->parent;
	}

	enum swayc_layouts old_layout = parent->layout;

	if (strcasecmp(argv[0], "default") == 0) {
		swayc_change_layout(parent, parent->prev_layout);
		if (parent->layout == L_NONE) {
			swayc_t *output = swayc_parent_by_type(parent, C_OUTPUT);
			swayc_change_layout(parent, default_layout(output));
		}
	} else {
		if (parent->layout != L_TABBED && parent->layout != L_STACKED) {
			parent->prev_layout = parent->layout;
		}

		if (strcasecmp(argv[0], "tabbed") == 0) {
			if (parent->type != C_CONTAINER && !swayc_is_empty_workspace(parent)){
				parent = new_container(parent, L_TABBED);
			}

			swayc_change_layout(parent, L_TABBED);
		} else if (strcasecmp(argv[0], "stacking") == 0) {
			if (parent->type != C_CONTAINER && !swayc_is_empty_workspace(parent)) {
				parent = new_container(parent, L_STACKED);
			}

			swayc_change_layout(parent, L_STACKED);
		} else if (strcasecmp(argv[0], "splith") == 0) {
			swayc_change_layout(parent, L_HORIZ);
		} else if (strcasecmp(argv[0], "splitv") == 0) {
			swayc_change_layout(parent, L_VERT);
		} else if (strcasecmp(argv[0], "toggle") == 0 && argc == 2 && strcasecmp(argv[1], "split") == 0) {
			if (parent->layout == L_HORIZ && (parent->workspace_layout == L_NONE || parent->workspace_layout == L_HORIZ)) {
				swayc_change_layout(parent, L_VERT);
			} else {
				swayc_change_layout(parent, L_HORIZ);
			}
		}
	}

	update_layout_geometry(parent, old_layout);
	update_geometry(parent);

	arrange_windows(parent, parent->width, parent->height);

	return cmd_results_new(CMD_SUCCESS, NULL, NULL);
}