Example #1
0
void show_desktop(desktop_t *d)
{
	if (d == NULL) {
		return;
	}
	show_node(d, d->root);
}
Example #2
0
void
lego_diagram_t::show_node(node_t *node, scenegen_t *sg)
{
    string_var label;

    label = g_strdup_printf("%s %4.2f%%",
	node->name_.data(),
	100.0 * node->stats_.blocks_fraction());

    _log.debug2("legowin_t::show_node depth=%u name=\"%s\" label=\"%s\"\n",
		node->depth_, node->name_.data(), label.data());

    sg->fill(bg_rgb_by_status_[cov::COVERED]);
    sg->noborder();
    sg->box(node->x_, node->y_, node->w_, node->h_cov_);

    sg->fill(bg_rgb_by_status_[cov::UNCOVERED]);
    sg->noborder();
    sg->box(node->x_, node->y_+node->h_cov_, node->w_, node->h_uncov_);

    sg->nofill();
    sg->border(RGB(0,0,0));
    sg->box(node->x_, node->y_, node->w_, node->h_);
    sg->object(node->file_);
    sg->textbox(node->x_, node->y_, node->w_, node->h_, label.data());

    for (list_iterator_t<node_t> niter = node->children_.first() ; *niter ; ++niter)
	show_node(*niter, sg);
}
int main(){
   struct node *ls;
   ls=NULL;
   int choice,ele;
   while(1){
       printf("Enter 1 to insert into list\n2 to delete from list\n3 to show\n4 to exit\n");
       scanf("%d",&choice);
       switch(choice){
       case 1:
           printf("Enter a no. to insert\n");
           scanf("%d",&ele);
           insert_node(&ls,ele);
           break;
       case 2:
           if(ls!=NULL){
               ele=delete_node(&ls);
               printf("Deleted No. is %d\n",ele);
           }
           else
               printf("Stack underflow\n");
           break;
       case 3:
            show_node(&ls);
            break;
       case 4:
           exit(0);
       }
   }
   return 0;
}
Example #4
0
int main(){
    NODE *ptr = NULL;
    int ch;
    
    while(1){  
        printf("choose stack function <1>push <2>pop <3>show all nodes :");
        scanf("%d",&ch);
        switch(ch){
               case 1:
                      ptr = push_node(ptr);
                      //printf("ptr->data:%d ptr->next:%p\n",ptr->data,ptr->nextpoint);                  
                      break;   
               case 2:
                      ptr = pop_node(ptr);
                      break;
               case 3:
                      show_node(ptr);
                      break;                          
               default:
                       printf("wrong input,try again\n");    
        
        }    
    }
    system("pause");
    return(0);
    }
Example #5
0
/* for debug. */
void show_node(f_node *ptr, int depth)
{
    int cnt;
    for (cnt = 0; cnt < depth; cnt++)
	printf("\t");

    printf("name: %s/%d(%d %d)\n", ptr->name, depth, ptr->is_dir, ptr->is_wr);
    if (ptr->child != NULL) 
    {
	show_node(ptr->child, depth+1);
    }
    if (ptr->next != NULL) 
    {
	show_node(ptr->next, depth);
    }
}
Example #6
0
File: graph.c Project: orumin/Graph
//Show a graph
void show_graph(Graph *graph) {
    int i;
    for(i=0; i<graph->n_nodes; i++) {
        printf("  ");
        show_node(graph->nodes[i]);
    }
}
Example #7
0
int print_list(sp head)
{
	int scount=0;

	for(;head;head=head->next)
		scount+=show_node(head);
		

	return scount;
}
Example #8
0
/*=================================================================
 * expand_tree -- Create copy of node tree with additional link info
 *===============================================================*/
static NODE
expand_tree (NODE root0)
{
	NODE copy, node, sub;
	STRING key;
	static NODE root;	/* root of record being edited */
	LIST subs;	/* list of contained records */
	NODE expd;	/* expanded main record - copy - our retval */

	root = root0;
	expd = copy_nodes(root, TRUE, TRUE);
	subs = create_list();
	traverse_nodes(expd, advedit_expand_traverse, subs);

   /* expand the list of records into the copied record */
	FORLIST(subs, el)
		node = (NODE) el;
#ifdef DEBUG
		llwprintf("in list: %s %s\n", ntag(node), nval(node));
#endif
		key = rmvat(nval(node));
		if ((sub = nztop(key_possible_to_record(key, *key)))) {
			copy = copy_node_subtree(sub);
			nxref(node)    = nxref(copy);
			ntag(node)     = ntag(copy);
			nchild(node)   = nchild(copy);
			nparent(node)  = nparent(copy);
/*MEMORY LEAK; MEMORY LEAK; MEMORY LEAK: node not removed (because its
  value and possibly xref [probably not] are still being referred to */
		}
	ENDLIST
	/* Shouldn't we free subs now ? Perry 2001/06/22 */
#ifdef DEBUG
	show_node(expd);
#endif
	return expd;
}
Example #9
0
void
lego_diagram_t::render(scenegen_t *sg)
{
    show_node(root_, sg);
}
Example #10
0
/**
   P                     P
      N                     R
     B C        -\         B C
       ...      -/          ...
        R                     N
       X Y                   X Y
 */
