![]() |
TE_open | Function (ROM Call 0xAC) |
textedit.h |
short TE_open (TEXT_EDIT *te, WINDOW *w, WIN_RECT *rect, HANDLE BufHandle, unsigned short cur_offset, unsigned short ReadOnly, unsigned short Flags); |
Initializes the text editor.
TE_open initializes the text editor and displays the initial contents of the editor. All
text editor operations are controled using a structure of type
TEXT_EDIT. TE_open will initialize such a structure pointed
to by the parameter te, which later needs to be passed to all text editor operations
(i.e. te must be allocated statically to maintain state between calls to the text
edit routines). It returns TRUE if the edit buffer could
be allocated, or FALSE if there is insufficient memory to
allocate the edit buffer. This routine always returns TRUE
if BufHandle is passed in with the handle to a text buffer.
Note: The window w must already be open. The handle BufHandle must not
be locked.
This routine may cause heap compression.
w is a pointer to the parent window of the editor: you can create a new window to be
the parent using WinOpen, or you can pass
DeskTop as the parameter, if you are happy with
its settings (which is usually the case). rect is a pointer to the
WIN_RECT structure which describes the actual
dimensions of the rectangular text editor area (You can pass
NULL to use entire client rectangle of the window w
for the edit region). Note that if you use your own window as a parent window, this
window must not be "dirty" (i.e. it must not have the
WF_DIRTY flag set). Windows created by
WinOpen are "dirty" by default, so you need to clear
the "dirty" flag manually before calling TE_open. For example, you can do
w->Flags &= ~WF_DIRTY;BufHandle is the handle of the text editor buffer, which may be pre-filled with the text (if you want to edit existing text), or filled with zeros (if you want to create a new text). BufHandle may be, for example, the result of a HeapAlloc operation. BufHandle can also be H_NULL, in this case TE_open will allocate a new handle and initialize it with no text. Note that contrary to what I said in the documentation of TIGCCLIB releases prior to 2.2, it cannot be a handle of a text variable, because text variables contain additional system data on the begining, and the editor expect raw data (see the Frequently Asked Questions to learn how you can pass a text variable to the editor though).
TE_WRAP | Set this flag for multiline edit regions. Reset it for single-line edit regions: the editor will operate in "compact" mode, in which the editor is only one character high, and where the contents of the editor will scroll left/right when necessary (such a mode is used in request boxes in dialogs). In "compact" mode, the contents of the editor buffer must not contain '\r' characters, else the editor will be fooled. In multiline edit regions, text can wrap around the end of the line to the beginning of the next line. The program editor is an example of a multiline edit region. The Home screen entry line is an example of a single-line edit region. |
TE_COLON | When set, each line of the editor will be preceded with a colon (":"), like in the "Text editor" or the "Program editor". When TE_COLON is reset, there will not be a preceding colon. The program editor uses this flag to mark the beginning of each line of the program. |
TE_COMMANDS | When set, the first character of
each line will be regarded as "command character", and it will be displayed before the colon.
The "Text editor" application uses this mode to store editor commands (like "P" = "PrintObj"
etc.). Note that when this flag is set, the parameter cur_offset must not be zero (it
is usually set to 1 in this case). Note: This flag includes the TE_COLON flag (as needed by the AMS). |
TE_MORE_ARROWS | Set this flag to display arrows at the left and right ends of a single-line edit region to indicate when more text is to the left or right of the edit region. |
TE_MORE_ELLIPSES | Set this flag to display ellipses
(...) at the left and right ends of a single-line edit region to indicate when
more text is to the left or right of the edit region. Note: This flag includes the TE_MORE_ARROWS flag (as needed by the AMS). |
TE_SELECT | This flag is an internal flag. It is set if there currently is a selection in the text editor. It is clear if nothing is selected. Do not set this flag. |
TE_CURSOR | This flag is an internal flag. It represents the current blinking state of the cursor: it is set if the blinking cursor is currently visible. Do not set this flag. |
TE_FIXED_LENGTH | This flag is an internal flag. It is set for text editors opened with TE_openFixed. Do not set this flag. |
TE_CHANGED | This flag is an internal flag. It is a status flag which, if 1, indicates the contents of the edit buffer have changed. Do not set this flag. |
TE_FOCUSED | This flag is an internal flag. It is set if the text editor currently has the focus, i.e. if the cursor is currently in the text editor. See TE_focus and TE_unfocus. Do not set this flag. |
TE_AUTO_ANS | Set this flag to 1 to cause "ans(1)" to be inserted automatically when the edit buffer is empty and an arithmetic operation is typed. |
TE_READ_ONLY | When set, the editor enters read-only mode. In this mode, the editor displays text and allows arrow keys to navigate through the edit buffer, but it does not allow changing the text, i.e. you can't insert, delete or change any characters. |