From 62245de7ae38468f337e4c64bc2c254e13c6fedc Mon Sep 17 00:00:00 2001
From: Mnikolenko Productengine <mnikolenko@productengine.com>
Date: Tue, 1 Aug 2023 20:14:27 +0300
Subject: SL-19982 Adjustable font size in LSL editor

---
 indra/llui/llkeywords.cpp                          |  47 +++++++++++----
 indra/llui/llkeywords.h                            |   9 ++-
 indra/newview/app_settings/settings.xml            |  11 ++++
 indra/newview/llfloaterpreference.cpp              |  20 +------
 indra/newview/llinventoryfunctions.cpp             |  18 ++++++
 indra/newview/llinventoryfunctions.h               |   1 +
 indra/newview/llpreviewscript.cpp                  |  48 +++++++++++++++-
 indra/newview/llpreviewscript.h                    |  13 ++++-
 indra/newview/llscripteditor.cpp                   |  45 +++++++++++++--
 indra/newview/llscripteditor.h                     |  10 +++-
 .../default/textures/icons/Icon_Color_Palette.png  | Bin 0 -> 3419 bytes
 .../default/textures/icons/Icon_Font_Size.png      | Bin 0 -> 2994 bytes
 indra/newview/skins/default/textures/textures.xml  |   3 +
 .../default/xui/en/floater_script_ed_prefs.xml     |   1 +
 .../default/xui/en/floater_script_preview.xml      |  23 ++++++--
 indra/newview/skins/default/xui/en/fonts.xml       |   8 +++
 .../skins/default/xui/en/menu_lsl_font_size.xml    |  64 +++++++++++++++++++++
 .../skins/default/xui/en/panel_script_ed.xml       |  36 ++++++++----
 18 files changed, 294 insertions(+), 63 deletions(-)
 create mode 100644 indra/newview/skins/default/textures/icons/Icon_Color_Palette.png
 create mode 100644 indra/newview/skins/default/textures/icons/Icon_Font_Size.png
 create mode 100644 indra/newview/skins/default/xui/en/menu_lsl_font_size.xml

diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp
index 69e338ddb9..56e0c4f0f8 100644
--- a/indra/llui/llkeywords.cpp
+++ b/indra/llui/llkeywords.cpp
@@ -479,7 +479,7 @@ LLTrace::BlockTimerStatHandle FTM_SYNTAX_COLORING("Syntax Coloring");
 
 // Walk through a string, applying the rules specified by the keyword token list and
 // create a list of color segments.
