Skip to content

Project Viewer: SLua editor #3537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 51 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
7f88aed
#3423 Add Lua as Compile Target in Viewer Script Editor
LLGuru Jan 23, 2025
fd82aa0
#3423 Adapt the code to the changes on a server
marchcat Feb 5, 2025
a54ac5a
#3423 Gray out Lua selection on unsupported regions
marchcat Feb 11, 2025
f650597
#3422 Fix two-sided delimiter tail processing
marchcat Feb 11, 2025
34c1627
#3422 Process Lua-style comments
marchcat Feb 11, 2025
ad7dee8
#3422 Add Lua keywords
marchcat Feb 12, 2025
23ac8f6
Merge pull request #3535 from secondlife/marchcat/lua_editor
marchcat Feb 12, 2025
8f0e0fc
Fix xcode16 build errors
marchcat Feb 13, 2025
a0e31b1
Bump macos runner to os version 15 with xcode 16.1
marchcat Feb 13, 2025
bf8a9e8
Merge pull request #3560 from secondlife/marchcat/lua_editor
marchcat Feb 14, 2025
385838c
#3423 Handle region properly
marchcat Feb 21, 2025
10de131
#3423 Use correct 'lsl-luau' compile target
marchcat Feb 21, 2025
0cc0db8
#3422 Better handling of Lua syntax
marchcat Feb 25, 2025
0aaf2e4
Merge pull request #3609 from secondlife/marchcat/lua_editor
marchcat Feb 25, 2025
c663b3f
#3614 Tidy up Script editor UI
marchcat Feb 27, 2025
7c5297d
#3615 WIP: Improve script editor code for the inventory
marchcat Mar 1, 2025
359f604
#3615 WIP: Store correct script compile target in inventory
marchcat Mar 6, 2025
7aad509
Merge pull request #3662 from secondlife/marchcat/lua_editor
marchcat Mar 6, 2025
668c8c6
#3422 Code cleanup
marchcat Mar 7, 2025
f5a6851
#3691 Fix Reset button
marchcat Mar 8, 2025
66faf3d
#3422 Improve handling of Lua functions
marchcat Mar 8, 2025
8c7a5bd
#3730 Change compiler dropdown options to "SLua"
marchcat Mar 14, 2025
5b23e28
#3731 Remove unused code
marchcat Mar 14, 2025
da0a819
Temporary hack to determine script language when opened from inventory
marchcat Mar 14, 2025
e2333b4
Merge pull request #3701 from secondlife/marchcat/lua_editor
marchcat Mar 14, 2025
a0e8b5f
#3731 Temporary viewer-side workaround to create SLua scripts by default
marchcat Mar 17, 2025
dba481f
Merge pull request #3752 from secondlife/marchcat/lua_editor
marchcat Mar 17, 2025
fe5d7d4
#3731 Follow-up: Use SLua defaults only on SLua-enabled regions (#3753)
marchcat Mar 17, 2025
39dda55
#3731 Delete temporary script from server
marchcat Mar 17, 2025
e59d44d
Merge pull request #3756 from secondlife/marchcat/lua_editor
marchcat Mar 17, 2025
19cdf73
#3747 Use correct extension for temporary script files
marchcat Mar 17, 2025
aab20f5
#3639 Update keywords_lsl_default.xml
marchcat Mar 20, 2025
9efd188
#3639 Sync keywords_lua_default.xml with keywords_lsl_default.xml
marchcat Mar 20, 2025
078170a
#3639 Add Luau functions from https://luau.org/library
marchcat Mar 20, 2025
62a196b
Merge pull request #3781 from secondlife/marchcat/lua_editor
marchcat Mar 20, 2025
0b9458b
secondlife/viewer-private#408 Add Luau License to the About Section
marchcat Mar 25, 2025
bb2447c
#3801 Update "types" section in keywords_lua_default.xml
marchcat Mar 25, 2025
372aa3c
#3800 Use regex to support multi-line strings and nested comments
marchcat Mar 30, 2025
57dfeaf
Merge pull request #3807 from secondlife/marchcat/lua_editor
marchcat Mar 31, 2025
42355fa
#3800 Use range-based for loop for regex token iteration
marchcat Mar 31, 2025
3c2933b
#3800 Add support for single-quoted strings
marchcat Mar 31, 2025
a1f682b
#3800 Add support for interpolated strings
marchcat Apr 2, 2025
403fcb2
#3867 Print script errors to disk when external editor is used
marchcat Apr 3, 2025
18ead6a
Merge pull request #3860 from secondlife/marchcat/lua_editor
marchcat Apr 3, 2025
e9d6b27
Optimize LLKeywords: pre-compile regex patterns
marchcat Apr 15, 2025
bf7a9f8
Optimize LLKeywords: few small improvements
marchcat Apr 18, 2025
9f73e81
Fix llhttpdate test on windows and macos (#3909)
marchcat Apr 14, 2025
0787d41
Add "ScriptEditorDisableSyntaxHighlight" debug setting
marchcat May 7, 2025
3af711e
Merge pull request #3935 from secondlife/marchcat/lua_editor
marchcat May 7, 2025
d3bd73a
Merge branch 'main' into marchcat/slua-editor-merge
marchcat May 28, 2025
9602397
Merge pull request #4181 from secondlife/marchcat/slua-editor-merge
marchcat May 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions indra/llmessage/message_prehash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,9 @@ char const* const _PREHASH_FirstName = LLMessageStringTable::getInstance()->getS
char const* const _PREHASH_AttachedSoundGainChange = LLMessageStringTable::getInstance()->getString("AttachedSoundGainChange");
char const* const _PREHASH_LocationID = LLMessageStringTable::getInstance()->getString("LocationID");
char const* const _PREHASH_Running = LLMessageStringTable::getInstance()->getString("Running");
char const* const _PREHASH_Mono = LLMessageStringTable::getInstance()->getString("Mono");
char const* const _PREHASH_Luau = LLMessageStringTable::getInstance()->getString("Luau");
char const* const _PREHASH_LuauLanguage = LLMessageStringTable::getInstance()->getString("LuauLanguage");
char const* const _PREHASH_AgentThrottle = LLMessageStringTable::getInstance()->getString("AgentThrottle");
char const* const _PREHASH_NeighborList = LLMessageStringTable::getInstance()->getString("NeighborList");
char const* const _PREHASH_PathTaperX = LLMessageStringTable::getInstance()->getString("PathTaperX");
Expand Down
3 changes: 3 additions & 0 deletions indra/llmessage/message_prehash.h
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,9 @@ extern char const* const _PREHASH_FirstName;
extern char const* const _PREHASH_AttachedSoundGainChange;
extern char const* const _PREHASH_LocationID;
extern char const* const _PREHASH_Running;
extern char const* const _PREHASH_Mono;
extern char const* const _PREHASH_Luau;
extern char const* const _PREHASH_LuauLanguage;
extern char const* const _PREHASH_AgentThrottle;
extern char const* const _PREHASH_NeighborList;
extern char const* const _PREHASH_PathTaperX;
Expand Down
17 changes: 16 additions & 1 deletion indra/llui/llcombobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,26 @@ void LLComboBox::resetDirty()
}
}

