---
name: "Gtk2::Ex::HyperTextView"
section: "3pm"
platform: "linux"
package: "zim"
version: "0.25-1"
release: "Debian 5.0 (Lenny)"
platforms: ["linux"]
url: "https://new.carta.tech/Gtk2::Ex::HyperTextView"
---

# Gtk2::Ex::HyperTextView(3pm)

A TextView widget with hyper links

## 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.

- "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.
