aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llpreviewscript.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llpreviewscript.cpp')
-rw-r--r--linden/indra/newview/llpreviewscript.cpp165
1 files changed, 13 insertions, 152 deletions
diff --git a/linden/indra/newview/llpreviewscript.cpp b/linden/indra/newview/llpreviewscript.cpp
index 2718c2f..9369a3a 100644
--- a/linden/indra/newview/llpreviewscript.cpp
+++ b/linden/indra/newview/llpreviewscript.cpp
@@ -76,6 +76,7 @@
76#include "lldir.h" 76#include "lldir.h"
77#include "llcombobox.h" 77#include "llcombobox.h"
78//#include "llfloaterchat.h" 78//#include "llfloaterchat.h"
79#include "llfloatersearchreplace.h"
79#include "llviewerstats.h" 80#include "llviewerstats.h"
80#include "llviewertexteditor.h" 81#include "llviewertexteditor.h"
81#include "llviewerwindow.h" 82#include "llviewerwindow.h"
@@ -147,147 +148,6 @@ static bool have_script_upload_cap(LLUUID& object_id)
147} 148}
148 149
149/// --------------------------------------------------------------------------- 150/// ---------------------------------------------------------------------------
150/// LLFloaterScriptSearch
151/// ---------------------------------------------------------------------------
152class LLFloaterScriptSearch : public LLFloater
153{
154public:
155 LLFloaterScriptSearch(std::string title, LLRect rect, LLScriptEdCore* editor_core);
156 ~LLFloaterScriptSearch();
157
158 static void show(LLScriptEdCore* editor_core);
159 static void onBtnSearch(void* userdata);
160 void handleBtnSearch();
161
162 static void onBtnReplace(void* userdata);
163 void handleBtnReplace();
164
165 static void onBtnReplaceAll(void* userdata);
166 void handleBtnReplaceAll();
167
168 LLScriptEdCore* getEditorCore() { return mEditorCore; }
169 static LLFloaterScriptSearch* getInstance() { return sInstance; }
170
171 void open(); /*Flawfinder: ignore*/
172
173private:
174
175 LLScriptEdCore* mEditorCore;
176
177 static LLFloaterScriptSearch* sInstance;
178};
179
180LLFloaterScriptSearch* LLFloaterScriptSearch::sInstance = NULL;
181
182LLFloaterScriptSearch::LLFloaterScriptSearch(std::string title, LLRect rect, LLScriptEdCore* editor_core)
183 : LLFloater("script search",rect,title), mEditorCore(editor_core)
184{
185
186 LLUICtrlFactory::getInstance()->buildFloater(this,"floater_script_search.xml");
187
188 childSetAction("search_btn", onBtnSearch,this);
189 childSetAction("replace_btn", onBtnReplace,this);
190 childSetAction("replace_all_btn", onBtnReplaceAll,this);
191
192 setDefaultBtn("search_btn");
193
194 if (!getHost())
195 {
196 LLRect curRect = getRect();
197 translate(rect.mLeft - curRect.mLeft, rect.mTop - curRect.mTop);
198 }
199
200 sInstance = this;
201
202 childSetFocus("search_text", TRUE);
203
204 // find floater in which script panel is embedded
205 LLView* viewp = (LLView*)editor_core;
206 while(viewp)
207 {
208 LLFloater* floaterp = dynamic_cast<LLFloater*>(viewp);
209 if (floaterp)
210 {
211 floaterp->addDependentFloater(this);
212 break;
213 }
214 viewp = viewp->getParent();
215 }
216}
217
218//static
219void LLFloaterScriptSearch::show(LLScriptEdCore* editor_core)
220{
221 if (sInstance && sInstance->mEditorCore && sInstance->mEditorCore != editor_core)
222 {
223 sInstance->close();
224 delete sInstance;
225 }
226
227 if (!sInstance)
228 {
229 S32 left = 0;
230 S32 top = 0;
231 gFloaterView->getNewFloaterPosition(&left,&top);
232
233 // sInstance will be assigned in the constructor.
234 new LLFloaterScriptSearch("Script Search",LLRect(left,top,left + SCRIPT_SEARCH_WIDTH,top - SCRIPT_SEARCH_HEIGHT),editor_core);
235 }
236
237 sInstance->open(); /*Flawfinder: ignore*/
238}
239
240LLFloaterScriptSearch::~LLFloaterScriptSearch()
241{
242 sInstance = NULL;
243}
244
245// static
246void LLFloaterScriptSearch::onBtnSearch(void *userdata)
247{
248 LLFloaterScriptSearch* self = (LLFloaterScriptSearch*)userdata;
249 self->handleBtnSearch();
250}
251
252void LLFloaterScriptSearch::handleBtnSearch()
253{
254 LLCheckBoxCtrl* caseChk = getChild<LLCheckBoxCtrl>("case_text");
255 mEditorCore->mEditor->selectNext(childGetText("search_text"), caseChk->get());
256}
257
258// static
259void LLFloaterScriptSearch::onBtnReplace(void *userdata)
260{
261 LLFloaterScriptSearch* self = (LLFloaterScriptSearch*)userdata;
262 self->handleBtnReplace();
263}
264
265void LLFloaterScriptSearch::handleBtnReplace()
266{
267 LLCheckBoxCtrl* caseChk = getChild<LLCheckBoxCtrl>("case_text");
268 mEditorCore->mEditor->replaceText(childGetText("search_text"), childGetText("replace_text"), caseChk->get());
269}
270
271// static
272void LLFloaterScriptSearch::onBtnReplaceAll(void *userdata)
273{
274 LLFloaterScriptSearch* self = (LLFloaterScriptSearch*)userdata;
275 self->handleBtnReplaceAll();
276}
277
278void LLFloaterScriptSearch::handleBtnReplaceAll()
279{
280 LLCheckBoxCtrl* caseChk = getChild<LLCheckBoxCtrl>("case_text");
281 mEditorCore->mEditor->replaceTextAll(childGetText("search_text"), childGetText("replace_text"), caseChk->get());
282}
283
284void LLFloaterScriptSearch::open() /*Flawfinder: ignore*/
285{
286 LLFloater::open(); /*Flawfinder: ignore*/
287 childSetFocus("search_text", TRUE);
288}
289
290/// ---------------------------------------------------------------------------
291/// LLScriptEdCore 151/// LLScriptEdCore
292/// --------------------------------------------------------------------------- 152/// ---------------------------------------------------------------------------
293 153
@@ -385,14 +245,6 @@ LLScriptEdCore::LLScriptEdCore(
385LLScriptEdCore::~LLScriptEdCore() 245LLScriptEdCore::~LLScriptEdCore()
386{ 246{
387 deleteBridges(); 247 deleteBridges();
388
389 // If the search window is up for this editor, close it.
390 LLFloaterScriptSearch* script_search = LLFloaterScriptSearch::getInstance();
391 if (script_search && script_search->getEditorCore() == this)
392 {
393 script_search->close();
394 delete script_search;
395 }
396} 248}
397 249
398void LLScriptEdCore::initMenu() 250void LLScriptEdCore::initMenu()
@@ -931,7 +783,10 @@ void LLScriptEdCore::onBtnLoadFromDisc( void* data )
931void LLScriptEdCore::onSearchMenu(void* userdata) 783void LLScriptEdCore::onSearchMenu(void* userdata)
932{ 784{
933 LLScriptEdCore* sec = (LLScriptEdCore*)userdata; 785 LLScriptEdCore* sec = (LLScriptEdCore*)userdata;
934 LLFloaterScriptSearch::show(sec); 786 if ( (sec) && (sec->mEditor) )
787 {
788 LLFloaterSearchReplace::show(sec->mEditor);
789 }
935} 790}
936 791
937// static 792// static
@@ -1335,7 +1190,10 @@ void LLPreviewLSL::onSearchReplace(void* userdata)
1335{ 1190{
1336 LLPreviewLSL* self = (LLPreviewLSL*)userdata; 1191 LLPreviewLSL* self = (LLPreviewLSL*)userdata;
1337 LLScriptEdCore* sec = self->mScriptEd; 1192 LLScriptEdCore* sec = self->mScriptEd;
1338 LLFloaterScriptSearch::show(sec); 1193 if ( (sec) && (sec->mEditor) )
1194 {
1195 LLFloaterSearchReplace::show(sec->mEditor);
1196 }
1339} 1197}
1340 1198
1341// static 1199// static
@@ -2155,7 +2013,10 @@ void LLLiveLSLEditor::onSearchReplace(void* userdata)
2155 LLLiveLSLEditor* self = (LLLiveLSLEditor*)userdata; 2013 LLLiveLSLEditor* self = (LLLiveLSLEditor*)userdata;
2156 2014
2157 LLScriptEdCore* sec = self->mScriptEd; 2015 LLScriptEdCore* sec = self->mScriptEd;
2158 LLFloaterScriptSearch::show(sec); 2016 if ( (sec) && (sec->mEditor) )
2017 {
2018 LLFloaterSearchReplace::show(sec->mEditor);
2019 }
2159} 2020}
2160 2021
2161struct LLLiveLSLSaveData 2022struct LLLiveLSLSaveData