bool LLComboBox::itemExists(const std::string& name)
bool LLComboBox::itemExists(const std::string& name) const
{
return mList->getItemByLabel(name);
}

bool LLComboBox::valueExists(const std::string& value) const
{
return mList->getItemByValue(value);
}

LLScrollListItem* LLComboBox::findItemByValue(const std::string& value) const
{
return mList->getItemByValue(value);
}

std::vector<LLScrollListItem*> LLComboBox::getAllData() const
{
return mList->getAllData();
}

// add item "name" to menu
LLScrollListItem* LLComboBox::add(const std::string& name, EAddPosition pos, bool enabled)
{
Expand Down
5 changes: 4 additions & 1 deletion indra/llui/llcombobox.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ class LLComboBox
LLScrollListItem* addSeparator(EAddPosition pos = ADD_BOTTOM);
bool remove( S32 index ); // remove item by index, return true if found and removed
void removeall() { clearRows(); }
bool itemExists(const std::string& name);
bool itemExists(const std::string& name) const;
bool valueExists(const std::string& value) const;
LLScrollListItem* findItemByValue(const std::string& value) const;
std::vector<LLScrollListItem*> getAllData() const;

void sortByName(bool ascending = true); // Sort the entries in the combobox by name

Expand Down
341 changes: 280 additions & 61 deletions indra/llui/llkeywords.cpp

Large diffs are not rendered by default.

26 changes: 24 additions & 2 deletions indra/llui/llkeywords.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <map>
#include <list>
#include <deque>
#include <regex>
#include "llpointer.h"

class LLTextSegment;
Expand All @@ -53,6 +54,11 @@ class LLKeywordToken
* - TT_ONE_SIDED_DELIMITER are for open-ended delimiters which are terminated by EOL.
* - TT_TWO_SIDED_DELIMITER are for delimiters that end with a different delimiter than they open with.
* - TT_DOUBLE_QUOTATION_MARKS are for delimiting areas using the same delimiter to open and close.
* - TT_REGEX_MATCH are for pattern-based matching using regular expressions.
* For TT_REGEX_MATCH: mToken contains the start pattern, mDelimiter contains the end pattern (if any).
* If mDelimiter is empty, the entire match is considered one segment.
* If mDelimiter contains capture group references (e.g. \1, \2), these will be replaced with
* the corresponding capture groups from the start pattern match.
*/
typedef enum e_token_type
{
Expand All @@ -62,6 +68,7 @@ class LLKeywordToken
TT_TWO_SIDED_DELIMITER,
TT_ONE_SIDED_DELIMITER,
TT_DOUBLE_QUOTATION_MARKS,
TT_REGEX_MATCH,
// Following constants are more specific versions of the preceding ones
TT_CONSTANT, // WORD
TT_CONTROL, // WORD
Expand All @@ -78,10 +85,20 @@ class LLKeywordToken
mToken( token ),
mColor( color ),
mToolTip( tool_tip ),
mDelimiter( delimiter ) // right delimiter
mDelimiter( delimiter ), // right delimiter
mCompiledRegex( nullptr )
{
}

~LLKeywordToken()
{
if (mCompiledRegex)
{
delete mCompiledRegex;
mCompiledRegex = nullptr;
}
}

S32 getLengthHead() const { return static_cast<S32>(mToken.size()); }
S32 getLengthTail() const { return static_cast<S32>(mDelimiter.size()); }
bool isHead(const llwchar* s) const;
Expand All @@ -91,6 +108,8 @@ class LLKeywordToken
ETokenType getType() const { return mType; }
const LLWString& getToolTip() const { return mToolTip; }
const LLWString& getDelimiter() const { return mDelimiter; }
std::regex* getCompiledRegex() const { return mCompiledRegex; }
void setCompiledRegex(std::regex* regex) { mCompiledRegex = regex; }

#ifdef _DEBUG
void dump();
Expand All @@ -102,6 +121,7 @@ class LLKeywordToken
LLUIColor mColor;
LLWString mToolTip;
LLWString mDelimiter;
std::regex* mCompiledRegex;
};

class LLKeywords
Expand All @@ -118,7 +138,7 @@ class LLKeywords
const LLWString& text,
class LLTextEditor& editor,
LLStyleConstSP style);
void initialize(LLSD SyntaxXML);
void initialize(LLSD SyntaxXML, bool luau_language = false);
void processTokens();