static inline void
swap_nodes(struct RBTREE_TYPENAME* target,
           struct RBTREE_NODE* N, struct RBTREE_NODE* R)
{
  struct RBTREE_NODE* P = N->parent;
  struct RBTREE_NODE* B = N->left;
  struct RBTREE_NODE* C = N->right;
  struct RBTREE_NODE* X = R->left;
  struct RBTREE_NODE* Y = R->right;

  // Possibilities
  // N, R unrelated
  // R->parent == N

  // Link P to R
  if (P == NULL)
  {
    assert(target->root == N);
    target->root = R;
  }
  else
  {
    replace(P, N, R);
  }

  // Link N to its new parent
  if (R->parent != N)
  {
    N->parent = R->parent;
    show_node(N->parent);
    replace(R->parent, R, N);
  }
  else
  {
    tree_side s = which_side(N, R);
    N->parent = R;
    if (s == LEFT)
      R->left = N;
    else
      R->right = N;
  }

  R->parent = P;

  // Set N's children
  N->left   = X;
  if (X != NULL)
    X->parent = N;
  N->right  = Y;
  if (Y != NULL)
    Y->parent = N;

  // Set R's children
  if (B != R) // otherwise set above
  {
    R->left = B;
    if (B != NULL)
      B->parent = R;
  }
  if (C != R) // otherwise set above
  {
    R->right = C;
    if (C != NULL)
      C->parent = R;
  }

