Xacobeo

 view release on metacpan or  search on metacpan

lib/Xacobeo/UI/SourceView.pm  view on Meta::CPAN


	_add_tag($tag_table, syntax =>
		foreground => 'black',
		weight     => PANGO_WEIGHT_BOLD,
	);

	_add_tag($tag_table, literal =>
		foreground => 'black',
	);

	_add_tag($tag_table, cdata =>
		foreground => 'red',
		weight     => PANGO_WEIGHT_BOLD
	);

	_add_tag($tag_table, cdata_content =>
		foreground => 'purple',
		weight     => PANGO_WEIGHT_LIGHT,
		style      => 'italic',
	);

	_add_tag($tag_table, namespace_name =>
		foreground => 'red',
		style      => 'italic',
		weight     => PANGO_WEIGHT_LIGHT,
	);

lib/Xacobeo/Utils.pm  view on Meta::CPAN

	isa_dom_attr
	isa_dom_nodelist
	isa_dom_text
	isa_dom_comment
	isa_dom_literal
	isa_dom_boolean
	isa_dom_number
	isa_dom_node
	isa_dom_pi
	isa_dom_dtd
	isa_dom_cdata
	isa_dom_namespace

	scrollify
);

our %EXPORT_TAGS = (
	'xml' => [
		qw(
			escape_xml_text
			escape_xml_attribute

lib/Xacobeo/Utils.pm  view on Meta::CPAN

			isa_dom_attr
			isa_dom_nodelist
			isa_dom_text
			isa_dom_comment
			isa_dom_literal
			isa_dom_boolean
			isa_dom_number
			isa_dom_node
			isa_dom_pi
			isa_dom_dtd
			isa_dom_cdata
			isa_dom_namespace
		)
	],

	'ui' => [
		qw(
			scrollify
		)
	],

lib/Xacobeo/Utils.pm  view on Meta::CPAN


The node to check.

=back

=cut

sub isa_dom_text {
	my ($node) = @_;
	return unless defined $node;
	return if isa_dom_comment($node) or isa_dom_cdata($node);
	return $node->isa('XML::LibXML::Text');
}



=head2 isa_dom_comment

Returns true if the node is a DOM C<Comment> (instance of
L<XML::LibXML::Comment>).

lib/Xacobeo/Utils.pm  view on Meta::CPAN


=cut

sub isa_dom_dtd {
	my ($node) = @_;
	return defined $node ? $node->isa('XML::LibXML::Dtd') : 0;
}



=head2 isa_dom_cdata

Returns true if the node is a DOM C<CDATASection> (instance of
L<XML::LibXML::CDATASection>).

Parameters:

=over

=item * $node

The node to check.

=back

=cut

sub isa_dom_cdata {
	my ($node) = @_;
	return defined $node ? $node->isa('XML::LibXML::CDATASection') : 0;
}



=head2 isa_dom_namespace

Returns true if the node is a C<Namespace> (instance of
L<XML::LibXML::Namespace>).

xs/code.c  view on Meta::CPAN

	GtkTextTag *number;
	GtkTextTag *attribute_name;
	GtkTextTag *attribute_value;
	GtkTextTag *comment;
	GtkTextTag *dtd;
	GtkTextTag *element;
	GtkTextTag *pi;
	GtkTextTag *pi_data;
	GtkTextTag *syntax;
	GtkTextTag *literal;
	GtkTextTag *cdata;
	GtkTextTag *cdata_content;
	GtkTextTag *namespace_name;
	GtkTextTag *namespace_uri;
	GtkTextTag *entity_ref;
	GtkTextTag *error;
} MarkupTags;


// The context used for displaying the XML. Since a lot of functions need these
// parameters, it's easier to group them in a custom struct and pass that struct
// around.

xs/code.c  view on Meta::CPAN

