@ -25,6 +25,8 @@
@@ -25,6 +25,8 @@
// http://www.fltk.org/str.php
//
// TODO: check all functions for UTF-8/UCS-4 compatibility!
# include <stdio.h>
# include <stdlib.h>
# include <FL/fl_utf8.h>
@ -79,7 +81,7 @@ static int scroll_x = 0;
@@ -79,7 +81,7 @@ static int scroll_x = 0;
/** Creates a new text display widget.*/
Fl_Text_Display : : Fl_Text_Display ( int X , int Y , int W , int H , const char * l )
: Fl_Group ( X , Y , W , H , l ) {
: Fl_Group ( X , Y , W , H , l ) {
int i ;
mMaxsize = 0 ;
@ -156,7 +158,7 @@ Fl_Text_Display::Fl_Text_Display(int X, int Y, int W, int H, const char* l)
@@ -156,7 +158,7 @@ Fl_Text_Display::Fl_Text_Display(int X, int Y, int W, int H, const char* l)
Note , the text BUFFER that the text display displays is a separate
entity and is not freed , nor are the style buffer or style table .
*/
*/
Fl_Text_Display : : ~ Fl_Text_Display ( ) {
if ( scroll_direction ) {
Fl : : remove_timeout ( scroll_timer_cb , this ) ;
@ -169,9 +171,11 @@ Fl_Text_Display::~Fl_Text_Display() {
@@ -169,9 +171,11 @@ Fl_Text_Display::~Fl_Text_Display() {
if ( mLineStarts ) delete [ ] mLineStarts ;
}
/**
Attach a text buffer to display , replacing the current buffer ( if any )
*/
\ param buf attach this text buffer
*/
void Fl_Text_Display : : buffer ( Fl_Text_Buffer * buf ) {
/* If the text display is already displaying a buffer, clear it off
of the display and remove our callback from it */
@ -212,7 +216,7 @@ void Fl_Text_Display::buffer( Fl_Text_Buffer *buf ) {
@@ -212,7 +216,7 @@ void Fl_Text_Display::buffer( Fl_Text_Buffer *buf ) {
Style buffers , tables and their associated memory are managed by the caller .
Styles are ranged from 65 ( ' A ' ) to 126.
*/
*/
void Fl_Text_Display : : highlight_data ( Fl_Text_Buffer * styleBuffer ,
const Style_Table_Entry * styleTable ,
int nStyles , char unfinishedStyle ,
@ -238,7 +242,7 @@ int Fl_Text_Display::longest_vline() const {
@@ -238,7 +242,7 @@ int Fl_Text_Display::longest_vline() const {
/**
Change the size of the displayed text area
*/
*/
void Fl_Text_Display : : resize ( int X , int Y , int W , int H ) {
# ifdef DEBUG
printf ( " Fl_Text_Display::resize(X=%d, Y=%d, W=%d, H=%d) \n " , X , Y , W , H ) ;
@ -403,7 +407,7 @@ void Fl_Text_Display::resize(int X, int Y, int W, int H) {
@@ -403,7 +407,7 @@ void Fl_Text_Display::resize(int X, int Y, int W, int H) {
/**
Refresh a rectangle of the text display . left and top are in coordinates of
the text drawing window
*/
*/
void Fl_Text_Display : : draw_text ( int left , int top , int width , int height ) {
int fontHeight , firstLine , lastLine , line ;
@ -468,7 +472,7 @@ void Fl_Text_Display::redisplay_range(int startpos, int endpos) {
@@ -468,7 +472,7 @@ void Fl_Text_Display::redisplay_range(int startpos, int endpos) {
If end points beyond the end of the buffer , refresh the whole display
after pos , including blank lines which are not technically part of
any range of characters .
*/
*/
void Fl_Text_Display : : draw_range ( int startpos , int endpos ) {
int i , startLine , lastLine , startIndex , endIndex ;
@ -559,7 +563,7 @@ void Fl_Text_Display::show_cursor(int b) {
@@ -559,7 +563,7 @@ void Fl_Text_Display::show_cursor(int b) {
\ li Fl_Text_Display : : BLOCK_CURSOR - Shows an unfilled box around the current
character .
\ li Fl_Text_Display : : HEAVY_CURSOR - Shows a thick I beam .
*/
*/
void Fl_Text_Display : : cursor_style ( int style ) {
mCursorStyle = style ;
if ( mCursorOn ) show_cursor ( ) ;
@ -568,7 +572,7 @@ void Fl_Text_Display::cursor_style(int style) {
@@ -568,7 +572,7 @@ void Fl_Text_Display::cursor_style(int style) {
/**
If < i > mode < / i > is not zero , this call enables automatic word wrapping at column < i > pos < / i > .
Word - wrapping does not change the text buffer itself , only the way that the text is displayed .
*/
*/
void Fl_Text_Display : : wrap_mode ( int wrap , int wrapMargin ) {
mWrapMargin = wrapMargin ;
mContinuousWrap = wrap ;
@ -604,7 +608,7 @@ void Fl_Text_Display::wrap_mode(int wrap, int wrapMargin) {
@@ -604,7 +608,7 @@ void Fl_Text_Display::wrap_mode(int wrap, int wrapMargin) {
effect as inserting the text into the buffer using BufInsert and
then moving the insert position after the newly inserted text , except
that it ' s optimized to do less redrawing .
*/
*/
void Fl_Text_Display : : insert ( const char * text ) {
int pos = mCursorPos ;
@ -671,7 +675,7 @@ void Fl_Text_Display::overstrike(const char* text) {
@@ -671,7 +675,7 @@ void Fl_Text_Display::overstrike(const char* text) {
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 .
*/
*/
int Fl_Text_Display : : position_to_xy ( int pos , int * X , int * Y ) const {
int lineStartPos , fontHeight , lineLen ;
@ -713,7 +717,7 @@ int Fl_Text_Display::position_to_xy( int pos, int* X, int* Y ) const {
@@ -713,7 +717,7 @@ int Fl_Text_Display::position_to_xy( int pos, int* X, int* Y ) const {
calculation involving scanning large amounts of text in the buffer ) .
If continuous wrap mode is on , returns the absolute line number ( as opposed
to the wrapped line number which is used for scrolling ) .
*/
*/
int Fl_Text_Display : : position_to_linecol ( int pos , int * lineNum , int * column ) const {
int retVal ;
@ -725,15 +729,13 @@ int Fl_Text_Display::position_to_linecol( int pos, int* lineNum, int* column ) c
@@ -725,15 +729,13 @@ int Fl_Text_Display::position_to_linecol( int pos, int* lineNum, int* column ) c
pos < mFirstChar | | pos > mLastChar )
return 0 ;
* lineNum = mAbsTopLineNum + buffer ( ) - > count_lines ( mFirstChar , pos ) ;
* column
= buffer ( ) - > count_displayed_characters ( buffer ( ) - > line_start ( pos ) , pos ) ;
* column = buffer ( ) - > count_displayed_characters ( buffer ( ) - > line_start ( pos ) , pos ) ;
return 1 ;
}
retVal = position_to_line ( pos , lineNum ) ;
if ( retVal ) {
* column = mBuffer - > count_displayed_characters (
mLineStarts [ * lineNum ] , pos ) ;
* column = mBuffer - > count_displayed_characters ( mLineStarts [ * lineNum ] , pos ) ;
* lineNum + = mTopLineNum ;
}
return retVal ;
@ -741,12 +743,12 @@ int Fl_Text_Display::position_to_linecol( int pos, int* lineNum, int* column ) c
@@ -741,12 +743,12 @@ int Fl_Text_Display::position_to_linecol( int pos, int* lineNum, int* column ) c
/**
Return 1 if position ( X , Y ) is inside of the primary Fl_Text_Selection
*/
*/
int Fl_Text_Display : : in_selection ( int X , int Y ) const {
int pos = xy_to_position ( X , Y , CHARACTER_POS ) ;
Fl_Text_Buffer * buf = mBuffer ;
return buf - > primary_selection ( ) - > includes ( pos ) ;
}
}
/**
Correct a column number based on an unconstrained position ( as returned by
@ -757,7 +759,7 @@ int Fl_Text_Display::in_selection( int X, int Y ) const {
@@ -757,7 +759,7 @@ int Fl_Text_Display::in_selection( int X, int Y ) const {
which thinks that the unconstrained column is the number of characters
from the last newline . Obviously this is time consuming , because it
invloves character re - counting .
*/
*/
int Fl_Text_Display : : wrapped_column ( int row , int column ) const {
int lineStart , dispLineStart ;
@ -777,7 +779,7 @@ int Fl_Text_Display::wrapped_column(int row, int column) const {
@@ -777,7 +779,7 @@ int Fl_Text_Display::wrapped_column(int row, int column) const {
top line of the display . Because rectangular selections are based on
newlines , rather than display wrapping , and anywhere a rectangular selection
needs a row , it needs it in terms of un - wrapped lines .
*/
*/
int Fl_Text_Display : : wrapped_row ( int row ) const {
if ( ! mContinuousWrap | | row < 0 | | row > mNVisibleLines )
return row ;
@ -786,19 +788,19 @@ int Fl_Text_Display::wrapped_row(int row) const{
@@ -786,19 +788,19 @@ int Fl_Text_Display::wrapped_row(int row) const{
/**
Scroll the display to bring insertion cursor into view .
* *
* *
Note : it would be nice to be able to do this without counting lines twice
( scroll_ ( ) counts them too ) and / or to count from the most efficient
starting point , but the efficiency of this routine is not as important to
the overall performance of the text display .
*/
*/
void Fl_Text_Display : : display_insert ( ) {
int hOffset , topLine , X , Y ;
hOffset = mHorizOffset ;
topLine = mTopLineNum ;
// FIXME: I don't understand this well enough to know if it is correct
// it is different than nedit 5.3
// FIXME: I don't understand this well enough to know if it is correct
// it is different than nedit 5.3
if ( insert_position ( ) < mFirstChar ) {
topLine - = count_lines ( insert_position ( ) , mFirstChar , false ) ;
} else if ( mLineStarts [ mNVisibleLines - 2 ] ! = - 1 ) {
@ -816,9 +818,9 @@ void Fl_Text_Display::display_insert() {
@@ -816,9 +818,9 @@ void Fl_Text_Display::display_insert() {
if ( ! position_to_xy ( mCursorPos , & X , & Y ) ) {
scroll_ ( topLine , hOffset ) ;
if ( ! position_to_xy ( mCursorPos , & X , & Y ) ) {
# ifdef DEBUG
# ifdef DEBUG
printf ( " *** display_insert/position_to_xy # GIVE UP ! \n " ) ; fflush ( stdout ) ;
# endif // DEBUG
# endif // DEBUG
return ; /* Give up, it's not worth it (but why does it fail?) */
}
}
@ -840,7 +842,7 @@ void Fl_Text_Display::show_insert_position() {
@@ -840,7 +842,7 @@ void Fl_Text_Display::show_insert_position() {
/*
Cursor movement functions
*/
*/
/**
Moves the current insert position right one character .
@ -956,7 +958,7 @@ int Fl_Text_Display::move_down() {
@@ -956,7 +958,7 @@ int Fl_Text_Display::move_down() {
turned on . If the caller knows that startPos is at a line start , it
can pass " startPosIsLineStart " as True to make the call more efficient
by avoiding the additional step of scanning back to the last newline .
*/
*/
int Fl_Text_Display : : count_lines ( int startPos , int endPos ,
bool startPosIsLineStart ) const {
int retLines , retPos , retLineStart , retLineEnd ;
@ -987,7 +989,7 @@ int Fl_Text_Display::count_lines(int startPos, int endPos,
@@ -987,7 +989,7 @@ int Fl_Text_Display::count_lines(int startPos, int endPos,
wrapping is turned on . If the caller knows that startPos is at a line start ,
it can pass " startPosIsLineStart " as True to make the call more efficient
by avoiding the additional step of scanning back to the last newline .
*/
*/
int Fl_Text_Display : : skip_lines ( int startPos , int nLines ,
bool startPosIsLineStart ) {
int retLines , retPos , retLineStart , retLineEnd ;
@ -1012,7 +1014,7 @@ int Fl_Text_Display::skip_lines(int startPos, int nLines,
@@ -1012,7 +1014,7 @@ int Fl_Text_Display::skip_lines(int startPos, int nLines,
is turned on . If the caller knows that startPos is at a line start , it
can pass " startPosIsLineStart " as True to make the call more efficient
by avoiding the additional step of scanning back to the last newline .
* *
* *
Note that the definition of the end of a line is less clear when continuous
wrap is on . With continuous wrap off , it ' s just a pointer to the newline
that ends the line . When it ' s on , it ' s the character beyond the last
@ -1022,7 +1024,7 @@ int Fl_Text_Display::skip_lines(int startPos, int nLines,
@@ -1022,7 +1024,7 @@ int Fl_Text_Display::skip_lines(int startPos, int nLines,
line had no whitespace . In this case , this routine returns a pointer to
the start of the next line . This is also consistent with the model used by
visLineLength .
*/
*/
int Fl_Text_Display : : line_end ( int pos , bool startPosIsLineStart ) const {
int retLines , retPos , retLineStart , retLineEnd ;
@ -1041,7 +1043,7 @@ int Fl_Text_Display::line_end(int pos, bool startPosIsLineStart) const {
@@ -1041,7 +1043,7 @@ int Fl_Text_Display::line_end(int pos, bool startPosIsLineStart) const {
/**
Same as BufStartOfLine , but returns the character after last wrap point
rather than the last newline .
*/
*/
int Fl_Text_Display : : line_start ( int pos ) const {
int retLines , retPos , retLineStart , retLineEnd ;
@ -1057,7 +1059,7 @@ int Fl_Text_Display::line_start(int pos) const {
@@ -1057,7 +1059,7 @@ int Fl_Text_Display::line_start(int pos) const {
/**
Same as BufCountBackwardNLines , but takes in to account line breaks when
wrapping is turned on .
*/
*/
int Fl_Text_Display : : rewind_lines ( int startPos , int nLines ) {
Fl_Text_Buffer * buf = buffer ( ) ;
int pos , lineStart , retLines , retPos , retLineStart , retLineEnd ;
@ -1123,7 +1125,7 @@ void Fl_Text_Display::previous_word() {
@@ -1123,7 +1125,7 @@ void Fl_Text_Display::previous_word() {
/**
Callback attached to the text buffer to receive delete information before
the modifications are actually made .
*/
*/
void Fl_Text_Display : : buffer_predelete_cb ( int pos , int nDeleted , void * cbArg ) {
Fl_Text_Display * textD = ( Fl_Text_Display * ) cbArg ;
if ( textD - > mContinuousWrap )
@ -1142,7 +1144,7 @@ void Fl_Text_Display::buffer_predelete_cb(int pos, int nDeleted, void *cbArg) {
@@ -1142,7 +1144,7 @@ void Fl_Text_Display::buffer_predelete_cb(int pos, int nDeleted, void *cbArg) {
/**
Callback attached to the text buffer to receive modification information
*/
*/
void Fl_Text_Display : : buffer_modified_cb ( int pos , int nInserted , int nDeleted ,
int nRestyled , const char * deletedText , void * cbArg ) {
int linesInserted , linesDeleted , startDispPos , endDispPos ;
@ -1269,7 +1271,7 @@ void Fl_Text_Display::buffer_modified_cb( int pos, int nInserted, int nDeleted,
@@ -1269,7 +1271,7 @@ void Fl_Text_Display::buffer_modified_cb( int pos, int nInserted, int nDeleted,
want this line count maintained ( for use via TextDPosToLineAndCol ) .
More specifically , this allows the line number reported in the statistics
line to be calibrated in absolute lines , rather than post - wrapped lines .
*/
*/
void Fl_Text_Display : : maintain_absolute_top_line_number ( int state ) {
mNeedAbsTopLineNum = state ;
reset_absolute_top_line_number ( ) ;
@ -1278,7 +1280,7 @@ void Fl_Text_Display::maintain_absolute_top_line_number(int state) {
@@ -1278,7 +1280,7 @@ void Fl_Text_Display::maintain_absolute_top_line_number(int state) {
/**
Returns the absolute ( non - wrapped ) line number of the first line displayed .
Returns 0 if the absolute top line number is not being maintained .
*/
*/
int Fl_Text_Display : : get_absolute_top_line_number ( ) const {
if ( ! mContinuousWrap )
return mTopLineNum ;
@ -1289,7 +1291,7 @@ int Fl_Text_Display::get_absolute_top_line_number() const {
@@ -1289,7 +1291,7 @@ int Fl_Text_Display::get_absolute_top_line_number() const {
/**
Re - calculate absolute top line number for a change in scroll position .
*/
*/
void Fl_Text_Display : : absolute_top_line_number ( int oldFirstChar ) {
if ( maintaining_absolute_top_line_number ( ) ) {
if ( mFirstChar < oldFirstChar )
@ -1302,7 +1304,7 @@ void Fl_Text_Display::absolute_top_line_number(int oldFirstChar) {
@@ -1302,7 +1304,7 @@ void Fl_Text_Display::absolute_top_line_number(int oldFirstChar) {
/**
Return true if a separate absolute top line number is being maintained
( for displaying line numbers or showing in the statistics line ) .
*/
*/
int Fl_Text_Display : : maintaining_absolute_top_line_number ( ) const {
return mContinuousWrap & &
( mLineNumWidth ! = 0 | | mNeedAbsTopLineNum ) ;
@ -1312,7 +1314,7 @@ int Fl_Text_Display::maintaining_absolute_top_line_number() const {
@@ -1312,7 +1314,7 @@ int Fl_Text_Display::maintaining_absolute_top_line_number() const {
Count lines from the beginning of the buffer to reestablish the
absolute ( non - wrapped ) top line number . If mode is not continuous wrap ,
or the number is not being maintained , does nothing .
*/
*/
void Fl_Text_Display : : reset_absolute_top_line_number ( ) {
mAbsTopLineNum = 1 ;
absolute_top_line_number ( 0 ) ;
@ -1321,7 +1323,7 @@ void Fl_Text_Display::reset_absolute_top_line_number() {
@@ -1321,7 +1323,7 @@ void Fl_Text_Display::reset_absolute_top_line_number() {
/**
Find the line number of position " pos " relative to the first line of
displayed text . Returns 0 if the line is not displayed .
*/
*/
int Fl_Text_Display : : position_to_line ( int pos , int * lineNum ) const {
int i ;
@ -1431,6 +1433,10 @@ int Fl_Text_Display::handle_vline(
@@ -1431,6 +1433,10 @@ int Fl_Text_Display::handle_vline(
startX + = w ;
startIndex = i ;
}
if ( len = = - 1 ) {
// FIXME: what happened? Is there an illegal charater, or an illegal index?
len = 1 ;
}
i + = len ;
}
int w = string_width ( lineStr + startIndex , i - startIndex , style ) ;
@ -1477,15 +1483,15 @@ int Fl_Text_Display::find_x(const char *s, int len, int style, int x) const {
@@ -1477,15 +1483,15 @@ int Fl_Text_Display::find_x(const char *s, int len, int style, int x) const {
" leftClip " and " rightClip " window coordinates and " leftCharIndex " and
" rightCharIndex " character positions ( not including the character at
position " rightCharIndex " ) .
*/
*/
void Fl_Text_Display : : draw_vline ( int visLineNum , int leftClip , int rightClip ,
int leftCharIndex , int rightCharIndex ) {
int Y , lineStartPos , lineLen , fontHeight ;
int stdCharWidth ;
// printf("draw_vline(visLineNum=%d, leftClip=%d, rightClip=%d, leftCharIndex=%d, rightCharIndex=%d)\n",
// visLineNum, leftClip, rightClip, leftCharIndex, rightCharIndex);
// printf("nNVisibleLines=%d\n", mNVisibleLines);
// printf("draw_vline(visLineNum=%d, leftClip=%d, rightClip=%d, leftCharIndex=%d, rightCharIndex=%d)\n",
// visLineNum, leftClip, rightClip, leftCharIndex, rightCharIndex);
// printf("nNVisibleLines=%d\n", mNVisibleLines);
/* If line is not displayed, skip it */
if ( visLineNum < 0 | | visLineNum > = mNVisibleLines )
@ -1497,7 +1503,7 @@ void Fl_Text_Display::draw_vline(int visLineNum, int leftClip, int rightClip,
@@ -1497,7 +1503,7 @@ void Fl_Text_Display::draw_vline(int visLineNum, int leftClip, int rightClip,
/* Get the text, length, and buffer position of the line to display */
lineStartPos = mLineStarts [ visLineNum ] ;
// printf("lineStartPos=%d\n", lineStartPos);
// printf("lineStartPos=%d\n", lineStartPos);
if ( lineStartPos = = - 1 ) {
lineLen = 0 ;
} else {
@ -1523,7 +1529,7 @@ void Fl_Text_Display::draw_vline(int visLineNum, int leftClip, int rightClip,
@@ -1523,7 +1529,7 @@ void Fl_Text_Display::draw_vline(int visLineNum, int leftClip, int rightClip,
lineStartPos , lineLen , leftCharIndex , rightCharIndex ,
Y , Y + fontHeight , leftClip , rightClip ) ;
return ;
}
}
/**
Draw a string or blank area according to parameter " style " , using the
@ -1532,7 +1538,7 @@ void Fl_Text_Display::draw_vline(int visLineNum, int leftClip, int rightClip,
@@ -1532,7 +1538,7 @@ void Fl_Text_Display::draw_vline(int visLineNum, int leftClip, int rightClip,
characters , and draw " nChars " , if style is FILL , erase
rectangle where text would have drawn from X to toX and from Y to
the maximum Y extent of the current font ( s ) .
*/
*/
void Fl_Text_Display : : draw_string ( int style ,
int X , int Y , int toX ,
const char * string , int nChars ) const {
@ -1617,7 +1623,7 @@ void Fl_Text_Display::draw_string(int style,
@@ -1617,7 +1623,7 @@ void Fl_Text_Display::draw_string(int style,
/**
Clear a rectangle with the appropriate background color for " style "
*/
*/
void Fl_Text_Display : : clear_rect ( int style ,
int X , int Y ,
int width , int height ) const {
@ -1646,7 +1652,7 @@ void Fl_Text_Display::clear_rect(int style,
@@ -1646,7 +1652,7 @@ void Fl_Text_Display::clear_rect(int style,
/**
Draw a cursor with top center at X , y .
*/
*/
void Fl_Text_Display : : draw_cursor ( int X , int Y ) {
typedef struct {
int x1 , y1 , x2 , y2 ;
@ -1718,16 +1724,16 @@ void Fl_Text_Display::draw_cursor( int X, int Y ) {
@@ -1718,16 +1724,16 @@ void Fl_Text_Display::draw_cursor( int X, int Y ) {
the number of characters past the beginning of the line , and " dispIndex " ,
the number of displayed characters past the beginning of the line . Passing
lineStartPos of - 1 returns the drawing style for " no text " .
* *
* *
Why not just : position_style ( pos ) ? Because style applies to blank areas
of the window beyond the text boundaries , and because this routine must also
decide whether a position is inside of a rectangular Fl_Text_Selection , and do
so efficiently , without re - counting character positions from the start of the
line .
* *
* *
Note that style is a somewhat incorrect name , drawing method would
be more appropriate .
*/
*/
int Fl_Text_Display : : position_style ( int lineStartPos , int lineLen , int lineIndex ) const
{
Fl_Text_Buffer * buf = mBuffer ;
@ -1760,7 +1766,7 @@ int Fl_Text_Display::position_style( int lineStartPos, int lineLen, int lineInde
@@ -1760,7 +1766,7 @@ int Fl_Text_Display::position_style( int lineStartPos, int lineLen, int lineInde
/**
Find the width of a string in the font of a particular style
*/
*/
int Fl_Text_Display : : string_width ( const char * string , int length , int style ) const {
Fl_Font font ;
int fsize ;
@ -1787,7 +1793,7 @@ int Fl_Text_Display::string_width( const char *string, int length, int style ) c
@@ -1787,7 +1793,7 @@ int Fl_Text_Display::string_width( const char *string, int length, int style ) c
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 ) .
*/
*/
int Fl_Text_Display : : xy_to_position ( int X , int Y , int posType ) const {
int lineStart , lineLen , fontHeight ;
int visLineNum ;
@ -1814,7 +1820,7 @@ int Fl_Text_Display::xy_to_position( int X, int Y, int posType ) const {
@@ -1814,7 +1820,7 @@ int Fl_Text_Display::xy_to_position( int X, int Y, int posType ) const {
lineStart , lineLen , 0 , 0 ,
0 , 0 ,
text_area . x , X ) ;
}
}
/**
Translate window coordinates to the nearest row and column number for
@ -1823,7 +1829,7 @@ int Fl_Text_Display::xy_to_position( int X, int Y, int posType ) const {
@@ -1823,7 +1829,7 @@ int Fl_Text_Display::xy_to_position( int X, int Y, int posType ) const {
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 .
*/
*/
void Fl_Text_Display : : xy_to_rowcol ( int X , int Y , int * row ,
int * column , int posType ) const {
int fontHeight = mMaxsize ;
@ -1844,7 +1850,7 @@ void Fl_Text_Display::xy_to_rowcol( int X, int Y, int *row,
@@ -1844,7 +1850,7 @@ void Fl_Text_Display::xy_to_rowcol( int X, int Y, int *row,
lines will still be visible , salvage the line starts values , otherwise ,
count lines from the nearest known line start ( start or end of buffer , or
the closest value in the mLineStarts array )
*/
*/
void Fl_Text_Display : : offset_line_starts ( int newTopLineNum ) {
int oldTopLineNum = mTopLineNum ;
int oldFirstChar = mFirstChar ;
@ -1901,7 +1907,7 @@ void Fl_Text_Display::offset_line_starts( int newTopLineNum ) {
@@ -1901,7 +1907,7 @@ void Fl_Text_Display::offset_line_starts( int newTopLineNum ) {
display " textD " after a modification to the text buffer , given by the
position where the change began " pos " , and the nmubers of characters
and lines inserted and deleted .
*/
*/
void Fl_Text_Display : : update_line_starts ( int pos , int charsInserted ,
int charsDeleted , int linesInserted , int linesDeleted , int * scrolled ) {
int * lineStarts = mLineStarts ;
@ -1999,7 +2005,7 @@ void Fl_Text_Display::update_line_starts( int pos, int charsInserted,
@@ -1999,7 +2005,7 @@ void Fl_Text_Display::update_line_starts( int pos, int charsInserted,
" startLine " ( or mFirstChar if startLine is 0 ) is good , and re - counts
newlines to fill in the requested entries . Out of range values for
" startLine " and " endLine " are acceptable .
*/
*/
void Fl_Text_Display : : calc_line_starts ( int startLine , int endLine ) {
int startPos , bufLen = mBuffer - > length ( ) ;
int line , lineEnd , nextLineStart , nVis = mNVisibleLines ;
@ -2056,7 +2062,7 @@ void Fl_Text_Display::calc_line_starts( int startLine, int endLine ) {
@@ -2056,7 +2062,7 @@ void Fl_Text_Display::calc_line_starts( int startLine, int endLine ) {
/**
Given a Fl_Text_Display with a complete , up - to - date lineStarts array , update
the lastChar entry to point to the last buffer position displayed .
*/
*/
void Fl_Text_Display : : calc_last_char ( ) {
int i ;
for ( i = mNVisibleLines - 1 ; i > = 0 & & mLineStarts [ i ] = = - 1 ; i - - ) ;
@ -2099,7 +2105,7 @@ void Fl_Text_Display::scroll_(int topLineNum, int horizOffset) {
@@ -2099,7 +2105,7 @@ void Fl_Text_Display::scroll_(int topLineNum, int horizOffset) {
/**
Update the minimum , maximum , slider size , page increment , and value
for vertical scroll bar .
*/
*/
void Fl_Text_Display : : update_v_scrollbar ( ) {
/* The Vert. scroll bar value and slider size directly represent the top
line number , and the number of visible lines respectively . The scroll
@ -2118,7 +2124,7 @@ void Fl_Text_Display::update_v_scrollbar() {
@@ -2118,7 +2124,7 @@ void Fl_Text_Display::update_v_scrollbar() {
/**
Update the minimum , maximum , slider size , page increment , and value
for the horizontal scroll bar .
*/
*/
void Fl_Text_Display : : update_h_scrollbar ( ) {
int sliderMax = max ( longest_vline ( ) , text_area . w + mHorizOffset ) ;
mHScrollBar - > value ( mHorizOffset , text_area . w , 0 , sliderMax ) ;
@ -2126,7 +2132,7 @@ void Fl_Text_Display::update_h_scrollbar() {
@@ -2126,7 +2132,7 @@ void Fl_Text_Display::update_h_scrollbar() {
/**
Callbacks for drag or valueChanged on scroll bars
*/
*/
void Fl_Text_Display : : v_scrollbar_cb ( Fl_Scrollbar * b , Fl_Text_Display * textD ) {
if ( b - > value ( ) = = textD - > mTopLineNum ) return ;
textD - > scroll ( b - > value ( ) , textD - > mHorizOffset ) ;
@ -2142,7 +2148,7 @@ void Fl_Text_Display::h_scrollbar_cb(Fl_Scrollbar* b, Fl_Text_Display* textD) {
@@ -2142,7 +2148,7 @@ void Fl_Text_Display::h_scrollbar_cb(Fl_Scrollbar* b, Fl_Text_Display* textD) {
the character cell areas . Setting clearAll to True will clear out any
stray marks outside of the character cell area , which might have been
left from before a resize or font change .
*/
*/
void Fl_Text_Display : : draw_line_numbers ( bool /*clearAll*/ ) {
#if 0
// FIXME: don't want this yet, so will leave for another time
@ -2207,7 +2213,7 @@ static int min( int i1, int i2 ) {
@@ -2207,7 +2213,7 @@ static int min( int i1, int i2 ) {
/**
Count the number of newlines in a null - terminated text string ;
*/
*/
static int countlines ( const char * string ) {
const char * c ;
int lineCount = 0 ;
@ -2221,27 +2227,26 @@ static int countlines( const char *string ) {
@@ -2221,27 +2227,26 @@ static int countlines( const char *string ) {
/**
Return the width in pixels of the displayed line pointed to by " visLineNum "
*/
*/
int Fl_Text_Display : : measure_vline ( int visLineNum ) const {
// FIXME: the horizontal scroll bar is still messed up. Clicking the right container is not possible.
int lineLen = vline_length ( visLineNum ) ;
int lineStartPos = mLineStarts [ visLineNum ] ;
if ( lineStartPos < 0 | | lineLen = = 0 ) return 0 ;
return handle_vline ( GET_WIDTH , lineStartPos , lineLen , 0 , 0 , 0 , 0 , 0 , 0 ) ;
}
}
/**
Return true if there are lines visible with no corresponding buffer text
*/
*/
int Fl_Text_Display : : empty_vlines ( ) const {
return mNVisibleLines > 0 & &
mLineStarts [ mNVisibleLines - 1 ] = = - 1 ;
return ( mNVisibleLines > 0 ) & & ( mLineStarts [ mNVisibleLines - 1 ] = = - 1 ) ;
}
/**
Return the length of a line ( number of displayable characters ) by examining
entries in the line starts array rather than by scanning for newlines
*/
*/
int Fl_Text_Display : : vline_length ( int visLineNum ) const {
int nextLineStart , lineStartPos ;
@ -2270,7 +2275,7 @@ int Fl_Text_Display::vline_length( int visLineNum ) const {
@@ -2270,7 +2275,7 @@ int Fl_Text_Display::vline_length( int visLineNum ) const {
what has to be counted and re - displayed , so the results can be useful
both for delimiting where the line starts need to be recalculated , and
for deciding what part of the text to redisplay .
*/
*/
void Fl_Text_Display : : find_wrap_range ( const char * deletedText , int pos ,
int nInserted , int nDeleted , int * modRangeStart , int * modRangeEnd ,
int * linesInserted , int * linesDeleted ) {
@ -2424,7 +2429,7 @@ void Fl_Text_Display::find_wrap_range(const char *deletedText, int pos,
@@ -2424,7 +2429,7 @@ void Fl_Text_Display::find_wrap_range(const char *deletedText, int pos,
is no longer available _after_ the modification . In other cases , we
can still perform the calculation afterwards ( possibly even more
efficiently ) .
*/
*/
void Fl_Text_Display : : measure_deleted_lines ( int pos , int nDeleted ) {
int retPos , retLines , retLineStart , retLineEnd ;
Fl_Text_Buffer * buf = buffer ( ) ;
@ -2497,16 +2502,16 @@ void Fl_Text_Display::measure_deleted_lines(int pos, int nDeleted) {
@@ -2497,16 +2502,16 @@ void Fl_Text_Display::measure_deleted_lines(int pos, int nDeleted) {
widget . In that case it must be a ( partial ) copy of the actual text buffer
and the styleBufOffset argument must indicate the starting position of the
copy , to take into account the correct style information .
* *
* *
Returned values :
* *
* *
retPos : Position where counting ended . When counting lines , the
position returned is the start of the line " maxLines "
lines beyond " startPos " .
retLines : Number of line breaks counted
retLineStart : Start of the line where counting ended
retLineEnd : End position of the last line traversed
*/
*/
void Fl_Text_Display : : wrapped_line_counter ( Fl_Text_Buffer * buf , int startPos ,
int maxPos , int maxLines , bool startPosIsLineStart , int styleBufOffset ,
int * retPos , int * retLines , int * retLineStart , int * retLineEnd ,
@ -2643,7 +2648,7 @@ void Fl_Text_Display::wrapped_line_counter(Fl_Text_Buffer *buf, int startPos,
@@ -2643,7 +2648,7 @@ void Fl_Text_Display::wrapped_line_counter(Fl_Text_Buffer *buf, int startPos,
Measure the width in pixels of the first character of string " s " at a
particular column " colNum " and buffer position " pos " . This is for measuring
characters in proportional or mixed - width highlighting fonts .
* *
* *
A note about proportional and mixed - width fonts : the mixed width and
proportional font code in nedit does not get much use in general editing ,
because nedit doesn ' t allow per - language - mode fonts , and editing programs
@ -2652,7 +2657,7 @@ void Fl_Text_Display::wrapped_line_counter(Fl_Text_Buffer *buf, int startPos,
@@ -2652,7 +2657,7 @@ void Fl_Text_Display::wrapped_line_counter(Fl_Text_Buffer *buf, int startPos,
width syntax highlighting cases where things don ' t redraw properly for
insertion / deletion , though static display and wrapping and resizing
should now be solid because they are now used for online help display .
*/
*/
int Fl_Text_Display : : measure_proportional_character ( const char * s , int colNum , int pos ) const {
int charLen = fl_utf8len ( * s ) , style = 0 ;
if ( mStyleBuffer ) {
@ -2660,7 +2665,7 @@ int Fl_Text_Display::measure_proportional_character(const char *s, int colNum, i
@@ -2660,7 +2665,7 @@ int Fl_Text_Display::measure_proportional_character(const char *s, int colNum, i
style = * b ;
}
return string_width ( s , charLen , style ) ;
}
}
/**
Finds both the end of the current line and the start of the next line . Why ?
@ -2671,7 +2676,7 @@ int Fl_Text_Display::measure_proportional_character(const char *s, int colNum, i
@@ -2671,7 +2676,7 @@ int Fl_Text_Display::measure_proportional_character(const char *s, int colNum, i
whether the trailing space or tab is being used as a line break or just a
normal character , and to find that out would otherwise require counting all
the way back to the beginning of the line .
*/
*/
void Fl_Text_Display : : find_line_end ( int startPos , bool startPosIsLineStart ,
int * lineEnd , int * nextLineStart ) const {
int retLines , retLineStart ;
@ -2698,14 +2703,14 @@ void Fl_Text_Display::find_line_end(int startPos, bool startPosIsLineStart,
@@ -2698,14 +2703,14 @@ void Fl_Text_Display::find_line_end(int startPos, bool startPosIsLineStart,
line terminating character , and this distinction causes endless trouble
with all of the text display code which was originally written without
continuous wrap mode and always expects to wrap at a newline character .
* *
* *
Given the position of the end of the line , as returned by TextDEndOfLine
or BufEndOfLine , this returns true if there is a line terminating
character , and false if there ' s not . On the last character in the
buffer , this function can ' t tell for certain whether a trailing space was
used as a wrap point , and just guesses that it wasn ' t . So if an exact
accounting is necessary , don ' t use this function .
*/
*/
int Fl_Text_Display : : wrap_uses_character ( int lineEndPos ) const {
char c ;
@ -2722,7 +2727,7 @@ int Fl_Text_Display::wrap_uses_character(int lineEndPos) const {
@@ -2722,7 +2727,7 @@ int Fl_Text_Display::wrap_uses_character(int lineEndPos) const {
Extend the range of a redraw request ( from * start to * end ) with additional
redraw requests resulting from changes to the attached style buffer ( which
contains auxiliary information for coloring or styling text ) .
*/
*/
void Fl_Text_Display : : extend_range_for_styles ( int * startpos , int * endpos ) {
Fl_Text_Selection * sel = mStyleBuffer - > primary_selection ( ) ;
int extended = 0 ;
@ -2764,7 +2769,7 @@ void Fl_Text_Display::draw(void) {
@@ -2764,7 +2769,7 @@ void Fl_Text_Display::draw(void) {
// draw the non-text, non-scrollbar areas.
if ( damage ( ) & FL_DAMAGE_ALL ) {
// printf("drawing all (box = %d)\n", box());
// printf("drawing all (box = %d)\n", box());
// draw the box()
int W = w ( ) , H = h ( ) ;
draw_box ( box ( ) , x ( ) , y ( ) , W , H , color ( ) ) ;
@ -2801,7 +2806,7 @@ void Fl_Text_Display::draw(void) {
@@ -2801,7 +2806,7 @@ void Fl_Text_Display::draw(void) {
// blank the previous cursor protrusions
}
else if ( damage ( ) & ( FL_DAMAGE_SCROLL | FL_DAMAGE_EXPOSE ) ) {
// printf("blanking previous cursor extrusions at Y: %d\n", mCursorOldY);
// printf("blanking previous cursor extrusions at Y: %d\n", mCursorOldY);
// CET - FIXME - save old cursor position instead and just draw side needed?
fl_push_clip ( text_area . x - LEFT_MARGIN ,
text_area . y ,
@ -2862,7 +2867,7 @@ void Fl_Text_Display::draw(void) {
@@ -2862,7 +2867,7 @@ void Fl_Text_Display::draw(void) {
int X , Y ;
if ( position_to_xy ( mCursorPos , & X , & Y ) ) draw_cursor ( X , Y ) ;
// else puts("position_to_xy() failed - unable to draw cursor!");
// else puts("position_to_xy() failed - unable to draw cursor!");
//printf("drew cursor at pos: %d (%d,%d)\n", mCursorPos, X, Y);
mCursorOldY = Y ;
fl_pop_clip ( ) ;