SpellingUserWords class

Namespace Runic.Spelling in Runic.Spelling 0.23.0-preview.1

public sealed class SpellingUserWords

The user's own words, which every checker given them counts as spelled right: a UTF-8 file of one word per line. By default the file all Runic applications of the user share (SpellingUserWords.SharedPath), so a word added in one is known in all; an application may name its own. Safe to use from several threads.

Remarks

Adding and removing read the file again before writing it, so the words another application added since are kept, and write it whole to a temporary file that then replaces it. A file that cannot be read counts as empty; one that cannot be written keeps the change for this process.

Properties

Path

public string Path { get; }

The word list's file.

SharedPath

public static string SharedPath { get; }

The file all Runic applications of the user share: user-words.txt in $XDG_DATA_HOME/runic on Linux, %LOCALAPPDATA%\Runic on Windows, ~/Library/Application Support/Runic on macOS.

Words

public IReadOnlyList<string> Words { get; }

The words, in ordinal order.

Methods

AddAsync

public Task<bool> AddAsync(string word, CancellationToken cancellationToken = default)

Adds word; false when it was there.

Exceptions

ArgumentException

word is empty or not one word.

Contains

public bool Contains(string word)

Whether word is one of the words as written.

OpenAsync

public static Task<SpellingUserWords> OpenAsync(string? path = null, CancellationToken cancellationToken = default)

Reads the word list in path, or SpellingUserWords.SharedPath; a missing file is an empty list that adding a word creates.

ReloadAsync

public Task ReloadAsync(CancellationToken cancellationToken = default)

Reads the file again, for words another application changed.

RemoveAsync

public Task<bool> RemoveAsync(string word, CancellationToken cancellationToken = default)

Removes word; false when it was not there.