<commit_before>\section{Cursor Positioning}

Once a widget is properly positioned, the widget can display a cursor.
This is especially useful for edit widgets, since the user needs to
know the cursor position.  The \fw{Core} module provides a top-level
function to accomplish this called \fw{getCursorPosition}; this
function calls the \fw{WidgetImpl} type's \fw{getCursorPosition\_}
function to query widgets.

The \fw{getCursorPosition\_} function returns \fw{Maybe
  DisplayRegion}; a return value of \fw{Nothing} indicates that the
widget does not want to show a cursor, so when it gains focus, no
cursor will be displayed.  Otherwise, positioning the cursor at row
\fw{r} and column \fw{c} is accomplished by returning \fw{Just
  (DisplayRegion r c)}.  The cursor is then shown at that location by
the event loop.

Typically, the position of the cursor is computed as an offset to the
widget's current position.  In Section \ref{sec:deferring} we deferred
to the child widget to control the cursor, but we might instead
specify our own position:

\begin{minted}{haskell}
 getCursorPosition_ = \this -> do
   childCursor <- getCursorPosition child
   case childCursor of
     Nothing -> return Nothing
     Just pos -> return $ Just $ pos `plusWidth` 1 `plusHeight` 1
\end{minted}
<commit_msg>Manual updates<commit_after>\section{Cursor Positioning}

Once a widget is properly positioned, the widget can display a cursor.
This is especially useful for edit widgets, since the user needs to
know the cursor position.  The \fw{Core} module provides a top-level
function to accomplish this called \fw{getCursorPosition}; this
function calls the \fw{WidgetImpl} type's \fw{getCursorPosition\_}
function to query widgets.

The \fw{getCursorPosition\_} function returns \fw{Maybe
  DisplayRegion}; a return value of \fw{Nothing} indicates that the
widget does not want to show a cursor, so when it gains focus, no
cursor will be displayed.  Otherwise, positioning the cursor at row
\fw{r} and column \fw{c} is accomplished by returning \fw{Just
  (DisplayRegion r c)}.  The cursor is then shown at that location by
the event loop.

Typically, the position of the cursor is computed as an offset to the
widget's current position.  In Section \ref{sec:deferring} we deferred
to the child widget to control the cursor, but we might instead
specify our own position:

\begin{minted}{haskell}
 getCursorPosition_ = \this -> do
   (Wrapper child) <- getState this
   childCursor <- getCursorPosition child
   case childCursor of
     Nothing -> return Nothing
     Just pos -> return $ Just $ pos `plusWidth` 1 `plusHeight` 1
\end{minted}

{'fraction_non_alphanumeric': 0.06841505131128849, 'fraction_numerical': 0.0015203344735841885, 'mean_word_length': 4.360488798370672, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6407013', 'n_tokens_mistral': 714, 'n_tokens_neox': 696, 'n_words': 355}