nano-ui
Safe HaskellNone
LanguageGHC2024

NanoUI.Frame.TextEdit

Description

Text-field editing facade: single-line fields (NanoUI.Frame.TextInput), text areas (NanoUI.Frame.TextArea) and their context menu (NanoUI.Frame.TextEdit.Menu), plus the dispatchers that pick between the two field kinds.

Synopsis

Dispatch between field kinds

finalizeTextFieldMouse :: Context -> Input -> IO () Source #

Mouse selection in the focused field, whichever kind it is. A release ends any drag.

Context menu

textEditMenuRectAt :: Float -> Float -> Float -> Size -> Rect Source #

Menu rect at the pointer, kept inside the window.

Shared field helpers

normalizeTextFieldClicks :: Context -> WidgetId -> Int -> Int -> Int -> Bool -> Int -> IO Int Source #

Count a press as a multi-click only when it lands on the same cell as the previous press; anything else restarts the count at one.

textWordBounds :: Text -> Int -> (Int, Int) Source #

Find the word bounds around a character position in text.

Text areas

resolveTextAreaFont :: Context -> NodeIdx -> IO FontMetrics Source #

Font the text-area content is laid out and painted in. Honors the node's layoutFontSize (set via fontSize on the editor layout) so a single text area can zoom without changing the rest of the UI. A size of 0 means the base UI font.

textAreaContentMetrics :: Context -> NodeIdx -> IO (Float, Float) Source #

Content extent of a text area, (contentWidth, contentHeight). Measuring the width scans every character of the document, so the result is cached per widget and only refreshed when the text changes (the editor clears SlotTextAreaContentFont) or the node font changes.

textAreaBarLane :: Float Source #

Width of the vertical and height of the horizontal scrollbar lane.

textAreaLineHeight :: FontMetrics -> Float Source #

Text area row height, snapped to the device pixel grid.