11.119Class GtkTextView

Widget that displays a GtkTextBuffer

Class GtkTextView

You may wish to begin by reading the text widget conceptual overview which gives an overview of all the objects and data types related to the text widget and how they work together.

Methods
add_child_in_windowAdds a child at fixed coordinates in one of the text widget's windows.
backward_display_lineMoves the given iter backward by one display (wrapped) line.
backward_display_line_startMoves the given iter backward to the next display line start.
buffer_to_window_coordsConverts coordinate (buffer_x, buffer_y) to coordinates for the window win, and stores the result in (window_x, window_y).
forward_display_lineMoves the given iter forward by one display (wrapped) line.
forward_display_line_endMoves the given iter forward to the next display line end.
get_accepts_tabReturns whether pressing the Tab key inserts a tab characters.
get_border_window_sizeGets the width of the specified border window.
get_bufferReturns the GtkTextBuffer being displayed by this text view.
get_cursor_visibleFind out whether the cursor is being displayed.
get_editableReturns the default editability of the GtkTextView.
get_indentGets the default indentation of paragraphs in text_view.
get_iter_at_locationRetrieves the iterator at buffer coordinates x and y.
get_iter_at_positionRetrieves the iterator pointing to the character at buffer coordinates x and y.
get_justificationGets the default justification of paragraphs in text_view.
get_left_marginGets the default left margin size of paragraphs in the text_view.
get_line_at_yGets the GtkTextIter at the start of the line containing the coordinate y.
get_line_yrangeGets the y coordinate of the top of the line containing iter, and the height of the line.
get_overwriteReturns whether the GtkTextView is in overwrite mode or not.
get_pixels_above_linesGets the default number of pixels to put above paragraphs.
get_pixels_below_linesGets the value set by set_pixels_below_lines().
get_pixels_inside_wrapGets the value set by set_pixels_inside_wrap().
get_right_marginSets the default right margin for text in the text view.
get_wrap_modeGets the line wrapping for the view.
move_childUpdates the position of a child, as for add_child_in_window().
move_mark_onscreenMoves a mark within the buffer so that it's located within the currently-visible text area.
move_visuallyMove the iterator a given number of characters visually, treating it as the strong cursor position.
new_with_bufferCreates a new GtkTextView widget displaying the buffer buffer.
place_cursor_onscreenMoves the cursor to the currently visible region of the buffer, it it isn't there already.
scroll_mark_onscreenScrolls text_view the minimum distance such that mark is contained within the visible area of the widget.
scroll_to_iterScrolls text_view so that iter is on the screen in the position indicated by xalign and yalign.
scroll_to_markScrolls text_view so that mark is on the screen in the position indicated by xalign and yalign.
set_accepts_tabSets the behavior of the text widget when the Tab key is pressed.
set_border_window_sizeSets the width of GTK_TEXT_WINDOW_LEFT or GTK_TEXT_WINDOW_RIGHT, or the height of GTK_TEXT_WINDOW_TOP or GTK_TEXT_WINDOW_BOTTOM.
set_bufferSets buffer as the buffer being displayed by text_view.
set_cursor_visibleToggles whether the insertion point is displayed.
set_editableSets the default editability of the GtkTextView.
set_indentSets the default indentation for paragraphs in text_view.
set_justificationSets the default justification of text in text_view.
set_left_marginSets the default left margin for text in text_view.
set_overwriteChanges the GtkTextView overwrite mode.
set_pixels_above_linesSets the default number of blank pixels above paragraphs in text_view.
set_pixels_below_linesSets the default number of pixels of blank space to put below paragraphs in text_view.
set_pixels_inside_wrapSets the default number of pixels of blank space to leave between display/wrapped lines within a paragraph.
set_right_marginSets the default right margin for text in the text view.
set_wrap_modeSets the line wrapping for the view.
starts_display_lineDetermines whether iter is at the start of a display line.
window_to_buffer_coordsConverts coordinates on the window identified by win to buffer coordinates, storing the result in (buffer_x,buffer_y).

