*********** wx.TextCtrl *********** Inheritance diagram for `wx.TextCtrl`: | .. inheritance-diagram:: wx.TextCtrl | Description =========== A text control allows text to be displayed and edited. It may be single line or multi-line. Derived From ^^^^^^^^^^^^^ * `wx.Control `_ * `wx.Window `_ * `wx.EvtHandler `_ * `wx.Object `_ Known Subclasses ^^^^^^^^^^^^^^^^ `wx.SearchCtrl `_ Window Styles ^^^^^^^^^^^^^ ================================================== ================================================== Window Style Description ================================================== ================================================== ``wx.TE_PROCESS_ENTER`` The control will generate the event ``wx.wxEVT_COMMAND_TEXT_ENTER`` (otherwise pressing ``Enter`` key is either processed internally by the control or used for navigation between dialog controls). ``wx.TE_PROCESS_TAB`` The control will receive wx.EVT_CHAR events for ``TAB`` pressed -- normally, ``TAB`` is used for passing to the next control in a dialog instead. For the control created with this style, you can still use ``Ctrl-Enter`` to pass to the next control from the keyboard. ``wx.TE_MULTILINE`` The text control allows multiple lines. ``wx.TE_PASSWORD`` The text will be echoed as asterisks. ``wx.TE_READONLY`` The text will not be user-editable. ``wx.TE_RICH`` Use rich text control under Win32, this allows to have more than 64KB of text in the control even under Win9x. This style is ignored under other platforms. ``wx.TE_RICH2`` Use rich text control version 2.0 or 3.0 under Win32, this style is ignored under other platforms ``wx.TE_AUTO_URL`` Highlight the URLs and generate the `wx.TextUrlEvents` when mouse events occur over them. This style is only supported for ``wx.TE_RICH`` Win32 and multi-line wxGTK2 text controls. ``wx.TE_NOHIDESEL`` By default, the Windows text control doesn't show the selection when it doesn't have focus - use this style to force it to always show it. It doesn't do anything under other platforms. ``wx.HSCROLL`` A horizontal scrollbar will be created and used, so that text won't be wrapped. No effect under wxGTK1. ``wx.TE_LEFT`` The text in the control will be left-justified (default). ``wx.TE_CENTRE`` The text in the control will be centered (currently wxMSW and wxGTK2 only). ``wx.TE_RIGHT`` The text in the control will be right-justified (currently wxMSW and wxGTK2 only). ``wx.TE_DONTWRAP`` Same as ``wx.HSCROLL`` style: don't wrap at all, show horizontal scrollbar instead. ``wx.TE_CHARWRAP`` Wrap the lines too long to be shown entirely at any position (wxUniv and wxGTK2 only). ``wx.TE_WORDWRAP`` Wrap the lines too long to be shown entirely at word boundaries (wxUniv and wxGTK2 only). ``wx.TE_BESTWRAP`` Wrap the lines at word boundaries or at any other character if there are words longer than the window width (this is the default). ``wx.TE_CAPITALIZE`` On PocketPC and Smartphone, causes the first letter to be capitalized. ================================================== ================================================== .. note:: Note that alignment styles (``wx.TE_LEFT``, ``wx.TE_CENTRE`` and ``wx.TE_RIGHT``) can be changed dynamically after control creation on wxMSW and wxGTK. ``wx.TE_READONLY``, ``wx.TE_PASSWORD`` and wrapping styles can be dynamically changed under wxGTK but not wxMSW. The other styles can be only set during control creation. Multi-line text controls support the styles, i.e. provide a possibility to set colours and font for individual characters in it (note that under Windows ``wx.TE_RICH`` style is required for style support). To use the styles you can either call `SetDefaultStyle <#SetDefaultStyle>`_ before inserting the text or call `SetStyle <#SetStyle>`_ later to change the style of the text already in the control (the first solution is much more efficient). In either case, if the style doesn't specify some of the attributes (for example you only want to set the text colour but without changing the font nor the text background), the values of the default style will be used for them. If there is no default style, the attributes of the text control itself are used. So the following code correctly describes what it does: the second call to `SetDefaultStyle` doesn't change the text foreground colour (which stays red) while the last one doesn't change the background colour (which stays grey):: text.SetDefaultStyle(wx.TextAttr(wx.RED)) text.AppendText("Red text\n") text.SetDefaultStyle(wx.TextAttr(wx.NullColour, wx.LIGHT_GREY)) text.AppendText("Red on grey text\n") text.SetDefaultStyle(wx.TextAttr(wx.BLUE)) text.AppendText("Blue on grey text\n") Text Format ^^^^^^^^^^^ The multiline text controls always store the text as a sequence of lines separated by ``\n`` characters, i.e. in the Unix text format even on non-Unix platforms. This allows the user code to ignore the differences between the platforms but at a price: the indices in the control such as those returned by `GetInsertionPoint <#GetInsertionPoint>`_ or `GetSelection <#GetSelection>`_ can not be used as indices into the string returned by `GetValue <#GetValue>`_ as they're going to be slightly off for platforms using ``\r\n`` as separator (as Windows does), for example. Instead, if you need to obtain a substring between the 2 indices obtained from the control with the help of the functions mentioned above, you should use `GetRange <#GetRange>`_. And the indices themselves can only be passed to other methods, for example `SetInsertionPoint <#SetInsertionPoint>`_ or `SetSelection <#SetSelection>`_. To summarize: never use the indices returned by (multiline) `wx.TextCtrl` as indices into the string it contains, but only as arguments to be passed back to the other `wx.TextCtrl` methods. Event Handling ^^^^^^^^^^^^^^ The following commands are processed by default event handlers in `wx.TextCtrl`: ``wx.ID_CUT``, ``wx.ID_COPY``, ``wx.ID_PASTE``, ``wx.ID_UNDO``, ``wx.ID_REDO``. The associated UI update events are also processed automatically, when the control has the focus. To process input from a text control, use these event handler macros to direct input to member functions that take a `wx.CommandEvent <../Events/wx.CommandEvent.html>`_ argument. ================================================================= ================================================== Event Name Description ================================================================= ================================================== wx.EVT_TEXT(id, func) Respond to a ``wx.wxEVT_COMMAND_TEXT_UPDATED`` event, generated when the text changes. Notice that this event will be sent when the text controls contents changes - whether this is due to user input or comes from the program itself (for example, if `SetValue() <#SetValue>`_ is called); see `ChangeValue() <#ChangeValue>`_ for a function which does not send this event. wx.EVT_TEXT_ENTER(id, func) Respond to a ``wx.wxEVT_COMMAND_TEXT_ENTER`` event, generated when enter is pressed in a text control (which must have ``wx.TE_PROCESS_ENTER`` style for this event to be generated). wx.EVT_TEXT_URL(id, func) A mouse event occurred over an URL in the text control (wxMSW and wxGTK2 only) wx.EVT_TEXT_MAXLEN(id, func) User tried to enter more text into the control than the limit set by `SetMaxLength <#SetMaxLength>`_. ================================================================= ================================================== | Control Appearance ^^^^^^^^^^^^^^^^^^ | .. figure:: ../images/wxWidgets/wxmsw/textctrl.png :alt: wxMSW :figclass: floatleft **wxMSW** .. figure:: ../images/wxWidgets/wxmac/textctrl.png :alt: wxMAC :figclass: floatright **wxMAC** .. figure:: ../images/wxWidgets/wxgtk/textctrl.png :alt: wxGTK :figclass: floatcenter **wxGTK** | Methods Summary ^^^^^^^^^^^^^^^ * `__init__ <#__init__>`_ * `AppendText <#AppendText>`_ * `CanCopy <#CanCopy>`_ * `CanCut <#CanCut>`_ * `CanPaste <#CanPaste>`_ * `CanRedo <#CanRedo>`_ * `CanUndo <#CanUndo>`_ * `ChangeValue <#ChangeValue>`_ * `Clear <#Clear>`_ * `Copy <#Copy>`_ * `Cut <#Cut>`_ * `DiscardEdits <#DiscardEdits>`_ * `EmulateKeyPress <#EmulateKeyPress>`_ * `GetDefaultStyle <#GetDefaultStyle>`_ * `GetInsertionPoint <#GetInsertionPoint>`_ * `GetLastPosition <#GetLastPosition>`_ * `GetLineLength <#GetLineLength>`_ * `GetLineText <#GetLineText>`_ * `GetNumberOfLines <#GetNumberOfLines>`_ * `GetRange <#GetRange>`_ * `GetSelection <#GetSelection>`_ * `GetString <#GetString>`_ * `GetStringSelection <#GetStringSelection>`_ * `GetStyle <#GetStyle>`_ * `GetValue <#GetValue>`_ * `HideNativeCaret <#HideNativeCaret>`_ * `HitTest <#HitTest>`_ * `HitTestPos <#HitTestPos>`_ * `IsEditable <#IsEditable>`_ * `IsEmpty <#IsEmpty>`_ * `IsModified <#IsModified>`_ * `IsMultiLine <#IsMultiLine>`_ * `IsSingleLine <#IsSingleLine>`_ * `LoadFile <#LoadFile>`_ * `MacCheckSpelling <#MacCheckSpelling>`_ * `MarkDirty <#MarkDirty>`_ * `Paste <#Paste>`_ * `PositionToXY <#PositionToXY>`_ * `Redo <#Redo>`_ * `Remove <#Remove>`_ * `Replace <#Replace>`_ * `SaveFile <#SaveFile>`_ * `SelectAll <#SelectAll>`_ * `SendTextUpdatedEvent <#SendTextUpdatedEvent>`_ * `SetDefaultStyle <#SetDefaultStyle>`_ * `SetEditable <#SetEditable>`_ * `SetInsertionPoint <#SetInsertionPoint>`_ * `SetInsertionPointEnd <#SetInsertionPointEnd>`_ * `SetMaxLength <#SetMaxLength>`_ * `SetModified <#SetModified>`_ * `SetSelection <#SetSelection>`_ * `SetStyle <#SetStyle>`_ * `SetValue <#SetValue>`_ * `ShowNativeCaret <#ShowNativeCaret>`_ * `ShowPosition <#ShowPosition>`_ * `Undo <#Undo>`_ * `WriteText <#WriteText>`_ * `XYToPosition <#XYToPosition>`_ * `write <#write>`_ Properties Summary ^^^^^^^^^^^^^^^^^^ * `DefaultStyle <#DefaultStyle>`_ * `InsertionPoint <#InsertionPoint>`_ * `LastPosition <#LastPosition>`_ * `NumberOfLines <#NumberOfLines>`_ * `Selection <#Selection>`_ * `StringSelection <#StringSelection>`_ * `Value <#Value>`_ Class API ========= Methods ^^^^^^^ .. method:: __init__(parent, id=-1, value="", pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, validator=wx.DefaultValidator, name=wx.TextCtrlNameStr) Constructor, creating and showing a text control. **Parameters:** * `parent` (`wx.Window `_) * `id` (int) * `value` (string) * `pos` (`wx.Point `_) * `size` (`wx.Size `_) * `style` (long) * `validator` (`wx.Validator `_) * `name` (string) | **Returns:** `wx.TextCtrl `_ -------- .. method:: AppendText(text) Appends the text to the end of the text control. **Parameters:** * `text` (string): Text to write to the text control. .. note:: After the text is appended, the insertion point will be at the end of the text control. If this behaviour is not desired, the programmer should use `GetInsertionPoint <#GetInsertionPoint>`_ and `SetInsertionPoint <#SetInsertionPoint>`_. .. seealso:: `WriteText <#WriteText>`_ -------- .. method:: CanCopy() Returns ``True`` if the selection can be copied to the clipboard. | **Returns:** `bool` -------- .. method:: CanCut() Returns ``True`` if the selection can be cut to the clipboard. | **Returns:** `bool` -------- .. method:: CanPaste() Returns ``True`` if the contents of the clipboard can be pasted into the text control. On some platforms (Motif, GTK) this is an approximation and returns ``True`` if the control is editable, ``False`` otherwise. | **Returns:** `bool` -------- .. method:: CanRedo() Returns ``True`` if there is a redo facility available and the last operation can be redone. | **Returns:** `bool` -------- .. method:: CanUndo() Returns ``True`` if there is an undo facility available and the last operation can be undone. | **Returns:** `bool` -------- .. method:: ChangeValue(value) Sets the text value and marks the control as not-modified (which means that `IsModified <#IsModified>`_ would return ``False`` immediately after the call to `ChangeValue`). This function is new since wxWidgets version 2.7.1 **Parameters:** * `value` (string): The new value to set. It may contain newline characters if the text control is multi-line. .. note:: Note that this function will **not** generate the ``wx.wxEVT_COMMAND_TEXT_UPDATED`` event. This is the only difference with `SetValue <#SetValue>`_. -------- .. method:: Clear() Clears the text in the control. .. note:: Note that this function will generate a ``wx.wxEVT_COMMAND_TEXT_UPDATED`` event. -------- .. method:: Copy() Copies the selected text to the clipboard under Motif and MS Windows. -------- .. method:: Cut() Copies the selected text to the clipboard and removes the selection. -------- .. method:: DiscardEdits() Resets the internal 'modified' flag as if the current edits had been saved. -------- .. method:: EmulateKeyPress(event) This functions inserts into the control the character which would have been inserted if the given key event had occurred in the text control. The `event` object should be the same as the one passed to ``EVT_KEY_DOWN`` handler previously by wxWidgets. **Parameters:** * `event` (`wx.KeyEvent `_) | **Returns:** `bool` .. note:: Please note that this function doesn't currently work correctly for all keys under any platform but MSW. -------- .. method:: GetDefaultStyle() Returns the style currently used for the new text. | **Returns:** `wx.TextAttr `_ .. seealso:: `SetDefaultStyle <#SetDefaultStyle>`_ -------- .. method:: GetInsertionPoint() Returns the insertion point. This is defined as the zero based index of the character position to the right of the insertion point. For example, if the insertion point is at the end of the text control, it is equal to both len(`GetValue() <#GetValue>`_) and `GetLastPosition <#GetLastPosition>`_. The following code snippet safely returns the character at the insertion point or the zero character if the point is at the end of the control:: def GetCurrentChar(myTextCtrl): if myTextCtrl.GetInsertionPoint() == myTextCtrl.GetLastPosition(): return '\0' return myTextCtrl.GetValue()[myTextCtrl.GetInsertionPoint()] | **Returns:** `long` -------- .. method:: GetLastPosition() Returns the zero based index of the last position in the text control, which is equal to the number of characters in the control. | **Returns:** `int` -------- .. method:: GetLineLength(lineNo) Gets the length of the specified line, not including any trailing newline character(s). **Parameters:** * `lineNo` (long): Line number (starting from zero). | **Returns:** `int` -------- .. method:: GetLineText(lineNo) Returns the contents of a given line in the text control, not including any trailing newline character(s). **Parameters:** * `lineNo` (long): The line number, starting from zero. | **Returns:** `string` -------- .. method:: GetNumberOfLines() Returns the number of lines in the text control buffer. | **Returns:** `int` .. note:: Note that even empty text controls have one line (where the insertion point is), so `GetNumberOfLines()` never returns 0. -------- .. method:: GetRange(from, to) Returns the string containing the text starting in the positions `from` and up to `to` in the control. The positions must have been returned by another `wx.TextCtrl` method. **Parameters:** * `from` (long) * `to` (long) | **Returns:** `string` .. note:: Please note that the positions in a multiline `wx.TextCtrl` do **not** correspond to the indices in the string returned by `GetValue <#GetValue>`_ because of the different new line representations (``CR`` or ``CR LF``) and so this method should be used to obtain the correct results instead of extracting parts of the entire value. It may also be more efficient, especially if the control contains a lot of data. -------- .. method:: GetSelection() Gets the current selection span. If the returned values are equal, there was no selection. | **Returns:** `(from, to)` .. note:: Please note that the indices returned may be used with the other `wx.TextCtrl` methods but don't necessarily represent the correct indices into the string returned by `GetValue <#GetValue>`_ for multiline controls under Windows (at least) you should use `GetStringSelection <#GetStringSelection>`_ to get the selected text. -------- .. method:: GetString(from, to) | **Parameters:** * `from` (long) * `to` (long) **Returns:** `string` -------- .. method:: GetStringSelection() Gets the text currently selected in the control. If there is no selection, the returned string is empty. | **Returns:** `string` -------- .. method:: GetStyle(position, style) Returns the style at this position in the text control. Not all platforms support this function. **Parameters:** * `position` (long) * `style` (`wx.TextAttr `_) | **Returns:** `bool` .. seealso:: `SetStyle <#SetStyle>`_, `wx.TextAttr `_ -------- .. method:: GetValue() Gets the contents of the control. Notice that for a multiline text control, the lines will be separated by (Unix-style) ``\n`` characters, even under Windows where they are separated by a ``\r\n`` sequence in the native control. | **Returns:** `string` -------- .. method:: HideNativeCaret() `No docstrings available for this method.` -------- .. method:: HitTest(pt) Find the character position in the text coresponding to the point given in pixels. Possible return values for `result` are: * ``wx.TE_HT_UNKNOWN`` ---> this means `HitTest()` is simply not implemented * ``wx.TE_HT_BEFORE`` ---> either to the left or upper * ``wx.TE_HT_ON_TEXT`` ---> directly on * ``wx.TE_HT_BELOW`` ---> below [the last line] * ``wx.TE_HT_BEYOND`` ---> after [the end of line] **Parameters:** * `pt` (`wx.Point `_) | **Returns:** `(result, col, row)` .. note:: `pt` is in device coords but is not adjusted for the client area origin nor scrolling. -------- .. method:: HitTestPos(pt) Find the character position in the text coresponding to the point given in pixels. Possible return values for `result` are: * ``wx.TE_HT_UNKNOWN`` ---> this means `HitTest()` is simply not implemented * ``wx.TE_HT_BEFORE`` ---> either to the left or upper * ``wx.TE_HT_ON_TEXT`` ---> directly on * ``wx.TE_HT_BELOW`` ---> below [the last line] * ``wx.TE_HT_BEYOND`` ---> after [the end of line] **Parameters:** * `pt` (`wx.Point `_) | **Returns:** `(result, position)` .. note:: `pt` is in device coords but is not adjusted for the client area origin nor scrolling. -------- .. method:: IsEditable() Returns ``True`` if the controls contents may be edited by user (note that it always can be changed by the program), i.e. if the control hasn't been put in read-only mode by a previous call to `SetEditable <#SetEditable>`_. | **Returns:** `bool` -------- .. method:: IsEmpty() Returns ``True`` if the control is currently empty. This is the same as `len(GetValue()) == 0` but can be much more efficient for the multiline controls containing big amounts of text. This function is new since wxWidgets version 2.7.1 | **Returns:** `bool` -------- .. method:: IsModified() Returns ``True`` if the text has been modified by user. | **Returns:** `bool` .. note:: Note that calling `SetValue <#SetValue>`_ doesn't make the control modified. .. seealso:: `MarkDirty <#MarkDirty>`_ -------- .. method:: IsMultiLine() Returns ``True`` if this is a multi line edit control and ``False`` otherwise. | **Returns:** `bool` .. seealso:: `IsSingleLine <#IsSingleLine>`_ -------- .. method:: IsSingleLine() Returns ``True`` if this is a single line edit control and ``False`` otherwise. | **Returns:** `bool` .. seealso:: `IsMultiLine <#IsMultiLine>`_ -------- .. method:: LoadFile(fileName, fileType=wx.TEXT_TYPE_ANY) Loads and displays the named file, if it exists. Returns ``True`` if successful, ``False`` otherwise. **Parameters:** * `fileName` (string): The filename of the file to load. * `fileType` (int): The type of file to load. This is currently ignored in `wx.TextCtrl`. | **Returns:** `bool` -------- .. method:: MacCheckSpelling(check) | **Parameters:** * `check` (bool) -------- .. method:: MarkDirty() Mark text as modified (dirty). .. seealso:: `IsModified <#IsModified>`_ -------- .. method:: Paste() Pastes text from the clipboard to the text item. -------- .. method:: PositionToXY(pos) Converts given position to a zero-based column, line number pair. **Parameters:** * `pos` (long): Position. | **Returns:** `(x, y)` .. seealso:: `XYToPosition <#XYToPosition>`_ -------- .. method:: Redo() If there is a redo facility and the last operation can be redone, redoes the last operation. Does nothing if there is no redo facility. -------- .. method:: Remove(from, to) Removes the text starting at the first given position up to (but not including) the character at the last position. **Parameters:** * `from` (long): The first position. * `to` (long): The last position. -------- .. method:: Replace(from, to, value) Replaces the text starting at the first position up to (but not including) the character at the last position with the given text. **Parameters:** * `from` (long): The first position. * `to` (long): The last position. * `value` (string): The value to replace the existing text with. -------- .. method:: SaveFile(fileName, fileType=wx.TEXT_TYPE_ANY) Saves the contents of the control in a text file. Returns ``True`` if successful, ``False`` otherwise. **Parameters:** * `fileName` (string): The filename of the file to save. * `fileType` (int): The type of file to save. This is currently ignored in `wx.TextCtrl`. | **Returns:** `bool` -------- .. method:: SelectAll() `No docstrings available for this method.` -------- .. method:: SendTextUpdatedEvent() `No docstrings available for this method.` -------- .. method:: SetDefaultStyle(style) Changes the default style to use for the new text which is going to be added to the control using `WriteText <#WriteText>`_ or `AppendText <#AppendText>`_. If either of the font, foreground, or background colour is not set in `style`, the values of the previous default style are used for them. If the previous default style didn't set them neither, the global font or colours of the text control itself are used as fall back. However if the `style` parameter is the default `wx.TextAttr `_, then the default style is just reset (instead of being combined with the new style which wouldn't change it at all). Returns ``True`` if successful, ``False`` if an error occurred - may also mean that the styles are not supported under this platform. **Parameters:** * `style` (`wx.TextAttr `_): The style for the new text. | **Returns:** `bool` .. seealso:: `GetDefaultStyle <#GetDefaultStyle>`_ -------- .. method:: SetEditable(editable) Makes the text item editable or read-only, overriding the ``wx.TE_READONLY`` flag. **Parameters:** * `editable` (bool): If ``True``, the control is editable. If ``False``, the control is read-only. .. seealso:: `IsEditable <#IsEditable>`_ -------- .. method:: SetInsertionPoint(pos) Sets the insertion point at the given position. **Parameters:** * `pos` (int): position to set. -------- .. method:: SetInsertionPointEnd() Sets the insertion point at the end of the text control. This is equivalent to `SetInsertionPoint <#SetInsertionPoint>`_ ( `GetLastPosition <#GetLastPosition>`_ () ). -------- .. method:: SetMaxLength(len) This function sets the maximum number of characters the user can enter into the control. In other words, it allows to limit the text value length to `len` not counting the terminating ``NUL`` character. If `len` is 0, the previously set max length limit, if any, is discarded and the user may enter as much text as the underlying native text control widget supports (typically at least 32Kb). If the user tries to enter more characters into the text control when it already is filled up to the maximal length, a ``wx.wxEVT_COMMAND_TEXT_MAXLEN`` event is sent to notify the program about it (giving it the possibility to show an explanatory message, for example) and the extra input is discarded. .. note:: Note that under GTK+, this function may only be used with single line text controls. -------- .. method:: SetModified(modified) Marks the control as being modified by the user or not. **Parameters:** * `modified` (bool) .. seealso:: `MarkDirty <#MarkDirty>`_, `DiscardEdits <#DiscardEdits>`_ -------- .. method:: SetSelection(from, to) Selects the text starting at the first position up to (but not including) the character at the last position. If both parameters are equal to -1 all text in the control is selected. **Parameters:** * `from` (long): The first position. * `to` (long): The last position. -------- .. method:: SetStyle(start, end, style) Changes the style of the given range. If any attribute within `style` is not set, the corresponding attribute from `GetDefaultStyle <#GetDefaultStyle>`_ is used. **Parameters:** * `start` (long): The start of the range to change. * `end` (long): The end of the range to change. * `style` (`wx.TextAttr `_): The new style for the range. | **Returns:** `bool` .. seealso:: `GetStyle <#GetStyle>`_, `wx.TextAttr `_ -------- .. method:: SetValue(value) Sets the text value and marks the control as not-modified (which means that `IsModified <#IsModified>`_ would return ``False`` immediately after the call to `SetValue`). This function is deprecated and should not be used in new code. Please use the `ChangeValue <#ChangeValue>`_ function instead. **Parameters:** * `value` (string): The new value to set. It may contain newline characters if the text control is multi-line. .. note:: Note that this function will generate a ``wx.wxEVT_COMMAND_TEXT_UPDATED`` event. .. seealso:: `ChangeValue <#ChangeValue>`_ -------- .. method:: ShowNativeCaret(show=True) | **Parameters:** * `show` (bool) | **Returns:** `bool` -------- .. method:: ShowPosition(pos) Makes the line containing the given position visible. **Parameters:** * `pos` (long): The position that should be visible. -------- .. method:: Undo() If there is an undo facility and the last operation can be undone, undoes the last operation. Does nothing if there is no undo facility. -------- .. method:: WriteText(text) Writes the text into the text control at the current insertion position. **Parameters:** * `text` (string): Text to write to the text control. .. note:: Newlines in the text string are the only control stringacters allowed, and they will cause appropriate line breaks. See `AppendText <#AppendText>`_ for more convenient ways of writing to the window. .. seealso:: `AppendText <#AppendText>`_ -------- .. method:: XYToPosition(x, y) Converts the given zero based column and line number to a position. **Parameters:** * `x` (long): The column number. * `y` (long): The line number. | **Returns:** `long` -------- .. method:: write(text) | **Parameters:** * `text` (string) -------- Properties ^^^^^^^^^^ .. attribute:: DefaultStyle See `GetDefaultStyle <#GetDefaultStyle>`_ and `SetDefaultStyle <#SetDefaultStyle>`_ .. attribute:: InsertionPoint See `GetInsertionPoint <#GetInsertionPoint>`_ and `SetInsertionPoint <#SetInsertionPoint>`_ .. attribute:: LastPosition See `GetLastPosition <#GetLastPosition>`_ .. attribute:: NumberOfLines See `GetNumberOfLines <#GetNumberOfLines>`_ .. attribute:: Selection See `GetSelection <#GetSelection>`_ and `SetSelection <#SetSelection>`_ .. attribute:: StringSelection See `GetStringSelection <#GetStringSelection>`_ .. attribute:: Value See `GetValue <#GetValue>`_ and `SetValue <#SetValue>`_