mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/escher] Factorize TxtArea and Code::EditorCtrlr's k_indentSpaces
This commit is contained in:
@@ -82,8 +82,8 @@ bool EditorController::textAreaDidReceiveEvent(TextArea * textArea, Ion::Events:
|
||||
cursorIsPrecededOnTheLineBySpacesOnly = true;
|
||||
}
|
||||
numberOfSpaces = numberOfSpaces / UTF8Decoder::CharSizeOfCodePoint(' ');
|
||||
if (cursorIsPrecededOnTheLineBySpacesOnly && numberOfSpaces >= k_indentationSpacesNumber) {
|
||||
for (int i = 0; i < k_indentationSpacesNumber; i++) {
|
||||
if (cursorIsPrecededOnTheLineBySpacesOnly && numberOfSpaces >= TextArea::k_indentationSpaces) {
|
||||
for (int i = 0; i < TextArea::k_indentationSpaces; i++) {
|
||||
textArea->removePreviousGlyph();
|
||||
}
|
||||
return true;
|
||||
@@ -96,11 +96,11 @@ bool EditorController::textAreaDidReceiveEvent(TextArea * textArea, Ion::Events:
|
||||
assert(firstNonSpace >= text);
|
||||
if (UTF8Helper::CodePointIs(firstNonSpace, '\n')) {
|
||||
assert(UTF8Decoder::CharSizeOfCodePoint(' ') == 1);
|
||||
char indentationBuffer[k_indentationSpacesNumber+1];
|
||||
for (int i = 0; i < k_indentationSpacesNumber; i++) {
|
||||
char indentationBuffer[TextArea::k_indentationSpaces+1];
|
||||
for (int i = 0; i < TextArea::k_indentationSpaces; i++) {
|
||||
indentationBuffer[i] = ' ';
|
||||
}
|
||||
indentationBuffer[k_indentationSpacesNumber] = 0;
|
||||
indentationBuffer[TextArea::k_indentationSpaces] = 0;
|
||||
textArea->handleEventWithText(indentationBuffer);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ public:
|
||||
VariableBoxController * variableBoxForInputEventHandler(InputEventHandler * textInput) override;
|
||||
|
||||
private:
|
||||
static constexpr int k_indentationSpacesNumber = 2; //TODO LEA merge with text area k_indentationSpaces
|
||||
StackViewController * stackController();
|
||||
void saveScript();
|
||||
EditorView m_editorView;
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
class TextArea : public TextInput, public InputEventHandler {
|
||||
public:
|
||||
static constexpr int k_indentationSpaces = 2;
|
||||
|
||||
TextArea(Responder * parentResponder, View * contentView, const KDFont * font = KDFont::LargeFont);
|
||||
void setDelegates(InputEventHandlerDelegate * inputEventHandlerDelegate, TextAreaDelegate * delegate) { m_inputEventHandlerDelegate = inputEventHandlerDelegate; m_delegate = delegate; }
|
||||
bool handleEvent(Ion::Events::Event event) override;
|
||||
@@ -124,7 +126,6 @@ protected:
|
||||
|
||||
ContentView * contentView() { return static_cast<ContentView *>(TextInput::contentView()); }
|
||||
private:
|
||||
static constexpr int k_indentationSpaces = 2;
|
||||
TextAreaDelegate * m_delegate;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user