// Add the token as described
Expand Down Expand Up @@ -189,10 +209,12 @@ class LLKeywords

bool mLoaded;
LLSD mSyntax;
bool mLuauLanguage;
word_token_map_t mWordTokenMap;
typedef std::deque<LLKeywordToken*> token_list_t;
token_list_t mLineTokenList;
token_list_t mDelimiterTokenList;
token_list_t mRegexTokenList;

typedef std::map<std::string, std::string, std::less<>> element_attributes_t;
typedef element_attributes_t::const_iterator attribute_iterator_t;
Expand Down
13 changes: 13 additions & 0 deletions indra/llui/llscrolllistctrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,19 @@ LLScrollListItem* LLScrollListCtrl::getItemByLabel(const std::string& label, boo
return NULL;
}

LLScrollListItem* LLScrollListCtrl::getItemByValue(const std::string& value)
{
for (LLScrollListItem* item : mItemList)
{
if (item->getValue().asString() == value)
{
return item;
}
}

return NULL;
}

LLScrollListItem* LLScrollListCtrl::getItemByIndex(S32 index)
{
if (index >= 0 && index < (S32)mItemList.size())
Expand Down
3 changes: 2 additions & 1 deletion indra/llui/llscrolllistctrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ class LLScrollListCtrl : public LLUICtrl, public LLEditMenuHandler,
bool selectItemByLabel(const std::string& item, bool case_sensitive = true, S32 column = 0); // false if item not found
bool selectItemByPrefix(const std::string& target, bool case_sensitive = true, S32 column = -1);
bool selectItemByPrefix(const LLWString& target, bool case_sensitive = true, S32 column = -1);
LLScrollListItem* getItemByLabel(const std::string& item, bool case_sensitive = true, S32 column = 0);
LLScrollListItem* getItemByLabel(const std::string& label, bool case_sensitive = true, S32 column = 0);
LLScrollListItem* getItemByValue(const std::string& value);
LLScrollListItem* getItemByIndex(S32 index);
std::string getSelectedItemLabel(S32 column = 0) const;
LLSD getSelectedValue();
Expand Down
Loading