6663b6c9
adorian
projet complet av...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#include "app.h"
#include "../apps_container.h"
#include "code_icon.h"
#include "../shared/toolbox_helpers.h"
#include "../i18n.h"
namespace Code {
I18n::Message App::Descriptor::name() {
return I18n::Message::CodeApp;
}
I18n::Message App::Descriptor::upperName() {
return I18n::Message::CodeAppCapital;
}
const Image * App::Descriptor::icon() {
return ImageStore::CodeIcon;
}
App * App::Snapshot::unpack(Container * container) {
return new App(container, this);
}
void App::Snapshot::reset() {
m_scriptStore.deleteAllScripts();
}
App::Descriptor * App::Snapshot::descriptor() {
static Descriptor descriptor;
return &descriptor;
}
ScriptStore * App::Snapshot::scriptStore() {
return &m_scriptStore;
}
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, ButtonRowController::Size::Large),
m_menuController(&m_listFooter, snapshot->scriptStore(), &m_listFooter),
m_codeStackViewController(&m_modalViewController, &m_listFooter),
m_toolboxActionForTextArea([](void * sender, const char * text) {
TextArea * textArea = static_cast<TextArea *>(sender);
int previousCursorLocation = textArea->cursorLocation();
if (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 = - 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) {
TextField * textField = static_cast<TextField *>(sender);
if (!textField->isEditing()) {
textField->setEditing(true);
}
int newCursorLocation = textField->cursorLocation() + Shared::ToolboxHelpers::CursorIndexInCommand(text);
if (textField->insertTextAtLocation(text, textField->cursorLocation())) {
textField->setCursorLocation(newCursorLocation);
}}),
m_variableBoxController(&m_menuController, snapshot->scriptStore())
{
}
}
|