From a1a9f61330900796a7b6a6147db9f03d9b1fe2c1 Mon Sep 17 00:00:00 2001 From: Artyom Shalkhakov Date: Sat, 15 Feb 2025 09:10:27 -0700 Subject: [PATCH] Setup language definition based on the keywords file. Although, seems like those files are not in the base game? --- neo/tools/imgui/util/SyntaxRichEditCtrl.cpp | 47 +++++++++++---------- neo/tools/imgui/util/SyntaxRichEditCtrl.h | 1 - 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/neo/tools/imgui/util/SyntaxRichEditCtrl.cpp b/neo/tools/imgui/util/SyntaxRichEditCtrl.cpp index ab397011..b9c1d2c5 100644 --- a/neo/tools/imgui/util/SyntaxRichEditCtrl.cpp +++ b/neo/tools/imgui/util/SyntaxRichEditCtrl.cpp @@ -321,6 +321,31 @@ void SyntaxRichEditCtrl::SetKeyWords( const keyWord_t kws[] ) { } keyWordHash.Add( hash, i ); } + + TextEditor::LanguageDefinition langDef; + + for ( i = 0; i < numKeyWords; i++ ) { + if ( keyWords[i].description != '\0' ) { + TextEditor::Identifier id; + id.mDeclaration = keyWords[i].description; + langDef.mIdentifiers.insert( std::make_pair( std::string( keyWords[i].keyWord ), id ) ); + } else { + langDef.mKeywords.insert( std::string( keyWords[i].keyWord ) ); + } + } + + langDef.mTokenize = TextEditor::LanguageDefinition::C().mTokenize; + + langDef.mCommentStart = "/*"; + langDef.mCommentEnd = "*/"; + langDef.mSingleLineComment = "//"; + + langDef.mCaseSensitive = caseSensitive; + langDef.mAutoIndentation = true; + + langDef.mName = "doomscript"; // TODO: change? + + scriptEdit->SetLanguageDefinition( langDef ); } /* @@ -588,28 +613,6 @@ void SyntaxRichEditCtrl::SetColor( int startCharIndex, int endCharIndex, const i updateSyntaxHighlighting = true;*/ } -/* -================ -SyntaxRichEditCtrl::GetForeColor -================ -*/ -idVec3 SyntaxRichEditCtrl::GetForeColor( int charIndex ) const { - /*tom::ITextRange* range; - tom::ITextFont *font; - long foreColor; - - m_TextDoc->Range( charIndex, charIndex, &range ); - range->get_Font( &font ); - - font->get_BackColor( &foreColor ); - - font->Release(); - range->Release(); - - return foreColor;*/ - return vec3_origin; -} - /* ================ SyntaxRichEditCtrl::GetBackColor diff --git a/neo/tools/imgui/util/SyntaxRichEditCtrl.h b/neo/tools/imgui/util/SyntaxRichEditCtrl.h index 5cf8685e..fc0084aa 100644 --- a/neo/tools/imgui/util/SyntaxRichEditCtrl.h +++ b/neo/tools/imgui/util/SyntaxRichEditCtrl.h @@ -112,7 +112,6 @@ public: void SetStringColor( const idVec3 &color, const idVec3 &altColor = vec3_origin ); void SetLiteralColor( const idVec3 &color ); - idVec3 GetForeColor( int charIndex ) const; idVec3 GetBackColor( int charIndex ) const; void GetCursorPos( int &line, int &column, int &character ) const;