mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[code] Python toolbox.
Change-Id: I4028b05c662cae04a5ac3af5021f3438bb22dcd0
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "app.h"
|
||||
#include "../apps_container.h"
|
||||
#include "code_icon.h"
|
||||
#include "../shared/toolbox_helpers.h"
|
||||
#include "../i18n.h"
|
||||
|
||||
namespace Code {
|
||||
@@ -38,7 +39,25 @@ App::App(Container * container, Snapshot * snapshot) :
|
||||
::App(container, snapshot, &m_codeStackViewController, I18n::Message::Warning),
|
||||
m_listFooter(&m_codeStackViewController, &m_menuController, &m_menuController, ButtonRowController::Position::Bottom, ButtonRowController::Style::EmbossedGrey),
|
||||
m_menuController(&m_listFooter, snapshot->scriptStore(), &m_listFooter),
|
||||
m_codeStackViewController(&m_modalViewController, &m_listFooter)
|
||||
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
|
||||
// position we want (which is after the first parenthesis or before the
|
||||
// first point).
|
||||
int deltaCursorLocation = - (strlen(text) - Shared::ToolboxHelpers::CursorIndexInCommand(text));
|
||||
textArea->moveCursor(deltaCursorLocation);
|
||||
}),
|
||||
m_toolboxActionForTextField([](void * sender, const char * text) {
|
||||
TextField * textField = static_cast<TextField *>(sender);
|
||||
if (!textField->isEditing()) {
|
||||
textField->setEditing(true);
|
||||
}
|
||||
int newCursorLocation = textField->cursorLocation() + Shared::ToolboxHelpers::CursorIndexInCommand(text);
|
||||
textField->insertTextAtLocation(text, textField->cursorLocation());
|
||||
textField->setCursorLocation(newCursorLocation);
|
||||
})
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user