MatchEditor(3I)

✨ MatchEditor(3I) ✨

okay bestie so this is a page from the InterViews Reference Manual, section 3I, and the whole vibe is: string editor but it finishes your sentences for you πŸ’… (yes, the page is called MatchEditor, but the star of the show is lowkey named CompletionEditor β€” we don't make the rules, we just report them fr fr).


🌸 NAME 🌸

MatchEditor β€” a StringEditor with string completion ✨


πŸŽ€ SYNOPSIS πŸŽ€

#include <InterViews/compeditor.h>

πŸ¦‹ DESCRIPTION πŸ¦‹

CompletionEditor is a StringEditor subclass, and her whole main character thing is that she can complete whatever's currently chillin' in the edit buffer, matched against a list of strings you give her. She's literally made for the situation where the user has to pick one thing out of a huge pile of well-known strings β€” instead of typing the whole thing out like a peasant, they type the first few characters, then hit the completion character, and she fills in the rest. slay πŸ’–

so here's the lore, no cap: when the user types the completion character, CompletionEditor checks the current string against the list of possible completions. 🧚

  • if the current string is a prefix of one or more completion strings, characters get appended so the edit string holds the longest common prefix 🌈
  • if the current string doesn't match any completion string, trailing characters get removed until the string matches at least one completion βœ‚οΈ
  • and in any case, if there's more than one possible completion of a string, CompletionEditor rings the workstation bell πŸ”” (yes she's dramatic, we love that for her)

πŸ‘‘ PUBLIC OPERATIONS πŸ‘‘

πŸ’œ CompletionEditor(ButtonState*, const char* sample, const char* done)

spin up a brand new CompletionEditor object ✨ The ButtonState, the sample string, and the done termination string all get passed straight along to the StringEditor constructor. passing the aux cord, basically 🎧

πŸ’œ void Completions(const char* completions[], int count, char complete)

tell her the list of completion strings and the completion character πŸ’« Heads up though:

  • the initial completion list is empty πŸ™ˆ
  • the completion character defaults to a space ␣
  • and ngl, CompletionEditor does not copy the strings in the list β€” she just points at them, so keep them alive, bestie πŸ‘€

πŸ”₯ SEE ALSO πŸ”₯

StringEditor(3I) β€” her origin story πŸ’…


and that's the whole page, periodt 🫢 This gem dropped as part of InterViews, dated 13 Dec 1989 β€” vintage but make it iconic πŸ‘‘βœ¨