  // Restore colors
  rbtree_color tmp = R->color;
  R->color = N->color;
  N->color = tmp;
}
Example #11
0
File: window.c Project: nfnty/bspwm
void manage_window(xcb_window_t win, rule_consequence_t *csq, int fd)
{
	monitor_t *m = mon;
	desktop_t *d = mon->desk;
	node_t *f = mon->desk->focus;

	parse_rule_consequence(fd, csq);

	if (!csq->manage) {
		free(csq->layer);
		free(csq->state);
		window_show(win);
		return;
	}

	if (csq->node_desc[0] != '\0') {
		coordinates_t ref = {m, d, f};
		coordinates_t trg = {NULL, NULL, NULL};
		if (node_from_desc(csq->node_desc, &ref, &trg) == SELECTOR_OK) {
			m = trg.monitor;
			d = trg.desktop;
			f = trg.node;
		}
	} else if (csq->desktop_desc[0] != '\0') {
		coordinates_t ref = {m, d, NULL};
		coordinates_t trg = {NULL, NULL, NULL};
		if (desktop_from_desc(csq->desktop_desc, &ref, &trg) == SELECTOR_OK) {
			m = trg.monitor;
			d = trg.desktop;
			f = trg.desktop->focus;
		}
	} else if (csq->monitor_desc[0] != '\0') {
		coordinates_t ref = {m, NULL, NULL};
		coordinates_t trg = {NULL, NULL, NULL};
		if (monitor_from_desc(csq->monitor_desc, &ref, &trg) == SELECTOR_OK) {
			m = trg.monitor;
			d = trg.monitor->desk;
			f = trg.monitor->desk->focus;
		}
	}

	if (csq->sticky) {
		m = mon;
		d = mon->desk;
		f = mon->desk->focus;
	}

	if (csq->split_dir[0] != '\0' && f != NULL) {
		direction_t dir;
		if (parse_direction(csq->split_dir, &dir)) {
			presel_dir(m, d, f, dir);
		}
	}

	if (csq->split_ratio != 0 && f != NULL) {
		presel_ratio(m, d, f, csq->split_ratio);
	}

	node_t *n = make_node(win);
	client_t *c = make_client();
	c->border_width = csq->border ? d->border_width : 0;
	n->client = c;
	initialize_client(n);
	initialize_floating_rectangle(n);

	if (c->floating_rectangle.x == 0 && c->floating_rectangle.y == 0) {
		csq->center = true;
	}

	monitor_t *mm = monitor_from_client(c);
	embrace_client(mm, c);
	adapt_geometry(&mm->rectangle, &m->rectangle, n);

	if (csq->center) {
		window_center(m, c);
	}

	snprintf(c->class_name, sizeof(c->class_name), "%s", csq->class_name);
	snprintf(c->instance_name, sizeof(c->instance_name), "%s", csq->instance_name);

	f = insert_node(m, d, n, f);
	clients_count++;

	put_status(SBSC_MASK_NODE_MANAGE, "node_manage 0x%08X 0x%08X 0x%08X 0x%08X\n", m->id, d->id, win, f!=NULL?f->id:0);

	if (f != NULL && f->client != NULL && csq->state != NULL && *(csq->state) == STATE_FLOATING) {
		c->layer = f->client->layer;
	}

	if (csq->layer != NULL) {
		c->layer = *(csq->layer);
	}

	if (csq->state != NULL) {
		set_state(m, d, n, *(csq->state));
	}

	set_hidden(m, d, n, csq->hidden);
	set_sticky(m, d, n, csq->sticky);
	set_private(m, d, n, csq->private);
	set_locked(m, d, n, csq->locked);

	arrange(m, d);

	uint32_t values[] = {CLIENT_EVENT_MASK | (focus_follows_pointer ? XCB_EVENT_MASK_ENTER_WINDOW : 0)};
	xcb_change_window_attributes(dpy, win, XCB_CW_EVENT_MASK, values);

	if (d == m->desk) {
		show_node(d, n);
	} else {
		hide_node(d, n);
	}

	if (!csq->hidden && csq->focus) {
		if (d == mon->desk || csq->follow) {
			focus_node(m, d, n);
		} else {
			activate_node(m, d, n);
		}
	} else {
		stack(d, n, false);
	}

	ewmh_set_wm_desktop(n, d);
	ewmh_update_client_list(false);
	free(csq->layer);
	free(csq->state);
}
Example #12
0
static int report_leaves (char *probname, double restart_upbound,
                          int bbcount, double branchzeit, double mod, char *format,
                          tsp_bbnode *rootbbnode, int shownodes)
{
    double lower = 0.0;
    int leafcount = 0;
    double *leafvals = (double *) NULL;
    tsp_bbnode **leafbbs = (tsp_bbnode **) NULL;
    int *leafperm = (int *) NULL;
    int i;
    int rval = 0;
    char buf[80];
    size_t outcnt;
    double v;

    leafvals = CC_SAFE_MALLOC (bbcount, double);
    if (leafvals == (double *) NULL) {
        fprintf (stderr, "Out of memory in report_leaves\n");
        rval = 1;
        goto CLEANUP;
    }

    if (shownodes) {
        leafbbs = CC_SAFE_MALLOC (bbcount, tsp_bbnode *);
        if (leafbbs == (tsp_bbnode **) NULL) {
            fprintf (stderr, "Out of memory in report_leaves\n");
            rval = 1;
            goto CLEANUP;
        }
    }

    lower = restart_upbound;
    collect_leaves (rootbbnode, &lower, &leafcount, leafvals, leafbbs);

    printf ("%s: >= %.2f <= %.2f bb %d active %d time %.2f\n", probname, lower,
            restart_upbound, bbcount, leafcount, branchzeit);

    if (leafcount == 0) {
        rval = 0;
        goto CLEANUP;
    }

    leafperm = CC_SAFE_MALLOC (leafcount, int);
    if (leafperm == (int *) NULL) {
        fprintf (stderr, "Out of memory in report_leaves\n");
        rval = 1;
        goto CLEANUP;
    }

    for (i=0; i<leafcount; i++) leafperm[i] = i;

    CCutil_double_perm_quicksort (leafperm, leafvals, leafcount);

    outcnt = 0;
    for (i=0; i<leafcount; i++) {
        if (shownodes) {
            show_node (leafbbs[leafperm[i]], mod, format);
        } else {
            v = leafvals[leafperm[i]];
            if (mod > 0.0) v = fmod(v, mod);
            sprintf (buf, format, v);
            outcnt += strlen(buf) + 1;
            if (outcnt >= 75) {
                printf ("\n");
                outcnt = strlen(buf) + 1;
            }
            printf ("%s ",buf);
        }
    }
    if (!shownodes) {
        printf ("\n");
    }
    rval = 0;

CLEANUP:
    CC_IFFREE (leafvals, double);
    CC_IFFREE (leafbbs, tsp_bbnode *);
    CC_IFFREE (leafperm, int);
    return rval;
}