- Text Edit Widget
- MakeTextWidget
- SetTextWidgetText
- GetTextWidgetText

## Text Edit Widget

A text edit widget is an area used to display and optionally edit multiple lines of text. You can specify the text to be displayed as either an in memory string or as a file name. The text edit area manages its scrollbars and internal affairs, you need not do anything (in fact there are no callbacks for the text edit widget).

Widget MakeTextWidget(char *txt, int is_file, int editable, int w, int h);

This functions lets you create a text edit widget that will display some text and optionally let the user edit and manipulate it. The first argument, txt, is a pointer to a string (NULL is ok). The second argument, is_file, is a boolean value indicating if the first argument should be interpreted as a file name or not. The next argument, editable, is a boolean value indicating whether or not the user is allowed to edit the text. The final two arguments specify the width and height of the drawing area box. If the area is too small to display the text, scrollbars will appear.

The txt argument can either contain the entire string (null terminated) that you would like the user to edit, or it can contain the name of a file to be loaded into the text edit widget. If the second argument is_file is TRUE (1), then the first argument gets interpreted as a file name. If is_file is FALSE (0), then the first argument contains the actual text to be displayed.

If the txt argument contains the actual text to be displayed, after calling MakeTextWidget() you can free the memory if necessary (the text edit widget makes an internal copy of the string).

The argument `editable' is a boolean value indicating whether or not to allow editing of the text in the widget. If you just wish to display some text (such as a help file), set the editable argument to FALSE (0) and the user will not be allowed to modify the text.

SEE ALSO: GetTextWidgetText() , SetTextWidgetText() , SetWidgetPos() , SetFgColor() , SetBgColor() , SetWidgetFont()

void SetTextWidgetText(Widget w, char *text, int is_file);

This argument lets you modify the text displayed in a text edit widget. The first argument identifies the text edit widget to change. The second argument is a null-terminated string that either contains the actual text to display or the name of a file to read in. If the is_file argument is TRUE (1), then the string pointed to by the argument, text, is interpreted as a file name. If is_file is FALSE, the string pointed to by text is directly displayed in the text edit widget.

After calling this function, you can free the string pointed to by text if necessary. The text edit widget makes an internal copy of the text. If you wish to update the displayed text again, you should call SetTextWidgetText() again.

BUGS: The function name is way too long.

SEE ALSO: GetTextWidgetText() , MakeTextWidget()

char *GetTextWidgetText(Widget w);

This function lets you retrieve the text contained in a text edit widget. The only argument, w, should be a text edit widget created with MakeTextWidget() .

The return from this function is a character pointer to a null-terminated string that contains the current text in the widget. If there is an error, a NULL is returned.

NOTE: You should not free or otherwise modify the text returned by this function. If you need to make modifications, make a copy of the buffer. Again, DO NOT MODIFY THE TEXT RETURNED BY THIS FUNCTION. Make a copy if you need to modify it.

BUGS: The function name is way too long.

SEE ALSO: SetTextWidgetText() , MakeTextWidget()