Fl_Text_Display

## class Fl_Text_Display

### Class Hierarchy

    Fl_Group
       |
       +----Fl_Text_Display----Fl_Text_Buffer
               |
               +----Fl_Text_Editor

### Include Files

    #include <FL/Fl_Text_Display.H>

### Description

This is the FLTK text display widget. It allows the user to view multiple lines of text and supports highlighting and scrolling. The buffer that is displayed in the widget is managed by the `Fl_Text_Buffer` class.

### Methods

Fl_Text_Display ~Fl_Text_Display buffer cursor_color cursor_style hide_cursor highlight_data in_selection insert insert_position move_down | move_left move_right move_up next_word overstrike position_style previous_word redisplay_range scrollbar_align scrollbar_width | scroll show_cursor show_insert_position textcolor textfont textsize word_end word_start wrap_mode

#### Fl_Text_Display(int X, int Y, int W, int H, const char *l = 0);

Creates a new text display widget.

#### ~Fl_Text_Display();

Destroys a text display widget.

#### void buffer(Fl_Text_Buffer* buf);
void buffer(Fl_Text_Buffer& buf);
Fl_Text_Buffer* buffer();

Sets or gets the current text buffer associated with the text widget. Multiple text widgets can be associated with the same text buffer.

#### void cursor_color(Fl_Color c);
Fl_Color cursor_color();

Sets or gets the text cursor color.

#### void cursor_style(int style);

Sets the text cursor style to one of the following:

- `Fl_Text_Display::NORMAL_CURSOR` - Shows an I beam.
- `Fl_Text_Display::CARET_CURSOR` - Shows a caret under the text.
- `Fl_Text_Display::DIM_CURSOR` - Shows a dimmed I beam.
- `Fl_Text_Display::BLOCK_CURSOR` - Shows an unfilled box around the current character.
- `Fl_Text_Display::HEAVY_CURSOR` - Shows a thick I beam.

#### void hide_cursor();

Hides the text cursor.

#### void highlight_data(Fl_Text_Buffer *styleBuffer, Style_Table_Entry *styleTable, int nStyles, char unfinishedStyle, Unfinished_Style_Cb unfinishedHighlightCB, void *cbArg);

Sets the text buffer, text styles, and callbacks to use when displaying text in the widget. Style buffers cannot be shared between widgets and are often used to do syntax highlighting. The editor example from Chapter 4 shows how to use the `highlight_data()` method.

#### int in_selection(int x, int y);

Returns non-zero if the specified mouse position is inside the current selection.

#### void insert(const char* text);

Inserts text at the current insert position.

#### void insert_position(int newPos);
int insert_position()

Sets or gets the current insert position.

#### int move_down();

Moves the current insert position down one line.

#### int move_left();

Moves the current insert position left one character.

#### int move_right();

Moves the current insert position right one character.

#### int move_up();

Moves the current insert position up one line.

#### void next_word(void);

Moves the current insert position right one word.

#### void overstrike(const char* text);

Replaces text at the current insert position.

#### int position_style(int lineStartPos, int lineLen, int lineIndex, int dispIndex);

Returns the style associated with the character at position `lineStartPos + lineIndex`.

#### void previous_word(void);

Moves the current insert position left one word.

#### void redisplay_range(int start, int end);

Marks text from `start` to `end` as needing a redraw.

#### void scrollbar_align(Fl_Align a);
Fl_Align scrollbar_align();

Sets or gets where scrollbars are attached to the widget - `FL_ALIGN_LEFT` and `FL_ALIGN_RIGHT` for the vertical scrollbar and `FL_ALIGN_TOP` and `FL_ALIGN_BOTTOM` for the horizontal scrollbar.

#### void scrollbar_width(int w);
int scrollbar_width();

Sets or gets the width/height of the scrollbars.

#### void scroll(int topLineNum, int horizOffset);

Scrolls the current buffer to start at the specified line and column.

#### void show_cursor(int b = 1);

Shows or hides the text cursor.

#### void show_insert_position();

Scrolls the text buffer to show the current insert position.

#### void textcolor(unsigned n);
Fl_Color textcolor() const;

Sets or gets the default color of text in the widget.

#### void textfont(uchar s);
Fl_Font textfont() const;

Sets or gets the default font used when drawing text in the widget.

#### void textsize(uchar s);
uchar textsize() const;

Sets or gets the default size of text in the widget.

#### int word_end(int pos);

Moves the insert position to the end of the current word.

#### int word_start(int pos);

Moves the insert position to the beginning of the current word.

#### void wrap_mode(int mode, int pos);

If mode is not zero, this call enables automatic word wrapping at column pos. Word-wrapping does not change the text buffer itself, only the way that the text is displayed.