TextDocument: Added auto indent type and width detection.

Fixed a bug in UIListBoxIitem.
Minor refactor in LuaPatternMatcher.
This commit is contained in:
Martín Lucas Golini
2020-06-21 17:18:41 -03:00
parent 088161e718
commit 924de8b08f
10 changed files with 98 additions and 27 deletions

View File

@@ -13,17 +13,24 @@ class EE_API LuaPatternMatcher {
int end;
};
static std::string match( const std::string& string, const std::string& pattern );
LuaPatternMatcher( const std::string& pattern );
bool matches( const char* stringSearch, int stringStartOffset,
LuaPatternMatcher::Match* matches, size_t stringLength );
LuaPatternMatcher::Match* matchList, size_t stringLength );
bool find( const char* stringSearch, int stringStartOffset, int& startMatch, int& endMatch,
bool matches( const std::string& str, LuaPatternMatcher::Match* matchList,
int stringStartOffset = 0 ) {
return matches( str.c_str(), stringStartOffset, matchList, str.size() );
}
bool find( const char* stringSearch, int& startMatch, int& endMatch, int stringStartOffset = 0,
int stringLength = 0, int returnMatchIndex = 0 );
bool find( const std::string& s, int offset, int& startMatch, int& endMatch,
bool find( const std::string& s, int& startMatch, int& endMatch, int offset = 0,
int returnedMatchIndex = 0 ) {
return find( s.c_str(), offset, startMatch, endMatch, s.size(), returnedMatchIndex );
return find( s.c_str(), startMatch, endMatch, offset, s.size(), returnedMatchIndex );
}
int getNumMatches();

View File

@@ -242,9 +242,9 @@ class EE_API TextDocument {
String getIndentString();
const Uint32& getTabWidth() const;
const Uint32& getIndentWidth() const;
void setTabWidth( const Uint32& tabWidth );
void setIndentWidth( const Uint32& tabWidth );
TextPosition sanitizePosition( const TextPosition& position ) const;
@@ -284,6 +284,10 @@ class EE_API TextDocument {
void resetSyntax();
bool getAutoDetectIndentType() const;
void setAutoDetectIndentType( bool autodetect );
protected:
friend class UndoStack;
UndoStack mUndoStack;
@@ -293,7 +297,8 @@ class EE_API TextDocument {
std::unordered_set<Client*> mClients;
bool mIsCLRF{false};
bool mIsBOM{false};
Uint32 mTabWidth{4};
bool mAutoDetectIndentType{true};
Uint32 mIndentWidth{4};
IndentType mIndentType{IndentTabs};
Clock mTimer;
SyntaxDefinition mSyntaxDefinition;
@@ -329,6 +334,8 @@ class EE_API TextDocument {
TextPosition insert( TextPosition position, const String::StringBaseType& text );
void appendLineIfLastLine( Int64 line );
void guessIndentType();
};
}}} // namespace EE::UI::Doc