mod/maxgui.mod/fltkmaxgui.mod/src/Fl_Text_Display.cxx
int Fl_Text_Display::xy_to_position( int X, int Y, int posType ) const {
  int lineStart, lineLen, fontHeight;
  int visLineNum;
  
  /* Find the visible line number corresponding to the Y coordinate */
  fontHeight = mMaxsize;
  visLineNum = ( Y - text_area.y ) / fontHeight;
  if ( visLineNum < 0 )
    return mFirstChar;
  if ( visLineNum >= mNVisibleLines )
    visLineNum = mNVisibleLines - 1;
  
  /* Find the position at the start of the line */
  lineStart = mLineStarts[ visLineNum ];
  
  /* If the line start was empty, return the last position in the buffer */
  if ( lineStart == -1 )
    return mBuffer->length();
  
  /* Get the line text and its length */
  lineLen = vline_length( visLineNum );
  
  return handle_vline(FIND_INDEX, 
                      lineStart, lineLen, 0, 0, 
                      0, 0,
                      text_area.x, X);
}
/**
 \brief Translate a pixel position into a charcter index.
 
 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).
 
 \param X, Y pixel position
 \param posType CURSOR_POS or CHARACTER_POS
 \return index into text buffer
 */
\brief Translate a pixel position into a charcter index.
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).

\param X, Y pixel position
\param posType CURSOR_POS or CHARACTER_POS
\return index into text buffer
\ brief Translate a pixel position into a charcter index . 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 ) . \ param X Y pixel position \ param posType CURSOR_POS or CHARACTER_POS \ return index into text buffer
int Fl_Text_Display::xy_to_position( int X, int Y, int posType ) const {
  int lineStart, lineLen, fontHeight;
  int visLineNum;
  fontHeight = mMaxsize;
  visLineNum = ( Y - text_area.y ) / fontHeight;
  if ( visLineNum < 0 )
    return mFirstChar;
  if ( visLineNum >= mNVisibleLines )
    visLineNum = mNVisibleLines - 1;
  lineStart = mLineStarts[ visLineNum ];
  if ( lineStart == -1 )
    return mBuffer->length();
  lineLen = vline_length( visLineNum );
  return handle_vline(FIND_INDEX, 
                      lineStart, lineLen, 0, 0, 
                      0, 0,
                      text_area.x, X);
}
int Fl_Text_Display :: xy_to_position ( int X , int Y , int posType ) const { int lineStart , lineLen , fontHeight ; int visLineNum ; fontHeight = mMaxsize ; visLineNum = ( Y - text_area . y ) / fontHeight ; if ( visLineNum < 0 ) return mFirstChar ; if ( visLineNum >= mNVisibleLines ) visLineNum = mNVisibleLines - 1 ; lineStart = mLineStarts [ visLineNum ] ; if ( lineStart == -1 ) return mBuffer -> length ( ) ; lineLen = vline_length ( visLineNum ) ; return handle_vline ( FIND_INDEX , lineStart , lineLen , 0 , 0 , 0 , 0 , text_area . x , X ) ; }
\brief Translate a pixel position into a charcter index.
\ brief Translate a pixel position into a charcter index .
/* Find the visible line number corresponding to the Y coordinate */ /* Find the position at the start of the line */ /* If the line start was empty, return the last position in the buffer */ /* Get the line text and its length */