diff --git a/trunk/EditForm.cs b/trunk/EditForm.cs
index ffd36b8..50b755e 100644
--- a/trunk/EditForm.cs
+++ b/trunk/EditForm.cs
@@ -564,8 +564,7 @@ namespace LSLEditor
if (LSLIPathHelper.IsExpandedLSL(ScriptName))
{
// Check if a LSLI readonly is open
- EditForm readOnlyLSLI = (EditForm)parent.GetForm(Path.GetFileName(
- LSLIPathHelper.CreateCollapsedScriptName(ScriptName)) + " (Read Only)");
+ EditForm readOnlyLSLI = (EditForm)parent.GetForm(Path.GetFileName(LSLIPathHelper.GetReadOnlyTabName(ScriptName)));
if (readOnlyLSLI != null)
{
@@ -573,11 +572,21 @@ namespace LSLEditor
}
}
- // Delete expanded file when closing
- string expandedFile = LSLIPathHelper.CreateExpandedPathAndScriptName(FullPathName);
- if (File.Exists(expandedFile))
+ if(!this.parent.IsReadOnly(this)) // If this is not a readonly (LSLI)
{
- File.Delete(expandedFile);
+ // Delete expanded file when closing
+ string expandedFile = LSLIPathHelper.CreateExpandedPathAndScriptName(FullPathName);
+ EditForm expandedForm = (EditForm)parent.GetForm(LSLIPathHelper.GetExpandedTabName(Path.GetFileName(expandedFile)));
+
+ if (expandedForm != null && !LSLIPathHelper.IsExpandedLSL(ScriptName))
+ {
+ expandedForm.Close();
+ }
+
+ if (File.Exists(expandedFile))
+ {
+ File.Delete(expandedFile);
+ }
}
}
this.parent.CancelClosing = e.Cancel;
diff --git a/trunk/Helpers/LSLIConverter.cs b/trunk/Helpers/LSLIConverter.cs
index d60dc2d..45c0bf2 100644
--- a/trunk/Helpers/LSLIConverter.cs
+++ b/trunk/Helpers/LSLIConverter.cs
@@ -34,6 +34,8 @@
//
//
// This class is used to convert LSLI to LSL and the other way around.
+// Created by Jasper Wiggerink
+// 13-11-2017
//
using System;
@@ -49,16 +51,16 @@ namespace LSLEditor.Helpers
class LSLIConverter
{
private EditForm editForm;
- private const string BEGIN = "//@BEGIN";
- private const string END = "//@END";
- private const string INCLUDE = "//@include";
+ private const string BEGIN = "//#BEGIN";
+ private const string END = "//#END";
+ private const string INCLUDE = "//#include";
public const string EXPANDED_SUBEXT = ".expanded";
public const string LSL_EXT = ".lsl";
public const string LSLI_EXT = ".lsli";
public static List validExtensions = new List() { LSLI_EXT, LSL_EXT };
- private const string INCLUDE_REGEX = "(\n|^)\\s*" + INCLUDE + "\\(\".*?\"\\).*";//"(\\s+|^)" + INCLUDE + "\\(\".*?\"\\)";
+ private const string INCLUDE_REGEX = "(\n|^)\\s*" + INCLUDE + "\\(\".*?\"\\).*";
private const string BEGIN_REGEX = "(\\s+|^)" + BEGIN;
private const string END_REGEX = "(\\s+|^)" + END;
private const string EMPTY_OR_WHITESPACE_REGEX = "^\\s*$";
@@ -74,43 +76,22 @@ namespace LSLEditor.Helpers
}
- //private string GetFile(string file) // TODO?
- //{
- // if (File.Exists(directory))
- // {
- // return file;
- // }
- // if (Path.GetExtension(file) == "")
- // {
- // string pFile = "";
-
- // foreach (string extension in validExtensions)
- // {
- // pFile = file + extension;
-
- // if (File.Exists(pFile))
- // {
- // return pFile;
- // }
- // }
- // }
- //}
-
///
/// Searches for a file with one of the validExtensions based on a name or path. Also searches in the IncludeDirectories
///
///
/// File path
- private string SearchFile(string file)
+ private static string SearchFile(string file)
{
- // If setting IncludeDirectories is enabled
+ // Search in optional include directories
foreach (string directory in Properties.Settings.Default.IncludeDirectories)
{
string pFile;
- if(file.Contains(directory))
+ if (file.ToLower().Contains(directory.ToLower()))
{
pFile = file;
- } else
+ }
+ else
{
pFile = directory + file;
}
@@ -141,33 +122,66 @@ namespace LSLEditor.Helpers
}
}
- // If IncludeDirectories setting is disabled
- if (Properties.Settings.Default.IncludeDirectories.Count == 0)
+ // Search for file relative to the script
+ if (File.Exists(file))
{
- if (File.Exists(file))
+ return file;
+ }
+
+ if (Path.GetExtension(file) == "")
+ {
+ string pFile = "";
+
+ foreach (string extension in validExtensions)
{
- return file;
- }
+ pFile = file + extension;
- if (Path.GetExtension(file) == "")
- {
- string pFile = "";
-
- foreach (string extension in validExtensions)
- {
- pFile = file + extension;
-
- if (File.Exists(pFile)) {
- return pFile;
- }
+ if (File.Exists(pFile)) {
+ return pFile;
}
}
}
-
return "";
}
+ ///
+ /// Returns the path of the file
+ ///
+ ///
+ ///
+ ///
+ private string GetFilePath(string pathOfInclude, string pathOfScript)
+ {
+ // Step 1 (optional). Search from include directories
+ // Step 2. Search from relative path from script
+
+ string pathOfIncludeOriginal = pathOfInclude;
+ pathOfInclude = SearchFile(pathOfInclude);
+
+ if (pathOfInclude == "")
+ {
+ // If path is relative and no includedirectories
+ if (!Path.IsPathRooted(pathOfIncludeOriginal))
+ {
+ pathOfInclude = LSLIPathHelper.GetRelativePath(pathOfScript, Environment.CurrentDirectory) + pathOfIncludeOriginal;
+ }
+ else if (this.implementedIncludes.Count > 0) // If there are already includes, the relative path is already correct
+ {
+ pathOfInclude = Path.GetDirectoryName(this.implementedIncludes.LastOrDefault()) + '\\' + pathOfIncludeOriginal;
+ }
+ else
+ {
+ pathOfInclude = pathOfIncludeOriginal;
+ }
+
+ // If path is absolute it will stay the pathOfInclude
+ pathOfInclude = SearchFile(pathOfInclude);
+ }
+
+ return pathOfInclude;
+ }
+
///
/// Finds all indexes of a value in a string
///
@@ -176,16 +190,34 @@ namespace LSLEditor.Helpers
///
public static List AllIndexesOf(string str, string value)
{
- if (String.IsNullOrEmpty(value))
- throw new ArgumentException("The string to find may not be empty", "value");
- List indexes = new List();
- for (int index = 0; ; index += value.Length)
+ if (!String.IsNullOrEmpty(value))
{
- index = str.IndexOf(value, index);
- if (index == -1)
- return indexes;
- indexes.Add(index);
+ List indexes = new List();
+ for (int index = 0; ; index += value.Length)
+ {
+ index = str.IndexOf(value, index);
+ if (index == -1)
+ return indexes;
+ indexes.Add(index);
+ }
}
+ return null;
+ }
+
+ ///
+ /// Compares 2 paths and returns true if they are different, false if they're the same.
+ /// Warning: This doesn't compare extensions.
+ ///
+ ///
+ ///
+ ///
+ public static bool IsDifferentScript(string pathOfInclude, string pathOfScript)
+ {
+ string pathOfScriptNoExt = LSLIPathHelper.RemoveExpandedSubExtension(Path.GetFileNameWithoutExtension(pathOfScript));
+ string pathOfIncludeNoExt = LSLIPathHelper.RemoveExpandedSubExtension(Path.GetFileNameWithoutExtension(pathOfInclude));
+
+ // Compare paths
+ return !pathOfScriptNoExt.EndsWith(pathOfIncludeNoExt);
}
///
@@ -254,7 +286,6 @@ namespace LSLEditor.Helpers
}
context.Insert(includeIndex, newLine);
- string test = context.ToString(); // Debug only
return context;
}
@@ -277,7 +308,7 @@ namespace LSLEditor.Helpers
///
///
///
- private string GetTabsForIncludeDepth(int includeDepth, bool OneLess = false) // TODO: Dit wordt wss een setting. Tabs hangt namelijk af van de hoeveelheid ingedente include statement.
+ private string GetTabsForIncludeDepth(int includeDepth, bool OneLess = false)
{
string tabs = "";
if(OneLess && includeDepth != 0)
@@ -299,14 +330,22 @@ namespace LSLEditor.Helpers
///
private string GetTabsForIndentedInclude(string includeLine, int includeDepth, bool isDebug = false)
{
- if(includeLine.Contains("\t"))
+ if(includeLine.Contains('\t'))
{
int includeIndex = Regex.Match(includeLine, INCLUDE).Index;
string beforeInclude = includeLine.Substring(0, includeIndex);
+
+ if(beforeInclude.Contains('\n'))
+ {
+ // Last '\n' before includeIndex
+ int lastIndexNewLine = beforeInclude.LastIndexOf('\n');
+ beforeInclude = beforeInclude.Substring(lastIndexNewLine, beforeInclude.Length - lastIndexNewLine);
+ }
+
int tabCount = 0;
- // Count the tabs between the start of the line and the begin of the include. NOTE: HIJ MOET ALLEEN DE INCLUDEDEPTH AFTREKKEN WANNEER HIJ DEBUG IS
+ // Count the tabs between the start of the line and the begin of the include.
if (isDebug)
{
tabCount = beforeInclude.Count(f => f == '\t') - (includeDepth - 1); // The tabcount should be without the includeDepth, because this was already added.
@@ -326,7 +365,42 @@ namespace LSLEditor.Helpers
}
///
- /// Returns the amount of tabs for an include script
+ /// Returns the amount of spaces in front of an include statement
+ ///
+ ///
+ ///
+ private string GetSpacesForIndentedInclude(string includeLine, int includeDepth, bool isDebug = false)
+ {
+ if (includeLine.Contains(" "))
+ {
+ int includeIndex = Regex.Match(includeLine, INCLUDE).Index;
+
+ string beforeInclude = includeLine.Substring(0, includeIndex);
+ int spaceCount = 0;
+
+ // Count the space between the start of the line and the begin of the include.
+ if (isDebug)
+ {
+ // The spacecount should be without the includeDepth, because this was already added.
+ spaceCount = beforeInclude.Count(f => f == ' ') - (includeDepth - 1);
+ }
+ else
+ {
+ spaceCount = beforeInclude.Count(f => f == ' ');
+ }
+
+ string spaces = "";
+ for (int i = 0; i < spaceCount; i++)
+ {
+ spaces += " ";
+ }
+ return spaces;
+ }
+ return "";
+ }
+
+ ///
+ /// Returns the amount of tabs/spaces for an include script
///
///
///
@@ -336,9 +410,9 @@ namespace LSLEditor.Helpers
{
string includeDepthTabs = GetTabsForIncludeDepth(includeDepth, OneLess);
string indentedIncludeTabs = GetTabsForIndentedInclude(includeLine, includeDepth, true);
-
+ string spacesForIndentedInclude = GetSpacesForIndentedInclude(includeLine, includeDepth, true);
- return includeDepthTabs + indentedIncludeTabs;
+ return includeDepthTabs + indentedIncludeTabs + spacesForIndentedInclude;
}
///
@@ -424,7 +498,7 @@ namespace LSLEditor.Helpers
}
///
- /// Imports scripts from //@include statements
+ /// Imports scripts from //#include statements
///
/// Sourcecode
/// Path of the source code of the script
@@ -433,7 +507,7 @@ namespace LSLEditor.Helpers
{
if(!LSLIPathHelper.IsLSLI(pathOfScript))
{
- // If it's not LSLI extension it can't import a script
+ // If it's not an LSLI script, it can't import a script
return strC;
}
@@ -455,26 +529,17 @@ namespace LSLEditor.Helpers
string pathOfInclude = pathOfIncludeOriginal;
string ext = Path.GetExtension(pathOfInclude).ToLower();
- if ((validExtensions.Contains(ext) || ext == "") && !LSLIPathHelper.CreateExpandedScriptName(pathOfScript).Contains(pathOfInclude)
- && !pathOfScript.Contains(pathOfInclude))
+ if ((validExtensions.Contains(ext) || ext == "") && IsDifferentScript(pathOfInclude, pathOfScript))
{
- // If path is relative
- if (!Path.IsPathRooted(pathOfInclude) && Properties.Settings.Default.IncludeDirectories.Count == 0)
- {
- pathOfInclude = LSLIPathHelper.GetRelativePath(pathOfScript, Environment.CurrentDirectory) + pathOfInclude;
- } else if (this.implementedIncludes.Count > 0)
- {
- pathOfInclude = Path.GetDirectoryName(this.implementedIncludes.LastOrDefault()) + '\\' + pathOfInclude;
- }
-
- pathOfInclude = SearchFile(pathOfInclude);
+ pathOfInclude = GetFilePath(pathOfInclude, pathOfScript);
if (pathOfInclude != "" && !this.implementedIncludes.Contains(Path.GetFullPath(pathOfInclude)))
{
- if(!ShowBeginEnd)
+ if (!ShowBeginEnd)
{
sb = WriteExportScript(pathOfInclude, sb, line);
- } else
+ }
+ else
{
sb = WriteDebugScript(pathOfInclude, sb, line);
}
@@ -488,7 +553,8 @@ namespace LSLEditor.Helpers
ShowError(message);
} else
{
- string correctPath = Path.GetFullPath(LSLIPathHelper.GetRelativePath(pathOfScript, Environment.CurrentDirectory) + pathOfIncludeOriginal);
+ string relativeToPathOfScript = LSLIPathHelper.GetRelativePath(pathOfScript, Environment.CurrentDirectory);
+ string correctPath = Path.GetFullPath(relativeToPathOfScript) + pathOfIncludeOriginal;
string message = "Error: Unable to find file \"" + correctPath +
"\". In script \"" + Path.GetFileName(pathOfScript) + "\". Line " + lineNumber + ".";
@@ -598,6 +664,7 @@ namespace LSLEditor.Helpers
/// LSL
public string ExpandToLSL(EditForm editForm, bool ShowBeginEnd = true)
{
+ editForm.verboseQueue = new List();
this.editForm = editForm;
string strC = editForm.SourceCode;
string fullPathName = editForm.FullPathName;
diff --git a/trunk/Helpers/LSLIPathHelper.cs b/trunk/Helpers/LSLIPathHelper.cs
index 41ca3a3..c1027da 100644
--- a/trunk/Helpers/LSLIPathHelper.cs
+++ b/trunk/Helpers/LSLIPathHelper.cs
@@ -34,18 +34,19 @@
//
//
// This class is used to help with paths and LSLI files.
+// Created by Jasper Wiggerink
+// 13-11-2017
//
using System;
-using System.Collections.Generic;
using System.IO;
-using System.Linq;
-using System.Text;
namespace LSLEditor.Helpers
{
static class LSLIPathHelper
{
+ public const string READONLY_TAB_EXTENSION = " (Read Only)";
+ public const string EXPANDED_TAB_EXTENSION = " (Expanded LSL)";
///
/// Checks if a filename is LSLI
@@ -79,12 +80,22 @@ namespace LSLEditor.Helpers
return nameCollapsed;
}
+ ///
+ /// Removes only the last extension
+ ///
+ ///
+ ///
private static string RemoveExtension(string filename)
{
filename = TrimStarsAndWhiteSpace(filename.Remove(filename.LastIndexOf(Path.GetExtension(filename))));
return filename;
}
+ ///
+ /// Removes the .expanded in a filename
+ ///
+ ///
+ ///
public static string RemoveExpandedSubExtension(string filename)
{
if (filename.Contains(LSLIConverter.EXPANDED_SUBEXT))
@@ -136,6 +147,11 @@ namespace LSLEditor.Helpers
return PutDotInFrontOfFilename(TrimStarsAndWhiteSpace(nameExpanded));
}
+ ///
+ /// Puts dot in front of a filename, e.g. "path/file.lsl" to "path/.file.lsl"
+ ///
+ ///
+ ///
private static string PutDotInFrontOfFilename(string filename)
{
int afterLastIndexOfSeperator = (filename.LastIndexOf('\\') > filename.LastIndexOf('/') ? filename.LastIndexOf('\\') : filename.LastIndexOf('/')) + 1;
@@ -149,6 +165,11 @@ namespace LSLEditor.Helpers
return filename;
}
+ ///
+ /// If found, removes the dot in front of a filename.
+ ///
+ ///
+ ///
public static string RemoveDotInFrontOfFilename(string filename)
{
int afterLastIndexOfSeperator = (filename.LastIndexOf('\\') > filename.LastIndexOf('/') ? filename.LastIndexOf('\\') : filename.LastIndexOf('/')) + 1;
@@ -183,6 +204,11 @@ namespace LSLEditor.Helpers
}
}
+ ///
+ /// Trims the "dirty" stars and whitespace in a string. E.g. "file*.lsl " to "file.lsl"
+ ///
+ ///
+ ///
public static string TrimStarsAndWhiteSpace(string str)
{
return str.Trim(' ').TrimEnd('*');
@@ -196,10 +222,19 @@ namespace LSLEditor.Helpers
public static string GetExpandedTabName(string path)
{
if (path == null) return "";
- return RemoveDotInFrontOfFilename(Path.GetFileNameWithoutExtension(RemoveExpandedSubExtension(path)) + LSLIConverter.LSLI_EXT + " (Expanded LSL)");
+ return RemoveDotInFrontOfFilename(Path.GetFileNameWithoutExtension(RemoveExpandedSubExtension(path)) + LSLIConverter.LSLI_EXT + EXPANDED_TAB_EXTENSION);
}
- // TODO: CREATE SAME FUNCTION AS ABOVE FOR READONLY TAB NAME (IS CURRENTLY HARD-CODED)
+ ///
+ /// Turns a LSLI readonly script name into a string to be displayed as the tab name
+ ///
+ ///
+ ///
+ public static string GetReadOnlyTabName(string filename)
+ {
+ if (filename == null) return "";
+ return CreateCollapsedPathAndScriptName(filename) + READONLY_TAB_EXTENSION;
+ }
///
/// Creates a relative path between two paths
diff --git a/trunk/ImagesSolutionExplorer/LSLIScript.gif b/trunk/ImagesSolutionExplorer/LSLIScript.gif
new file mode 100644
index 0000000..90f2467
Binary files /dev/null and b/trunk/ImagesSolutionExplorer/LSLIScript.gif differ
diff --git a/trunk/LSLEditorForm.cs b/trunk/LSLEditorForm.cs
index 8f1e4f8..517c59b 100644
--- a/trunk/LSLEditorForm.cs
+++ b/trunk/LSLEditorForm.cs
@@ -356,7 +356,7 @@ namespace LSLEditor
{
EditForm editForm = (EditForm)this.ActiveMdiForm;
string expandedWarning = "";
- if (Helpers.LSLIPathHelper.IsExpandedLSL(editForm.ScriptName))
+ if (editForm != null && Helpers.LSLIPathHelper.IsExpandedLSL(editForm.ScriptName))
{
expandedWarning = "Warning: Editing in included sections will be erased when collapsing/saving!";
}
@@ -599,15 +599,24 @@ namespace LSLEditor
DialogResult dialogresult = DialogResult.OK;
if (editForm.FullPathName == Properties.Settings.Default.ExampleName || blnSaveAs) {
SaveFileDialog saveDialog = editForm.IsScript ? this.saveScriptFilesDialog : this.saveNoteFilesDialog;
- saveDialog.FileName = editForm.FullPathName;
- string strExtension = Path.GetExtension(editForm.FullPathName);
+
+ // Save as LSLI when it's an expanded LSL
+ if (Helpers.LSLIPathHelper.IsExpandedLSL(editForm.ScriptName))
+ {
+ saveDialog.FileName = Helpers.LSLIPathHelper.CreateCollapsedScriptName(editForm.ScriptName);
+ } else
+ {
+ saveDialog.FileName = editForm.ScriptName;
+ }
+ //saveDialog.FileName = editForm.FullPathName;
+ string strExtension = Path.GetExtension(editForm.FullPathName);
dialogresult = saveDialog.ShowDialog();
if (dialogresult == DialogResult.OK) {
editForm.FullPathName = saveDialog.FileName;
}
}
if (dialogresult == DialogResult.OK) {
- editForm.SaveCurrentFile();
+ editForm.SaveCurrentFile();
UpdateRecentFileList(editForm.FullPathName);
return true;
}
@@ -753,6 +762,7 @@ namespace LSLEditor
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
+ // Check if a LSLI or expanded LSL open is, and close that one as well
this.Close();
}
@@ -1160,8 +1170,19 @@ namespace LSLEditor
if (editForm == null || editForm.IsDisposed) {
continue;
}
+
if (editForm.FullPathName == e.FullPathName) {
- ActivateMdiForm(editForm);
+ if (!editForm.Visible)
+ {
+ if(Helpers.LSLIPathHelper.IsExpandedLSL(editForm.ScriptName) && GetForm(Helpers.LSLIPathHelper.CreateCollapsedScriptName(editForm.ScriptName)).Visible)
+ {
+ //SetReadOnly((EditForm) GetForm(Helpers.LSLIPathHelper.CreateCollapsedScriptName(editForm.ScriptName)), true); // Doesn't seem to work? Why?
+ EditForm LSLIForm = (EditForm)GetForm(Helpers.LSLIPathHelper.CreateCollapsedScriptName(editForm.ScriptName));
+ LSLIForm.Close();
+ }
+ editForm.Show();
+ }
+ ActivateMdiForm(editForm);
editForm.TextBox.Goto(e.Line, e.Char);
editForm.Focus();
return;
@@ -1198,6 +1219,43 @@ namespace LSLEditor
this.SimulatorConsole = null;
}
+ ///
+ /// When running an LSLI script, a related expanded LSL script or LSLI readonly may be opened. These should not be ran/checked for syntax.
+ /// An LSLI script should also first be expanded to an LSL script before it checks for syntax.
+ ///
+ ///
+ ///
+ private EditForm SelectEditFormToRun(EditForm editForm)
+ {
+ if (Helpers.LSLIPathHelper.IsLSLI(editForm.ScriptName) && editForm.Visible && !IsReadOnly(editForm))
+ {
+ // Open and hide or select the expanded LSLI form
+ EditForm expandedForm = (EditForm)GetForm(Helpers.LSLIPathHelper.GetExpandedTabName(editForm.ScriptName));
+ if (expandedForm == null)
+ {
+ // Create the LSL
+ ExpandForm(editForm);
+ expandedForm = (EditForm)GetForm(Helpers.LSLIPathHelper.GetExpandedTabName(editForm.ScriptName));
+ editForm = expandedForm;
+ }
+ else
+ {
+ ExpandForm(editForm);
+ editForm.Close();
+ }
+ }
+ else if (Helpers.LSLIPathHelper.IsExpandedLSL(editForm.ScriptName))
+ {
+ // NOTE: WAAROM COLLAPSED HIJ HEM EERST? ZO VERWIJDERD HIJ DE VERANDERINGEN IN DE EXPANDED INCLUDE SECTIONS
+ //CollapseForm(editForm);
+ //EditForm collapsedForm = (EditForm)GetForm(Helpers.LSLIPathHelper.CreateCollapsedScriptName(editForm.ScriptName));
+ //ExpandForm(collapsedForm);
+ EditForm expandedForm = (EditForm)GetForm(Helpers.LSLIPathHelper.GetExpandedTabName(editForm.ScriptName));
+ editForm = expandedForm;
+ }
+ return editForm;
+ }
+
private bool SyntaxCheck(bool Silent)
{
//TODO: What do we hide on SyntaxCheck?
@@ -1206,7 +1264,9 @@ namespace LSLEditor
foreach (Form form in this.Children) {
EditForm editForm = form as EditForm;
- if (editForm == null || editForm.IsDisposed) {
+ editForm = SelectEditFormToRun(editForm);
+
+ if (editForm == null || editForm.IsDisposed || !editForm.Visible || IsReadOnly(editForm)) {
continue;
}
if (Properties.Settings.Default.AutoSaveOnDebug) {
@@ -1856,10 +1916,10 @@ namespace LSLEditor
public Form GetForm(string formName)
{
EditForm desirableForm = null;
- for (int i = 0; i < Children.Length; i++) //Application.OpenForms
+ for (int i = 0; i < Children.Length; i++)
{
Form form = Children[i];
- if (Helpers.LSLIPathHelper.TrimStarsAndWhiteSpace(form.Text) == formName) //.TrimEnd(' ')
+ if (Helpers.LSLIPathHelper.TrimStarsAndWhiteSpace(form.Text) == formName)
{
desirableForm = (EditForm)form;
}
@@ -1877,7 +1937,6 @@ namespace LSLEditor
{
foreach (Control c in form.tabControl.SelectedTab.Controls)
{
- Type dfsa = c.GetType();
if (c.GetType() == typeof(SplitContainer))
{
NumberedTextBox.NumberedTextBoxUC a = (NumberedTextBox.NumberedTextBoxUC)((SplitContainer)c).ActiveControl;
@@ -1898,7 +1957,6 @@ namespace LSLEditor
{
foreach (Control c in form.tabControl.SelectedTab.Controls)
{
- Type dfsa = c.GetType();
if (c.GetType() == typeof(SplitContainer))
{
NumberedTextBox.NumberedTextBoxUC a = (NumberedTextBox.NumberedTextBoxUC)((SplitContainer)c).ActiveControl;
@@ -1914,33 +1972,27 @@ namespace LSLEditor
return false;
}
- private void expandToLSLToolStripMenuItem_Click(object sender, EventArgs e)
+ ///
+ /// Expands an editform and opens it. Hides the LSLI
+ ///
+ ///
+ public void ExpandForm(EditForm editForm)
{
- EditForm editForm = this.ActiveMdiForm as EditForm;
-
- if (editForm != null && Helpers.LSLIPathHelper.IsLSLI(editForm.Text))
+ if (editForm != null && Helpers.LSLIPathHelper.IsLSLI(editForm.ScriptName))
{
Helpers.LSLIConverter converter = new Helpers.LSLIConverter();
string lsl = converter.ExpandToLSL(editForm);
string file = Helpers.LSLIPathHelper.CreateExpandedPathAndScriptName(editForm.FullPathName);
+ EditForm oldExpandedForm = (EditForm)GetForm(Helpers.LSLIPathHelper.GetExpandedTabName(Helpers.LSLIPathHelper.CreateExpandedScriptName(editForm.ScriptName)));
// Check if the expanded form is already open. If so, then overwrite the content of it.
- if(GetForm(Helpers.LSLIPathHelper.GetExpandedTabName(Helpers.LSLIPathHelper.CreateExpandedScriptName(editForm.ScriptName))) != null)
+ if (oldExpandedForm != null)//
{
- EditForm oldExpandedForm = (EditForm)GetForm(Helpers.LSLIPathHelper.GetExpandedTabName(Helpers.LSLIPathHelper.CreateExpandedScriptName(editForm.ScriptName)));
oldExpandedForm.SourceCode = lsl;
//oldExpandedForm.TabIndex = editForm.TabIndex; // TODO: Keep tabIndex when expanding/collapsing the same
oldExpandedForm.Show();
SetReadOnly(oldExpandedForm, false);
oldExpandedForm.Dirty = editForm.Dirty;
-
- if (editForm.Dirty)
- {
- oldExpandedForm.Text = Helpers.LSLIPathHelper.GetExpandedTabName(editForm.Text) + "*";
- } else
- {
- oldExpandedForm.Text = Helpers.LSLIPathHelper.GetExpandedTabName(editForm.Text);
- }
}
else
{ // If not already open
@@ -1950,7 +2002,7 @@ namespace LSLEditor
{
sw.Write(lsl);
}
-
+
Helpers.LSLIPathHelper.HideFile(file);
EditForm expandedForm = (EditForm)GetForm(Helpers.LSLIPathHelper.CreateExpandedScriptName(Path.GetFileName(file)));
@@ -1963,16 +2015,20 @@ namespace LSLEditor
OpenFile(file);
EditForm lslForm = (EditForm)GetForm(Helpers.LSLIPathHelper.GetExpandedTabName(file));
lslForm.Dirty = editForm.Dirty;
- //lslForm.Text = Helpers.LSLIPathHelper.GetExpandedTabName(editForm.Text);
}
editForm.Hide();
}
}
- private void CollapseToLSLIToolStripMenuItem_Click(object sender, EventArgs e)
+ // Expand to LSL button (F11)
+ private void expandToLSLToolStripMenuItem_Click(object sender, EventArgs e)
{
EditForm editForm = this.ActiveMdiForm as EditForm;
-
+ ExpandForm(editForm);
+ }
+
+ public void CollapseForm(EditForm editForm)
+ {
if (editForm != null && Helpers.LSLIPathHelper.IsExpandedLSL(editForm.ScriptName))
{
Helpers.LSLIConverter converter = new Helpers.LSLIConverter();
@@ -1981,7 +2037,7 @@ namespace LSLEditor
string lsli = converter.CollapseToLSLIFromEditform(editForm);
string file = Helpers.LSLIPathHelper.CreateCollapsedPathAndScriptName(editForm.FullPathName);
-
+
// Check if the LSLI form is already open (but hidden)
if (GetForm(Path.GetFileName(file)) != null)
{
@@ -1996,17 +2052,26 @@ namespace LSLEditor
{
OpenFile(file);
EditForm LSLIform = (EditForm)GetForm(Path.GetFileName(file));
+ LSLIform.SourceCode = lsli;
LSLIform.Dirty = editForm.Dirty;
}
- if (GetForm(Path.GetFileName(file) + " (Read Only)") != null) // if readonly is open, close it
+ if (GetForm(Path.GetFileName(file) + Helpers.LSLIPathHelper.READONLY_TAB_EXTENSION) != null) // if readonly is open, close it
{
- GetForm(Path.GetFileName(file) + " (Read Only)").Close();
+ GetForm(Path.GetFileName(file) + Helpers.LSLIPathHelper.READONLY_TAB_EXTENSION).Close();
}
editForm.Hide();
}
}
+ // Collapse to LSLI button (F10)
+ private void CollapseToLSLIToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ EditForm editForm = this.ActiveMdiForm as EditForm;
+ CollapseForm(editForm);
+ }
+
+ // View LSLI button (F12)
private void viewLSLIToolStripMenuItem_Click(object sender, EventArgs e)
{
EditForm editForm = this.ActiveMdiForm as EditForm;
@@ -2021,7 +2086,7 @@ namespace LSLEditor
string pathOfLSLI = Helpers.LSLIPathHelper.CreateCollapsedPathAndScriptName(editForm.FullPathName);
if (File.Exists(pathOfLSLI)) {
- string tabText = Path.GetFileName(pathOfLSLI) + " (Read Only)";
+ string tabText = Path.GetFileName(pathOfLSLI) + Helpers.LSLIPathHelper.READONLY_TAB_EXTENSION;
// If old LSLI readonly is open
Form OldReadOnlyLSLIform = GetForm(tabText);
@@ -2072,6 +2137,7 @@ namespace LSLEditor
}
}
+ // New LSLI script button (Ctrl+M)
private void lSLIScriptToolStripMenuItem_Click(object sender, EventArgs e)
{
NewFile(true);
diff --git a/trunk/Properties/AssemblyInfo.cs b/trunk/Properties/AssemblyInfo.cs
index 02bdcf3..fa44df2 100644
--- a/trunk/Properties/AssemblyInfo.cs
+++ b/trunk/Properties/AssemblyInfo.cs
@@ -70,7 +70,7 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
//
-[assembly: AssemblyVersion("2.55.0.825")]
+[assembly: AssemblyVersion("2.55.0.1054")]
//
// In order to sign your assembly you must specify a key to use. Refer to the
@@ -100,4 +100,4 @@ using System.Runtime.InteropServices;
[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyName("")]
[assembly: ComVisibleAttribute(false)]
-[assembly: AssemblyFileVersionAttribute("2.55.0.825")]
+[assembly: AssemblyFileVersionAttribute("2.55.0.1054")]
diff --git a/trunk/Resource/ConfLSL.xml b/trunk/Resource/ConfLSL.xml
index cfaf548..8e77377 100644
--- a/trunk/Resource/ConfLSL.xml
+++ b/trunk/Resource/ConfLSL.xml
@@ -5,15 +5,17 @@
-
+
"[^"\\]* (?>\\.[^"\\]*)*"
-
-
-
-
+
+
+
+
+
+
diff --git a/trunk/Solution/SolutionExplorer.cs b/trunk/Solution/SolutionExplorer.cs
index e60f20e..9eda5d8 100644
--- a/trunk/Solution/SolutionExplorer.cs
+++ b/trunk/Solution/SolutionExplorer.cs
@@ -38,16 +38,16 @@
//
using System;
-using System.IO;
-using System.Xml;
-using System.Text;
-using System.Drawing;
-using System.Windows.Forms;
using System.Collections.Generic;
+using System.Drawing;
+using System.IO;
+using System.Text;
+using System.Windows.Forms;
+using System.Xml;
namespace LSLEditor.Solution
{
- public partial class SolutionExplorer : ToolWindow
+ public partial class SolutionExplorer : ToolWindow
{
public enum TypeSL : int
{
@@ -89,6 +89,7 @@ namespace LSLEditor.Solution
Snapshot = 25,
Script = 26,
+ LSLIScript = 42,
Sound = 27,
Texture = 28,
@@ -137,6 +138,7 @@ namespace LSLEditor.Solution
TypeSL.Snapshot,
TypeSL.Object,
TypeSL.Script,
+ TypeSL.LSLIScript,
TypeSL.Sound,
TypeSL.Texture
};
@@ -222,7 +224,7 @@ namespace LSLEditor.Solution
imageList1 = new ImageList();
imageList1.TransparentColor = Color.Transparent;
- for (int intI = 0; intI <= 41; intI++)
+ for (int intI = 0; intI <= 42; intI++)//41
{
TypeSL typeSL = (TypeSL)intI;
imageList1.Images.Add(intI.ToString(), new Bitmap(typeof(LSLEditorForm), "ImagesSolutionExplorer." + typeSL.ToString().Replace("_", " ") + ".gif"));
@@ -586,6 +588,7 @@ namespace LSLEditor.Solution
}
RealTag rt = (RealTag)e.Node.Tag;
+ string oldName = rt.Name;
rt.Name = e.Node.Text;
e.Node.Tag = rt; // save name
EditForm editForm = GetEditForm(rt.Guid);
@@ -594,7 +597,33 @@ namespace LSLEditor.Solution
editForm.FullPathName = strDestination; // GetFullPath(e.Node);
editForm.SaveCurrentFile();
}
- return; // rename file complete
+
+ if (rt.ItemType == TypeSL.LSLIScript)
+ {
+ EditForm form = GetEditForm(rt.Guid);
+ if(form != null)
+ {
+ form.SaveCurrentFile();
+ form.Dirty = true;
+ form.Show();
+
+ // Get the expanded version of the form
+ string x = Helpers.LSLIPathHelper.GetExpandedTabName(Helpers.LSLIPathHelper.CreateExpandedScriptName(oldName));
+ EditForm xform = (EditForm)parent.GetForm(x);
+
+ if (xform != null && xform.Visible)
+ {
+ string src = xform.SourceCode;
+ xform.Dirty = false;
+ xform.Close();
+ form.SourceCode = src;
+ form.Dirty = true;
+ parent.ExpandForm(form);
+ }
+ }
+ }
+
+ return; // rename file complete
}
// rename directory
@@ -1008,7 +1037,10 @@ namespace LSLEditor.Solution
{
case TypeSL.Script:
strExtension = ".lsl";
- break;
+ break;
+ case TypeSL.LSLIScript:
+ strExtension = ".lsli";
+ break;
case TypeSL.Notecard:
strExtension = ".txt";
break;
@@ -1043,10 +1075,13 @@ namespace LSLEditor.Solution
switch (typeFile)
{
- case TypeSL.Script:
+ case TypeSL.Script:
sw.Write(AutoFormatter.ApplyFormatting(0,Helpers.GetTemplate.Source()));
break;
- case TypeSL.Notecard:
+ case TypeSL.LSLIScript:
+ sw.Write(AutoFormatter.ApplyFormatting(0, Helpers.GetTemplate.Source()));
+ break;
+ case TypeSL.Notecard:
sw.Write("notecard");
break;
default:
@@ -1057,11 +1092,11 @@ namespace LSLEditor.Solution
}
TreeNode newFile = new TreeNode(strNewName, (int)typeFile, (int)typeFile);
- newFile.Tag = new RealTag(typeFile, strNewName, Guid.NewGuid());
+ newFile.Tag = new RealTag(typeFile, strNewName, Guid.NewGuid());
parent.Nodes.Add(newFile);
parent.Expand();
- this.m_dirty = true;
+ this.m_dirty = true;
}
private void AddExistingFile(TreeNode parent, string strName, Guid guid)
@@ -1694,7 +1729,7 @@ namespace LSLEditor.Solution
tn.BeginEdit();
}
- private void CutAction(TreeNode tn)
+ private void CutAction(TreeNode tn)
{
if (CutObject != null)
CutObject.ForeColor = Color.Empty;
@@ -1736,7 +1771,7 @@ namespace LSLEditor.Solution
{
if(editForm.Visible)
{
- editForm.Focus();
+ editForm.Focus();
} else
{
// Check if there's a related expanded lsl or lsli opened. If so, focus it. Else open the lsli.
@@ -1753,7 +1788,7 @@ namespace LSLEditor.Solution
else
{
// Open a new one
- if (GetTypeSL(e.Node) == TypeSL.Script)
+ if (GetTypeSL(e.Node) == TypeSL.Script || GetTypeSL(e.Node) == TypeSL.LSLIScript)
{
this.parent.OpenFile(GetFullPath(e.Node), guid, true);
}
@@ -1770,7 +1805,7 @@ namespace LSLEditor.Solution
}
// Check if it's an lsli that has an open expanded form
- if (GetTypeSL(e.Node) == TypeSL.Script)
+ if (GetTypeSL(e.Node) == TypeSL.Script || GetTypeSL(e.Node) == TypeSL.LSLIScript)
{
if (Helpers.LSLIPathHelper.IsLSLI(path)) {
// Check if there's a related expanded lsl opened. If so, focus it. Else open the lsli.
@@ -1785,7 +1820,7 @@ namespace LSLEditor.Solution
} else
{
// Open a new one
- if (GetTypeSL(e.Node) == TypeSL.Script)
+ if (GetTypeSL(e.Node) == TypeSL.Script || GetTypeSL(e.Node) == TypeSL.LSLIScript)
{
this.parent.OpenFile(GetFullPath(e.Node), guid, true);
}
@@ -1793,7 +1828,7 @@ namespace LSLEditor.Solution
} else
{
// Open a new one
- if (GetTypeSL(e.Node) == TypeSL.Script)
+ if (GetTypeSL(e.Node) == TypeSL.Script || GetTypeSL(e.Node) == TypeSL.LSLIScript)
{
this.parent.OpenFile(GetFullPath(e.Node), guid, true);
}
diff --git a/trunk/lsleditor.csproj b/trunk/lsleditor.csproj
index f24ba4c..4c42c41 100644
--- a/trunk/lsleditor.csproj
+++ b/trunk/lsleditor.csproj
@@ -29,22 +29,24 @@
false
C:\Users\User\Desktop\Workspace_Jasper\LSL_editor\lsleditor-code\trunk\LSLEditor.RES
3.5
- true
+ false
v3.5
- http://localhost/LSLEditor/
+ C:\Users\User\Desktop\Workspace_Jasper\LSL_editor\Published LSLEditor\
true
- Web
- true
+ Disk
+ false
Foreground
7
Days
false
false
true
- 0
+ true
+ 10
1.0.0.%2a
false
+ true
true
@@ -100,6 +102,9 @@
5CBB20152EC70EC13542B336790AF2E7AB2E1DEB
+
+ true
+
System
@@ -971,6 +976,7 @@
+