TextDisplay Class Reference

Inherits Group.

Inherited by 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

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

Protected Member Functions

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

Static Protected Member Functions

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

Protected Attributes

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


Detailed Description

TextDisplay


Member Function Documentation

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

Append text to the end of the buffer

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

Return attached buffer

TextBuffer* TextDisplay::buffer  )  [inline]
 

Return attached buffer

void TextDisplay::buffer TextBuffer buf  )  [inline]
 

Associate 'buf' with display

void TextDisplay::buffer TextBuffer buf  ) 
 

Associate 'buf' with display

void TextDisplay::cursor_color Color  n  )  [inline]
 

Set cursor color

Color TextDisplay::cursor_color  )  const [inline]
 

Return cursor color

bool TextDisplay::cursor_on  )  const [inline]
 

Return cursor visibility state

void TextDisplay::cursor_style int  style  ) 
 

Set cursor style

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

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

void TextDisplay::hide_cursor  )  [inline]
 

Hide cursor

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

Set new highlight data

int TextDisplay::hor_offset  )  const [inline]
 

Return current horizontal offset

bool TextDisplay::in_selection int  x,
int  y
 

Returns true if position is inside selection

void TextDisplay::insert const char *  text  ) 
 

Insert text to current cursor position

int TextDisplay::insert_position  )  const [inline]
 

Return current cursor position

void TextDisplay::insert_position int  newPos  ) 
 

Set new cursor position

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

Returns end of the line where 'pos' is located

int TextDisplay::line_start int  pos  ) 
 

Returns begining of the line where 'pos' is located

int TextDisplay::linenumber_width  )  const [inline]
 

Return line number area width

void TextDisplay::linenumber_width int  width  ) 
 

Set line number area width

bool TextDisplay::move_down  ) 
 

Move cursor down

bool TextDisplay::move_left  ) 
 

Move cursor left

bool TextDisplay::move_right  ) 
 

Move cursor right

bool TextDisplay::move_up  ) 
 

Move cursor down

void TextDisplay::next_word void   ) 
 

Go to next word

void TextDisplay::overstrike const char *  text  ) 
 

Overstrike text from current cursor position

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.

void TextDisplay::previous_word void   ) 
 

Go to previous word

void TextDisplay::redisplay_range int  start,
int  end
 

Redisplay text

void TextDisplay::scroll int  topLineNum,
int  horizOffset
 

Scroll to new position

void TextDisplay::show_cursor bool  b = true  ) 
 

Show cursor

void TextDisplay::show_insert_position  ) 
 

Make cursor position visible in screen

int TextDisplay::top_line  )  const [inline]
 

Return current visible topline

int TextDisplay::visible_lines  )  const [inline]
 

Return number of visible lines

int TextDisplay::word_end int  pos  )  [inline]
 

Return end of the word where 'pos' is located

int TextDisplay::word_start int  pos  )  [inline]
 

Return begining of the word where 'pos' is located

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

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

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

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.


The documentation for this class was generated from the following files:
Sun Jan 7 00:55:18 2007. FLTK ©2006 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.