40 #define LINENUM_LEFT_OF_VSCROLL // uncomment this line ... 53 #define BOTTOM_MARGIN 1 55 #define RIGHT_MARGIN 3 61 #define FILL_MASK 0x0100 62 #define SECONDARY_MASK 0x0200 63 #define PRIMARY_MASK 0x0400 64 #define HIGHLIGHT_MASK 0x0800 65 #define BG_ONLY_MASK 0x1000 66 #define TEXT_ONLY_MASK 0x2000 67 #define STYLE_LOOKUP_MASK 0xff 72 #define MAX_DISP_LINE_LEN 1000 74 static int max(
int i1,
int i2 );
75 static int min(
int i1,
int i2 );
86 #define TMPFONTWIDTH 6 168 #if FLTK_ABI_VERSION >= 10303 172 linenumber_bgcolor_ = 53;
174 linenumber_format_ = strdup(
"%d");
196 #if FLTK_ABI_VERSION >= 10303 197 if (linenumber_format_) {
198 free((
void*)linenumber_format_);
199 linenumber_format_ = 0;
213 if (width < 0)
return;
230 #if FLTK_ABI_VERSION >= 10303 231 linenumber_font_ = val;
241 #if FLTK_ABI_VERSION >= 10303 242 return linenumber_font_;
253 #if FLTK_ABI_VERSION >= 10303 254 linenumber_size_ = val;
264 #if FLTK_ABI_VERSION >= 10303 265 return linenumber_size_;
276 #if FLTK_ABI_VERSION >= 10303 277 linenumber_fgcolor_ = val;
287 #if FLTK_ABI_VERSION >= 10303 288 return linenumber_fgcolor_;
299 #if FLTK_ABI_VERSION >= 10303 300 linenumber_bgcolor_ = val;
310 #if FLTK_ABI_VERSION >= 10303 311 return linenumber_bgcolor_;
323 #if FLTK_ABI_VERSION >= 10303 324 linenumber_align_ = val;
334 #if FLTK_ABI_VERSION >= 10303 335 return linenumber_align_;
361 #if FLTK_ABI_VERSION >= 10303 362 if ( linenumber_format_ )
free((
void*)linenumber_format_);
363 linenumber_format_ = val ? strdup(val) : 0;
373 #if FLTK_ABI_VERSION >= 10303 374 return linenumber_format_;
444 int nStyles,
char unfinishedStyle,
445 Unfinished_Style_Cb unfinishedHighlightCB,
484 printf(
"Fl_Text_Display::resize(X=%d, Y=%d, W=%d, H=%d)\n", X,
Y, W,
H);
485 printf(
" current size(x=%d, y=%d, w=%d, h=%d)\n",
x(),
y(),
w(),
h());
486 printf(
" box_d* size(x=%d, y=%d, w=%d, h=%d)\n",
488 printf(
" text_area size(x=%d, y=%d, w=%d, h=%d)\n",
490 printf(
" mContinuousWrap=%d, mWrapMarginPix=%d\n",
523 #if (1) // optimization (experimental - seems to work well) 536 if (nvlines < 1) nvlines = 1;
537 if (nlines >= nvlines-1) {
543 #endif // optimization 545 for (
int again = 1; again;) {
552 printf(
"*** again ... text_area.w = %d, oldTAWidth = %d, diff = %d\n",
574 if (nvlines < 1) nvlines = 1;
625 if (!wrap_at_bounds) {
648 #ifdef LINENUM_LEFT_OF_VSCROLL 684 if (mNBufferLines < mNVisibleLines || mBuffer == NULL || mBuffer->
length() == 0) {
725 int fontHeight, firstLine, lastLine, line;
729 firstLine = ( top -
text_area.y - fontHeight + 1 ) / fontHeight;
730 lastLine = ( top + height -
text_area.y ) / fontHeight + 1;
735 for ( line = firstLine; line <= lastLine; line++ )
736 draw_vline( line, left, left + width, 0, INT_MAX );
790 int i, startLine, lastLine, startIndex, endIndex;
797 if ( startpos < 0 ) startpos = 0;
799 if ( endpos < 0 ) endpos = 0;
827 if ( startLine == lastLine ) {
828 draw_vline( startLine, 0, INT_MAX, startIndex, endIndex );
833 draw_vline( startLine, 0, INT_MAX, startIndex, INT_MAX );
836 for ( i = startLine + 1; i < lastLine; i++ )
840 draw_vline( lastLine, 0, INT_MAX, 0, endIndex );
856 if ( newPos < 0 ) newPos = 0;
1011 int lineStart =
buf->line_start( startPos );
1012 int textLen = (int) strlen( text );
1013 int i,
p, endPos,
indent, startIndent, endIndent;
1016 char *paddedText =
NULL;
1021 for ( c = text; *c !=
'\0'; c +=
fl_utf8len1(*c) )
1028 for (
p = startPos; ;
p =
buf->next_char(
p) ) {
1029 if (
p ==
buf->length() )
1031 ch =
buf->char_at(
p );
1035 if (
indent == endIndent ) {
1036 p =
buf->next_char(
p);
1038 }
else if (
indent > endIndent ) {
1040 p =
buf->next_char(
p);
1042 strcpy( paddedText, text );
1043 for ( i = 0; i <
indent - endIndent; i++ )
1044 paddedText[ textLen + i ] =
' ';
1045 paddedText[ textLen + i ] =
'\0';
1053 buf->replace( startPos, endPos, paddedText ==
NULL ? text : paddedText );
1055 if ( paddedText !=
NULL )
1056 delete [] paddedText;
1077 int lineStartPos, fontHeight;
1098 if ( lineStartPos == -1 ) {
1160 return buf->primary_selection()->includes(pos);
1186 int lineStart, dispLineStart;
1191 if (dispLineStart == -1)
1232 int hOffset, topLine, X,
Y;
1253 printf (
"*** display_insert/position_to_xy # GIVE UP !\n"); fflush(stdout);
1319 int lineStartPos, xPos, prevLineStartPos, newPos, visLineNum;
1329 if ( lineStartPos == 0 )
1337 0, 0, 0, 0, 0, INT_MAX);
1340 if ( visLineNum != -1 && visLineNum != 0 )
1345 int lineEnd =
line_end(prevLineStartPos,
true);
1347 0, 0, 0, 0, 0, xPos);
1364 int lineStartPos, xPos, newPos, visLineNum;
1379 0, 0, 0, 0, 0, INT_MAX);
1382 int nextLineStartPos =
skip_lines( lineStartPos, 1,
true );
1383 int lineEnd =
line_end(nextLineStartPos,
true);
1385 0, 0, 0, 0, 0, xPos);
1408 bool startPosIsLineStart)
const {
1412 int retLines, retPos, retLineStart, retLineEnd;
1415 printf(
"Fl_Text_Display::count_lines(startPos=%d, endPos=%d, startPosIsLineStart=%d\n",
1416 startPos, endPos, startPosIsLineStart);
1424 startPosIsLineStart, 0, &retPos, &retLines, &retLineStart,
1428 printf(
" # after WLC: retPos=%d, retLines=%d, retLineStart=%d, retLineEnd=%d\n",
1429 retPos, retLines, retLineStart, retLineEnd);
1451 bool startPosIsLineStart) {
1454 int retLines, retPos, retLineStart, retLineEnd;
1466 nLines, startPosIsLineStart, 0,
1467 &retPos, &retLines, &retLineStart, &retLineEnd);
1499 int retLines, retPos, retLineStart, retLineEnd;
1509 startPosIsLineStart, 0, &retPos, &retLines, &retLineStart,
1530 int retLines, retPos, retLineStart, retLineEnd;
1537 &retPos, &retLines, &retLineStart, &retLineEnd);
1540 return retLineStart;
1559 int pos, lineStart, retLines, retPos, retLineStart, retLineEnd;
1563 return buf->rewind_lines(startPos, nLines);
1567 lineStart =
buf->line_start(pos);
1569 &retPos, &retLines, &retLineStart, &retLineEnd,
false);
1570 if (retLines > nLines)
1571 return skip_lines(lineStart, retLines-nLines,
true);
1573 pos = lineStart - 1;
1584 return c !=
'$' && c !=
'_' && (isspace(c) || ispunct(c));
1684 int nRestyled,
const char *deletedText,
void *cbArg ) {
1685 int linesInserted, linesDeleted, startDispPos, endDispPos;
1689 int scrolled, origCursorPos = textD->
mCursorPos;
1690 int wrapModStart = 0, wrapModEnd = 0;
1696 if ( nInserted != 0 || nDeleted != 0 )
1703 &wrapModStart, &wrapModEnd, &linesInserted, &linesDeleted);
1705 linesInserted = nInserted == 0 ? 0 :
buf->count_lines( pos, pos + nInserted );
1706 linesDeleted = nDeleted == 0 ? 0 :
countlines( deletedText );
1710 if ( nInserted != 0 || nDeleted != 0 ) {
1713 nDeleted + pos-wrapModStart + (wrapModEnd-(pos+nInserted)),
1714 linesInserted, linesDeleted, &scrolled );
1717 linesDeleted, &scrolled );
1725 (nInserted != 0 || nDeleted != 0)) {
1726 if (deletedText && (pos + nDeleted < oldFirstChar))
1729 else if (pos < oldFirstChar)
1748 textD->
resize(textD->
x(), textD->
y(), textD->
w(), textD->
h());
1769 if ( origCursorPos == startDispPos && textD->
mCursorPos != startDispPos )
1770 startDispPos =
min( startDispPos,
buf->prev_char_clipped(origCursorPos) );
1773 if ( linesInserted == linesDeleted ) {
1774 if ( nInserted == 0 && nDeleted == 0 )
1775 endDispPos = pos + nRestyled;
1778 endDispPos = wrapModEnd;
1780 endDispPos =
buf->next_char(
buf->line_end( pos + nInserted ));
1785 if (linesInserted > 1) {
1920 if ( mLastChar < mBuffer->
length() ) {
1922 Fl::error(
"Fl_Text_Display::position_to_line(): Consistency check ptvl failed");
1969 int lineStartPos,
int lineLen,
int leftChar,
int rightChar,
1970 int Y,
int bottomClip,
1971 int leftClip,
int rightClip)
const 1977 int i, X, startX, startIndex, style, charStyle;
1980 if ( lineStartPos == -1 ) {
2005 return lineStartPos;
2010 char currChar = 0, prevChar = 0;
2013 for (i=0; i<lineLen; ) {
2014 currChar = lineStr[i];
2016 if (len<=0) len = 1;
2018 if (charStyle!=style || currChar==
'\t' || prevChar==
'\t') {
2021 if (prevChar==
'\t') {
2025 w = (((xAbs/tab)+1)*tab) - xAbs;
2031 return lineStartPos + startIndex;
2035 w = int(
string_width( lineStr+startIndex, i-startIndex, style ) );
2037 draw_string( style, startX,
Y, startX+
w, lineStr+startIndex, i-startIndex );
2040 int di =
find_x(lineStr+startIndex, i-startIndex, style, rightClip-startX);
2043 return lineStartPos + startIndex + di;
2051 prevChar = currChar;
2054 if (currChar==
'\t') {
2058 w = (((xAbs/tab)+1)*tab) - xAbs;
2064 return lineStartPos + startIndex + ( rightClip-startX>
w ? 1 : 0 );
2067 w = int(
string_width( lineStr+startIndex, i-startIndex, style ) );
2069 draw_string( style, startX,
Y, startX+
w, lineStr+startIndex, i-startIndex );
2072 int di =
find_x(lineStr+startIndex, i-startIndex, style, rightClip-startX);
2075 return lineStartPos + startIndex + di;
2091 return lineStartPos + lineLen;
2134 int leftCharIndex,
int rightCharIndex) {
2135 int Y, lineStartPos, lineLen, fontHeight;
2151 if ( lineStartPos == -1 ) {
2162 lineStartPos, lineLen, leftCharIndex, rightCharIndex,
2163 Y,
Y+fontHeight, leftClip, rightClip);
2186 int X,
int Y,
int toX,
2187 const char *
string,
int nChars)
const {
2214 font = styleRec->
font;
2215 fsize = styleRec->
size;
2256 #if !(defined(__APPLE__) || defined(WIN32)) && USE_XFT 2261 #ifdef __APPLE__ // Mac OS: underline marked (= selected + Fl::compose_state != 0) text 2267 #if !(defined(__APPLE__) || defined(WIN32)) && USE_XFT 2302 int width,
int height)
const {
2342 int left, right, cursorWidth, midY;
2347 int bot =
Y + fontHeight - 1;
2353 Fl::insertion_point_location(X, bot, fontHeight);
2359 left = X - cursorWidth / 2;
2360 right = left + cursorWidth;
2364 midY = bot - fontHeight / 5;
2365 segs[ 0 ].x1 = left; segs[ 0 ].y1 = bot; segs[ 0 ].x2 = X; segs[ 0 ].y2 = midY;
2366 segs[ 1 ].x1 = X; segs[ 1 ].y1 = midY; segs[ 1 ].x2 = right; segs[ 1 ].y2 = bot;
2367 segs[ 2 ].x1 = left; segs[ 2 ].y1 = bot; segs[ 2 ].x2 = X; segs[ 2 ].y2 = midY - 1;
2368 segs[ 3 ].x1 = X; segs[ 3 ].y1 = midY - 1; segs[ 3 ].x2 = right; segs[ 3 ].y2 = bot;
2371 segs[ 0 ].x1 = left; segs[ 0 ].y1 =
Y; segs[ 0 ].x2 = right; segs[ 0 ].y2 =
Y;
2372 segs[ 1 ].x1 = X; segs[ 1 ].y1 =
Y; segs[ 1 ].x2 = X; segs[ 1 ].y2 = bot;
2373 segs[ 2 ].x1 = left; segs[ 2 ].y1 = bot; segs[ 2 ].x2 = right; segs[ 2 ].y2 = bot;
2376 segs[ 0 ].x1 = X - 1; segs[ 0 ].y1 =
Y; segs[ 0 ].x2 = X - 1; segs[ 0 ].y2 = bot;
2377 segs[ 1 ].x1 = X; segs[ 1 ].y1 =
Y; segs[ 1 ].x2 = X; segs[ 1 ].y2 = bot;
2378 segs[ 2 ].x1 = X + 1; segs[ 2 ].y1 =
Y; segs[ 2 ].x2 = X + 1; segs[ 2 ].y2 = bot;
2379 segs[ 3 ].x1 = left; segs[ 3 ].y1 =
Y; segs[ 3 ].x2 = right; segs[ 3 ].y2 =
Y;
2380 segs[ 4 ].x1 = left; segs[ 4 ].y1 = bot; segs[ 4 ].x2 = right; segs[ 4 ].y2 = bot;
2383 midY =
Y + fontHeight / 2;
2384 segs[ 0 ].x1 = X; segs[ 0 ].y1 =
Y; segs[ 0 ].x2 = X; segs[ 0 ].y2 =
Y;
2385 segs[ 1 ].x1 = X; segs[ 1 ].y1 = midY; segs[ 1 ].x2 = X; segs[ 1 ].y2 = midY;
2386 segs[ 2 ].x1 = X; segs[ 2 ].y1 = bot; segs[ 2 ].x2 = X; segs[ 2 ].y2 = bot;
2389 right = X + fontWidth;
2390 segs[ 0 ].x1 = X; segs[ 0 ].y1 =
Y; segs[ 0 ].x2 = right; segs[ 0 ].y2 =
Y;
2391 segs[ 1 ].x1 = right; segs[ 1 ].y1 =
Y; segs[ 1 ].x2 = right; segs[ 1 ].y2 = bot;
2392 segs[ 2 ].x1 = right; segs[ 2 ].y1 = bot; segs[ 2 ].x2 = X; segs[ 2 ].y2 = bot;
2393 segs[ 3 ].x1 = X; segs[ 3 ].y1 = bot; segs[ 3 ].x2 = X; segs[ 3 ].y2 =
Y;
2396 segs[ 0 ].x1 = X; segs[ 0 ].y1 =
Y; segs[ 0 ].x2 = X; segs[ 0 ].y2 = bot;
2397 segs[ 1 ].x1 = X+1; segs[ 1 ].y1 =
Y; segs[ 1 ].x2 = X+1; segs[ 1 ].y2 = bot;
2402 for (
int k = 0; k < nSegs; k++ ) {
2403 fl_line( segs[ k ].x1, segs[ k ].y1, segs[ k ].x2, segs[ k ].y2 );
2440 if ( lineStartPos == -1 ||
buf ==
NULL )
2443 pos = lineStartPos +
min( lineIndex, lineLen );
2445 if ( lineIndex >= lineLen )
2447 else if ( styleBuf !=
NULL ) {
2448 style = (
unsigned char ) styleBuf->
byte_at( pos );
2452 style = (
unsigned char) styleBuf->
byte_at( pos);
2455 if (
buf->primary_selection()->includes(pos))
2457 if (
buf->highlight_selection()->includes(pos))
2459 if (
buf->secondary_selection()->includes(pos))
2510 int lineStart, lineLen, fontHeight;
2515 visLineNum = (
Y -
text_area.y ) / fontHeight;
2516 if ( visLineNum < 0 )
2525 if ( lineStart == -1 )
2532 lineStart, lineLen, 0, 0,
2554 int *column,
int posType )
const {
2560 if ( *row < 0 ) *row = 0;
2564 ( posType ==
CURSOR_POS ? fontWidth / 2 : 0 ) ) / fontWidth;
2565 if ( *column < 0 ) * column = 0;
2584 int lineDelta = newTopLineNum - oldTopLineNum;
2591 if ( lineDelta == 0 )
2597 lastLineNum = oldTopLineNum + nVisLines - 1;
2598 if ( newTopLineNum < oldTopLineNum && newTopLineNum < -lineDelta ) {
2600 }
else if ( newTopLineNum < oldTopLineNum ) {
2602 }
else if ( newTopLineNum < lastLineNum ) {
2603 mFirstChar = lineStarts[ newTopLineNum - oldTopLineNum ];
2604 }
else if ( newTopLineNum - lastLineNum <
mNBufferLines - newTopLineNum ) {
2606 newTopLineNum - lastLineNum,
true );
2612 if ( lineDelta < 0 && -lineDelta < nVisLines ) {
2613 for ( i = nVisLines - 1; i >= -lineDelta; i-- )
2614 lineStarts[ i ] = lineStarts[ i + lineDelta ];
2616 }
else if ( lineDelta > 0 && lineDelta < nVisLines ) {
2617 for ( i = 0; i < nVisLines - lineDelta; i++ )
2618 lineStarts[ i ] = lineStarts[ i + lineDelta ];
2650 int charsDeleted,
int linesInserted,
2651 int linesDeleted,
int *scrolled ) {
2656 int charDelta = charsInserted - charsDeleted;
2657 int lineDelta = linesInserted - linesDeleted;
2664 for ( i = 0; i < nVisLines && lineStarts[i] != -1; i++ )
2665 lineStarts[ i ] += charDelta;
2677 ++lineOfEnd < nVisLines && lineStarts[ lineOfEnd ] != -1 ) {
2704 if ( lineDelta == 0 ) {
2705 for ( i = lineOfPos + 1; i < nVisLines && lineStarts[ i ] != -1; i++ )
2706 lineStarts[ i ] += charDelta;
2707 }
else if ( lineDelta > 0 ) {
2708 for ( i = nVisLines - 1; i >= lineOfPos + lineDelta + 1; i-- )
2709 lineStarts[ i ] = lineStarts[ i - lineDelta ] +
2710 ( lineStarts[ i - lineDelta ] == -1 ? 0 : charDelta );
2712 for ( i =
max( 0, lineOfPos + 1 ); i < nVisLines + lineDelta; i++ )
2713 lineStarts[ i ] = lineStarts[ i - lineDelta ] +
2714 ( lineStarts[ i - lineDelta ] == -1 ? 0 : charDelta );
2717 if ( linesInserted >= 0 )
2719 if ( lineDelta < 0 )
2761 if ( endLine < 0 ) endLine = 0;
2762 if ( endLine >= nVis ) endLine = nVis - 1;
2763 if ( startLine < 0 ) startLine = 0;
2764 if ( startLine >= nVis ) startLine = nVis - 1;
2765 if ( startLine > endLine )
2769 if ( startLine == 0 ) {
2773 startPos = lineStarts[ startLine - 1 ];
2777 if ( startPos == -1 ) {
2778 for ( line = startLine; line <= endLine; line++ )
2779 lineStarts[ line ] = -1;
2785 for ( line = startLine; line <= endLine; line++ ) {
2787 startPos = nextLineStart;
2788 if ( startPos >= bufLen ) {
2793 if ( line == 0 || ( lineStarts[ line - 1 ] != bufLen &&
2794 lineEnd != nextLineStart ) ) {
2795 lineStarts[ line ] = bufLen;
2800 lineStarts[ line ] = startPos;
2804 for ( ; line <= endLine; line++ )
2805 lineStarts[ line ] = -1;
2848 if (topLineNum < 1) topLineNum = 1;
2852 if (horizOffset < 0) horizOffset = 0;
2885 printf(
"Fl_Text_Display::update_v_scrollbar():\n" 2886 " mTopLineNum=%d, mNVisibleLines=%d, mNBufferLines=%d\n",
2941 int Y, line, visLine, lineStart;
2942 char lineNumString[16];
2957 #ifndef LINENUM_LEFT_OF_VSCROLL 2989 if (lineStart != -1 && (lineStart==0 ||
buffer()->char_at(lineStart-1)==
'\n')) {
2991 int xx =
x() + xoff + 3,
2999 if (visLine == 0) line++;
3007 static int max(
int i1,
int i2 ) {
3008 return i1 >= i2 ? i1 : i2;
3011 static int min(
int i1,
int i2 ) {
3012 return i1 <= i2 ? i1 : i2;
3026 if (!
string)
return 0;
3028 for ( c =
string; *c !=
'\0'; c++ )
3029 if ( *c ==
'\n' ) lineCount++;
3044 if (lineStartPos < 0 || lineLen == 0)
return 0;
3070 int nextLineStart, lineStartPos;
3077 if ( lineStartPos == -1 )
3084 if ( nextLineStart == -1 )
3089 return nextLineStartMinus1 - lineStartPos;
3091 return nextLineStart - lineStartPos;
3117 int nInserted,
int nDeleted,
3118 int *modRangeStart,
int *modRangeEnd,
3119 int *linesInserted,
int *linesDeleted) {
3123 int length, retPos, retLines, retLineStart, retLineEnd;
3127 int countFrom, countTo, lineStart, adjLineStart, i;
3128 int visLineNum = 0, nLines = 0;
3136 for (i=nVisLines-1; i>0; i--) {
3137 if (lineStarts[i] != -1 && pos >= lineStarts[i]) {
3142 countFrom = lineStarts[i-1];
3145 countFrom =
buf->line_start(pos);
3148 countFrom =
buf->line_start(pos);
3158 lineStart = countFrom;
3159 *modRangeStart = countFrom;
3165 &retPos, &retLines, &retLineStart, &retLineEnd);
3166 if (retPos >=
buf->length()) {
3167 countTo =
buf->length();
3168 *modRangeEnd = countTo;
3169 if (retPos != retLineEnd)
3176 if (lineStart > pos + nInserted &&
buf->char_at(
buf->prev_char(lineStart)) ==
'\n') {
3177 countTo = lineStart;
3178 *modRangeEnd = lineStart;
3193 if (lineStart <= pos) {
3194 while (visLineNum<nVisLines && lineStarts[visLineNum] < lineStart)
3196 if (visLineNum < nVisLines && lineStarts[visLineNum] == lineStart) {
3197 countFrom = lineStart;
3199 if (visLineNum+1 < nVisLines && lineStarts[visLineNum+1] != -1)
3200 *modRangeStart =
min(pos,
buf->prev_char(lineStarts[visLineNum+1]));
3202 *modRangeStart = countFrom;
3204 *modRangeStart =
min(*modRangeStart,
buf->prev_char(lineStart));
3209 else if (lineStart > pos + nInserted) {
3210 adjLineStart = lineStart - nInserted + nDeleted;
3211 while (visLineNum<nVisLines && lineStarts[visLineNum]<adjLineStart)
3213 if (visLineNum < nVisLines && lineStarts[visLineNum] != -1 &&
3214 lineStarts[visLineNum] == adjLineStart) {
3215 countTo =
line_end(lineStart,
true);
3216 *modRangeEnd = lineStart;
3221 *linesInserted = nLines;
3250 length = (pos-countFrom) + nDeleted +(countTo-(pos+nInserted));
3252 deletedTextBuf->
copy(
buffer(), countFrom, pos, 0);
3254 deletedTextBuf->
insert(pos-countFrom, deletedText);
3255 deletedTextBuf->
copy(
buffer(), pos+nInserted, countTo, pos-countFrom+nDeleted);
3259 &retPos, &retLines, &retLineStart, &retLineEnd,
false);
3260 delete deletedTextBuf;
3261 *linesDeleted = retLines;
3287 int retPos, retLines, retLineStart, retLineEnd;
3291 int countFrom, lineStart;
3299 for (i=nVisLines-1; i>0; i--)
3300 if (lineStarts[i] != -1 && pos >= lineStarts[i])
3303 countFrom = lineStarts[i-1];
3305 countFrom =
buf->line_start(pos);
3307 countFrom =
buf->line_start(pos);
3314 lineStart = countFrom;
3319 &retPos, &retLines, &retLineStart, &retLineEnd);
3320 if (retPos >=
buf->length()) {
3321 if (retPos != retLineEnd)
3327 if (lineStart > pos + nDeleted &&
buf->char_at(lineStart-1) ==
'\n') {
3377 int maxPos,
int maxLines,
bool startPosIsLineStart,
int styleBufOffset,
3378 int *retPos,
int *retLines,
int *retLineStart,
int *retLineEnd,
3379 bool countLastLineMissingNewLine)
const {
3383 int lineStart, newLineStart = 0,
b,
p, colNum, wrapMarginPix;
3398 if (startPosIsLineStart)
3399 lineStart = startPos;
3410 for (
p=lineStart;
p<
buf->length();
p=
buf->next_char(
p)) {
3411 c =
buf->char_at(
p);
3419 *retLineStart = lineStart;
3420 *retLineEnd = maxPos;
3424 int p1 =
buf->next_char(
p);
3425 if (nLines >= maxLines) {
3436 const char *s =
buf->address(
p);
3445 if (width > wrapMarginPix) {
3447 for (
b=
p;
b>=lineStart;
b=
buf->prev_char(
b)) {
3448 c =
buf->char_at(
b);
3449 if (c ==
'\t' || c ==
' ') {
3450 newLineStart =
buf->next_char(
b);
3453 int iMax =
buf->next_char(
p);
3454 for (i=
buf->next_char(
b); i<iMax; i =
buf->next_char(i)) {
3463 if (
b<lineStart)
b = lineStart;
3465 newLineStart =
max(
p,
buf->next_char(lineStart));
3467 if (
b >=
buf->length()) {
3470 const char *s =
buf->address(
b);
3476 *retLines = maxPos < newLineStart ? nLines : nLines + 1;
3477 *retLineStart = maxPos < newLineStart ? lineStart : newLineStart;
3478 *retLineEnd = maxPos;
3482 if (nLines >= maxLines) {
3483 *retPos = foundBreak ?
buf->next_char(
b) :
max(
p,
buf->next_char(lineStart));
3485 *retLineStart = lineStart;
3486 *retLineEnd = foundBreak ?
b :
p;
3489 lineStart = newLineStart;
3494 *retPos =
buf->length();
3496 if (countLastLineMissingNewLine && colNum > 0)
3497 *retLines =
buf->next_char(*retLines);
3498 *retLineStart = lineStart;
3499 *retLineEnd =
buf->length();
3530 return (((xPix/tab)+1)*tab) - xPix;
3560 int *lineEnd,
int *nextLineStart)
const {
3563 int retLines, retLineStart;
3576 1, startPosIsLineStart, 0, nextLineStart, &retLines,
3577 &retLineStart, lineEnd);
3612 return c ==
'\n' || ((c ==
'\t' || c ==
' ') &&
3648 if ( sel->
start() < *startpos ) {
3649 *startpos = sel->
start();
3655 if ( sel->
end() > *endpos ) {
3656 *endpos = sel->
end();
3696 int W =
w(),
H =
h();
3788 !has_selection || mCursorPos < start || mCursorPos >
end) &&
3837 d->
buffer()->line_end(pos)+1);
3935 if (
buffer()->primary_selection()->includes(pos)) {
3949 if (
buffer()->primary_selection()->selected())
4041 if (*copy)
Fl::copy(copy, (
int) strlen(copy), 0);
4053 if (
buffer()->selected()) {
4058 if (
buffer()->secondary_selected()) {
4063 if (
buffer()->highlight()) {
4073 if (!
buffer()->selected())
return 1;
4075 if (*copy)
Fl::copy(copy, (
int) strlen(copy), 1);
4084 if (*copy)
Fl::copy(copy, (
int) strlen(copy), 0);