22#ifndef FL_TEXT_DISPLAY_H
23#define FL_TEXT_DISPLAY_H
29#include "Fl_Scrollbar.H"
30#include "Fl_Text_Buffer.H"
130 typedef void (*Unfinished_Style_Cb)(int,
void *);
157 ATTR_BGCOLOR = 0x0001,
158 ATTR_BGCOLOR_EXT_ = 0x0002,
159 ATTR_BGCOLOR_EXT = 0x0003,
160 ATTR_UNDERLINE = 0x0004,
161 ATTR_GRAMMAR = 0x0008,
162 ATTR_SPELLING = 0x000C,
163 ATTR_STRIKE_THROUGH = 0x0010,
164 ATTR_LINES_MASK = 0x001C
198 void redisplay_range(
int start,
int end);
199 void scroll(
int topLineNum,
int horizOffset);
200 void insert(
const char* text);
201 void overstrike(
const char* text);
202 void insert_position(
int newPos);
216 int position_to_xy(
int pos,
int* x,
int* y)
const;
218 int in_selection(
int x,
int y)
const;
219 void show_insert_position();
225 int count_lines(
int start,
int end,
bool start_pos_is_line_start)
const;
226 int line_start(
int pos)
const;
227 int line_end(
int startPos,
bool startPosIsLineStart)
const;
228 int skip_lines(
int startPos,
int nLines,
bool startPosIsLineStart);
229 int rewind_lines(
int startPos,
int nLines);
230 void next_word(
void);
231 void previous_word(
void);
233 void show_cursor(
int b = 1);
240 void cursor_style(
int style);
241 int cursor_style()
const {
return mCursorStyle; }
271 scrollbar_width_ = 0;
284 return(scrollbar_width_);
307 scrollbar_width_ = newSize;
327 int word_start(
int pos)
const {
return buffer()->word_start(pos); }
334 int word_end(
int pos)
const {
return buffer()->word_end(pos); }
338 const Style_Table_Entry *styleTable,
339 int nStyles,
char unfinishedStyle,
340 Unfinished_Style_Cb unfinishedHighlightCB,
343 int position_style(
int lineStartPos,
int lineLen,
int lineIndex)
const;
431 int wrapped_column(
int row,
int column)
const;
432 int wrapped_row(
int row)
const;
433 void wrap_mode(
int wrap,
int wrap_margin);
435 virtual void recalc_display();
443 double x_to_col(
double x)
const;
451 double col_to_x(
double col)
const;
453 void linenumber_width(
int width);
454 int linenumber_width()
const;
455 void linenumber_font(
Fl_Font val);
456 Fl_Font linenumber_font()
const;
459 void linenumber_fgcolor(
Fl_Color val);
460 Fl_Color linenumber_fgcolor()
const;
461 void linenumber_bgcolor(
Fl_Color val);
462 Fl_Color linenumber_bgcolor()
const;
463 void linenumber_align(
Fl_Align val);
465 void linenumber_format(
const char* val);
466 const char* linenumber_format()
const;
475 void draw_text(
int X,
int Y,
int W,
int H);
476 void draw_range(
int start,
int end);
477 void draw_cursor(
int,
int);
479 void draw_string(
int style,
int x,
int y,
int toX, const
char *
string,
482 void draw_vline(
int visLineNum,
int leftClip,
int rightClip,
483 int leftCharIndex,
int rightCharIndex);
485 int find_x(const
char *s,
int len,
int style,
int x) const;
490 FIND_INDEX_FROM_ZERO,
495 int handle_vline(
int mode,
496 int lineStart,
int lineLen,
int leftChar,
int rightChar,
497 int topClip,
int bottomClip,
498 int leftClip,
int rightClip)
const;
500 int handle_rmb(
int readonly);
502 void draw_line_numbers(
bool clearAll);
504 void clear_rect(
int style,
int x,
int y,
int width,
int height)
const;
505 void display_insert();
507 void offset_line_starts(
int newTopLineNum);
509 void calc_line_starts(
int startLine,
int endLine);
511 void update_line_starts(
int pos,
int charsInserted,
int charsDeleted,
512 int linesInserted,
int linesDeleted,
int *scrolled);
514 void calc_last_char();
516 int position_to_line(
int pos,
int* lineNum )
const;
517 double string_width(
const char*
string,
int length,
int style)
const;
519 static void scroll_timer_cb(
void*);
521 static void buffer_predelete_cb(
int pos,
int nDeleted,
void* cbArg);
522 static void buffer_modified_cb(
int pos,
int nInserted,
int nDeleted,
523 int nRestyled,
const char* deletedText,
528 void update_v_scrollbar();
529 void update_h_scrollbar();
530 int measure_vline(
int visLineNum)
const;
531 int longest_vline()
const;
532 int empty_vlines()
const;
533 int vline_length(
int visLineNum)
const;
534 int xy_to_position(
int x,
int y,
int PosType = CHARACTER_POS)
const;
536 void xy_to_rowcol(
int x,
int y,
int* row,
int* column,
537 int PosType = CHARACTER_POS)
const;
538 void maintain_absolute_top_line_number(
int state);
539 int get_absolute_top_line_number()
const;
540 void absolute_top_line_number(
int oldFirstChar);
541 int maintaining_absolute_top_line_number()
const;
542 void reset_absolute_top_line_number();
543 int position_to_linecol(
int pos,
int* lineNum,
int* column)
const;
544 int scroll_(
int topLineNum,
int horizOffset);
546 void extend_range_for_styles(
int* start,
int* end);
548 void find_wrap_range(
const char *deletedText,
int pos,
int nInserted,
549 int nDeleted,
int *modRangeStart,
int *modRangeEnd,
550 int *linesInserted,
int *linesDeleted);
551 void measure_deleted_lines(
int pos,
int nDeleted);
552 void wrapped_line_counter(
Fl_Text_Buffer *buf,
int startPos,
int maxPos,
553 int maxLines,
bool startPosIsLineStart,
554 int styleBufOffset,
int *retPos,
int *retLines,
555 int *retLineStart,
int *retLineEnd,
556 bool countLastLineMissingNewLine =
true)
const;
557 void find_line_end(
int pos,
bool start_pos_is_line_start,
int *lineEnd,
558 int *nextLineStart)
const;
559 double measure_proportional_character(
const char *s,
int colNum,
int pos)
const;
560 int wrap_uses_character(
int lineEndPos)
const;
562 int damage_range1_start, damage_range1_end;
563 int damage_range2_start, damage_range2_end;
571 int mCursorPreferredXPos;
578 int mFirstChar, mLastChar;
601 int mNeedAbsTopLineNum;
607 int mHorizOffsetHint;
609 const Style_Table_Entry *mStyleTable;
611 char mUnfinishedStyle;
613 Unfinished_Style_Cb mUnfinishedHighlightCB;
615 void* mHighlightCBArg;
624 int mModifyingTabDistance;
626 mutable double mColumnScale;
635 int scrollbar_width_;
637 int dragPos, dragType, dragging;
638 int display_insert_position_hint;
639 struct {
int x,
y,
w,
h; } text_area;
648 Fl_Color secondary_selection_color_;
651 int mLineNumLeft, mLineNumWidth;
659 const char* linenumber_format_;
int Fl_Font
A font number is an index into the internal font table.
Definition Enumerations.H:1044
unsigned Fl_Align
FLTK type for alignment control.
Definition Enumerations.H:967
unsigned int Fl_Color
An FLTK color value; see also Colors
Definition Enumerations.H:1101
int Fl_Fontsize
Size of a font in pixels.
Definition Enumerations.H:1073
Fl_Group and Fl_End classes.
The Fl_Group class is the FLTK container widget.
Definition Fl_Group.H:56
int handle(int) FL_OVERRIDE
Handles the specified event.
Definition Fl_Group.cxx:145
void resize(int, int, int, int) FL_OVERRIDE
Resizes the Fl_Group widget and all of its children.
Definition Fl_Group.cxx:823
void draw() FL_OVERRIDE
Draws the widget.
Definition Fl_Group.cxx:926
void insert(Fl_Widget &, int i)
The widget is removed from its current group (if any) and then inserted into this group.
Definition Fl_Group.cxx:509
This class manages Unicode text displayed in one or more Fl_Text_Display widgets.
Definition Fl_Text_Buffer.H:201
Rich text display widget.
Definition Fl_Text_Display.H:78
int scrollbar_width() const
Returns the global value Fl::scrollbar_size() unless a specific scrollbar_width_ has been set.
Definition Fl_Text_Display.H:260
void textsize(Fl_Fontsize s)
Sets the default size of text in the widget.
Definition Fl_Text_Display.H:381
void hide_cursor()
Hides the text cursor.
Definition Fl_Text_Display.H:238
void cursor_color(Fl_Color n)
Sets the text cursor color.
Definition Fl_Text_Display.H:253
void scrollbar_size(int newSize)
Sets the pixel size of the scrollbars' troughs to newSize, in pixels.
Definition Fl_Text_Display.H:306
void textcolor(Fl_Color n)
Sets the default color of text in the widget.
Definition Fl_Text_Display.H:393
Fl_Align scrollbar_align() const
Gets the scrollbar alignment type.
Definition Fl_Text_Display.H:314
@ WRAP_AT_COLUMN
wrap text at the given text column
Definition Fl_Text_Display.H:122
@ WRAP_NONE
don't wrap text at all
Definition Fl_Text_Display.H:121
@ WRAP_AT_PIXEL
wrap text at a pixel position
Definition Fl_Text_Display.H:123
void shortcut(int s)
Definition Fl_Text_Display.H:357
Fl_Text_Buffer * buffer() const
Gets the current text buffer associated with the text widget.
Definition Fl_Text_Display.H:189
void scrollbar_width(int width)
Sets the global Fl::scrollbar_size(), and forces this instance of the widget to use it.
Definition Fl_Text_Display.H:269
void scrollbar_align(Fl_Align a)
Sets the scrollbar alignment type.
Definition Fl_Text_Display.H:320
int word_start(int pos) const
Moves the insert position to the beginning of the current word.
Definition Fl_Text_Display.H:327
int scrollbar_size() const
Gets the current size of the scrollbars' troughs, in pixels.
Definition Fl_Text_Display.H:283
int word_end(int pos) const
Moves the insert position to the end of the current word.
Definition Fl_Text_Display.H:334
Fl_Color cursor_color() const
Gets the text cursor color.
Definition Fl_Text_Display.H:247
Fl_Color textcolor() const
Gets the default color of text in the widget.
Definition Fl_Text_Display.H:387
void textfont(Fl_Font s)
Sets the default font used when drawing text in the widget.
Definition Fl_Text_Display.H:369
int insert_position() const
Gets the position of the text insertion cursor for text display.
Definition Fl_Text_Display.H:215
Fl_Color grammar_underline_color() const
Gets the underline color for style attribute ATTR_GRAMMAR.
Definition Fl_Text_Display.H:405
int shortcut() const
Definition Fl_Text_Display.H:350
Fl_Color secondary_selection_color() const
Gets the background color for the secondary selection block.
Definition Fl_Text_Display.H:429
Fl_Color spelling_underline_color() const
Gets the underline color for style attribute ATTR_SPELLING.
Definition Fl_Text_Display.H:417
Fl_Text_Buffer * style_buffer() const
Gets the current style buffer associated with the text widget.
Definition Fl_Text_Display.H:196
Fl_Fontsize textsize() const
Gets the default size of text in the widget.
Definition Fl_Text_Display.H:375
void grammar_underline_color(Fl_Color color)
Sets the underline color for style attribute ATTR_GRAMMAR.
Definition Fl_Text_Display.H:399
void spelling_underline_color(Fl_Color color)
Sets the underline color for style attribute ATTR_SPELLING.
Definition Fl_Text_Display.H:411
void buffer(Fl_Text_Buffer &buf)
Sets the current text buffer associated with the text widget.
Definition Fl_Text_Display.H:180
@ BLOCK_CURSOR
unfille box under the current character
Definition Fl_Text_Display.H:89
@ DIM_CURSOR
dim I-beam
Definition Fl_Text_Display.H:88
@ CARET_CURSOR
caret under the text
Definition Fl_Text_Display.H:87
@ NORMAL_CURSOR
I-beam.
Definition Fl_Text_Display.H:86
@ HEAVY_CURSOR
thick I-beam
Definition Fl_Text_Display.H:90
Fl_Font textfont() const
Gets the default font used when drawing text in the widget.
Definition Fl_Text_Display.H:363
void secondary_selection_color(Fl_Color color)
Sets the background color for the secondary selection block.
Definition Fl_Text_Display.H:423
static int scrollbar_size()
Gets the default scrollbar size used by Fl_Browser_, Fl_Help_View, Fl_Scroll, and Fl_Text_Display wid...
Definition Fl.cxx:148
#define FL_OVERRIDE
This macro makes it safe to use the C++11 keyword override with older compilers.
Definition fl_attr.h:46
utility header to pull drawing functions together
This structure associates the color, font, and font size of a string to draw with an attribute mask m...
Definition Fl_Text_Display.H:145
Fl_Color color
text color
Definition Fl_Text_Display.H:146
Fl_Fontsize size
text font size
Definition Fl_Text_Display.H:148
Fl_Font font
text font
Definition Fl_Text_Display.H:147
unsigned attr
further attributes for the text style (see ATTR_BGCOLOR, etc.)
Definition Fl_Text_Display.H:149
Fl_Color bgcolor
text background color if ATTR_BGCOLOR or ATTR_BGCOLOR_EXT is set
Definition Fl_Text_Display.H:150