From 8c39617c9ac469a8635d511142148ad5a38de836 Mon Sep 17 00:00:00 2001 From: Cinder Date: Fri, 18 Apr 2014 12:52:07 -0600 Subject: Begin moving script editor portions of LLTextEditor to their own derived class. This should fix the run off segment bugs by not overriding LLTextBase::clearSegments() in LLTextEditor TODO: Move the rest of the script stuff out of LLTextEditor for simplicity sake --- indra/newview/llscripteditor.cpp | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 indra/newview/llscripteditor.cpp (limited to 'indra/newview/llscripteditor.cpp') diff --git a/indra/newview/llscripteditor.cpp b/indra/newview/llscripteditor.cpp new file mode 100644 index 0000000000..7067f49fba --- /dev/null +++ b/indra/newview/llscripteditor.cpp @@ -0,0 +1,51 @@ +/** + * @file llecripteditor.cpp + * @author Cinder Roxley + * @brief Text editor widget used for viewing and editing scripts + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" +#include "llscripteditor.h" + +static LLDefaultChildRegistry::Register r("script_editor"); + +LLScriptEditor::LLScriptEditor::Params::Params() +{ + +} + + +LLScriptEditor::LLScriptEditor(const Params& p) +: LLTextEditor(p) +{ + +} + +void LLScriptEditor::clearSegments() +{ + if (!mSegments.empty()) + { + mSegments.clear(); + } +} -- cgit v1.2.3 From 9ec900c3c440a8d1e25d55667c861d27a95b1297 Mon Sep 17 00:00:00 2001 From: Cinder Date: Fri, 18 Apr 2014 12:53:19 -0600 Subject: Trivial typo fix --- indra/newview/llscripteditor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llscripteditor.cpp') diff --git a/indra/newview/llscripteditor.cpp b/indra/newview/llscripteditor.cpp index 7067f49fba..67a43c0ef0 100644 --- a/indra/newview/llscripteditor.cpp +++ b/indra/newview/llscripteditor.cpp @@ -1,5 +1,5 @@ /** - * @file llecripteditor.cpp + * @file llscripteditor.cpp * @author Cinder Roxley * @brief Text editor widget used for viewing and editing scripts * -- cgit v1.2.3 From dcffb97518cb2888489c93b90862518f761967dd Mon Sep 17 00:00:00 2001 From: Cinder Date: Fri, 18 Apr 2014 23:13:57 -0600 Subject: Move some more script editor functions from LLTextEditor to LLScriptEditor --- indra/newview/llscripteditor.cpp | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'indra/newview/llscripteditor.cpp') diff --git a/indra/newview/llscripteditor.cpp b/indra/newview/llscripteditor.cpp index 67a43c0ef0..61b5eec9fc 100644 --- a/indra/newview/llscripteditor.cpp +++ b/indra/newview/llscripteditor.cpp @@ -28,6 +28,8 @@ #include "linden_common.h" #include "llscripteditor.h" +#include "llsyntaxid.h" + static LLDefaultChildRegistry::Register r("script_editor"); LLScriptEditor::LLScriptEditor::Params::Params() @@ -42,6 +44,48 @@ LLScriptEditor::LLScriptEditor(const Params& p) } +void LLScriptEditor::initKeywords() +{ + mKeywords.initialise(LLSyntaxIdLSL::getInstance()->getKeywordsXML()); +} + +static LLFastTimer::DeclareTimer FTM_SYNTAX_HIGHLIGHTING("Syntax Highlighting"); + +void LLScriptEditor::loadKeywords() +{ + LLFastTimer ft(FTM_SYNTAX_HIGHLIGHTING); + mKeywords.processTokens(); + + segment_vec_t segment_list; + mKeywords.findSegments(&segment_list, getWText(), mDefaultColor.get(), *this); + + mSegments.clear(); + segment_set_t::iterator insert_it = mSegments.begin(); + for (segment_vec_t::iterator list_it = segment_list.begin(); list_it != segment_list.end(); ++list_it) + { + insert_it = mSegments.insert(insert_it, *list_it); + } +} + +void LLScriptEditor::updateSegments() +{ + if (mReflowIndex < S32_MAX && mKeywords.isLoaded() && mParseOnTheFly) + { + LLFastTimer ft(FTM_SYNTAX_HIGHLIGHTING); + // HACK: No non-ascii keywords for now + segment_vec_t segment_list; + mKeywords.findSegments(&segment_list, getWText(), mDefaultColor.get(), *this); + + clearSegments(); + for (segment_vec_t::iterator list_it = segment_list.begin(); list_it != segment_list.end(); ++list_it) + { + insertSegment(*list_it); + } + } + + LLTextBase::updateSegments(); +} + void LLScriptEditor::clearSegments() { if (!mSegments.empty()) -- cgit v1.2.3 From 3dc1b32bf32643613c9912f1165de0f52d0a82c8 Mon Sep 17 00:00:00 2001 From: Cinder Date: Mon, 21 Apr 2014 09:33:21 -0600 Subject: Windows build fix. --- indra/newview/llscripteditor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llscripteditor.cpp') diff --git a/indra/newview/llscripteditor.cpp b/indra/newview/llscripteditor.cpp index 61b5eec9fc..bb59a1d821 100644 --- a/indra/newview/llscripteditor.cpp +++ b/indra/newview/llscripteditor.cpp @@ -25,7 +25,7 @@ * $/LicenseInfo$ */ -#include "linden_common.h" +#include "llviewerprecompiledheaders.h" #include "llscripteditor.h" #include "llsyntaxid.h" -- cgit v1.2.3 From 54d392c4ff8a2a211e00a62023409b2dba85e8e9 Mon Sep 17 00:00:00 2001 From: Cinder Date: Mon, 21 Apr 2014 12:07:46 -0600 Subject: Another oops windows build fix. --- indra/newview/llscripteditor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llscripteditor.cpp') diff --git a/indra/newview/llscripteditor.cpp b/indra/newview/llscripteditor.cpp index bb59a1d821..5d87f7ba0c 100644 --- a/indra/newview/llscripteditor.cpp +++ b/indra/newview/llscripteditor.cpp @@ -32,7 +32,7 @@ static LLDefaultChildRegistry::Register r("script_editor"); -LLScriptEditor::LLScriptEditor::Params::Params() +LLScriptEditor::Params::Params() { } -- cgit v1.2.3