Gtk2::Ex::HyperTextBuffer.3pm

Langue: en

Autres versions - même langue

Version: 2009-03-16 (fedora - 05/07/09)

Section: 3 (Bibliothèques de fonctions)

NAME

HyperTextBuffer - A TextBuffer for the HyperTextView widget

DESCRIPTION

This module is a subclass of Gtk2::TextBuffer intended for use with Gtk2::Ex::HyperTextView. It has a high level interface that uses parse trees instead of plain text. It also keeps an undo-/redo-stack.

HIERARCHY

   Glib::Object
   +----Gtk2::TextBuffer
        +----Gtk2::Ex::HyperTextBuffer
 
 

METHODS

"new(PROPERTY => VALUE, ..)"
Simple constructor.
"clear()"
Deletes all buffer contents.

Be aware that this module sometimes stores a reference to the buffer in a global variable in order to get copy-pasting with markup work. This means you could save a lot of memory when you always clear the object when you are done with it.

"create_default_tags()"
Initialise pre-defined text tags. See TAGS for a listing of these tags.
"set_parse_tree(TREE)"
Load the buffer with contents from a parse tree. The tree format is based on the format as used by Pod::Simple but it uses more verbose element names.

For example:

         ['Page', {},
                 ['head1', {}, 'Test page'],
                 "\n\n",
                 "This is a test page showing some syntax:\n\n",
                 ['bold', {}, 'Bold text'], "\n",
                 ['italic', {}, 'Italic text'], "\n",
                 ['bold', {},
                         ['italic', {}, 'Bold and Italic']
                 ], "\n",
         ]
 
 

This function creates a new unmodified buffer. This action is not un-doable.

"insert_blocks(ITER, BLOCK, ...)"
Insert one or more partial parse trees in the buffer at ITER. The blocks will also be added to the undo stack.
"insert_blocks_at_cursor(BLOCK, ...)"
Like "insert_blocks()" but inserts at current cursor position.
"insert_image_from_file(%PARAM)"
Insert an image in the buffer at the cursor. The params should at least contain 'file' and optionally 'src', 'width' and 'height'.

The 'file' param is used as source for the image. If both 'width' and 'height' are set the image is resized to these dimensions. If one of both is zero or undefined the image is scaled with fixed ratio. All other params are attached to the image as data field.

Use "insert_blocks()" if you want this action to be un-doable.

"get_parse_tree()"
Returns a parse tree based on the buffer contents.
"create_link_tag(LINK_DATA)"
Returns an anonymous Gtk2::TextIter that holds LINK_DATA.

Every link tag should only be applied to one text region.

"auto_selection(TAG, ITER)"
Returns start and end iterators for the current selection. If there is no selection in the buffer TAG and ITER are used to automaticly select a range if possible. ITER is optional and defaults to the cursor.
"select_word(ITER)"
Selects the current word if ITER is inside a word. Cursor is used when ITER is undefined. Returns Gtk2::TextIter for start and end or undef.
"select_line(ITER)"
Selects the line that contains ITER. Cursor is used when ITER is undefined. Returns Gtk2::TextIter for start and end or undef.
"select_tag(ITER, TAG)"
Selects TAG if ITER has TAG. Cursor is used when ITER is undefined. Tag can be either a Gtk2::TextTag or a tag name. Returns Gtk2::TextIter for start and end or undef.
"select_link(ITER)"
Selects link if ITER is on a link. Cursor is used when ITER is undefined. Returns Gtk2::TextIter for start and end or undef.
"replace_selection(TEXT)"
Replace any selected text with TEXT. Returns iterators for the start and end of the newly inserted selection.
"set_edit_mode_tags(TAG, ..)"
Set the current edit mode to a certain list of tags. This means that all text you insert will get these tags applied.
"set_edit_mode_from_cursor()"
Like "set_edit_mode_tags()" but copies tags from the cursor position. This function is called automaticly after moving the cursor.
"get_edit_mode_tags()"
Returns a list of tags that will be applied to newly entered text.
"toggle_edit_mode_tag(TAG, BOOL)"
Toggles a tag for editing. If BOOL is undefined it just toggles, else it sets the tag to the value of BOOL.
"undo"
Undo one editing step.
"redo"
Redo one editing step.
"copy_clipboard"
TODO
"cut_clipboard"
TODO
"paste_clipboard"
TODO

TAGS

Tags are used in Gtk2::TextBuffer to render certain parts of the text buffer with a certain colours or certain decorations. In Gtk2::Ex::HyperTextBuffer they also represent a node in the document parse tree. See Gtk2::TextTag for more details.

The following tags are pre-defined:

head1
head2
head3
head4
head5
bold
italic
underline
verbatim
Verbatim
Like 'verbatim' but intended for multiline blocks.
link
For links anonymous TextTags are used, but the visual properties are defined the same way as for other tags.

AUTHOR

Jaap Karssenberg (Pardus) <pardus@cpan.org>

Copyright (c) 2005 Jaap G Karssenberg. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO