SpellCheckScan.h header

#include <ew/app/SpellCheckScan.h>

Namespace ew::app

WordSpan struct

struct ew::app::WordSpan

A span of the analyzed text, in UTF-16 code units — one word the spell checker judges.

Members

qsizetype ew::app::style::WordSpan::offset = 0

Code-unit offset of the word within the analyzed text.

qsizetype ew::app::style::WordSpan::length = 0

Length of the word in code units.

bool operator==(const WordSpan &, const WordSpan &)=default

Spans compare equal when both fields match.

Functions

std::optional< WordSpan > ew::app::style::spellCheckWordAt(QStringView text, qsizetype offset)

The word of text containing offset, or std::nullopt when offset is not inside one. An offset at a word's very end counts as inside it, so right-clicking just past a word's last letter still finds it – which is where a click near a word's edge lands.

std::vector< WordSpan > ew::app::style::spellCheckWordSpans(QStringView text)

Every word in text that is a candidate for spell-checking, in order: a run of letters that may contain apostrophes but neither opens nor closes with one, so weren't is one word while the quotation marks around 'tired' are not part of it. Digits and symbols break a word, and a token containing a digit (v2, 3rd) is not a word at all.

This is the single scan the editor's red underline and its right-click menu both read, so a word can never be underlined without the menu finding it, nor the reverse.