diff -r 7a056d7afeb2 -r 3ea2afd9dad5 doc/contributions.txt --- a/doc/contributions.txt Wed Sep 12 18:34:11 2012 -0400 +++ b/doc/contributions.txt Thu Sep 13 14:47:07 2012 +0200 @@ -740,6 +740,7 @@ STORM-281 MartinRJ Fayray STORM-1845 + BUG-59 Matthew Anthony Matthew Dowd VWR-1344 diff -r 7a056d7afeb2 -r 3ea2afd9dad5 indra/newview/llpreviewscript.h --- a/indra/newview/llpreviewscript.h Wed Sep 12 18:34:11 2012 -0400 +++ b/indra/newview/llpreviewscript.h Thu Sep 13 14:47:07 2012 +0200 @@ -45,6 +45,7 @@ struct LLEntryAndEdCore; class LLMenuBarGL; class LLFloaterScriptSearch; +class LLFloaterGotoLine; class LLKeywordToken; class LLVFS; class LLViewerInventoryItem; @@ -57,6 +58,7 @@ friend class LLPreviewLSL; friend class LLLiveLSLEditor; friend class LLFloaterScriptSearch; + friend class LLFloaterGotoLine; friend class LLScriptEdContainer; protected: diff -r 7a056d7afeb2 -r 3ea2afd9dad5 indra/newview/llpreviewscript.cpp --- a/indra/newview/llpreviewscript.cpp Wed Sep 12 18:34:11 2012 -0400 +++ b/indra/newview/llpreviewscript.cpp Thu Sep 13 14:47:07 2012 +0200 @@ -163,6 +163,155 @@ } /// --------------------------------------------------------------------------- +/// LLFloaterGotoLine +/// --------------------------------------------------------------------------- +class LLFloaterGotoLine : public LLFloater +{ +public: + LLFloaterGotoLine(LLScriptEdCore* editor_core); + ~LLFloaterGotoLine(); + + /*virtual*/ BOOL postBuild(); + static void show(LLScriptEdCore* editor_core); + + static void onBtnGoto(void* userdata); + void handleBtnGoto(); + + LLScriptEdCore* getEditorCore() { return mEditorCore; } + static LLFloaterGotoLine* getInstance() { return sInstance; } + + virtual bool hasAccelerators() const; + virtual BOOL handleKeyHere(KEY key, MASK mask); + +private: + + LLScriptEdCore* mEditorCore; + + static LLFloaterGotoLine* sInstance; + +protected: + LLLineEditor* mGotoBox; + void onGotoBoxCommit(); +}; + +LLFloaterGotoLine* LLFloaterGotoLine::sInstance = NULL; + +LLFloaterGotoLine::LLFloaterGotoLine(LLScriptEdCore* editor_core) +: LLFloater(LLSD()), + mGotoBox(NULL), + mEditorCore(editor_core) +{ + buildFromFile("floater_goto_line.xml"); + + sInstance = this; + + // find floater in which script panel is embedded + LLView* viewp = (LLView*)editor_core; + while(viewp) + { + LLFloater* floaterp = dynamic_cast(viewp); + if (floaterp) + { + floaterp->addDependentFloater(this); + break; + } + viewp = viewp->getParent(); + } +} + +BOOL LLFloaterGotoLine::postBuild() +{ + mGotoBox = getChild("goto_line"); + mGotoBox->setCommitCallback(boost::bind(&LLFloaterGotoLine::onGotoBoxCommit, this)); + getChild("goto_line")->setPrevalidate(LLTextValidate::validateNonNegativeS32); + childSetAction("goto_btn", onBtnGoto,this); + setDefaultBtn("goto_btn"); + + return TRUE; +} + +//static +void LLFloaterGotoLine::show(LLScriptEdCore* editor_core) +{ + if (sInstance && sInstance->mEditorCore && sInstance->mEditorCore != editor_core) + { + sInstance->closeFloater(); + delete sInstance; + } + + if (!sInstance) + { + // sInstance will be assigned in the constructor. + new LLFloaterGotoLine(editor_core); + } + + sInstance->openFloater(); +} + +LLFloaterGotoLine::~LLFloaterGotoLine() +{ + sInstance = NULL; +} + +// static +void LLFloaterGotoLine::onBtnGoto(void *userdata) +{ + LLFloaterGotoLine* self = (LLFloaterGotoLine*)userdata; + self->handleBtnGoto(); +} + +void LLFloaterGotoLine::handleBtnGoto() +{ + S32 row = 0; + S32 column = 0; + row = getChild("goto_line")->getValue().asInteger(); + if (row >= 0) + { + mEditorCore->mEditor->setCursor(row, column); + mEditorCore->mEditor->setFocus(TRUE); + } +} + +bool LLFloaterGotoLine::hasAccelerators() const +{ + if (mEditorCore) + { + return mEditorCore->hasAccelerators(); + } + return FALSE; +} + +BOOL LLFloaterGotoLine::handleKeyHere(KEY key, MASK mask) +{ + if (mEditorCore) + { + return mEditorCore->handleKeyHere(key, mask); + } + + return FALSE; +} + +void LLFloaterGotoLine::onGotoBoxCommit() +{ + S32 row = 0; + S32 column = 0; + row = getChild("goto_line")->getValue().asInteger(); + if (row >= 0) + { + mEditorCore->mEditor->setCursor(row, column); + + S32 rownew = 0; + S32 columnnew = 0; + mEditorCore->mEditor->getCurrentLineAndColumn( &rownew, &columnnew, FALSE ); // don't include wordwrap + if (rownew == row && columnnew == column) + { //do nothing when the cursor-position didn't change + mEditorCore->mEditor->setFocus(TRUE); + sInstance->closeFloater(); + } + } +} + +/// --------------------------------------------------------------------------- /// LLFloaterScriptSearch /// --------------------------------------------------------------------------- class LLFloaterScriptSearch : public LLFloater @@ -193,12 +342,17 @@ LLScriptEdCore* mEditorCore; static LLFloaterScriptSearch* sInstance; + +protected: + LLLineEditor* mSearchBox; + void onSearchBoxCommit(); }; LLFloaterScriptSearch* LLFloaterScriptSearch::sInstance = NULL; LLFloaterScriptSearch::LLFloaterScriptSearch(LLScriptEdCore* editor_core) : LLFloater(LLSD()), + mSearchBox(NULL), mEditorCore(editor_core) { buildFromFile("floater_script_search.xml"); @@ -221,6 +375,8 @@ BOOL LLFloaterScriptSearch::postBuild() { + mSearchBox = getChild("search_text"); + mSearchBox->setCommitCallback(boost::bind(&LLFloaterScriptSearch::onSearchBoxCommit, this)); childSetAction("search_btn", onBtnSearch,this); childSetAction("replace_btn", onBtnReplace,this); childSetAction("replace_all_btn", onBtnReplaceAll,this); @@ -311,6 +467,12 @@ return FALSE; } +void LLFloaterScriptSearch::onSearchBoxCommit() +{ + LLCheckBoxCtrl* caseChk = getChild("case_text"); + mEditorCore->mEditor->selectNext(getChild("search_text")->getValue().asString(), caseChk->get()); +} + /// --------------------------------------------------------------------------- /// LLScriptEdCore /// --------------------------------------------------------------------------- @@ -499,6 +661,9 @@ menuItem = getChild("Search / Replace..."); menuItem->setClickCallback(boost::bind(&LLFloaterScriptSearch::show, this)); + menuItem = getChild("Go to line..."); + menuItem->setClickCallback(boost::bind(&LLFloaterGotoLine::show, this)); + menuItem = getChild("Help..."); menuItem->setClickCallback(boost::bind(&LLScriptEdCore::onBtnHelp, this)); diff -r 7a056d7afeb2 -r 3ea2afd9dad5 indra/newview/skins/default/xui/en/floater_goto_line.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/indra/newview/skins/default/xui/en/floater_goto_line.xml Thu Sep 13 14:47:07 2012 +0200 @@ -0,0 +1,44 @@ + + +