vendor/fltk-sys/cfltk/fltk/src/Fl_Text_Display.cxx
/**
  Convert a position index into a line number offset.

  Find the line number of position \p pos relative to the first line of
  displayed text, counting from 0 to <i>visible lines - 1</i>.
  The line number is returned in \p lineNum.

  Returns 0 if the line is not displayed. In this case \p lineNum is 0 as well.

  Returns 1 if the line is displayed. In this case \p lineNum is the relative
  line number.

  \param[in]  pos       byte position in buffer
  \param[out] lineNum   relative line number of byte \p pos in buffer

  \returns whether the character at byte position \p pos is currently displayed
  \retval 0 \p pos is not displayed; \p lineNum is invalid (zero)
  \retval 1 \p pos is displayed; \p lineNum is valid
*/
Convert a position index into a line number offset.
Find the line number of position \p pos relative to the first line of
displayed text, counting from 0 to visible lines - 1.
The line number is returned in \p lineNum.

Returns 0 if the line is not displayed. In this case \p lineNum is 0 as well.

Returns 1 if the line is displayed. In this case \p lineNum is the relative
line number.

\param[in]  pos       byte position in buffer
\param[out] lineNum   relative line number of byte \p pos in buffer


Convert a position index into a line number offset . Find the line number of position \ p pos relative to the first line of displayed text counting from 0 to visible lines - 1 . The line number is returned in \ p lineNum . Returns 0 if the line is not displayed . In this case \ p lineNum is 0 as well . Returns 1 if the line is displayed . In this case \ p lineNum is the relative line number . \ param [ in ] pos byte position in buffer \ param [ out ] lineNum relative line number of byte \ p pos in buffer
int Fl_Text_Display::position_to_line( int pos, int *lineNum ) const {
  IS_UTF8_ALIGNED2(buffer(), pos)
  int i;
  *lineNum = 0;
  if ( pos < mFirstChar ) return 0;
  if ( pos > mLastChar ) {
    if ( empty_vlines() ) {
      if ( mLastChar < mBuffer->length() ) {
        if ( !position_to_line( mLastChar, lineNum ) ) {
          Fl::error("Fl_Text_Display::position_to_line(): Consistency check ptvl failed");
          return 0;
        }
        return ++( *lineNum ) <= mNVisibleLines - 1;
      } else {
        position_to_line( buffer()->prev_char_clipped(mLastChar), lineNum );
        return 1;
      }
    }
    return 0;
  }
  for ( i = mNVisibleLines - 1; i >= 0; i-- ) {
    if ( mLineStarts[ i ] != -1 && pos >= mLineStarts[ i ] ) {
      *lineNum = i;
      return 1;
    }
  }
  return 0;   
}
int Fl_Text_Display :: position_to_line ( int pos , int * lineNum ) const { IS_UTF8_ALIGNED2 ( buffer ( ) , pos ) int i ; * lineNum = 0 ; if ( pos < mFirstChar ) return 0 ; if ( pos > mLastChar ) { if ( empty_vlines ( ) ) { if ( mLastChar < mBuffer -> length ( ) ) { if ( ! position_to_line ( mLastChar , lineNum ) ) { Fl :: error ( " " ) ; return 0 ; } return ++ ( * lineNum ) <= mNVisibleLines - 1 ; } else { position_to_line ( buffer ( ) -> prev_char_clipped ( mLastChar ) , lineNum ) ; return 1 ; } } return 0 ; } for ( i = mNVisibleLines - 1 ; i >= 0 ; i -- ) { if ( mLineStarts [ i ] != -1 && pos >= mLineStarts [ i ] ) { * lineNum = i ; return 1 ; } } return 0 ; }
Convert a position index into a line number offset.
Convert a position index into a line number offset .
/* probably never be reached */