Gtk2::Ex::HyperTextView.3pm

Langue: en

Autres versions - même langue

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

Section: 3 (Bibliothèques de fonctions)

NAME

Gtk2::Ex::HyperTextView - A TextView widget with hyper links

DESCRIPTION

This module derives from Gtk2::TextView but adds code to have hyperlinks in your text. It adds 3 signals to make it easier to work with links.

This module can be used together with Gtk2::Ex::HyperTextBuffer but also with other TextBuffer classes.

HIERARCHY

   Glib::Object
   +----Gtk2::Object
         +----Gtk2::Widget
               +----Gtk2::Container
                     +----Gtk2::TextView
                           +---- Gtk2::Ex::HyperTextView
 
 

METHODS

"new()"
"new_with_buffer(BUFFER)"
Constructors.
insert_link_at_iter(START, TEXT, DATA)
Inserts a piece of text into the buffer, giving it the usual appearance of a hyperlink in a web browser: blue and underlined. Additionally, attaches some data on the tag, to make it recognizable as a link.

DATA is the argument that will be passed back on events for this link, it can be any perl scalar.

apply_link(DATA, START, END)
Makes a link of all text between START and END and attaches the perl scalar DATA to this link.
get_link_at_cursor( )
Returns link data or undef.
get_link_at_pointer( )
Like ``get_link_at_cursor( )'' except that it looks at the mouse cursor, not at the text cursor.
get_link_at_iter(ITER)
Returns link data or undef.
click_if_link_at_cursor( )
Emits the link_clicked signal if the text cursor is at a link.

Returns undef or link data.

click_if_link_at_iter(ITER)
Emits the link_clicked signal if ITER is part of a link.

Returns undef or link data.

"get_iter_at_pointer()"
Returns the text iter for the current pointer (mouse cursor) position.
set_cursor_if_appropriate(X, Y)
Looks at all tags covering the position (X, Y) in the text view, and if one of them is a link, change the cursor to the ``hands'' cursor typically used by web browsers.

If no (X, Y) is given the pointer coordinates are used.

This method is called on a number of events.

Returns the link data if the cursor is above a link.

"toggle_if_checkbox_at_iter(ITER, TYPE)"
Toggles a checkbox. If type if ``x'' it uses the ``x checked'' state, else just normale ``v'' check.
"search(STRING, DIRECTION, CASE, WORD)"
Searches for STRING in the buffer and selects the next occurence it finds. The search is case-insensitive and TEXT can not include line breaks. The search wraps around when nothing is found before the end/begin of the buffer.

DIRECTION can be 1, -1 for forward and backward search. If DIRECTION is 0 it will match forward including the current cursor. Try:

         $entry->signal_connect( changed =>
                 sub { $htext->search( $entry->get_text, 0 ) }    );
 
 

to get an entry that searches while typing.

CASE is a boolean for case sensitive search.

WORD is a boolean for matching whole words only.

Returns boolean for success.

"replace(STRING)"
Replace the current selection with STRING. To be used in combination with "search()" to create a ``Find and Replace'' function.
"replace_all(OLD, NEW)"
Loop through the document once and replace all matches for OLD with NEW.

SIGNALS

link_clicked(DATA)
Emitted when the user clicks on a link or presses ``Enter'' while on a link.
link_enter(DATA)
Emitted when the mouse cursor enters the region of a link.
link_leave( )
Emitted when the mouse cursor leaves the region of a link.

AUTHOR

Jaap Karssenberg || Pardus [Larus] <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.