gtk-sharp2.6.0.0Gtk# is thread aware, but not thread safe; See the Gtk# Thread Programming for details.Widget that displays a
using System;
using Gtk;
class TextViewSample
{
static void Main ()
{
new TextViewSample ();
}
TextViewSample ()
{
Application.Init ();
Window win = new Window ("TextViewSample");
win.DeleteEvent += new DeleteEventHandler (OnWinDelete);
win.SetDefaultSize (600,400);
Gtk.TextView view;
Gtk.TextBuffer buffer;
view = new Gtk.TextView ();
buffer = view.Buffer;
buffer.Text = "Hello, this is some text";
win.Add (view);
win.ShowAll ();
Application.Run ();
}
void OnWinDelete (object obj, DeleteEventArgs args)
{
Application.Quit ();
}
}
Now you might put the view in a container and display it on
the screen; when the user edits the text, events on the
buffer will be emitted, such as , ,
and so on.
Gtk.ContainerMethodSystem.Void
Converts specified buffer coordinates to coordinates
for window
a ,
except for
x coordinate of the buffer
y coordinate of the buffer
return location for the window's x coordinate
return location for the window's y coordinate
Note that you can't convert coordinates for a nonexisting
window (see .
MethodSystem.Int32Gets the width of the specified border window.
a window to return size from
the width of the windowMethodSystem.BooleanMoves the given iter backward by one display (wrapped) line
the given if was moved and is not on the end iterator
Moves the given iter backward by one display (wrapped)
line. 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 .
MethodGdk.WindowRetrieves the corresponding to an area of the text view
window to get
a , or
Retrieves the corresponding to
an area of the text view; possible windows include the
overall widget window, child windows on the left, right,
top, bottom, and the window that displays the text
buffer. Windows are and
nonexistent if their width or height is 0, and are
nonexistent before the widget has been realized.
MethodSystem.Void
Sets the width of
or , or the height of
or .
the window to affect
the 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 , , or .
MethodSystem.BooleanMoves the cursor to the currently visible region of the buffer if it isn't there already. if the cursor had to be movedMethodSystem.BooleanMoves forward to the next display line end
a if was moved and is not on the end iterator
Moves the given iter forward to the next display line
end. 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
.
MethodSystem.VoidAdds a child widget in the text buffer, at the given anchor
any
a in the current MethodSystem.BooleanMoves the given backward to the next display line start
the given if 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 .
MethodSystem.BooleanMoves the given forward by one display (wrapped) line
the given if 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 .
MethodSystem.Void
Gets the y coordinate of the top of the line
containing , and the height of the line
the given
return location for the y coordinate
return location for the height
Gets the y coordinate of the top of the line containing
iter, and the height of the line. The coordinate is a buffer
coordinate; convert to window coordinates with .
MethodSystem.Void
Scrolls the view so that is on the
screen in the position indicated by and
a given
margin of screen size, the valid range is 0.0 to 0.5
whether to use alignment arguments (if , just get the mark onscreen)
horizontal alignment of mark within visible area
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 is ,
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 .
MethodSystem.BooleanDetermines whether iter is at the start of a display line
the given if begins a wrapped line
Determines whether iter is at the start of a display
line. See for an
explanation of display lines vs. paragraphs.
MethodGtk.TextWindowTypeUsed for finding out which window an event corresponds to
a window type
the window typeMethodSystem.BooleanMove the iterator a given number of characters visually, treating it as the strong cursor position
the given
the number of characters to move (negative moves left, positive moves right)
if iter moved and is not on the end iterator
Move the iterator a given number of characters visually,
treating it as the strong cursor position. 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 bidirection 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.
MethodSystem.BooleanMoves within the buffer so that it's located within the currently-visible text area
a if the mark moved (wasn't already onscreen)MethodSystem.Boolean
Scrolls the text view so that is on
the screen in the position indicated by and
the given
margin of screen size, the valid range is 0.0 to 0.5
whether to use alignment arguments (if , just get the mark onscreen)
horizontal alignment of mark within visible area
vertical alignment of mark within visible area
if scrolling occurred
Scrolls the text view so that is on the screen in the
position indicated by and . An alignment of
0.0 indicates left or top, 1.0 indicates right or bottom,
0.5 means center. If is , 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: This function uses the currently-computed height of
the lines in the text buffer. Note that 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 which saves a point to be scrolled to after line
validation.
MethodSystem.Void
Scrolls the text view the minimum distance such that is contained within the visible area of
the widget
a mark in the current MethodSystem.VoidConverts coordinates on the window to buffer coordinates
a except
x coordinate of the window
y coordinate of the window
return location for the buffer's x coordinate
return location for the buffer's y coordinate
Note that you can't convert coordinates for a nonexisting
window (see .
ConstructorInternal constructor
Pointer to the C object.
This is an internal constructor, and should not be used by user code.ConstructorCreates a new TextView
If you don't set the before using
the text view, an empty default buffer will be created for
you. If you want to specify your own buffer, use
.
ConstructorCreates a new TextView displaying a specified buffer.
the buffer to be displayed
Creates a new widget
displaying the buffer. One
buffer can be shared among many widgets.
PropertyGtk.TextAttributesThe default text attributesa s
Obtains a copy of the default text attributes. These are
the attributes used for text unless a tag overrides
them. You'd typically pass the default attributes in to
in order to get the attributes in effect at a given
text position.
The return valuea is a copy owned by the caller of this
function, and should be freed.
PropertyGtk.TextBuffer
The displayed by the text view
the current buffer that is displayedGLib.Property(Name="buffer")PropertySystem.BooleanWhether the insertion point is displayedwhether the insertion point is visibleDefaults to true.GLib.Property(Name="cursor_visible")PropertySystem.Int32The default left marginThe left margin.GLib.Property(Name="left_margin")PropertySystem.Int32The default right marginthe right marginGLib.Property(Name="right_margin")PropertySystem.Int32The default number of blank pixels above paragraphsthe number of pixels above paragraphs
Tags in the may
override the defaults.
GLib.Property(Name="pixels_above_lines")PropertyGtk.JustificationThe default justificationThe default justification of paragraphs
Tags in the may
override the defaults.
GLib.Property(Name="justification")PropertySystem.Int32The default indentation for paragraphsThe number of pixels of indentation.
Tags in the may override the default.
GLib.Property(Name="indent")PropertySystem.BooleanWhether the text can be modified by the userWhether or not the text can be edited by the user.Defaults to true.GLib.Property(Name="editable")PropertyGtk.WrapModeWhether to wrap lines never, at word boundaries, or at character boundaries.the of the text view GLib.Property(Name="wrap_mode")PropertyPango.TabArrayCustom tabs for this textcustom tabes for this textGLib.Property(Name="tabs")PropertySystem.Int32The default number of pixels of blank space to put below paragraphsthe blank space below paragraphs in pixels
Tags in the may
override this default.
GLib.Property(Name="pixels_below_lines")PropertySystem.Int32The default number of pixels of blank space to leave between display/wrapped lines within a paragraphdefault number of pixels of blank space between wrapped lines
Tags in the may
override this default.
GLib.Property(Name="pixels_inside_wrap")EventGtk.ScrollAdjustmentsSetHandlerRaised whenever the adjustment values for the scrollbars are set.GLib.Signal(CName="set_scroll_adjustments")EventSystem.EventHandlerRaised whenever an anchor (e.g. ) is set within the TextView. GLib.Signal(CName="set_anchor")EventGtk.MoveCursorHandlerRaised whenever the cursor is moved.GLib.Signal(CName="move_cursor")EventGtk.PopulatePopupHandlerRaised when the popup dialog on this object needs to be filled with data.GLib.Signal(CName="populate_popup")EventGtk.DeleteFromCursorHandlerRaised when text is deleted from the cursor (usually by hitting Backspace or Delete).GLib.Signal(CName="delete_from_cursor")EventSystem.EventHandlerRaised when text is copied to the clipboard.GLib.Signal(CName="copy_clipboard")EventGtk.MoveFocusHandlerRaised when the keyboard focus changes.GLib.Signal(CName="move_focus")EventGtk.PageHorizontallyHandlerRaised when the user scrolls horizontally in this widget.GLib.Signal(CName="page_horizontally")EventSystem.EventHandlerRaised whenever the insert/overwrite flag is toggled.GLib.Signal(CName="toggle_overwrite")EventSystem.EventHandlerRaised whenever a selection is cut to the clipboard.GLib.Signal(CName="cut_clipboard")EventGtk.InsertAtCursorHandlerRaised whenever text is inserted at the cursor.GLib.Signal(CName="insert_at_cursor")EventSystem.EventHandlerRaised whenever text is pasted from the clipboard.GLib.Signal(CName="paste_clipboard")MethodSystem.VoidThis method should be fixed
a
a y coordinate
return location for top coordinate of the line
Gets the at the start of the line containing the coordinate . is in buffer coordinates, convert from window coordinates with . If non-, will be filled with the coordinate of the top edge of the line.MethodSystem.VoidUpdates the position of a child
child widget already added to the text view
new X position in window coordinates
new Y position in window coordinates
MethodSystem.VoidAdds a child at fixed coordinates in one of the text widget's windows.
a
a
a
a The window must have non-zero size (see ). Note that the child coordinates are given relative to the 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 will need to compute the child's correct position in buffer coordinates any time scrolling occurs or buffer changes occur, and then call to update the child's position. Unfortunately there is 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.PropertyGLib.GTypeGType Property.a Returns the native value for .MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.
a Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.
a
a Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.
a Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.
a
a Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.
a Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.
a
a
a Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidDefault handler for the event.
a
a Override this method in a subclass to provide a default handler for the event.ConstructorProtected Constructor.
a Chain to this constructor if you have manually registered a native value for your subclass.System.Obsolete(Message=null, IsError=False)MethodGtk.TextIterRetrieves the iterator at buffer coordinates and .
x position, in buffer coordinates
y position, in buffer coordinates
a 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 .MethodGdk.RectangleGets a rectangle which roughly contains the character at iter.
a a , which is the bounds of the character at The rectangle position is in buffer coordinates; use to convert these coordinates to coordinates for one of the windows in the text view.PropertySystem.BooleanWhether Tab will result in a tab character being entered.a Defaults to true.GLib.Property(Name="accepts_tab")PropertySystem.BooleanWhether entered text overwrites existing contents.a Defaults to false.GLib.Property(Name="overwrite")PropertyGdk.RectangleReturns the currently-visible region of the buffer, in buffer coordinates.a
You can convert to window coordinates with .
EventSystem.EventHandlerTo be addedTo be addedGLib.Signal(CName="backspace")MethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.MethodSystem.Int32To be added
a
a
a a To be added