Files
Upsilon/apps/code/variable_box_controller.h
Émilie Feral a4f7d83805 [code] Load Variable box content before compiling any other python code
to avoid memory exhaustion when displaying variable box
2018-11-23 12:04:03 +01:00

48 lines
1.5 KiB
C++

#ifndef CODE_VARIABLE_BOX_CONTROLLER_H
#define CODE_VARIABLE_BOX_CONTROLLER_H
#include <escher.h>
#include "script_node.h"
#include "script_node_cell.h"
#include "script_store.h"
namespace Code {
class App;
class VariableBoxController : public NestedMenuController {
public:
VariableBoxController(App * pythonDelegate, ScriptStore * scriptStore);
/* Responder */
bool handleEvent(Ion::Events::Event event) override;
void didEnterResponderChain(Responder * previousFirstResponder) override;
/* ListViewDataSource */
int numberOfRows() override;
int reusableCellCount(int type) override;
void willDisplayCellForIndex(HighlightCell * cell, int index) override;
int typeAtLocation(int i, int j) override;
/* VariableBoxController */
void loadFunctionsAndVariables();
private:
constexpr static int k_maxScriptObjectNameSize = 100;
constexpr static int k_maxNumberOfDisplayedRows = 6; //240/40
constexpr static int k_maxScriptNodesCount = 32;
HighlightCell * leafCellAtIndex(int index) override;
HighlightCell * nodeCellAtIndex(int index) override { return nullptr; }
bool selectLeaf(int rowIndex) override;
void insertTextInCaller(const char * text);
void addFunctionAtIndex(const char * functionName, int scriptIndex);
void addVariableAtIndex(const char * variableName, int scriptIndex);
App * m_pythonDelegate;
ScriptNode m_scriptNodes[k_maxScriptNodesCount];
int m_scriptNodesCount;
ScriptStore * m_scriptStore;
ScriptNodeCell m_leafCells[k_maxNumberOfDisplayedRows];
};
}
#endif