fltk::TextDisplay Class Reference

Inherits fltk::Group.

Inherited by fltk::TextEditor.

List of all members.

Public Types

enum  {
  NORMAL_CURSOR, CARET_CURSOR, DIM_CURSOR, BLOCK_CURSOR,
  HEAVY_CURSOR
}
enum  { CURSOR_POS, CHARACTER_POS }
enum  { DRAG_CHAR, DRAG_WORD, DRAG_LINE }
enum  { ATTR_NONE, ATTR_UNDERLINE, ATTR_HIDDEN }

Public Member Functions

void append (const char *text)
char at (int i) const
const TextBufferbuffer () const
TextBufferbuffer ()
void buffer (TextBuffer &buf)
void buffer (TextBuffer *buf)
void cursor_color (Color n)
Color cursor_color () const
bool cursor_on () const
void cursor_style (int style)
virtual void draw ()
int find_next_char (int pos)
int find_prev_char (int pos)
virtual int handle (int e)
void hide_cursor ()
void highlight_data (TextBuffer *styleBuffer, StyleTableEntry *styleTable, int nStyles, char unfinishedStyle, UnfinishedStyleCb unfinishedHighlightCB, void *cbArg)
int hor_offset () const
bool in_selection (int x, int y)
void insert (const char *text)
int insert_position () const
void insert_position (int newPos)
virtual void layout ()
int line_end (int pos, bool start_pos_is_line_start=false)
int line_start (int pos)
int linenumber_width () const
void linenumber_width (int width)
bool move_down ()
bool move_left ()
bool move_right ()
bool move_up ()
void next_word (void)
void overstrike (const char *text)
bool position_to_xy (int pos, int *X, int *Y)
void previous_word (void)
void redisplay_range (int start, int end)
void scroll (int topLineNum, int horizOffset)
void show_cursor (bool b=true)
void show_insert_position ()
int size () const
void static_text (const char *v)
void text (const char *v)
const char * text () const
 TextDisplay (int X, int Y, int W, int H, const char *l=0)
int top_line () const
int total_lines ()
int visible_lines () const
int word_end (int pos)
int word_start (int pos)
void wrap_mode (bool wrap, int wrap_margin=0)
int xy_to_position (int X, int Y, int PosType=CHARACTER_POS)
void xy_to_rowcol (int X, int Y, int *row, int *column, int PosType=CHARACTER_POS)

Protected Member Functions

void absolute_top_line_number (int oldFirstChar)
void blank_cursor_protrusions ()
void calc_last_char ()
void calc_line_starts (int startLine, int endLine)
void clear_rect (int style, int x, int y, int width, int height)
int count_lines (int start, int end, bool start_pos_is_line_start)
void display_insert ()
void draw_cursor (int, int)
void draw_line_numbers (bool clearAll)
void draw_range (int start, int end)
void draw_string (int style, int x, int y, int toX, const char *string, int nChars)
void draw_text (int X, int Y, int W, int H)
void draw_vline (int visLineNum, int leftClip, int rightClip, int leftCharIndex, int rightCharIndex)
int empty_vlines ()
void extend_range_for_styles (int *start, int *end)
void find_line_end (int pos, bool start_pos_is_line_start, int *lineEnd, int *nextLineStart)
void find_wrap_range (const char *deletedText, int pos, int nInserted, int nDeleted, int *modRangeStart, int *modRangeEnd, int *linesInserted, int *linesDeleted)
int get_absolute_top_line_number ()
int longest_vline ()
void maintain_absolute_top_line_number (bool state)
int maintaining_absolute_top_line_number ()
void measure_deleted_lines (int pos, int nDeleted)
int measure_proportional_character (TextBuffer *buf, int bufpos, int colNum, int pos)
int measure_vline (int visLineNum)
void offset_line_starts (int newTopLineNum)
int position_style (int lineStartPos, int lineLen, int lineIndex, int dispIndex)
bool position_to_line (int pos, int *lineNum)
bool position_to_linecol (int pos, int *lineNum, int *column)
int range_touches_selection (TextSelection *sel, int rangeStart, int rangeEnd)
void reset_absolute_top_line_number ()
int rewind_lines (int startPos, int nLines)
void scroll_ (int topLineNum, int horizOffset)
int skip_lines (int startPos, int nLines, bool startPosIsLineStart)
int string_width (const char *string, int length, int style)
void text_drag_me (int pos)
void update_h_scrollbar (int longestvline=0)
void update_line_starts (int pos, int charsInserted, int charsDeleted, int linesInserted, int linesDeleted, bool *scrolled)
void update_v_scrollbar ()
int vline_length (int visLineNum)
int wrap_uses_character (int lineEndPos)
int wrapped_column (int row, int column)
void wrapped_line_counter (TextBuffer *buf, int startPos, int maxPos, int maxLines, bool startPosIsLineStart, int styleBufOffset, int *retPos, int *retLines, int *retLineStart, int *retLineEnd, bool countLastLineMissingNewLine=true)
int wrapped_row (int row)

