本文整理汇总了C++中show_tree函数的典型用法代码示例。如果您正苦于以下问题:C++ show_tree函数的具体用法?C++ show_tree怎么用?C++ show_tree使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了show_tree函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: event_callback
/* Mouse callback */
static int
event_callback (Gpm_Event *event, void *data)
{
WTree *tree = data;
if (!(event->type & GPM_UP))
return MOU_NORMAL;
if (tree->is_panel)
event->y--;
event->y--;
if (!tree->active)
change_panel ();
if (event->y < 0){
tree_move_backward (tree, tlines (tree) - 1);
show_tree (tree);
}
else if (event->y >= tlines (tree)){
tree_move_forward (tree, tlines (tree) - 1);
show_tree (tree);
} else {
tree_event (tree, event->y);
if ((event->type & (GPM_UP|GPM_DOUBLE)) == (GPM_UP|GPM_DOUBLE)){
chdir_sel (tree);
}
}
return MOU_NORMAL;
}
示例2: show_tree
/* this is very haphazzard */
void show_tree(rtn_t * root, struct trunk *prev, int is_left)
{
char *prev_str = NULL;
struct trunk this_disp;
if (root == NULL) return;
this_disp.prev = prev;
this_disp.str = " ";
prev_str = this_disp.str;
/* */
show_tree(root->next[0], &this_disp, 1);
if (!prev)
this_disp.str = "---";
else if (is_left) {
this_disp.str = ".--";
prev_str = " |";
} else {
this_disp.str = "`--";
prev->str = prev_str;
}
/* */
show_trunks(&this_disp);
printf("%d\n", *(int *)root->data);
if (prev) prev->str = prev_str;
this_disp.str = " |";
show_tree(root->next[1], &this_disp, 0);
if (!prev) puts("");
}
示例3: show_tree
void show_tree(node *start)
{
if(start->lptr != NULL)
show_tree(start->lptr);
if(start->rptr != NULL)
show_tree(start->rptr);
printf("%c \n",start->data);
}
示例4: tree_callback
static cb_ret_t
tree_callback (Widget *w, widget_msg_t msg, int parm)
{
WTree *tree = (WTree *) w;
Dlg_head *h = tree->widget.parent;
switch (msg) {
case WIDGET_DRAW:
tree_frame (h, tree);
show_tree (tree);
return MSG_HANDLED;
case WIDGET_KEY:
return tree_key (tree, parm);
case WIDGET_FOCUS:
tree->active = 1;
buttonbar_set_label (h, 1, _("Help"), tree_help_cmd);
buttonbar_set_label_data (h, 2, _("Rescan"),
tree_rescan_command, tree);
buttonbar_set_label_data (h, 3, _("Forget"), tree_forget_cmd, tree);
buttonbar_set_label_data (h, 5, _("Copy"), tree_copy_cmd, tree);
buttonbar_set_label_data (h, 6, _("RenMov"), tree_move_cmd, tree);
#if 0
/* FIXME: mkdir is currently defunct */
buttonbar_set_label_data (h, 7, _("Mkdir"), tree_mkdir_cmd, tree);
#else
buttonbar_clear_label (h, 7);
#endif
buttonbar_set_label_data (h, 8, _("Rmdir"), tree_rmdir_command, tree);
set_navig_label (tree);
buttonbar_redraw (h);
/* FIXME: Should find a better way of only displaying the
currently selected item */
show_tree (tree);
return MSG_HANDLED;
/* FIXME: Should find a better way of changing the color of the
selected item */
case WIDGET_UNFOCUS:
tree->active = 0;
show_tree (tree);
return MSG_HANDLED;
case WIDGET_DESTROY:
tree_destroy (tree);
return MSG_HANDLED;
default:
return default_proc (msg, parm);
}
}
示例5: tree_key
static inline cb_ret_t
tree_key (WTree *tree, int key)
{
int i;
for (i = 0; tree_keymap [i].key_code; i++){
if (key == tree_keymap [i].key_code){
if (tree_keymap [i].fn != tree_start_search)
tree->searching = 0;
(*tree_keymap [i].fn)(tree);
show_tree (tree);
return MSG_HANDLED;
}
}
/* We do not want to use them if we do not need to */
/* Input line may want to take the motion key event */
if (key == KEY_LEFT)
return move_left (tree) ? MSG_HANDLED : MSG_NOT_HANDLED;
if (key == KEY_RIGHT)
return move_right (tree) ? MSG_HANDLED : MSG_NOT_HANDLED;
if (is_abort_char (key)) {
if (tree->is_panel) {
tree->searching = 0;
show_tree (tree);
return MSG_HANDLED; /* eat abort char */
}
/* modal tree dialog: let upper layer see the
abort character and close the dialog */
return MSG_NOT_HANDLED;
}
/* Do not eat characters not meant for the tree below ' ' (e.g. C-l). */
if ((key >= ' ' && key <= 255) || key == KEY_BACKSPACE) {
if (tree->searching){
tree_do_search (tree, key);
show_tree (tree);
return MSG_HANDLED;
}
if (!command_prompt) {
tree_start_search (tree);
tree_do_search (tree, key);
return MSG_HANDLED;
}
return tree->is_panel ? MSG_HANDLED : MSG_NOT_HANDLED;
}
return MSG_NOT_HANDLED;
}
示例6: tree_event
static int
tree_event (Gpm_Event * event, void *data)
{
WTree *tree = (WTree *) data;
Widget *w = WIDGET (data);
Gpm_Event local;
if (!mouse_global_in_widget (event, w))
return MOU_UNHANDLED;
/* rest of the upper frame - call menu */
if (tree->is_panel && (event->type & GPM_DOWN) != 0 && event->y == WIDGET (w->owner)->y + 1)
return MOU_UNHANDLED;
local = mouse_get_local (event, w);
if ((local.type & GPM_UP) == 0)
return MOU_NORMAL;
if (tree->is_panel)
local.y--;
local.y--;
if (!tree->active)
change_panel ();
if (local.y < 0)
{
tree_move_backward (tree, tlines (tree) - 1);
show_tree (tree);
}
else if (local.y >= tlines (tree))
{
tree_move_forward (tree, tlines (tree) - 1);
show_tree (tree);
}
else if ((local.type & (GPM_UP | GPM_DOUBLE)) == (GPM_UP | GPM_DOUBLE))
{
if (tree->tree_shown[local.y] != NULL)
{
tree->selected_ptr = tree->tree_shown[local.y];
tree->topdiff = local.y;
}
tree_chdir_sel (tree);
}
return MOU_NORMAL;
}
示例7: show_tree
/**
* 木の内容を表示する関数(帰りがけ順)
* @param TREE *p 表示したい部分木
* for Debug
*/
void show_tree(TREE *p)
{
// 要素が登録されていない
if (p->left == p || p->right == p)
return ;
// 左へ
if(p->left != NULL)
show_tree(p->left);
printf("id: %d\n", p->id);
// 右へ
if(p->right != NULL)
show_tree(p->right);
}
示例8: show_entry
/* A file entry went away or appeared */
static void show_entry(struct diff_options *opt, const char *prefix,
struct tree_desc *desc, struct strbuf *base)
{
unsigned mode;
const char *path;
const unsigned char *sha1 = tree_entry_extract(desc, &path, &mode);
int pathlen = tree_entry_len(path, sha1);
int old_baselen = base->len;
strbuf_add(base, path, pathlen);
if (DIFF_OPT_TST(opt, RECURSIVE) && S_ISDIR(mode)) {
enum object_type type;
struct tree_desc inner;
void *tree;
unsigned long size;
tree = read_sha1_file(sha1, &type, &size);
if (!tree || type != OBJ_TREE)
die("corrupt tree sha %s", sha1_to_hex(sha1));
if (DIFF_OPT_TST(opt, TREE_IN_RECURSIVE))
opt->add_remove(opt, *prefix, mode, sha1, base->buf, 0);
strbuf_addch(base, '/');
init_tree_desc(&inner, tree, size);
show_tree(opt, prefix, &inner, base);
free(tree);
} else
opt->add_remove(opt, prefix[0], mode, sha1, base->buf, 0);
strbuf_setlen(base, old_baselen);
}
示例9: main
int main()
{
ptree root = NULL;
create_tree(&root);
show_tree(root);
return 0;
}
示例10: show_entry
/* A file entry went away or appeared */
static int show_entry(struct diff_options *opt, const char *prefix, struct tree_desc *desc, const char *base)
{
unsigned mode;
const char *path;
const unsigned char *sha1 = extract(desc, &path, &mode);
if (opt->recursive && S_ISDIR(mode)) {
char type[20];
char *newbase = malloc_base(base, path, strlen(path));
struct tree_desc inner;
void *tree;
tree = read_sha1_file(sha1, type, &inner.size);
if (!tree || strcmp(type, "tree"))
die("corrupt tree sha %s", sha1_to_hex(sha1));
inner.buf = tree;
show_tree(opt, prefix, &inner, newbase);
free(tree);
free(newbase);
return 0;
}
opt->add_remove(opt, prefix[0], mode, sha1, base, path);
return 0;
}
示例11: selected_lvl
void MainWindow::on_actionRemove_triggered()
{
if(ui->treeWidget->selectedItems().count() == 0)
{
QErrorMessage error_mes;
error_mes.showMessage("Node was not selected");
error_mes.exec();
return;
}
int lvl = selected_lvl();
space * wp = (space*)getRoot();
if(lvl == 0){
remove_space();
}else if(lvl == 1){
int index_star = selected_index(0);
remove_star(index_star);
}else if(lvl == 2){
int index_star = selected_index(1);
star * p_star = (star*)wp->sublvl[index_star];
int index_planet = selected_index(0);
remove_planet(p_star,index_planet);
}else if(lvl == 3){
int index_star = selected_index(2);
star * p_star = (star*)wp->sublvl[index_star];
int index_planet = selected_index(1);
planet * p_planet = (planet*)p_star->sublvl[index_planet];
int index_sat = selected_index(0);
remove_satellite(p_planet,index_sat);
}
show_tree();
}
示例12: show_entry
/* A file entry went away or appeared */
static void show_entry(struct diff_options *opt, const char *prefix, struct tree_desc *desc,
const char *base, int baselen)
{
unsigned mode;
const char *path;
const unsigned char *sha1 = tree_entry_extract(desc, &path, &mode);
int pathlen = tree_entry_len(path, sha1);
if (DIFF_OPT_TST(opt, RECURSIVE) && S_ISDIR(mode)) {
enum object_type type;
char *newbase = malloc_base(base, baselen, path, pathlen);
struct tree_desc inner;
void *tree;
unsigned long size;
tree = read_sha1_file(sha1, &type, &size);
if (!tree || type != OBJ_TREE)
die("corrupt tree sha %s", sha1_to_hex(sha1));
init_tree_desc(&inner, tree, size);
show_tree(opt, prefix, &inner, newbase, baselen + 1 + pathlen);
free(tree);
free(newbase);
} else {
char *fullname = malloc_fullname(base, baselen, path, pathlen);
opt->add_remove(opt, prefix[0], mode, sha1, fullname);
free(fullname);
}
}
示例13: cmd_ilist
int cmd_ilist(string str) {
object ob;
string file, *files;
int deep_list, i, s;
notify_fail(SYNTAX);
if(!str)
return 0;
seteuid(geteuid(previous_object()));
if(sscanf(str, "-R %s", file))
deep_list = 1;
else if(sscanf(str, "-T %s", file))
deep_list = 2;
else
file = str;
ob = ref_ob(file);
if(!ob || !objectp(ob)) {
notify_fail("Couldn't find object.\n");
return 0;
}
write(wrap("Files inherited by " + dump_variable(ob)));
if(!deep_list) files = inherit_list(ob);
else if(deep_list == 1) files = deep_inherit_list(ob);
else if(deep_list == 2) return show_tree(ob, 1);
for(i = 0, s = sizeof(files); i < s; i ++)
printf(" %d: %s\n", i + 1, files[i]);
return 1;
} // do_cmd
示例14: main
int main()
{
struct tree *phead = NULL;
init_node_head(&phead, sizeof(struct tree));
create_tree(phead);
show_tree(phead);
return 0;
}
示例15: tree_event
static int
tree_event (Gpm_Event * event, void *data)
{
WTree *tree = (WTree *) data;
Widget *w = (Widget *) data;
Gpm_Event local;
if (!mouse_global_in_widget (event, w))
return MOU_UNHANDLED;
local = mouse_get_local (event, w);
/* rest of the upper frame, the menu is invisible - call menu */
if (tree->is_panel && (local.type & GPM_DOWN) != 0 && local.y == 1 && !menubar_visible)
return the_menubar->widget.mouse (event, the_menubar);
if ((local.type & GPM_UP) == 0)
return MOU_NORMAL;
if (tree->is_panel)
local.y--;
local.y--;
if (!tree->active)
change_panel ();
if (local.y < 0)
{
tree_move_backward (tree, tlines (tree) - 1);
show_tree (tree);
}
else if (local.y >= tlines (tree))
{
tree_move_forward (tree, tlines (tree) - 1);
show_tree (tree);
}
else
{
tree_mouse_click (tree, local.y);
if ((local.type & (GPM_UP | GPM_DOUBLE)) == (GPM_UP | GPM_DOUBLE))
tree_chdir_sel (tree);
}
return MOU_NORMAL;
}