mod/maxgui.mod/fltkmaxgui.mod/src/Fl_Text_Display.cxx
void Fl_Text_Display::calc_line_starts( int startLine, int endLine ) {
  int startPos, bufLen = mBuffer->length();
  int line, lineEnd, nextLineStart, nVis = mNVisibleLines;
  int *lineStarts = mLineStarts;
  
  /* Clean up (possibly) messy input parameters */
  if ( endLine < 0 ) endLine = 0;
  if ( endLine >= nVis ) endLine = nVis - 1;
  if ( startLine < 0 ) startLine = 0;
  if ( startLine >= nVis ) startLine = nVis - 1;
  if ( startLine > endLine )
    return;
  
  /* Find the last known good line number -> position mapping */
  if ( startLine == 0 ) {
    lineStarts[ 0 ] = mFirstChar;
    startLine = 1;
  }
  startPos = lineStarts[ startLine - 1 ];
  
  /* If the starting position is already past the end of the text,
   fill in -1's (means no text on line) and return */
  if ( startPos == -1 ) {
    for ( line = startLine; line <= endLine; line++ )
      lineStarts[ line ] = -1;
    return;
  }
  
  /* Loop searching for ends of lines and storing the positions of the
   start of the next line in lineStarts */
  for ( line = startLine; line <= endLine; line++ ) {
    find_line_end(startPos, true, &lineEnd, &nextLineStart);
    startPos = nextLineStart;
    if ( startPos >= bufLen ) {
      /* If the buffer ends with a newline or line break, put
       buf->length() in the next line start position (instead of
       a -1 which is the normal marker for an empty line) to
       indicate that the cursor may safely be displayed there */
      if ( line == 0 || ( lineStarts[ line - 1 ] != bufLen &&
                         lineEnd != nextLineStart ) ) {
        lineStarts[ line ] = bufLen;
        line++;
      }
      break;
    }
    lineStarts[ line ] = startPos;
  }
  
  /* Set any entries beyond the end of the text to -1 */
  for ( ; line <= endLine; line++ )
    lineStarts[ line ] = -1;
}
/**
 \brief Update the line start arrays.
 
 Scan through the text in the "textD"'s buffer and recalculate the line
 starts array values beginning at index "startLine" and continuing through
 (including) "endLine".  It assumes that the line starts entry preceding
 "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.
 
 \param startLine, endLine range of lines to scan as line numbers
 */
\brief Update the line start arrays.

\param startLine, endLine range of lines to scan as line numbers
\ brief Update the line start arrays . \ param startLine endLine range of lines to scan as line numbers
void Fl_Text_Display::calc_line_starts( int startLine, int endLine ) {
  int startPos, bufLen = mBuffer->length();
  int line, lineEnd, nextLineStart, nVis = mNVisibleLines;
  int *lineStarts = mLineStarts;
  if ( endLine < 0 ) endLine = 0;
  if ( endLine >= nVis ) endLine = nVis - 1;
  if ( startLine < 0 ) startLine = 0;
  if ( startLine >= nVis ) startLine = nVis - 1;
  if ( startLine > endLine )
    return;
  if ( startLine == 0 ) {
    lineStarts[ 0 ] = mFirstChar;
    startLine = 1;
  }
  startPos = lineStarts[ startLine - 1 ];
  if ( startPos == -1 ) {
    for ( line = startLine; line <= endLine; line++ )
      lineStarts[ line ] = -1;
    return;
  }
  for ( line = startLine; line <= endLine; line++ ) {
    find_line_end(startPos, true, &lineEnd, &nextLineStart);
    startPos = nextLineStart;
    if ( startPos >= bufLen ) {
      if ( line == 0 || ( lineStarts[ line - 1 ] != bufLen &&
                         lineEnd != nextLineStart ) ) {
        lineStarts[ line ] = bufLen;
        line++;
      }
      break;
    }
    lineStarts[ line ] = startPos;
  }
  for ( ; line <= endLine; line++ )
    lineStarts[ line ] = -1;
}
void Fl_Text_Display :: calc_line_starts ( int startLine , int endLine ) { int startPos , bufLen = mBuffer -> length ( ) ; int line , lineEnd , nextLineStart , nVis = mNVisibleLines ; int * lineStarts = mLineStarts ; if ( endLine < 0 ) endLine = 0 ; if ( endLine >= nVis ) endLine = nVis - 1 ; if ( startLine < 0 ) startLine = 0 ; if ( startLine >= nVis ) startLine = nVis - 1 ; if ( startLine > endLine ) return ; if ( startLine == 0 ) { lineStarts [ 0 ] = mFirstChar ; startLine = 1 ; } startPos = lineStarts [ startLine - 1 ] ; if ( startPos == -1 ) { for ( line = startLine ; line <= endLine ; line ++ ) lineStarts [ line ] = -1 ; return ; } for ( line = startLine ; line <= endLine ; line ++ ) { find_line_end ( startPos , true , & lineEnd , & nextLineStart ) ; startPos = nextLineStart ; if ( startPos >= bufLen ) { if ( line == 0 || ( lineStarts [ line - 1 ] != bufLen && lineEnd != nextLineStart ) ) { lineStarts [ line ] = bufLen ; line ++ ; } break ; } lineStarts [ line ] = startPos ; } for ( ; line <= endLine ; line ++ ) lineStarts [ line ] = -1 ; }
\brief Update the line start arrays.
\ brief Update the line start arrays .
/* Clean up (possibly) messy input parameters */ /* Find the last known good line number -> position mapping */ /* If the starting position is already past the end of the text,
   fill in -1's (means no text on line) and return */ /* Loop searching for ends of lines and storing the positions of the
   start of the next line in lineStarts */ /* If the buffer ends with a newline or line break, put
       buf->length() in the next line start position (instead of
       a -1 which is the normal marker for an empty line) to
       indicate that the cursor may safely be displayed there */ /* Set any entries beyond the end of the text to -1 */