mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
50 lines
1.5 KiB
C++
50 lines
1.5 KiB
C++
#ifndef CODE_EDITOR_VIEW_H
|
|
#define CODE_EDITOR_VIEW_H
|
|
|
|
#include <escher.h>
|
|
#include "python_text_area.h"
|
|
|
|
namespace Code {
|
|
|
|
class EditorView : public Responder, public View, public ScrollViewDelegate {
|
|
public:
|
|
EditorView(Responder * parentResponder, App * pythonDelegate);
|
|
void setTextAreaDelegates(InputEventHandlerDelegate * inputEventHandlerDelegate, TextAreaDelegate * delegate) {
|
|
m_textArea.setDelegates(inputEventHandlerDelegate, delegate);
|
|
}
|
|
const char * text() const { return m_textArea.text(); }
|
|
void setText(char * textBuffer, size_t textBufferSize) {
|
|
m_textArea.setText(textBuffer, textBufferSize);
|
|
}
|
|
bool setCursorLocation(int location) {
|
|
return m_textArea.setCursorLocation(location);
|
|
}
|
|
void loadSyntaxHighlighter() { m_textArea.loadSyntaxHighlighter(); };
|
|
void unloadSyntaxHighlighter() { m_textArea.unloadSyntaxHighlighter(); };
|
|
void scrollViewDidChangeOffset(ScrollViewDataSource * scrollViewDataSource) override;
|
|
void didBecomeFirstResponder() override;
|
|
private:
|
|
int numberOfSubviews() const override;
|
|
View * subviewAtIndex(int index) override;
|
|
void layoutSubviews() override;
|
|
|
|
class GutterView : public View {
|
|
public:
|
|
GutterView(const KDFont * font);
|
|
void drawRect(KDContext * ctx, KDRect rect) const override;
|
|
void setOffset(KDCoordinate offset);
|
|
KDSize minimalSizeForOptimalDisplay() const override;
|
|
private:
|
|
static constexpr KDCoordinate k_margin = 2;
|
|
const KDFont * m_font;
|
|
KDCoordinate m_offset;
|
|
};
|
|
|
|
PythonTextArea m_textArea;
|
|
GutterView m_gutterView;
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|