diff --git a/TextEditor.h b/TextEditor.h index bd52e131..951921a3 100644 --- a/TextEditor.h +++ b/TextEditor.h @@ -48,14 +48,14 @@ class TextEditor struct Breakpoint { - int mLine; - bool mEnabled; - std::string mCondition; - Breakpoint() : mLine(-1) , mEnabled(false) {} + + bool mEnabled; + int mLine; + std::string mCondition; }; // Represents a character coordinate from the user's point of view, @@ -67,7 +67,6 @@ class TextEditor // because it is rendered as " ABC" on the screen. struct Coordinates { - int mLine, mColumn; Coordinates() : mLine(0), mColumn(0) {} Coordinates(int aLine, int aColumn) : mLine(aLine), mColumn(aColumn) { @@ -117,6 +116,9 @@ class TextEditor return mLine > o.mLine; return mColumn >= o.mColumn; } + + + int mLine, mColumn; }; struct Identifier @@ -135,8 +137,8 @@ class TextEditor struct Glyph { - Char mChar; PaletteIndex mColorIndex = PaletteIndex::Default; + Char mChar; bool mComment : 1; bool mMultiLineComment : 1; bool mPreprocessor : 1; @@ -152,21 +154,7 @@ class TextEditor { typedef std::pair TokenRegexString; typedef std::vector TokenRegexStrings; - typedef bool(*TokenizeCallback)(const char * in_begin, const char * in_end, const char *& out_begin, const char *& out_end, PaletteIndex & paletteIndex); - - std::string mName; - Keywords mKeywords; - Identifiers mIdentifiers; - Identifiers mPreprocIdentifiers; - std::string mCommentStart, mCommentEnd, mSingleLineComment; - char mPreprocChar; - bool mAutoIndentation; - - TokenizeCallback mTokenize; - - TokenRegexStrings mTokenRegexStrings; - - bool mCaseSensitive; + typedef bool(*TokenizeCallback)(const char* in_begin, const char* in_end, const char*& out_begin, const char*& out_end, PaletteIndex& paletteIndex); LanguageDefinition() : mPreprocChar('#'), mAutoIndentation(true), mTokenize(nullptr), mCaseSensitive(true) @@ -180,6 +168,18 @@ class TextEditor static const LanguageDefinition& SQL(); static const LanguageDefinition& AngelScript(); static const LanguageDefinition& Lua(); + + + bool mCaseSensitive; + bool mAutoIndentation; + char mPreprocChar; + TokenizeCallback mTokenize; + Keywords mKeywords; + TokenRegexStrings mTokenRegexStrings; + Identifiers mIdentifiers; + Identifiers mPreprocIdentifiers; + std::string mName; + std::string mCommentStart, mCommentEnd, mSingleLineComment; }; TextEditor(); @@ -218,13 +218,13 @@ class TextEditor Coordinates GetCursorPosition() const { return GetActualCursorCoordinates(); } void SetCursorPosition(const Coordinates& aPosition); - inline void SetHandleMouseInputs (bool aValue){ mHandleMouseInputs = aValue;} + inline void SetHandleMouseInputs(bool aValue) { mHandleMouseInputs = aValue; } inline bool IsHandleMouseInputsEnabled() const { return mHandleKeyboardInputs; } - inline void SetHandleKeyboardInputs (bool aValue){ mHandleKeyboardInputs = aValue;} + inline void SetHandleKeyboardInputs(bool aValue) { mHandleKeyboardInputs = aValue; } inline bool IsHandleKeyboardInputsEnabled() const { return mHandleKeyboardInputs; } - inline void SetImGuiChildIgnored (bool aValue){ mIgnoreImGuiChild = aValue;} + inline void SetImGuiChildIgnored(bool aValue) { mIgnoreImGuiChild = aValue; } inline bool IsImGuiChildIgnored() const { return mIgnoreImGuiChild; } inline void SetShowWhitespaces(bool aValue) { mShowWhitespaces = aValue; } @@ -297,16 +297,15 @@ class TextEditor void Undo(TextEditor* aEditor); void Redo(TextEditor* aEditor); - std::string mAdded; + Coordinates mAddedStart; Coordinates mAddedEnd; - - std::string mRemoved; Coordinates mRemovedStart; Coordinates mRemovedEnd; - EditorState mBefore; EditorState mAfter; + std::string mAdded; + std::string mRemoved; }; typedef std::vector UndoBuffer; @@ -348,13 +347,7 @@ class TextEditor void HandleMouseInputs(); void Render(); - float mLineSpacing; - Lines mLines; - EditorState mState; - UndoBuffer mUndoBuffer; - int mUndoIndex; - - int mTabSize; +private: bool mOverwrite; bool mReadOnly; bool mWithinRender; @@ -362,28 +355,31 @@ class TextEditor bool mScrollToTop; bool mTextChanged; bool mColorizerEnabled; - float mTextStart; // position (in pixels) where a code line starts relative to the left of the TextEditor. - int mLeftMargin; - bool mCursorPositionChanged; - int mColorRangeMin, mColorRangeMax; - SelectionMode mSelectionMode; bool mHandleKeyboardInputs; bool mHandleMouseInputs; bool mIgnoreImGuiChild; bool mShowWhitespaces; - - Palette mPaletteBase; - Palette mPalette; - LanguageDefinition mLanguageDefinition; - RegexList mRegexList; - + bool mCursorPositionChanged; bool mCheckComments; - Breakpoints mBreakpoints; - ErrorMarkers mErrorMarkers; + int mLeftMargin; + int mColorRangeMin, mColorRangeMax; + int mUndoIndex; + int mTabSize; + SelectionMode mSelectionMode; + float mTextStart; // position (in pixels) where a code line starts relative to the left of the TextEditor. + float mLineSpacing; + float mLastClick; + uint64_t mStartTime; ImVec2 mCharAdvance; Coordinates mInteractiveStart, mInteractiveEnd; + EditorState mState; + ErrorMarkers mErrorMarkers; + Lines mLines; + RegexList mRegexList; + UndoBuffer mUndoBuffer; std::string mLineBuffer; - uint64_t mStartTime; - - float mLastClick; + Breakpoints mBreakpoints; + Palette mPaletteBase; + Palette mPalette; + LanguageDefinition mLanguageDefinition; };