Static Protected Member Functions

static void buffer_modified_cb (int pos, int nInserted, int nDeleted, int nRestyled, const char *deletedText, void *cbArg)
static void buffer_predelete_cb (int pos, int nDeleted, void *cbArg)
static void h_scrollbar_cb (Scrollbar *w, TextDisplay *d)
static void v_scrollbar_cb (Scrollbar *w, TextDisplay *d)

Protected Attributes

int abs_topline_num_
int ascent_
TextBufferbuffer_
int bufferlines_cnt_
bool continuous_wrap_
Color cursor_color_
int cursor_hint_
int cursor_oldx_
int cursor_oldy_
bool cursor_on_
int cursor_pos_
int cursor_preferred_col_
int cursor_style_
int damage_range1_end
int damage_range1_start
int damage_range2_end
int damage_range2_start
int descent_
int dragging_
int dragpos_
int dragtype_
int firstchar_
int fixed_fontwidth_
void * highlight_cbarg_
int horiz_offset_
Scrollbarhscrollbar
int lastchar_
int linenumleft_
int linenumwidth_
int * linestarts_
int maxsize_
bool need_abs_topline_num_
int nlinesdeleted_
int numstyles_
bool own_buffer
int stdfontwidth_
TextBufferstylebuffer_
const StyleTableEntry * styletable_
bool suppressresync_
Rectangle text_area
int topline_num_
UnfinishedStyleCb unfinished_highlight_cb_
char unfinished_style_
int visiblelines_cnt_
Scrollbarvscrollbar
int wrapmargin_


Detailed Description

TextDisplay

Member Function Documentation

void TextDisplay::buffer ( TextBuffer buf  ) 

void fltk::TextDisplay::buffer ( TextBuffer buf  )  [inline]

Associate 'buf' with display

References buffer().

Referenced by buffer().

TextBuffer* fltk::TextDisplay::buffer (  )  [inline]

const TextBuffer* fltk::TextDisplay::buffer (  )  const [inline]

Return attached buffer

void fltk::TextDisplay::append ( const char *  text  )  [inline]

Append text to the end of the buffer

void TextDisplay::insert ( const char *  text  ) 

Insert text to current cursor position

References fltk::TextBuffer::insert().

void TextDisplay::overstrike ( const char *  text  ) 

void TextDisplay::insert_position ( int  newPos  ) 

Set new cursor position

References fltk::TextBuffer::length(), and redisplay_range().

int fltk::TextDisplay::insert_position (  )  const [inline]

Return current cursor position

Referenced by move_down(), move_left(), move_right(), move_up(), next_word(), and previous_word().

void TextDisplay::show_insert_position (  ) 

Make cursor position visible in screen

void TextDisplay::show_cursor ( bool  b = true  ) 

Show cursor

References redisplay_range().

Referenced by cursor_style().

void fltk::TextDisplay::hide_cursor (  )  [inline]

Hide cursor

bool fltk::TextDisplay::cursor_on (  )  const [inline]

Return cursor visibility state

void TextDisplay::cursor_style ( int  style  ) 

Set cursor style

References show_cursor().

Color fltk::TextDisplay::cursor_color (  )  const [inline]

Return cursor color

void fltk::TextDisplay::cursor_color ( Color  n  )  [inline]

Set cursor color

int fltk::TextDisplay::word_start ( int  pos  )  [inline]

Return begining of the word where 'pos' is located

int fltk::TextDisplay::word_end ( int  pos  )  [inline]

Return end of the word where 'pos' is located

void TextDisplay::next_word ( void   ) 

void TextDisplay::previous_word ( void   ) 

void TextDisplay::wrap_mode ( bool  wrap,
int  wrap_margin = 0 
)

Set wrapping mode. wrap_margin is width to wrap at, zero means use w()

References buffer(), line_start(), fltk::Widget::redraw(), and fltk::Widget::relayout().

void TextDisplay::linenumber_width ( int  width  ) 

Set line number area width

