Version: 01.10.00 - last Update: Tuesday, October 13, 2009, 12:40:00
_EdGetChar | _EdGetLNum | _EdGetLPos | _EdGetStr | _EdPosInVi | _EdSkipLin
Foxtools Editor Support Functions
_EDGETPOS
_EdGetPos() Returns either the starting point of highlighted text or the caret position in the editor session passed in <nWHAND> parameter.
VFP Syntax
nOffset = _EdGetPos(nWHAND)
Parameters
[in] nWHAND
Fox-window handle of the editor session in question. If nWHANDL is no valid editor-session handle, an error “API call caused an exception” (Error 2028) is raised.
Returns
Numeric – the number of bytes from the beginning of file. The return value is zero-based.
Remarks
_EdGetPos() counts all characters in the editor’s text buffer from BOF -> offset = 0. CRs at each end of line (EOL) are counted as well.
Note: The starting point of any highlighted text block is called the anchor position within the file. The anchor position can be at the beginning of the highlighted block or at its end. This depends on the direction the mouse was dragged over the text to highlight it. Dragging the mouse from right to left while highlighting causes the anchor to be at the right end of the selection area.
VFP Example(s)
Opening an editor session and returning the the caret position and selection information:
CLEAR *\\ Open editor session *\\ use file content like shown above nWHAND =_EDOPENFIL("TEST.TXT", 1) *\\ get caret position nCaret = _EdGetPos(m.nWHAND) *\\ get editor session environment LOCAL ARRAY aEnv[25] IF _EdGetEnv(m.nWHAND, @aEnv) = 1 ? aEnv[17] && selection Start ? aEnv[18] && selection End ? aEnv[19] && selection Anchor *\\ highlight test IF aEnv[17] = aEnv[18] ? "no text selected" ELSE *\\ dragging direction IF aEnv[19] = aEnv[17] ? "text selected from left to right" ELSE ? "text selected from right to left" ENDIF ENDIF *\\ caret position always equals to anchor ? "m.nCaret = aEnv[19] >>> " + TRANSFORM(m.nCaret = aEnv[19]) ENDIF