Methods

add_child_in_window

Adds a child at fixed coordinates in one of the text widget's windows.

GtkTextView.add_child_in_window( child, which_window, xpos, ypos )
child a GtkWidget
which_window (GtkTextWindowType) which window the child should appear in
xpos X position of child in window coordinates
ypos Y position of child in window coordinates

The window must have nonzero size (see set_border_window_size()). Note that the child coordinates are given relative to the GdkWindow in question, and that these coordinates have no sane relationship to scrolling. When placing a child in GTK_TEXT_WINDOW_WIDGET, scrolling is irrelevant, the child floats above all scrollable areas. But when placing a child in one of the scrollable windows (border windows or text window), you'll need to compute the child's correct position in buffer coordinates any time scrolling occurs or buffer changes occur, and then call gtk_text_view_move_child() to update the child's position. Unfortunately there's no good way to detect that scrolling has occurred, using the current API; a possible hack would be to update all child positions when the scroll adjustments change or the text buffer changes. See bug 64518 on bugzilla.gnome.org for status of fixing this issue.

backward_display_line

Moves the given iter backward by one display (wrapped) line.

GtkTextView.backward_display_line( iter )
iter a GtkTextIter
Returntrue if iter was moved and is not on the end iterator

A display line is different from a paragraph. Paragraphs are separated by newlines or other paragraph separator characters. Display lines are created by line-wrapping a paragraph. If wrapping is turned off, display lines and paragraphs will be the same. Display lines are divided differently for each view, since they depend on the view's width; paragraphs are the same in all views, since they depend on the contents of the GtkTextBuffer.

backward_display_line_start

Moves the given iter backward to the next display line start.

GtkTextView.backward_display_line_start( iter )
iter a GtkTextIter
Returntrue if iter was moved and is not on the end iterator

A display line is different from a paragraph. Paragraphs are separated by newlines or other paragraph separator characters. Display lines are created by line-wrapping a paragraph. If wrapping is turned off, display lines and paragraphs will be the same. Display lines are divided differently for each view, since they depend on the view's width; paragraphs are the same in all views, since they depend on the contents of the GtkTextBuffer.

buffer_to_window_coords

Converts coordinate (buffer_x, buffer_y) to coordinates for the window win, and stores the result in (window_x, window_y).

GtkTextView.buffer_to_window_coords( win, buffer_x, buffer_y )
win a GtkTextWindowType except GTK_TEXT_WINDOW_PRIVATE
buffer_x buffer x coordinate
buffer_y buffer y coordinate
Return[ window_x, window_y ]

Note that you can't convert coordinates for a nonexisting window (see set_border_window_size()).

forward_display_line

Moves the given iter forward by one display (wrapped) line.

GtkTextView.forward_display_line( iter )
iter a GtkTextIter
Returntrue if iter was moved and is not on the end iterator

A display line is different from a paragraph. Paragraphs are separated by newlines or other paragraph separator characters. Display lines are created by line-wrapping a paragraph. If wrapping is turned off, display lines and paragraphs will be the same. Display lines are divided differently for each view, since they depend on the view's width; paragraphs are the same in all views, since they depend on the contents of the GtkTextBuffer.

forward_display_line_end

Moves the given iter forward to the next display line end.

GtkTextView.forward_display_line_end( iter )
iter a GtkTextIter
Returntrue if iter was moved and is not on the end iterator

A display line is different from a paragraph. Paragraphs are separated by newlines or other paragraph separator characters. Display lines are created by line-wrapping a paragraph. If wrapping is turned off, display lines and paragraphs will be the same. Display lines are divided differently for each view, since they depend on the view's width; paragraphs are the same in all views, since they depend on the contents of the GtkTextBuffer.

get_accepts_tab

Returns whether pressing the Tab key inserts a tab characters.