References fltk::Widget::redraw(), and fltk::Widget::relayout().

int fltk::TextDisplay::linenumber_width (  )  const [inline]

Return line number area width

void TextDisplay::highlight_data ( TextBuffer styleBuffer,
StyleTableEntry *  styleTable,
int  nStyles,
char  unfinishedStyle,
UnfinishedStyleCb  unfinishedHighlightCB,
void *  cbArg 
)

bool TextDisplay::move_right (  ) 

Move cursor right

References find_next_char(), insert_position(), and fltk::TextBuffer::length().

bool TextDisplay::move_left (  ) 

Move cursor left

References find_prev_char(), and insert_position().

bool TextDisplay::move_up (  ) 

bool TextDisplay::move_down (  ) 

void TextDisplay::redisplay_range ( int  start,
int  end 
)

void TextDisplay::scroll ( int  topLineNum,
int  horizOffset 
)

Scroll to new position

bool TextDisplay::in_selection ( int  x,
int  y 
)

Returns true if position is inside selection

References fltk::TextBuffer::line_start(), fltk::TextBuffer::primary_selection(), xy_to_position(), and xy_to_rowcol().

int TextDisplay::line_start ( int  pos  ) 

Returns begining of the line where 'pos' is located

References buffer(), and fltk::TextBuffer::line_start().

Referenced by move_down(), and wrap_mode().

int TextDisplay::line_end ( int  pos,
bool  start_pos_is_line_start = false 
)

Returns end of the line where 'pos' is located

References buffer(), and fltk::TextBuffer::line_end().

Referenced by move_down(), and move_up().

int fltk::TextDisplay::visible_lines (  )  const [inline]

Return number of visible lines

int fltk::TextDisplay::top_line (  )  const [inline]

Return current visible topline

int fltk::TextDisplay::hor_offset (  )  const [inline]

Return current horizontal offset

int TextDisplay::find_next_char ( int  pos  ) 

Find start of the next character, starting from 'pos' If 'pos' points to start of character already, it is returned. This is mainly used with UTF-8 strings

References buffer(), and fltk::TextBuffer::character().

Referenced by move_down(), move_right(), next_word(), overstrike(), previous_word(), and redisplay_range().

int TextDisplay::find_prev_char ( int  pos  ) 

Find start of the previous character, starting from 'pos' If 'pos' points to start of character already, it is returned. This is mainly used with UTF-8 strings

References buffer(), and fltk::TextBuffer::character().

Referenced by move_left(), move_up(), previous_word(), and redisplay_range().

int TextDisplay::xy_to_position ( int  X,
int  Y,
int  posType = CHARACTER_POS 
)

Translate window coordinates to the nearest (insert cursor or character cell) text position. The parameter posType specifies how to interpret the position: CURSOR_POS means translate the coordinates to the nearest cursor position, and CHARACTER_POS means return the position of the character closest to (X, Y).

References fltk::TextBuffer::expand_character(), fltk::TextBuffer::length(), fltk::TextBuffer::null_substitution_character(), fltk::TextBuffer::tab_distance(), fltk::TextBuffer::text_range(), fltk::Rectangle::x(), and fltk::Rectangle::y().

Referenced by in_selection().

void TextDisplay::xy_to_rowcol ( int  X,
int  Y,
int *  row,
int *  column,
int  posType = CHARACTER_POS 
)

Translate window coordinates to the nearest row and column number for positioning the cursor. This, of course, makes no sense when the font is proportional, since there are no absolute columns. The parameter posType specifies how to interpret the position: CURSOR_POS means translate the coordinates to the nearest position between characters, and CHARACTER_POS means translate the position to the nearest character cell.

References fltk::Rectangle::x(), and fltk::Rectangle::y().

Referenced by in_selection().

bool TextDisplay::position_to_xy ( int  pos,
int *  X,
int *  Y 
)

Translate a buffer text position to the XY location where the top left of the cursor would be positioned to point to that character. Returns 0 if the position is not displayed because it is VERTICALLY out of view. If the position is horizontally out of view, returns the X coordinate where the position would be if it were visible.

References fltk::TextBuffer::expand_character(), fltk::TextBuffer::null_substitution_character(), fltk::TextBuffer::tab_distance(), fltk::TextBuffer::text_range(), fltk::Rectangle::x(), and fltk::Rectangle::y().


Wed Jun 17 08:45:39 2009. FLTK ©2007 Bill Spitzak and others.
Permission is granted to reproduce this manual or any portion for any purpose, provided this copyright and permission notice are preserved.