undoStudio
The IDE of the undoRT ecosystem
Loading...
Searching...
No Matches
undoAppSTSnippet.hpp
Go to the documentation of this file.
1
22#pragma once
23
24#include <string>
25#include <vector>
26
27namespace undoApp {
28namespace ST {
29
33enum class SnippetPane
34{
35 Variables,
36 Body
37};
38
53{
54 std::string label;
55 std::string detail;
56 std::string insert;
58 std::vector<std::string> lines;
59 int caretLine = 0;
60 int caretColumn = 0;
61};
62
67const std::vector<StatementSnippet>& allStatementSnippets();
68
74std::vector<StatementSnippet> snippetsForPane(SnippetPane pane);
75
89bool hasStatementPrefix(const std::string& prefix);
90
101std::string statementPrefixAt(const std::string& line, int column, int& startCol);
102
115void rankSnippets(std::vector<StatementSnippet>& snippets, const std::string& prefix);
116
122std::string leadingWhitespace(const std::string& line);
123
139void expandSnippet(const StatementSnippet& snippet, const std::string& base, const std::string& tab, std::string& text,
140 int& caretLine, int& caretCol);
141
142} // namespace ST
143} // namespace undoApp
void expandSnippet(const StatementSnippet &snippet, const std::string &base, const std::string &tab, std::string &text, int &caretLine, int &caretCol)
Write a snippet out at a line, in the indentation already in force there.
std::string statementPrefixAt(const std::string &line, int column, int &startCol)
The word being typed at the caret.
std::string leadingWhitespace(const std::string &line)
Indentation of a line, spaces and tabs alike.
bool hasStatementPrefix(const std::string &prefix)
Whether the list is worth opening for what has been typed.
SnippetPane
The pane a snippet is written into.
Definition undoAppSTSnippet.hpp:34
@ Variables
The Variables pane, which holds the VAR sections.
@ Body
The Body pane, which holds the cyclic code.
void rankSnippets(std::vector< StatementSnippet > &snippets, const std::string &prefix)
Keep the snippets matching a prefix, best match first.
std::vector< StatementSnippet > snippetsForPane(SnippetPane pane)
The snippets belonging to one pane.
const std::vector< StatementSnippet > & allStatementSnippets()
The statements on offer.
Definition undoAppCpp.hpp:26
One statement skeleton the suggestion list can write out.
Definition undoAppSTSnippet.hpp:53
int caretLine
Template line the caret lands on.
Definition undoAppSTSnippet.hpp:59
std::string label
What the list shows, e.g. "IF ... END_IF".
Definition undoAppSTSnippet.hpp:54
std::string detail
Dimmed right-hand column: what it is for.
Definition undoAppSTSnippet.hpp:55
SnippetPane pane
Definition undoAppSTSnippet.hpp:57
int caretColumn
Caret column, before the base indentation.
Definition undoAppSTSnippet.hpp:60
std::string insert
Keyword written when the skeleton is accepted.
Definition undoAppSTSnippet.hpp:56
std::vector< std::string > lines
Template lines, "\t" for one indent step.
Definition undoAppSTSnippet.hpp:58