コード例 #1
0
static void
do_go_cmd(const event& e, void*)
{
  binding *b;
  char *node_name;
  char *node_info;

  vmenu *menu = (vmenu *) e.get_source();
  menu->clear("Go");

  b = new binding((bfun) &do_go_back_cmd, 0);
  menu->add_command(b, "Go", "Back");

  menu->add_separator("Go");

  /* construct list of previously selected objects */
  vnode_list *hist = vman->get_selection_history();

  for ( s_count_t i=1; /* jump over current object */
        (i<20) && (i<hist->size()); i++ ) {
    vnode *vn = (*hist)[i];
    char *tag = vn->get_tag();

    if ( tag == tag_suif_object ) {
      SuifObject *obj = (SuifObject *) vn->get_object();
      node_info = (char*)obj->get_meta_class()->get_class_name().c_str();
    } else if (tag == tag_code_fragment) {
      node_info = "";
    } else {
      suif_assert_message( false, ("Unknown tag") );
    }

    node_name = new char[strlen(tag)+strlen(node_info)+100 /*just to be safe*/];

    sprintf(node_name, "[%s] (0x%p) %s", tag, vn->get_object(), node_info);

    b = new binding((bfun) &do_go_to_node_cmd, vn);
    menu->add_command(b, "Go", node_name);

    delete [] node_name;
  }
}
コード例 #2
0
/*--------------------------------------------------------------------
 * info_viewer::view
 *
 */
void info_viewer::view(vnode* vn)
{
  if ( !vn ) return;

  text->clear();
  text->tag_begin( vn );
  fstream& fout = text->fout();
  char *tag = vn->get_tag();

  text->tag_style(BOLD_BEGIN);
  fout << "Object: 0x" << (void*)vn->get_object() << '(' << tag << ")\n";
  text->tag_style(BOLD_END);

  /* properties */
  text->tag_style( BOLD_BEGIN );
  fout << "Properties:\n";
  text->tag_style( BOLD_END );

  list<vprop *> *plist = vn->get_prop_list();
  if ( !plist || plist->empty() ) {
    fout << "<No properties defined>\n";
  } else {
    for ( s_count_t i = 0; i < plist->size(); i++ ) {
      vprop* p = (*plist)[i];
      if ( p->name() ) {
	  char* desc = p->description();
	  fout << '[' << p->name() << "]: " << (desc ? desc : "") << endl;
      }
    }
  }
  fout << endl;

  SuifObject* obj;
  if ( tag == tag_suif_object ) {
    obj = (SuifObject*) vn->get_object();
  } else if ( tag == tag_code_fragment ) {
      code_fragment* f = (code_fragment*) vn->get_object();
      obj = (SuifObject*) f->node();
  } else {
      suif_assert_message(false, ("Unknown tag"));
  }

  text->tag_style( BOLD_BEGIN );
  const MetaClass *m = obj->get_meta_class();
  fout << "Suif object type: " << m->get_class_name().c_str() << "\n\n";
  text->tag_style( BOLD_END );

  // if obj is a file_set_block => print the whole file_set_block
  //   in all other cases just print the obj
  formater f(suif_env, text, -1 ); //is_file_set_block( obj ) ? -1 : 1 );

  if ( is_kind_of<FileSetBlock>( obj ) ) {
    // print only the annotes
    FileSetBlock *fb = to<FileSetBlock>(obj);
    Iter<Annote*> annote_iter = fb->get_annote_iterator();
    for ( int i = 0; i < (int)fb->get_annote_count(); i++ ) {
      Annote* ann = annote_iter.current();
      annote_iter.next();
      vn = create_vnode( ann );
      text->tag_begin( vn );
      f.print_zot( ann, fout );
      text->tag_end( vn );
      fout << endl;
    }
  } else {
    f.print_zot( obj, fout );
    fout << endl;
  } 

  text->tag_end( vn );
  text->update();
}