FLTK logo

Documentation

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 Home  |  Articles & FAQs  |  Bugs & Features  |  Documentation  |  Download  ]
 

class Fl_Text_Display


Class Hierarchy

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(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.


User Comments [ Add Comment ]

From matt, 08:00 Sep 18, 2005 (score=3)

This was long part of FL_Text_Display, just never documented. It will be in 1.1.7:

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.
Reply ]

From matt, 07:58 Sep 18, 2005 (score=3)

This was long part of FL_Text_Display, just never documented. It will be in 1.1.7:

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.
Reply ]

From Anonymous, 00:19 Oct 28, 2003 (score=1)

How can I get the current scrolling position of a Text_Display? FL_Scroll has special methods xposition() and yposition() but FL_Text_Display has not. :-(
Reply ]

From Beni, 04:09 Jun 28, 2003 (score=1)

I miss a word-wrapping feature, so you can switch word-wrapping off and on like you can do with Fl_Multiline_Output. This is really something which should be added in future releases.
Reply ]

 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.