Forum und email

GtkTextBuffer

An object for storing and editing text.

Йерархия на обектите

Директни подкласове

Описание

A GtkTextBuffer stores text, which can be edited. The text can then be displayed in one or more GtkTextView widgets. Text in a buffer can be marked with GtkTextTag widgets which apply attributes to a range of text.

Text in PHP-GTK 2 is UTF-8. This means that one character can be encoded as multiple bytes. Character counts are usually referred to as offsets, while byte counts are called indexes. If you confuse these two, things will work fine with ASCII, but as soon as your buffer contains multibyte characters, bad things will happen.

A combination of GtkTextBuffer and GtkTextView widgets should be used as instead of the deprecated GtkText widget.

Пример 115. Simple use of GtkTextBuffer.

<?php
// Create a new window.
$window = new GtkWindow();
// Properly handle closing of the window.
$window->connect_simple('destroy', array('Gtk', 'main_quit'));

// Create a new buffer and a new view to show the buffer.
$textBuffer = new GtkTextBuffer();
$textView   = new GtkTextView();

// Add some text to the buffer.
$textBuffer->set_text('Hello World!');

// Add the buffer to the view and make sure no one edits the text.
$textView->set_buffer($textBuffer);
$textView->set_editable(false);

// Add the view to the window, show everything, and start the main loop.
$window->add($textView);
$window->show_all();
Gtk::main();
?>

Виж също:GtkTextView, GtkTextTag, GtkTextTagTable, GtkTextIter, GtkTextMark, GtkTextChildAnchor

Constructors

GtkTextBuffer ([GtkTextTagTable tag_table = null]);

-- Returns a new GtkTextBuffer object.

Методи

add_selection_clipboard()
 
apply_tag()
  Apply a GtkTextTag to a range of text.
apply_tag_by_name()
 
backspace()
 
begin_user_action()
 
copy_clipboard()
 
create_child_anchor()
 
create_mark()
  Creates a mark with the name and position specified by the user.
cut_clipboard()
 
delete()
  Deletes the text between the range given by the user.
delete_interactive()
 
delete_mark()
 
delete_mark_by_name()
 
delete_selection()
 
end_user_action()
 
get_bounds()
 
get_char_count()
  Returns the number of characters in the buffer.
get_end_iter()
  Returns an iterator pointing at the last position in the text buffer.
get_insert()
 
get_iter_at_child_anchor()
 
get_iter_at_line()
 
get_iter_at_line_index()
 
get_iter_at_line_offset()
 
get_iter_at_mark()
 
get_iter_at_offset()
 
get_line_count()
 
get_mark()
 
get_modified()
 
get_selection_bound()
 
get_selection_bounds()
  Returns an array containing iterators that point at the start and end of the selection.
get_slice()
 
get_start_iter()
  Returns an iterator pointing at the location of the first position in the text buffer.
get_tag_table()
 
get_text()
  Returns the text in the specified range.
insert()
 
insert_at_cursor()
  Inserts the given text in the current cursor position.
insert_child_anchor()
 
insert_interactive()
 
insert_interactive_at_cursor()
 
insert_pixbuf()
  Inserts an image into the text buffer.
insert_range()
 
insert_range_interactive()
 
move_mark()
 
move_mark_by_name()
 
paste_clipboard()
 
place_cursor()
 
remove_all_tags()
 
remove_selection_clipboard()
 
remove_tag()
 
remove_tag_by_name()
 
select_range()
 
set_modified()
 
set_text()
  Replaces the current contents of the textbuffer.

Полета

tag_table:
 

Сигнали

"apply-tag"
 
"begin-user-action"
 
"changed"
 
"delete-range"
 
"end-user-action"
 
"insert-child-anchor"
 
"insert-pixbuf"
 
"insert-text"
 
"mark-deleted"
 
"mark-set"
 
"modified-changed"
 
"remove-tag"