14 m_areaBuffer(nullptr),
15 m_script(
Ion::Storage::Record()),
16 m_menuController(menuController)
23 m_areaBuffer =
nullptr;
29 size_t scriptBodySize =
strlen(scriptBody)+1;
31 assert(m_areaBuffer ==
nullptr);
32 m_areaBuffer =
new char[availableScriptSize];
33 strlcpy(m_areaBuffer, scriptBody, scriptBodySize);
34 m_textArea.
setText(m_areaBuffer, availableScriptSize);
44 stackController()->
pop();
61 delete[] m_areaBuffer;
62 m_areaBuffer =
nullptr;
66 if (static_cast<App *>(textArea->
app())->textInputDidReceiveEvent(textArea, event)) {
71 char * text =
const_cast<char *
>(textArea->
text());
73 int indentationSize = 0;
75 if (charBeforeCursorIndex >= 0 && text[charBeforeCursorIndex] ==
':') {
76 indentationSize += k_indentationSpacesNumber;
79 int indentationIndex = charBeforeCursorIndex;
80 while (indentationIndex >= 0 && text[indentationIndex] !=
'\n') {
83 if (indentationIndex >= 0) {
85 while (text[indentationIndex] ==
' ') {
90 char * indentationBuffer =
new char [indentationSize+2];
91 indentationBuffer[0] =
'\n';
92 for (
int i = 0; i < indentationSize; i++) {
93 indentationBuffer[i+1] =
' ';
95 indentationBuffer[indentationSize+1] = 0;
97 delete[] indentationBuffer;
104 char * text =
const_cast<char *
>(textArea->
text());
106 int indentationSize = 0;
107 while (charBeforeCursorIndex >= 0 && text[charBeforeCursorIndex] ==
' ') {
108 charBeforeCursorIndex--;
111 if (charBeforeCursorIndex >= 0 && text[charBeforeCursorIndex] ==
'\n' 112 && indentationSize >= k_indentationSpacesNumber)
114 for (
int i = 0; i < k_indentationSpacesNumber; i++) {
122 char * text =
const_cast<char *
>(textArea->
text());
124 while (charBeforeCursorIndex >= 0 && text[charBeforeCursorIndex] ==
' ') {
125 charBeforeCursorIndex--;
127 if (charBeforeCursorIndex >= 0 && text[charBeforeCursorIndex] ==
'\n') {
128 char indentationBuffer[k_indentationSpacesNumber+1];
129 for (
int i = 0; i < k_indentationSpacesNumber; i++) {
130 indentationBuffer[i] =
' ';
132 indentationBuffer[k_indentationSpacesNumber] = 0;
bool setCursorLocation(int location)
Toolbox * toolboxForTextInput(TextInput *textInput) override
size_t cursorLocation() const
Responder * parentResponder() const
EditorController(MenuController *menuController)
void viewDidDisappear() override
size_t strlcpy(char *dst, const char *src, size_t len)
const char * readContent() const
bool handleEvent(Ion::Events::Event event) override
void setScript(Script script)
static Storage * sharedStorage()
size_t strlen(const char *s)
void setDelegate(TextAreaDelegate *delegate)
PythonToolbox * pythonToolbox()
bool textAreaDidReceiveEvent(TextArea *textArea, Ion::Events::Event event) override
const char * text() const
void viewWillAppear() override
void setText(char *textBuffer, size_t textBufferSize)
void setFirstResponder(Responder *responder)
void didBecomeFirstResponder() override
ErrorStatus writeContent(const char *data, size_t size)
bool handleEventWithText(const char *text, bool indentation=false) override
constexpr Event Backspace