Exemplo n.º 1
0
int
main(int argc, char **argv)
{
	status_t error;
	device_node_cookie root;

	if ((error = init_dm_wrapper()) < 0) {
		printf("Error initializing device manager (%s)\n", strerror(error));
		return error;
	}

	if (argc > 2)
		usage();

	if (argc == 2) {
		if (!strcmp(argv[1], "-d")) {
			gMode = DUMP_MODE;
		} else {
			usage();
		}
	}

	if (gMode == DUMP_MODE) {
		get_root(&root);
		dump_nodes(&root, 0);
	} else {
		get_root(&root);
		display_nodes(&root, 0);
	}

	uninit_dm_wrapper();

	return 0;
}
Exemplo n.º 2
0
Arquivo: tduint.c Projeto: dse/tdu
void
tdu_interface_expand (int levels, int redraw)
{
	node_s *n;
	long scrolllines;

	n = find_node_numbered(root_node, cursor_line);
	if (!n) return;

	scrolllines = expand_tree(n, levels);
	if (!scrolllines) return;

	if (!redraw && (levels > 1))
		redraw = 1;

	if (redraw) {
		display_nodes(cursor_line - start_line,
			      visible_lines - (cursor_line - start_line),
			      root_node, cursor_line, cursor_line);
		tdu_interface_refresh();
	} 
	else {
		long maxlines = visible_lines - (cursor_line - start_line);

		if (scrolllines >= maxlines - 1) {
			display_nodes(cursor_line - start_line,
				      visible_lines - (cursor_line
						       - start_line),
				      root_node, cursor_line, cursor_line);
		}
		else {
			tdu_interface_refresh();
			winsdelln(main_window, scrolllines);
			display_nodes(cursor_line - start_line,
				      scrolllines + 1,
				      root_node, cursor_line, cursor_line);
		}
		tdu_interface_refresh();
	}
}
Exemplo n.º 3
0
Arquivo: tduint.c Projeto: dse/tdu
void
tdu_interface_collapse (int redraw)
{
	node_s *n;
	long scrolllines;

	n = find_node_numbered(root_node, cursor_line);
	if (!n) return;

	scrolllines = collapse_tree(n);
	if (!scrolllines) return;

	if (redraw) {
		display_nodes(cursor_line - start_line,
			      visible_lines - (cursor_line - start_line),
			      root_node, cursor_line, cursor_line);
		tdu_interface_refresh();
	}
	else {
		long maxlines = visible_lines - (cursor_line - start_line);
		if (scrolllines >= maxlines - 1) {
			display_nodes(cursor_line - start_line,
				      visible_lines - (cursor_line
						       - start_line),
				      root_node, cursor_line, cursor_line);
		}
		else {
			tdu_interface_refresh();
			winsdelln(main_window, -scrolllines);
			display_nodes(cursor_line - start_line, 1,
				      root_node, cursor_line, cursor_line);
			display_nodes(visible_lines - scrolllines, scrolllines,
				      root_node,
				      cursor_line + maxlines - scrolllines,
				      cursor_line);
		}
		tdu_interface_refresh();
	}
}
Exemplo n.º 4
0
static void
display_nodes(device_node_cookie *node, uint8 level)
{
	status_t err;
	device_node_cookie child = *node;
	level = display_device(node, level);

	if (get_child(&child) != B_OK)
		return;

	do {
		display_nodes(&child, level);
	} while ((err = get_next_child(&child)) == B_OK);
}
Exemplo n.º 5
0
Arquivo: tduint.c Projeto: dse/tdu
void
tdu_interface_sort (node_sort_fp fp, bool reverse, bool isrecursive)
{
	node_s *n = find_node_numbered(root_node, cursor_line);
	if (n && n->expanded) {

		long lines = n->expanded;
		long maxlines = visible_lines - (cursor_line - start_line) - 1;

		status_line_message("sorting...");
		tree_sort(n, fp, reverse, isrecursive);
		status_line_message(NULL);

		if (lines > maxlines) lines = maxlines;

		display_nodes(cursor_line - start_line + 1,
			      lines,
			      root_node,
			      cursor_line + 1,
			      cursor_line);
		tdu_interface_refresh();
	}
}
Exemplo n.º 6
0
Arquivo: tduint.c Projeto: dse/tdu
void
tdu_interface_display ()
{
	display_nodes(0, visible_lines, root_node, start_line, cursor_line);
	tdu_interface_refresh();
}
Exemplo n.º 7
0
Arquivo: tduint.c Projeto: dse/tdu
void
tdu_interface_refresh ()
{
	int lines;

	if (prev_start_line < 0) {
		display_nodes(0, visible_lines, root_node, start_line,
			      cursor_line);
	}
	else {
		/* make sure cursor_line is within reasonable range */
		if (cursor_line < 0)
			cursor_line = 0;
		else if (cursor_line > root_node->expanded)
			cursor_line = root_node->expanded;

		/* position start_line such that
		   cursor_line is on the screen */
		if (cursor_line < start_line)
			/* up off the screen? */
			start_line = cursor_line;
		else if (cursor_line > (start_line+visible_lines-1))
			/* down off the screen? */
			start_line = cursor_line - (visible_lines - 1);

		/* make sure start_line is within reasonable range */
		if (start_line < 0)
			start_line = 0;
		else if (start_line > root_node->expanded)
			start_line = root_node->expanded;

		/* do we have to scroll the screen? */
		lines = start_line - prev_start_line;

		/* if we scroll too much, just redisplay the whole thing */
		if (lines <= -visible_lines || lines >= visible_lines)
			display_nodes(0, visible_lines, root_node,
				      start_line, cursor_line);

		/* do we need to scroll down? */
		else if (lines < 0) {
			wscrl(main_window, lines);
			display_nodes(0, -lines, root_node,
				      start_line, cursor_line);
		}


		/* do we need to scroll up? */
		else if (lines > 0) {
			wscrl(main_window, lines);
			display_nodes(visible_lines - lines, lines, root_node,
				      start_line + visible_lines - lines,
				      cursor_line);
		}
	}

	wrefresh(status_window);
	wrefresh(main_window);
	tdu_show_cursor();
	prev_start_line = start_line;
}