-void LLKeywords::findSegments(std::vector<LLTextSegmentPtr>* seg_list, const LLWString& wtext, const LLColor4 &defaultColor, LLTextEditor& editor)
+void LLKeywords::findSegments(std::vector<LLTextSegmentPtr>* seg_list, const LLWString& wtext, LLTextEditor& editor, LLStyleConstSP style)
 {
 	LL_RECORD_BLOCK_TIME(FTM_SYNTAX_COLORING);
 	seg_list->clear();
@@ -491,7 +491,7 @@ void LLKeywords::findSegments(std::vector<LLTextSegmentPtr>* seg_list, const LLW
 
 	S32 text_len = wtext.size() + 1;
 
-	seg_list->push_back( new LLNormalTextSegment( defaultColor, 0, text_len, editor ) );
+	seg_list->push_back( new LLNormalTextSegment( style, 0, text_len, editor ) );
 
 	const llwchar* base = wtext.c_str();
 	const llwchar* cur = base;
@@ -503,7 +503,7 @@ void LLKeywords::findSegments(std::vector<LLTextSegmentPtr>* seg_list, const LLW
 			{
 				LLTextSegmentPtr text_segment = new LLLineBreakTextSegment(cur-base);
 				text_segment->setToken( 0 );
-				insertSegment( *seg_list, text_segment, text_len, defaultColor, editor);
+				insertSegment( *seg_list, text_segment, text_len, style, editor);
 				cur++;
 				if( !*cur || *cur == '\n' )
 				{
@@ -541,7 +541,7 @@ void LLKeywords::findSegments(std::vector<LLTextSegmentPtr>* seg_list, const LLW
 						S32 seg_end = cur - base;
 
 						//create segments from seg_start to seg_end
-						insertSegments(wtext, *seg_list,cur_token, text_len, seg_start, seg_end, defaultColor, editor);
+						insertSegments(wtext, *seg_list,cur_token, text_len, seg_start, seg_end, style, editor);
 						line_done = TRUE; // to break out of second loop.
 						break;
 					}
@@ -648,7 +648,7 @@ void LLKeywords::findSegments(std::vector<LLTextSegmentPtr>* seg_list, const LLW
 						seg_end = seg_start + between_delimiters + cur_delimiter->getLengthHead();
 					}
 
-					insertSegments(wtext, *seg_list,cur_delimiter, text_len, seg_start, seg_end, defaultColor, editor);
+					insertSegments(wtext, *seg_list,cur_delimiter, text_len, seg_start, seg_end, style, editor);
 					/*
 					LLTextSegmentPtr text_segment = new LLNormalTextSegment( cur_delimiter->getColor(), seg_start, seg_end, editor );
 					text_segment->setToken( cur_delimiter );
@@ -682,7 +682,7 @@ void LLKeywords::findSegments(std::vector<LLTextSegmentPtr>* seg_list, const LLW
 
 						// LL_INFOS("SyntaxLSL") << "Seg: [" << word.c_str() << "]" << LL_ENDL;
 
-						insertSegments(wtext, *seg_list,cur_token, text_len, seg_start, seg_end, defaultColor, editor);
+						insertSegments(wtext, *seg_list,cur_token, text_len, seg_start, seg_end, style, editor);
 					}
 					cur += seg_len;
 					continue;
@@ -697,30 +697,32 @@ void LLKeywords::findSegments(std::vector<LLTextSegmentPtr>* seg_list, const LLW
 	}
 }
 
-void LLKeywords::insertSegments(const LLWString& wtext, std::vector<LLTextSegmentPtr>& seg_list, LLKeywordToken* cur_token, S32 text_len, S32 seg_start, S32 seg_end, const LLColor4 &defaultColor, LLTextEditor& editor )
+void LLKeywords::insertSegments(const LLWString& wtext, std::vector<LLTextSegmentPtr>& seg_list, LLKeywordToken* cur_token, S32 text_len, S32 seg_start, S32 seg_end, LLStyleConstSP style, LLTextEditor& editor )
 {
 	std::string::size_type pos = wtext.find('\n',seg_start);
+    
+    LLStyleConstSP cur_token_style = new LLStyle(LLStyle::Params().font(style->getFont()).color(cur_token->getColor()));
 
 	while (pos!=-1 && pos < (std::string::size_type)seg_end)
 	{
 		if (pos!=seg_start)
 		{
-			LLTextSegmentPtr text_segment = new LLNormalTextSegment( cur_token->getColor(), seg_start, pos, editor );
+            LLTextSegmentPtr text_segment = new LLNormalTextSegment(cur_token_style, seg_start, pos, editor);
 			text_segment->setToken( cur_token );
-			insertSegment( seg_list, text_segment, text_len, defaultColor, editor);
+			insertSegment( seg_list, text_segment, text_len, style, editor);
 		}
 
 		LLTextSegmentPtr text_segment = new LLLineBreakTextSegment(pos);
 		text_segment->setToken( cur_token );
-		insertSegment( seg_list, text_segment, text_len, defaultColor, editor);
+		insertSegment( seg_list, text_segment, text_len, style, editor);
 
 		seg_start = pos+1;
 		pos = wtext.find('\n',seg_start);
 	}
 
-	LLTextSegmentPtr text_segment = new LLNormalTextSegment( cur_token->getColor(), seg_start, seg_end, editor );
+	LLTextSegmentPtr text_segment = new LLNormalTextSegment(cur_token_style, seg_start, seg_end, editor);
 	text_segment->setToken( cur_token );
-	insertSegment( seg_list, text_segment, text_len, defaultColor, editor);
+	insertSegment( seg_list, text_segment, text_len, style, editor);
 }
 
 void LLKeywords::insertSegment(std::vector<LLTextSegmentPtr>& seg_list, LLTextSegmentPtr new_segment, S32 text_len, const LLColor4 &defaultColor, LLTextEditor& editor )
@@ -744,6 +746,27 @@ void LLKeywords::insertSegment(std::vector<LLTextSegmentPtr>& seg_list, LLTextSe
 	}
 }
 
+void LLKeywords::insertSegment(std::vector<LLTextSegmentPtr>& seg_list, LLTextSegmentPtr new_segment, S32 text_len, LLStyleConstSP style, LLTextEditor& editor )
+{
+	LLTextSegmentPtr last = seg_list.back();
+	S32 new_seg_end = new_segment->getEnd();
+
+	if( new_segment->getStart() == last->getStart() )
+	{
+		seg_list.pop_back();
+	}
+	else
+	{
+		last->setEnd( new_segment->getStart() );
+	}
+	seg_list.push_back( new_segment );
+
+	if( new_seg_end < text_len )
+	{
+		seg_list.push_back( new LLNormalTextSegment( style, new_seg_end, text_len, editor ) );
+	}
+}
+
 #ifdef _DEBUG
 void LLKeywords::dump()
 {
diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h
index 18e2ed06c5..2410fe7d5a 100644
--- a/indra/llui/llkeywords.h
+++ b/indra/llui/llkeywords.h
@@ -29,6 +29,7 @@
 
 
 #include "lldir.h"
+#include "llstyle.h"
 #include "llstring.h"
 #include "v3color.h"
 #include "v4color.h"
@@ -115,8 +116,8 @@ public:
 
 	void		findSegments(std::vector<LLTextSegmentPtr> *seg_list,
 							 const LLWString& text,
-							 const LLColor4 &defaultColor,
-							 class LLTextEditor& editor);
+							 class LLTextEditor& editor,
+                             LLStyleConstSP style);
 	void		initialize(LLSD SyntaxXML);
 	void		processTokens();
 
@@ -181,9 +182,11 @@ protected:
 							   S32 text_len,
 							   S32 seg_start,
 							   S32 seg_end,
-							   const LLColor4 &defaultColor,
+							   LLStyleConstSP style,
 							   LLTextEditor& editor);
 
+    void insertSegment(std::vector<LLTextSegmentPtr>& seg_list, LLTextSegmentPtr new_segment, S32 text_len, LLStyleConstSP style, LLTextEditor& editor );
+
 	bool		mLoaded;
 	LLSD		mSyntax;
 	word_token_map_t mWordTokenMap;
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index ca1b1e2f20..c700302221 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -5420,6 +5420,17 @@
       <key>Value</key>
       <string>http://wiki.secondlife.com/wiki/[LSL_STRING]</string>
     </map>
+    <key>LSLFontSizeName</key>
+    <map>
+        <key>Comment</key>
+        <string>Text font size in LSL editor</string>
+        <key>Persist</key>
+        <integer>1</integer>
+        <key>Type</key>
+        <string>String</string>
+        <key>Value</key>
+        <string>Monospace</string>
+    </map>
     <key>GridStatusRSS</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 9ea49e935f..42b1c87314 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -114,6 +114,7 @@
 #include "llpresetsmanager.h"
 #include "llviewercontrol.h"
 #include "llpresetsmanager.h"
+#include "llinventoryfunctions.h"
 
 #include "llsearchableui.h"
 #include "llperfstats.h"
@@ -1609,25 +1610,6 @@ void LLFloaterPreference::onChangeMaturity()
 	getChild<LLIconCtrl>("rating_icon_adult")->setVisible(sim_access == SIM_ACCESS_ADULT);
 }
 
-std::string get_category_path(LLUUID cat_id)
-{
-    LLViewerInventoryCategory* cat = gInventory.getCategory(cat_id);
-    std::string localized_cat_name;
-    if (!LLTrans::findString(localized_cat_name, "InvFolder " + cat->getName()))
-    {
-        localized_cat_name = cat->getName();
-    }
-
-    if (cat->getParentUUID().notNull())
-    {
-        return get_category_path(cat->getParentUUID()) + " > " + localized_cat_name;
-    }
-    else
-    {
-        return localized_cat_name;
-    }
-}
-
 std::string get_category_path(LLFolderType::EType cat_type)
 {
     LLUUID cat_id = gInventory.findUserDefinedCategoryUUIDForType(cat_type);
diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp
index 67240ac7e7..004f0425fd 100644
--- a/indra/newview/llinventoryfunctions.cpp
+++ b/indra/newview/llinventoryfunctions.cpp
@@ -1967,6 +1967,24 @@ void move_items_to_new_subfolder(const uuid_vec_t& selected_uuids, const std::st
 
 }
 
+std::string get_category_path(LLUUID cat_id)
+{
+    LLViewerInventoryCategory *cat = gInventory.getCategory(cat_id);
+    std::string localized_cat_name;
+    if (!LLTrans::findString(localized_cat_name, "InvFolder " + cat->getName()))
+    {
+        localized_cat_name = cat->getName();
+    }
+
+    if (cat->getParentUUID().notNull())
+    {
+        return get_category_path(cat->getParentUUID()) + " > " + localized_cat_name;
+    }
+    else
+    {
+        return localized_cat_name;
+    }
+}
 ///----------------------------------------------------------------------------
 /// LLInventoryCollectFunctor implementations
 ///----------------------------------------------------------------------------
diff --git a/indra/newview/llinventoryfunctions.h b/indra/newview/llinventoryfunctions.h
index 56ad6f6496..873bd7233c 100644
--- a/indra/newview/llinventoryfunctions.h
+++ b/indra/newview/llinventoryfunctions.h
@@ -97,6 +97,7 @@ void move_items_to_new_subfolder(const uuid_vec_t& selected_uuids, const std::st
 void move_items_to_folder(const LLUUID& new_cat_uuid, const uuid_vec_t& selected_uuids);
 bool is_only_cats_selected(const uuid_vec_t& selected_uuids);
 bool is_only_items_selected(const uuid_vec_t& selected_uuids);
+std::string get_category_path(LLUUID cat_id);
 
 /**                    Miscellaneous global functions
  **                                                                            **
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index d677a996c1..2add126b2d 100644
--- a/indra/newview/llpreviewscript.cpp
+++ b/indra/newview/llpreviewscript.cpp
@@ -86,6 +86,9 @@
 #include "llexperiencecache.h"
 #include "llfloaterexperienceprofile.h"
 #include "llviewerassetupload.h"
+#include "lltoggleablemenu.h"
+#include "llmenubutton.h"
+#include "llinventoryfunctions.h"
 
 const std::string HELLO_LSL =
 	"default\n"
@@ -459,6 +462,13 @@ BOOL LLScriptEdCore::postBuild()
 	LLSyntaxIdLSL::getInstance()->initialize();
 	processKeywords();
 
+    mCommitCallbackRegistrar.add("FontSize.Set", boost::bind(&LLScriptEdCore::onChangeFontSize, this, _2));
+    mEnableCallbackRegistrar.add("FontSize.Check", boost::bind(&LLScriptEdCore::isFontSizeChecked, this, _2));
+
+    LLToggleableMenu *context_menu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>(
+        "menu_lsl_font_size.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
+    getChild<LLMenuButton>("font_btn")->setMenu(context_menu, LLMenuButton::MP_BOTTOM_LEFT, true);
+
 	return TRUE;
 }
 
@@ -1287,7 +1297,21 @@ LLUUID LLScriptEdCore::getAssociatedExperience()const
 	return mAssociatedExperience;
 }
 
-void LLLiveLSLEditor::setExperienceIds( const LLSD& experience_ids )
+void LLScriptEdCore::onChangeFontSize(const LLSD &userdata)
+{
+    const std::string font_name = userdata.asString();
+    gSavedSettings.setString("LSLFontSizeName", font_name);
+}
+
+bool LLScriptEdCore::isFontSizeChecked(const LLSD &userdata)
+{
+    const std::string current_size_name = LLScriptEditor::getScriptFontSize();
+    const std::string size_name = userdata.asString();
+
+    return (size_name == current_size_name);
+}
+
+    void LLLiveLSLEditor::setExperienceIds( const LLSD& experience_ids )
 {
 	mExperienceIds=experience_ids;
 	updateExperiencePanel();
@@ -1475,7 +1499,21 @@ bool LLScriptEdContainer::onExternalChange(const std::string& filename)
 	return true;
 }
 
-/// ---------------------------------------------------------------------------
+BOOL LLScriptEdContainer::handleKeyHere(KEY key, MASK mask) 
+{
+    if (('A' == key) && (MASK_CONTROL == (mask & MASK_MODIFIERS)))
+    {
+        mScriptEd->selectAll();
+        return TRUE;
+    }
+
+    if (!LLPreview::handleKeyHere(key, mask)) 
+    {
+        return mScriptEd->handleKeyHere(key, mask);
+    }
+    return TRUE;
+}
+    /// ---------------------------------------------------------------------------
 /// LLPreviewLSL
 /// ---------------------------------------------------------------------------
 
@@ -1527,10 +1565,14 @@ BOOL LLPreviewLSL::postBuild()
 	if (item)
 	{
 		getChild<LLUICtrl>("desc")->setValue(item->getDescription());
+
+        std::string item_path = get_category_path(item->getParentUUID());
+        getChild<LLUICtrl>("path_txt")->setValue(item_path);
+        getChild<LLUICtrl>("path_txt")->setToolTip(item_path);
 	}
 	childSetCommitCallback("desc", LLPreview::onText, this);
 	getChild<LLLineEditor>("desc")->setPrevalidate(&LLTextValidate::validateASCIIPrintableNoPipe);
-
+ 
 	return LLPreview::postBuild();
 }
 
diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h
index f851ff6f3f..2e5b8ad9bb 100644
--- a/indra/newview/llpreviewscript.h
+++ b/indra/newview/llpreviewscript.h
@@ -36,6 +36,7 @@
 #include "llfloatergotoline.h"
 #include "lllivefile.h"
 #include "llsyntaxid.h"
+#include "llscripteditor.h"
 
 class LLLiveLSLFile;
 class LLMessageSystem;
@@ -145,7 +146,13 @@ public:
     void 			setAssetID( const LLUUID& asset_id){ mAssetID = asset_id; };
     LLUUID 			getAssetID() { return mAssetID; }
 
-private:
+    bool isFontSizeChecked(const LLSD &userdata);
+    void onChangeFontSize(const LLSD &size_name);
+
+    virtual BOOL handleKeyHere(KEY key, MASK mask);
+    void selectAll() { mEditor->selectAll(); }
+
+  private:
 	void		onBtnDynamicHelp();
 	void		onBtnUndoChanges();
 
@@ -153,8 +160,6 @@ private:
 
 	void selectFirstError();
 
-	virtual BOOL handleKeyHere(KEY key, MASK mask);
-	
 	void enableSave(BOOL b) {mEnableSave = b;}
 
 protected:
@@ -207,6 +212,8 @@ public:
 	LLScriptEdContainer(const LLSD& key);
 	LLScriptEdContainer(const LLSD& key, const bool live);
 
+    BOOL handleKeyHere(KEY key, MASK mask);
+
 protected:
 	std::string		getTmpFileName(const std::string& script_name);
 	bool			onExternalChange(const std::string& filename);
diff --git a/indra/newview/llscripteditor.cpp b/indra/newview/llscripteditor.cpp
index 3278bd3aa9..693491e7e7 100644
--- a/indra/newview/llscripteditor.cpp
+++ b/indra/newview/llscripteditor.cpp
@@ -30,19 +30,22 @@
 
 #include "llsyntaxid.h"
 #include "lllocalcliprect.h"
+#include "llviewercontrol.h"
 
 const S32	UI_TEXTEDITOR_LINE_NUMBER_MARGIN = 32;
 
 static LLDefaultChildRegistry::Register<LLScriptEditor> r("script_editor");
 
 LLScriptEditor::Params::Params()
-:	show_line_numbers("show_line_numbers", true)
+:	show_line_numbers("show_line_numbers", true),
+    default_font_size("default_font_size", false)
 {}
 
 
 LLScriptEditor::LLScriptEditor(const Params& p)
 :	LLTextEditor(p)
-,	mShowLineNumbers(p.show_line_numbers)
+,	mShowLineNumbers(p.show_line_numbers),
+    mUseDefaultFontSize(p.default_font_size)
 {
 	if (mShowLineNumbers)
 	{
@@ -51,6 +54,12 @@ LLScriptEditor::LLScriptEditor(const Params& p)
 	}
 }
 
+BOOL LLScriptEditor::postBuild()
+{
+    gSavedSettings.getControl("LSLFontSizeName")->getCommitSignal()->connect(boost::bind(&LLScriptEditor::onFontSizeChange, this));
+    return LLTextEditor::postBuild();
+}
+
 void LLScriptEditor::draw()
 {
 	{
@@ -110,12 +119,11 @@ void LLScriptEditor::drawLineNumbers()
 			// draw the line numbers
 			if(line.mLineNum != last_line_num && line.mRect.mTop <= scrolled_view_rect.mTop)
 			{
-				const LLFontGL *num_font = LLFontGL::getFontMonospace();
 				const LLWString ltext = utf8str_to_wstring(llformat("%d", line.mLineNum ));
 				BOOL is_cur_line = cursor_line == line.mLineNum;
 				const U8 style = is_cur_line ? LLFontGL::BOLD : LLFontGL::NORMAL;
 				const LLColor4 fg_color = is_cur_line ? mCursorColor : mReadOnlyFgColor;
-				num_font->render(
+                getScriptFont()->render(
 								 ltext, // string to draw
 								 0, // begin offset
 								 UI_TEXTEDITOR_LINE_NUMBER_MARGIN - 2, // x
@@ -143,8 +151,10 @@ void LLScriptEditor::loadKeywords()
     LL_PROFILE_ZONE_SCOPED;
 	mKeywords.processTokens();
 	
+    LLStyleConstSP style = new LLStyle(LLStyle::Params().font(getScriptFont()).color(mDefaultColor.get()));
+
 	segment_vec_t segment_list;
-	mKeywords.findSegments(&segment_list, getWText(), mDefaultColor.get(), *this);
+    mKeywords.findSegments(&segment_list, getWText(), *this, style);
 	
 	mSegments.clear();
 	segment_set_t::iterator insert_it = mSegments.begin();
@@ -159,9 +169,12 @@ void LLScriptEditor::updateSegments()
 	if (mReflowIndex < S32_MAX && mKeywords.isLoaded() && mParseOnTheFly)
 	{
         LL_PROFILE_ZONE_SCOPED;
+
+        LLStyleConstSP style = new LLStyle(LLStyle::Params().font(getScriptFont()).color(mDefaultColor.get()));
+
 		// HACK:  No non-ascii keywords for now
 		segment_vec_t segment_list;
-		mKeywords.findSegments(&segment_list, getWText(), mDefaultColor.get(), *this);
+        mKeywords.findSegments(&segment_list, getWText(), *this, style);
 		
 		clearSegments();
 		for (segment_vec_t::iterator list_it = segment_list.begin(); list_it != segment_list.end(); ++list_it)
@@ -211,3 +224,23 @@ void LLScriptEditor::drawSelectionBackground()
 		}
 	}
 }
+
+std::string LLScriptEditor::getScriptFontSize()
+{ 
+    static LLCachedControl<std::string> size_name(gSavedSettings, "LSLFontSizeName", "Monospace");
+    return size_name;
+}
+
+LLFontGL* LLScriptEditor::getScriptFont()
+{
+    std::string font_size_name = mUseDefaultFontSize ? "Monospace" : getScriptFontSize();
+    return LLFontGL::getFont(LLFontDescriptor("Monospace", font_size_name, 0));
+}
+
+void LLScriptEditor::onFontSizeChange() 
+{
+    if (!mUseDefaultFontSize)
+    {
+        needsReflow();
+    }
+}
diff --git a/indra/newview/llscripteditor.h b/indra/newview/llscripteditor.h
index f458203a39..ef941f552a 100644
--- a/indra/newview/llscripteditor.h
+++ b/indra/newview/llscripteditor.h
@@ -37,7 +37,7 @@ public:
 	struct Params : public LLInitParam::Block<Params, LLTextEditor::Params>
 	{
 		Optional<bool>		show_line_numbers;
-		
+        Optional<bool> default_font_size;
 		Params();
 	};
 	
@@ -45,6 +45,7 @@ public:
 	
 	// LLView override
 	virtual void	draw();
+    BOOL postBuild();
 	
 	void	initKeywords();
 	void	loadKeywords();
@@ -52,7 +53,11 @@ public:
 	LLKeywords::keyword_iterator_t keywordsBegin()	{ return mKeywords.begin(); }
 	LLKeywords::keyword_iterator_t keywordsEnd()	{ return mKeywords.end(); }
 	
-protected:
+    static std::string getScriptFontSize();
+    LLFontGL* getScriptFont();
+    void onFontSizeChange();
+
+  protected:
 	friend class LLUICtrlFactory;
 	LLScriptEditor(const Params& p);
 	
@@ -65,6 +70,7 @@ private:
 	
 	LLKeywords	mKeywords;
 	bool		mShowLineNumbers;
+    bool mUseDefaultFontSize;
 };
 
 #endif // LL_SCRIPTEDITOR_H
diff --git a/indra/newview/skins/default/textures/icons/Icon_Color_Palette.png b/indra/newview/skins/default/textures/icons/Icon_Color_Palette.png
new file mode 100644
index 0000000000..28906001ea
Binary files /dev/null and b/indra/newview/skins/default/textures/icons/Icon_Color_Palette.png differ
diff --git a/indra/newview/skins/default/textures/icons/Icon_Font_Size.png b/indra/newview/skins/default/textures/icons/Icon_Font_Size.png
new file mode 100644
index 0000000000..37bdde69aa
Binary files /dev/null and b/indra/newview/skins/default/textures/icons/Icon_Font_Size.png differ
diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml
index 7d999a2ffa..21335bf6c3 100644
--- a/indra/newview/skins/default/textures/textures.xml
+++ b/indra/newview/skins/default/textures/textures.xml
@@ -881,4 +881,7 @@ with the same filename but different name
   <texture name="System_Notification" file_name="icons/SL_Logo.png" preload="true"/>
   <texture name="Icon_Attachment_Small" file_name="icons/Icon_Attachment_Small.png"	preload="true"/>
   <texture name="Icon_Attachment_Large" file_name="icons/Icon_Attachment_Large.png"	preload="true"/>
+
+  <texture name="Icon_Color_Palette" file_name="icons/Icon_Color_Palette.png" preload="false"/>
+  <texture name="Icon_Font_Size" file_name="icons/Icon_Font_Size.png" preload="false"/>
 </textures>
diff --git a/indra/newview/skins/default/xui/en/floater_script_ed_prefs.xml b/indra/newview/skins/default/xui/en/floater_script_ed_prefs.xml
index 8e4bcb3eb0..8ae1e74d52 100644
--- a/indra/newview/skins/default/xui/en/floater_script_ed_prefs.xml
+++ b/indra/newview/skins/default/xui/en/floater_script_ed_prefs.xml
@@ -335,6 +335,7 @@
      layout="topleft"
      max_length="300"
      name="Script Preview"
+     default_font_size="true"
      text_color="ScriptText"
      default_color="ScriptText"
      bg_writeable_color="ScriptBackground"
diff --git a/indra/newview/skins/default/xui/en/floater_script_preview.xml b/indra/newview/skins/default/xui/en/floater_script_preview.xml
index 91a9e67e4c..5bec45e666 100644
--- a/indra/newview/skins/default/xui/en/floater_script_preview.xml
+++ b/indra/newview/skins/default/xui/en/floater_script_preview.xml
@@ -2,10 +2,10 @@
 <floater
  legacy_header_height="18"
  can_resize="true"
- height="570"
+ height="593"
  layout="topleft"
  min_height="271"
- min_width="290"
+ min_width="320"
  name="preview lsl text"
  help_topic="preview_lsl_text"
  save_rect="true"
@@ -21,7 +21,7 @@
      layout="topleft"
      left="10"
      name="script panel"
-     top="42"
+     top="65"
      width="497" />
     <icon
      follows="top|right"
@@ -33,6 +33,21 @@
      name="lock"
      top="4"
      width="18" />
+    <text
+     type="string"
+     length="1"
+     follows="left|top|right"
+     width="490"
+     use_ellipses="true"
+     font="SansSerif"
+     height="19"
+     layout="topleft"
+     left="13"
+     name="path_txt"
+     text_color="white"
+     top="21">
+        File path
+    </text>
     <text
      type="string"
      length="1"
@@ -42,7 +57,7 @@
      layout="topleft"
      left="13"
      name="desc txt"
-     top="19"
+     top_pad="5"
      width="80">
         Description:
     </text>
diff --git a/indra/newview/skins/default/xui/en/fonts.xml b/indra/newview/skins/default/xui/en/fonts.xml
index d88c267a95..3c3eb6b66f 100644
--- a/indra/newview/skins/default/xui/en/fonts.xml
+++ b/indra/newview/skins/default/xui/en/fonts.xml
@@ -170,4 +170,12 @@
 	     comment="Size of small font (points, or 1/72 of an inch)"
 	     size="7.6"
 	     />
+  <font_size name="SmallLSL"
+         comment="Size of small font for LSL editor (points, or 1/72 of an inch)"
+         size="7"
+         />
+  <font_size name="HugeLSL"
+         comment="Size of huge font for LSL editor (points, or 1/72 of an inch)"
+         size="12"
+         />
 </fonts>
diff --git a/indra/newview/skins/default/xui/en/menu_lsl_font_size.xml b/indra/newview/skins/default/xui/en/menu_lsl_font_size.xml
new file mode 100644
index 0000000000..39a2bc511c
--- /dev/null
+++ b/indra/newview/skins/default/xui/en/menu_lsl_font_size.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<toggleable_menu
+ bottom="806"
+ layout="topleft"
+ left="0"
+ mouse_opaque="false"
+ name="menu_font_size"
+ visible="false">
+  <menu_item_check
+   label="Small"
+   layout="topleft"
+   name="font_small">
+    <on_click
+     function="FontSize.Set"
+     parameter="SmallLSL" />
+    <on_check
+     function="FontSize.Check"
+     parameter="SmallLSL" />
+  </menu_item_check>
+  <menu_item_check
+   label="Default"
+   layout="topleft"
+   name="font_monospace">
+    <on_click
+     function="FontSize.Set"
+     parameter="Monospace" />
+    <on_check
+     function="FontSize.Check"
+     parameter="Monospace" />
+    </menu_item_check>
+  <menu_item_check
+   label="Medium"
+   layout="topleft"
+   name="font_medium">
+    <on_click
+     function="FontSize.Set"
+     parameter="Medium" />
+    <on_check
+     function="FontSize.Check"
+     parameter="Medium" />
+  </menu_item_check>
+  <menu_item_check
+   label="Large"
+   layout="topleft"
+   name="font_large">
+    <on_click
+     function="FontSize.Set"
+     parameter="Large" />
+    <on_check
+     function="FontSize.Check"
+     parameter="Large" />
+  </menu_item_check>
+  <menu_item_check
+   label="Huge"
+   layout="topleft"
+   name="font_huge">
+    <on_click
+     function="FontSize.Set"
+     parameter="HugeLSL" />
+    <on_check
+     function="FontSize.Check"
+     parameter="HugeLSL" />
+  </menu_item_check>
+</toggleable_menu>
diff --git a/indra/newview/skins/default/xui/en/panel_script_ed.xml b/indra/newview/skins/default/xui/en/panel_script_ed.xml
index 545c01935b..be20cfd880 100644
--- a/indra/newview/skins/default/xui/en/panel_script_ed.xml
+++ b/indra/newview/skins/default/xui/en/panel_script_ed.xml
@@ -48,6 +48,7 @@
       width="138">
       <menu_item_call
         label="Save"
+        shortcut="control|S"
         layout="topleft"
         name="Save" />
       <menu_item_separator
@@ -66,16 +67,6 @@
         label="Save to file..."
         layout="topleft"
         name="SaveToFile" />
-          <menu_item_separator
-           layout="topleft" />
-          <menu_item_call
-           label="Colors..."
-           layout="topleft"
-           name="Colors">
-            <menu_item_call.on_click
-             function="Floater.Toggle"
-             parameter="script_colors"/>
-          </menu_item_call>
     </menu>
     <menu
       top="0"
@@ -117,6 +108,7 @@
         name="separator2" />
       <menu_item_call
         label="Select All"
+        shortcut="control|A"
         layout="topleft"
         name="Select All" />
       <menu_item_call
@@ -150,12 +142,34 @@
         name="Keyword Help..." />
     </menu>
   </menu_bar>
+  <menu_button
+   follows="right|top"
+   height="24"
+   image_overlay="Icon_Font_Size"
+   layout="topleft"
+   top_delta="-2"
+   right="453"
+   name="font_btn"
+   width="32" />
+  <button
+   follows="right|top"
+   height="24"
+   image_overlay="Icon_Color_Palette"
+   layout="topleft"
+   top_delta="0"
+   right="487"
+   name="color_btn"
+   width="32">
+    <button.commit_callback
+      function="Floater.Toggle"
+      parameter="script_colors"/>
+  </button>
     <script_editor
     left="0"
     type="string"
     length="1"
     follows="left|top|right|bottom"
-    font="Monospace"
+
      height="376"
     ignore_tab="false"
     layout="topleft"
-- 
cgit v1.2.3