//   attribute_value - The value of an attribute.
//   namespace_name  - The name (prefix) of a namespace declaration.
//   namespace_uri   - The URI of a namespace declaration.
//
// XML syntax
//   comment - An XML comment.
//   dtd           - A DTD definition.
//   pi            - The name of a processing instruction.
//   pi_data       - The data of a processing instruction.
//   syntax        - Syntax tokens : <, >, &, ;, etc.
//   cdata         - A CDATA (both opening and closing syntax).
//   cdata_content - The content of a CDATA.
//   entity_ref    - an entity reference.
//
void xacobeo_populate_gtk_text_buffer (GtkTextBuffer *buffer, xmlNode *node, HV *namespaces) {

	////
	// Parameters validation
	if (buffer == NULL) {
		WARN("GtkTextBuffer is NULL");
		return;
	}

xs/code.c  view on Meta::CPAN


// Displays a Comment ex: <!-- comment -->
static void my_XML_COMMENT_NODE (TextRenderCtx *xargs, xmlNode *node) {
	buffer_cat(xargs, xargs->markup->comment, "<!--", (gchar *) node->content, "-->");
}



// Displays a CDATA section ex: <![CDATA[<greeting>Hello, world!</greeting>]]>
static void my_XML_CDATA_SECTION_NODE (TextRenderCtx *xargs, xmlNode *node) {
	buffer_add(xargs, xargs->markup->cdata, "<![CDATA[");
	buffer_add(xargs, xargs->markup->cdata_content, (gchar *) node->content);
	buffer_add(xargs, xargs->markup->cdata, "]]>");
}



// Displays a PI (processing instruction) ex: <?stuff ?>
static void my_XML_PI_NODE (TextRenderCtx *xargs, xmlNode *node) {
	buffer_add(xargs, xargs->markup->syntax, "<?");
	buffer_add(xargs, xargs->markup->pi, (gchar *) node->name);

	// Add the data if there's something

xs/code.c  view on Meta::CPAN


	markup->attribute_name  = gtk_text_tag_table_lookup(table, "attribute_name");
	markup->attribute_value = gtk_text_tag_table_lookup(table, "attribute_value");

	markup->comment       = gtk_text_tag_table_lookup(table, "comment");
	markup->dtd           = gtk_text_tag_table_lookup(table, "dtd");
	markup->element       = gtk_text_tag_table_lookup(table, "element");
	markup->pi            = gtk_text_tag_table_lookup(table, "pi");
	markup->pi_data       = gtk_text_tag_table_lookup(table, "pi_data");
	markup->syntax        = gtk_text_tag_table_lookup(table, "syntax");
	markup->cdata         = gtk_text_tag_table_lookup(table, "cdata");
	markup->cdata_content = gtk_text_tag_table_lookup(table, "cdata_content");

	markup->entity_ref = gtk_text_tag_table_lookup(table, "entity_ref");

	markup->namespace_name = gtk_text_tag_table_lookup(table, "namespace_name");
	markup->namespace_uri  = gtk_text_tag_table_lookup(table, "namespace_uri");
	markup->error  = gtk_text_tag_table_lookup(table, "error");

	return markup;
}

xs/main.c  view on Meta::CPAN

	);
	
	TAG("text", 
		"foreground",  "black"
	);
	
	TAG("literal", 
		"foreground",  "black"
	);
	
	TAG("cdata", 
		"foreground",  "red",
		"weight",      PANGO_WEIGHT_BOLD
	);
	
	TAG("cdata_content", 
		"foreground",  "purple",
		"weight",      PANGO_WEIGHT_BOLD,
		"style",       PANGO_STYLE_ITALIC,
		"weight",      PANGO_WEIGHT_LIGHT
	);
	
	TAG("namespace_name", 
		"foreground",  "red",
		"style",       PANGO_STYLE_ITALIC,
		"weight",      PANGO_WEIGHT_LIGHT



( run in 0.254 second using v1.01-cache-2.11-cpan-ec4f86ec37b )