GtkTextView.get_accepts_tab()
Returntrue if pressing the Tab key inserts a tab character, false if pressing the Tab key moves the keyboard focus.

get_border_window_size

Gets the width of the specified border window.

GtkTextView.get_border_window_size( type )
type (GtkTextWindowType) window to return size from
Returnwidth of window

See set_border_window_size().

get_buffer

Returns the GtkTextBuffer being displayed by this text view.

GtkTextView.get_buffer()
Returna GtkTextBuffer.

get_cursor_visible

Find out whether the cursor is being displayed.

GtkTextView.get_cursor_visible()
Returnwhether the insertion mark is visible

get_editable

Returns the default editability of the GtkTextView.

GtkTextView.get_editable()
Returnwhether text is editable by default

Tags in the buffer may override this setting for some ranges of text.

get_indent

Gets the default indentation of paragraphs in text_view.

GtkTextView.get_indent()
Returnnumber of pixels of indentation$

Tags in the view's buffer may override the default. The indentation may be negative.

get_iter_at_location

Retrieves the iterator at buffer coordinates x and y.

GtkTextView.get_iter_at_location( x, y )
x x position, in buffer coordinates
y y position, in buffer coordinates
Returna GtkTextIter

Buffer coordinates are coordinates for the entire buffer, not just the currently-displayed portion. If you have coordinates from an event, you have to convert those to buffer coordinates with window_to_buffer_coords().

get_iter_at_position

Retrieves the iterator pointing to the character at buffer coordinates x and y.

GtkTextView.get_iter_at_position( x, y )
x x position, in buffer coordinates
y y position, in buffer coordinates
Return[ GtkTextIter, trailing ]. trailing is an integer indicating where in the grapheme the user clicked. It will either be zero, or the number of characters in the grapheme. 0 represents the trailing edge of the grapheme.

Buffer coordinates are coordinates for the entire buffer, not just the currently-displayed portion. If you have coordinates from an event, you have to convert those to buffer coordinates with window_to_buffer_coords().

Note that this is different from get_iter_at_location(), which returns cursor locations, i.e. positions between characters.

get_justification

Gets the default justification of paragraphs in text_view.

GtkTextView.get_justification()
Returndefault justification

Tags in the buffer may override the default.

get_left_margin

Gets the default left margin size of paragraphs in the text_view.

GtkTextView.get_left_margin()
Returnleft margin in pixels Tags in the buffer may override the default.

get_line_at_y

Gets the GtkTextIter at the start of the line containing the coordinate y.

GtkTextView.get_line_at_y( target_iter, y )
target_iter a GtkTextIter
y a y coordinate (integer)
Returntop coordinate of the line

y is in buffer coordinates, convert from window coordinates with gtk_text_view_window_to_buffer_coords(). If non-NULL, line_top will be filled with the coordinate of the top edge of the line.

get_line_yrange

Gets the y coordinate of the top of the line containing iter, and the height of the line.

GtkTextView.get_line_yrange( iter )
iter a GtkTextIter
Return[ y coordinate, height ]

The coordinate is a buffer coordinate; convert to window coordinates with buffer_to_window_coords().

get_overwrite

Returns whether the GtkTextView is in overwrite mode or not.

GtkTextView.get_overwrite()
Returnwhether text_view is in overwrite mode or not.

get_pixels_above_lines

Gets the default number of pixels to put above paragraphs.

GtkTextView.get_pixels_above_lines()
Returndefault number of pixels above paragraphs

get_pixels_below_lines

Gets the value set by set_pixels_below_lines().

GtkTextView.get_pixels_below_lines()
Returndefault number of blank pixels below paragraphs

get_pixels_inside_wrap

Gets the value set by set_pixels_inside_wrap().

GtkTextView.get_pixels_inside_wrap()
Returndefault number of pixels of blank space between wrapped lines

get_right_margin

Sets the default right margin for text in the text view.

GtkTextView.get_right_margin()
Returnright margin in pixels Tags in the buffer may override the default.

get_wrap_mode

