mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[code] Auto-indentation when inserting Toolbox items in scripts.
Change-Id: Id444ab91965999a3d322dee2fa58f73c86aa6992
This commit is contained in:
@@ -42,11 +42,16 @@ App::App(Container * container, Snapshot * snapshot) :
|
||||
m_codeStackViewController(&m_modalViewController, &m_listFooter),
|
||||
m_toolboxActionForTextArea([](void * sender, const char * text) {
|
||||
TextArea * textArea = static_cast<TextArea *>(sender);
|
||||
textArea->insertText(text);
|
||||
// insertText() also moves the cursor. We need to remove it to the
|
||||
int previousCursorLocation = textArea->cursorLocation();
|
||||
textArea->insertTextWithIndentation(text);
|
||||
// insertText() also moves the cursor. We need to re-move it to the
|
||||
// position we want (which is after the first parenthesis or before the
|
||||
// first point).
|
||||
int deltaCursorLocation = - (strlen(text) - Shared::ToolboxHelpers::CursorIndexInCommand(text));
|
||||
int deltaCursorLocation = - textArea->cursorLocation() + previousCursorLocation + Shared::ToolboxHelpers::CursorIndexInCommand(text);
|
||||
// WARNING: This is a dirty and only works because the cursor location we
|
||||
// want is always on the first line of the text we insert. Because of the
|
||||
// auto indentation, it would be difficult to compute the wanted cursor
|
||||
// location on other lines of the text.
|
||||
textArea->moveCursor(deltaCursorLocation);
|
||||
}),
|
||||
m_toolboxActionForTextField([](void * sender, const char * text) {
|
||||
|
||||
Reference in New Issue
Block a user