Text and code¶
PRISM has two kinds of text widgets.
Form text holds its text in a field: a text field for one line, a text area for a few. Right for a name, a message, a setting.
Documents hold their text in a
text::Document: a file, a log, a note, a page of code. Their views lay out only what is on screen, so a 100,000-line file types and scrolls as fast as a ten-line one.
This section covers documents.
struct CodeShowcase {
text::Document source{R"(#include <cstdio>
// Says hello.
int main() {
const char* name = "ada";
std::printf("Hello, %s!\n", name);
return 0;
})"};
void view(app::ViewBuilder& vb) { vb.code_editor(source, "cpp"); }
};
Page |
Covers |
|---|---|
|
|
|
|
the built-in languages, and plugging in your own highlighter |
|
|
|
a list of suggestions under the caret |
|
headings, lists and bold text; reading and writing Markdown |
Try them in the gallery’s Code tab: it opens a 100,000-line file on request.