Gets the line wrapping for the view.

GtkTextView.get_wrap_mode()
Returnthe line wrap setting

move_child

Updates the position of a child, as for add_child_in_window().

GtkTextView.move_child( child, xpos, ypos )
child child widget already added to the text view
xpos new X position in window coordinates
ypos new Y position in window coordinates

move_mark_onscreen

Moves a mark within the buffer so that it's located within the currently-visible text area.

GtkTextView.move_mark_onscreen( mark )
mark a GtkTextMark
Returntrue if the mark moved (wasn't already onscreen)

move_visually

Move the iterator a given number of characters visually, treating it as the strong cursor position.

GtkTextView.move_visually( iter, count )
iter a GtkTextIter
count number of characters to move (negative moves left, positive moves right)
Returntrue if iter moved and is not on the end iterator

If count is positive, then the new strong cursor position will be count positions to the right of the old cursor position. If count is negative then the new strong cursor position will be count positions to the left of the old cursor position.

In the presence of bi-directional text, the correspondence between logical and visual order will depend on the direction of the current run, and there may be jumps when the cursor is moved off of the end of a run.

new_with_buffer

Creates a new GtkTextView widget displaying the buffer buffer.

GtkTextView.new_with_buffer( buffer )
buffer a GtkTextBuffer (or nil)

One buffer can be shared among many widgets. buffer may be nil to create a default buffer, in which case this function is equivalent to gtk_text_view_new(). The text view adds its own reference count to the buffer.

place_cursor_onscreen

Moves the cursor to the currently visible region of the buffer, it it isn't there already.

GtkTextView.place_cursor_onscreen()
Returntrue if the cursor had to be moved.

scroll_mark_onscreen

Scrolls text_view the minimum distance such that mark is contained within the visible area of the widget.

GtkTextView.scroll_mark_onscreen( mark )
mark a mark in the buffer

scroll_to_iter

Scrolls text_view so that iter is on the screen in the position indicated by xalign and yalign.

GtkTextView.scroll_to_iter( iter, within_margin, use_align, xalign, yalign )
iter a GtkTextIter
within_margin margin as a [0.0,0.5] fraction of screen size
use_align (boolean) whether to use alignment arguments (if false, just get the mark onscreen)
xalign horizontal alignment of mark within visible area
yalign vertical alignment of mark within visible area
Returntrue if scrolling occurred

An alignment of 0.0 indicates left or top, 1.0 indicates right or bottom, 0.5 means center. If use_align is FALSE, the text scrolls the minimal distance to get the mark onscreen, possibly not scrolling at all. The effective screen for purposes of this function is reduced by a margin of size within_margin.

Note that this function uses the currently-computed height of the lines in the text buffer. Line heights are computed in an idle handler; so this function may not have the desired effect if it's called before the height computations. To avoid oddness, consider using scroll_to_mark() which saves a point to be scrolled to after line validation.

scroll_to_mark

Scrolls text_view so that mark is on the screen in the position indicated by xalign and yalign.

GtkTextView.scroll_to_mark( mark, within_margin, use_align, xalign, yalign )
mark a GtkTextMark
within_margin margin as a [0.0,0.5] fraction of screen size
use_align (boolean) whether to use alignment arguments (if false, just get the mark onscreen)
xalign horizontal alignment of mark within visible area
yalign vertical alignment of mark within visible area

An alignment of 0.0 indicates left or top, 1.0 indicates right or bottom, 0.5 means center. If use_align is FALSE, the text scrolls the minimal distance to get the mark onscreen, possibly not scrolling at all. The effective screen for purposes of this function is reduced by a margin of size within_margin.

set_accepts_tab

Sets the behavior of the text widget when the Tab key is pressed.

GtkTextView.set_accepts_tab( accept_tag )
accept_tag true if pressing the Tab key should insert a tab character, false, if pressing the Tab key should move the keyboard focus. If accepts_tab is true, a tab character is inserted. If accepts_tab is false the keyboard focus is moved to the next widget in the focus chain.

set_border_window_size

Sets the width of GTK_TEXT_WINDOW_LEFT or GTK_TEXT_WINDOW_RIGHT, or the height of GTK_TEXT_WINDOW_TOP or GTK_TEXT_WINDOW_BOTTOM.

GtkTextView.set_border_window_size( type, size )
type (GtkTextWindowType) window to affect
size width or height of the window

Automatically destroys the corresponding window if the size is set to 0, and creates the window if the size is set to non-zero. This function can only be used for the "border windows," it doesn't work with GTK_TEXT_WINDOW_WIDGET, GTK_TEXT_WINDOW_TEXT, or GTK_TEXT_WINDOW_PRIVATE.

set_buffer

Sets buffer as the buffer being displayed by text_view.

GtkTextView.set_buffer( buffer )
buffer a GtkTextBuffer (or nil)

set_cursor_visible

Toggles whether the insertion point is displayed.

GtkTextView.set_cursor_visible( setting )
setting whether to show the insertion cursor

A buffer with no editable text probably shouldn't have a visible cursor, so you may want to turn the cursor off.

set_editable

Sets the default editability of the GtkTextView.

GtkTextView.set_editable( setting )
setting (boolean) whether it's editable You can override this default setting with tags in the buffer, using the "editable" attribute of tags.

set_indent

Sets the default indentation for paragraphs in text_view.

GtkTextView.set_indent( indent )
indent indentation in pixels Tags in the buffer may override the default.

set_justification

Sets the default justification of text in text_view.

GtkTextView.set_justification( justification )
justification (GtkJustification)

Tags in the view's buffer may override the default.

set_left_margin

Sets the default left margin for text in text_view.

GtkTextView.set_left_margin( left_margin )
left_margin left margin in pixels

Tags in the buffer may override the default.

set_overwrite

Changes the GtkTextView overwrite mode.

GtkTextView.set_overwrite( true )
true to turn on overwrite mode, false to turn it off

set_pixels_above_lines

Sets the default number of blank pixels above paragraphs in text_view.

GtkTextView.set_pixels_above_lines( pixels_above_lines )
pixels_above_lines pixels above paragraphs

Tags in the buffer for text_view may override the defaults.

set_pixels_below_lines

Sets the default number of pixels of blank space to put below paragraphs in text_view.

GtkTextView.set_pixels_below_lines( pixels_below_lines )
pixels_below_lines pixels below paragraphs

May be overridden by tags applied to text_view's buffer.

set_pixels_inside_wrap

Sets the default number of pixels of blank space to leave between display/wrapped lines within a paragraph.

GtkTextView.set_pixels_inside_wrap( pixels_inside_wrap )
pixels_inside_wrap default number of pixels between wrapped lines

May be overridden by tags in text_view's buffer.

set_right_margin

Sets the default right margin for text in the text view.

GtkTextView.set_right_margin( right_margin )
right_margin right margin in pixels

Tags in the buffer may override the default.

set_wrap_mode

Sets the line wrapping for the view.

GtkTextView.set_wrap_mode( wrap_mode )
wrap_mode a GtkWrapMode

starts_display_line

Determines whether iter is at the start of a display line.

GtkTextView.starts_display_line( iter )
iter a GtkTextIter
Returntrue if iter begins a wrapped line

See gtk_text_view_forward_display_line() for an explanation of display lines vs. paragraphs.

window_to_buffer_coords

Converts coordinates on the window identified by win to buffer coordinates, storing the result in (buffer_x,buffer_y).

GtkTextView.window_to_buffer_coords( win, window_x, window_y )
win a GtkTextWindowType except GTK_TEXT_WINDOW_PRIVATE
window_x window x coordinate
window_y window y coordinate
Return[ buffer_x, buffer_y ]

Note that you can't convert coordinates for a nonexisting window (see set_border_window_size()).

Made with http://www.falconpl.org