Fix bug show include errors
This commit is contained in:
parent
b7911a5b87
commit
123808c7d5
9 changed files with 373 additions and 153 deletions
|
@ -564,8 +564,7 @@ namespace LSLEditor
|
||||||
if (LSLIPathHelper.IsExpandedLSL(ScriptName))
|
if (LSLIPathHelper.IsExpandedLSL(ScriptName))
|
||||||
{
|
{
|
||||||
// Check if a LSLI readonly is open
|
// Check if a LSLI readonly is open
|
||||||
EditForm readOnlyLSLI = (EditForm)parent.GetForm(Path.GetFileName(
|
EditForm readOnlyLSLI = (EditForm)parent.GetForm(Path.GetFileName(LSLIPathHelper.GetReadOnlyTabName(ScriptName)));
|
||||||
LSLIPathHelper.CreateCollapsedScriptName(ScriptName)) + " (Read Only)");
|
|
||||||
|
|
||||||
if (readOnlyLSLI != null)
|
if (readOnlyLSLI != null)
|
||||||
{
|
{
|
||||||
|
@ -573,11 +572,21 @@ namespace LSLEditor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete expanded file when closing
|
if(!this.parent.IsReadOnly(this)) // If this is not a readonly (LSLI)
|
||||||
string expandedFile = LSLIPathHelper.CreateExpandedPathAndScriptName(FullPathName);
|
|
||||||
if (File.Exists(expandedFile))
|
|
||||||
{
|
{
|
||||||
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;
|
this.parent.CancelClosing = e.Cancel;
|
||||||
|
|
|
@ -34,6 +34,8 @@
|
||||||
//
|
//
|
||||||
// <summary>
|
// <summary>
|
||||||
// This class is used to convert LSLI to LSL and the other way around.
|
// This class is used to convert LSLI to LSL and the other way around.
|
||||||
|
// Created by Jasper Wiggerink
|
||||||
|
// 13-11-2017
|
||||||
// </summary>
|
// </summary>
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
@ -49,16 +51,16 @@ namespace LSLEditor.Helpers
|
||||||
class LSLIConverter
|
class LSLIConverter
|
||||||
{
|
{
|
||||||
private EditForm editForm;
|
private EditForm editForm;
|
||||||
private const string BEGIN = "//@BEGIN";
|
private const string BEGIN = "//#BEGIN";
|
||||||
private const string END = "//@END";
|
private const string END = "//#END";
|
||||||
private const string INCLUDE = "//@include";
|
private const string INCLUDE = "//#include";
|
||||||
|
|
||||||
public const string EXPANDED_SUBEXT = ".expanded";
|
public const string EXPANDED_SUBEXT = ".expanded";
|
||||||
public const string LSL_EXT = ".lsl";
|
public const string LSL_EXT = ".lsl";
|
||||||
public const string LSLI_EXT = ".lsli";
|
public const string LSLI_EXT = ".lsli";
|
||||||
public static List<string> validExtensions = new List<string>() { LSLI_EXT, LSL_EXT };
|
public static List<string> validExtensions = new List<string>() { 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 BEGIN_REGEX = "(\\s+|^)" + BEGIN;
|
||||||
private const string END_REGEX = "(\\s+|^)" + END;
|
private const string END_REGEX = "(\\s+|^)" + END;
|
||||||
private const string EMPTY_OR_WHITESPACE_REGEX = "^\\s*$";
|
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;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Searches for a file with one of the validExtensions based on a name or path. Also searches in the IncludeDirectories
|
/// Searches for a file with one of the validExtensions based on a name or path. Also searches in the IncludeDirectories
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="file"></param>
|
/// <param name="file"></param>
|
||||||
/// <returns>File path</returns>
|
/// <returns>File path</returns>
|
||||||
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)
|
foreach (string directory in Properties.Settings.Default.IncludeDirectories)
|
||||||
{
|
{
|
||||||
string pFile;
|
string pFile;
|
||||||
if(file.Contains(directory))
|
if (file.ToLower().Contains(directory.ToLower()))
|
||||||
{
|
{
|
||||||
pFile = file;
|
pFile = file;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
pFile = directory + file;
|
pFile = directory + file;
|
||||||
}
|
}
|
||||||
|
@ -141,33 +122,66 @@ namespace LSLEditor.Helpers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If IncludeDirectories setting is disabled
|
// Search for file relative to the script
|
||||||
if (Properties.Settings.Default.IncludeDirectories.Count == 0)
|
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) == "")
|
if (File.Exists(pFile)) {
|
||||||
{
|
return pFile;
|
||||||
string pFile = "";
|
|
||||||
|
|
||||||
foreach (string extension in validExtensions)
|
|
||||||
{
|
|
||||||
pFile = file + extension;
|
|
||||||
|
|
||||||
if (File.Exists(pFile)) {
|
|
||||||
return pFile;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the path of the file
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pathOfInclude"></param>
|
||||||
|
/// <param name="pathOfScript"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Finds all indexes of a value in a string
|
/// Finds all indexes of a value in a string
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -176,16 +190,34 @@ namespace LSLEditor.Helpers
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static List<int> AllIndexesOf(string str, string value)
|
public static List<int> AllIndexesOf(string str, string value)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty(value))
|
if (!String.IsNullOrEmpty(value))
|
||||||
throw new ArgumentException("The string to find may not be empty", "value");
|
|
||||||
List<int> indexes = new List<int>();
|
|
||||||
for (int index = 0; ; index += value.Length)
|
|
||||||
{
|
{
|
||||||
index = str.IndexOf(value, index);
|
List<int> indexes = new List<int>();
|
||||||
if (index == -1)
|
for (int index = 0; ; index += value.Length)
|
||||||
return indexes;
|
{
|
||||||
indexes.Add(index);
|
index = str.IndexOf(value, index);
|
||||||
|
if (index == -1)
|
||||||
|
return indexes;
|
||||||
|
indexes.Add(index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Compares 2 paths and returns true if they are different, false if they're the same.
|
||||||
|
/// Warning: This doesn't compare extensions.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pathOfInclude"></param>
|
||||||
|
/// <param name="pathOfScript"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -254,7 +286,6 @@ namespace LSLEditor.Helpers
|
||||||
}
|
}
|
||||||
|
|
||||||
context.Insert(includeIndex, newLine);
|
context.Insert(includeIndex, newLine);
|
||||||
string test = context.ToString(); // Debug only
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,7 +308,7 @@ namespace LSLEditor.Helpers
|
||||||
/// <param name="includeDepth"></param>
|
/// <param name="includeDepth"></param>
|
||||||
/// <param name="OneLess"></param>
|
/// <param name="OneLess"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
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 = "";
|
string tabs = "";
|
||||||
if(OneLess && includeDepth != 0)
|
if(OneLess && includeDepth != 0)
|
||||||
|
@ -299,14 +330,22 @@ namespace LSLEditor.Helpers
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private string GetTabsForIndentedInclude(string includeLine, int includeDepth, bool isDebug = false)
|
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;
|
int includeIndex = Regex.Match(includeLine, INCLUDE).Index;
|
||||||
|
|
||||||
string beforeInclude = includeLine.Substring(0, includeIndex);
|
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;
|
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)
|
if (isDebug)
|
||||||
{
|
{
|
||||||
tabCount = beforeInclude.Count(f => f == '\t') - (includeDepth - 1); // The tabcount should be without the includeDepth, because this was already added.
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the amount of tabs for an include script
|
/// Returns the amount of spaces in front of an include statement
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="includeLine"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
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 "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the amount of tabs/spaces for an include script
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="includeLine"></param>
|
/// <param name="includeLine"></param>
|
||||||
/// <param name="includeDepth"></param>
|
/// <param name="includeDepth"></param>
|
||||||
|
@ -336,9 +410,9 @@ namespace LSLEditor.Helpers
|
||||||
{
|
{
|
||||||
string includeDepthTabs = GetTabsForIncludeDepth(includeDepth, OneLess);
|
string includeDepthTabs = GetTabsForIncludeDepth(includeDepth, OneLess);
|
||||||
string indentedIncludeTabs = GetTabsForIndentedInclude(includeLine, includeDepth, true);
|
string indentedIncludeTabs = GetTabsForIndentedInclude(includeLine, includeDepth, true);
|
||||||
|
string spacesForIndentedInclude = GetSpacesForIndentedInclude(includeLine, includeDepth, true);
|
||||||
|
|
||||||
return includeDepthTabs + indentedIncludeTabs;
|
return includeDepthTabs + indentedIncludeTabs + spacesForIndentedInclude;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -424,7 +498,7 @@ namespace LSLEditor.Helpers
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Imports scripts from //@include statements
|
/// Imports scripts from //#include statements
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="strC">Sourcecode</param>
|
/// <param name="strC">Sourcecode</param>
|
||||||
/// <param name="pathOfScript">Path of the source code of the script</param>
|
/// <param name="pathOfScript">Path of the source code of the script</param>
|
||||||
|
@ -433,7 +507,7 @@ namespace LSLEditor.Helpers
|
||||||
{
|
{
|
||||||
if(!LSLIPathHelper.IsLSLI(pathOfScript))
|
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;
|
return strC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -455,26 +529,17 @@ namespace LSLEditor.Helpers
|
||||||
string pathOfInclude = pathOfIncludeOriginal;
|
string pathOfInclude = pathOfIncludeOriginal;
|
||||||
string ext = Path.GetExtension(pathOfInclude).ToLower();
|
string ext = Path.GetExtension(pathOfInclude).ToLower();
|
||||||
|
|
||||||
if ((validExtensions.Contains(ext) || ext == "") && !LSLIPathHelper.CreateExpandedScriptName(pathOfScript).Contains(pathOfInclude)
|
if ((validExtensions.Contains(ext) || ext == "") && IsDifferentScript(pathOfInclude, pathOfScript))
|
||||||
&& !pathOfScript.Contains(pathOfInclude))
|
|
||||||
{
|
{
|
||||||
// If path is relative
|
pathOfInclude = GetFilePath(pathOfInclude, pathOfScript);
|
||||||
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);
|
|
||||||
|
|
||||||
if (pathOfInclude != "" && !this.implementedIncludes.Contains(Path.GetFullPath(pathOfInclude)))
|
if (pathOfInclude != "" && !this.implementedIncludes.Contains(Path.GetFullPath(pathOfInclude)))
|
||||||
{
|
{
|
||||||
if(!ShowBeginEnd)
|
if (!ShowBeginEnd)
|
||||||
{
|
{
|
||||||
sb = WriteExportScript(pathOfInclude, sb, line);
|
sb = WriteExportScript(pathOfInclude, sb, line);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
sb = WriteDebugScript(pathOfInclude, sb, line);
|
sb = WriteDebugScript(pathOfInclude, sb, line);
|
||||||
}
|
}
|
||||||
|
@ -488,7 +553,8 @@ namespace LSLEditor.Helpers
|
||||||
ShowError(message);
|
ShowError(message);
|
||||||
} else
|
} 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 +
|
string message = "Error: Unable to find file \"" + correctPath +
|
||||||
"\". In script \"" + Path.GetFileName(pathOfScript) + "\". Line " + lineNumber + ".";
|
"\". In script \"" + Path.GetFileName(pathOfScript) + "\". Line " + lineNumber + ".";
|
||||||
|
|
||||||
|
@ -598,6 +664,7 @@ namespace LSLEditor.Helpers
|
||||||
/// <returns>LSL</returns>
|
/// <returns>LSL</returns>
|
||||||
public string ExpandToLSL(EditForm editForm, bool ShowBeginEnd = true)
|
public string ExpandToLSL(EditForm editForm, bool ShowBeginEnd = true)
|
||||||
{
|
{
|
||||||
|
editForm.verboseQueue = new List<string>();
|
||||||
this.editForm = editForm;
|
this.editForm = editForm;
|
||||||
string strC = editForm.SourceCode;
|
string strC = editForm.SourceCode;
|
||||||
string fullPathName = editForm.FullPathName;
|
string fullPathName = editForm.FullPathName;
|
||||||
|
|
|
@ -34,18 +34,19 @@
|
||||||
//
|
//
|
||||||
// <summary>
|
// <summary>
|
||||||
// This class is used to help with paths and LSLI files.
|
// This class is used to help with paths and LSLI files.
|
||||||
|
// Created by Jasper Wiggerink
|
||||||
|
// 13-11-2017
|
||||||
// </summary>
|
// </summary>
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace LSLEditor.Helpers
|
namespace LSLEditor.Helpers
|
||||||
{
|
{
|
||||||
static class LSLIPathHelper
|
static class LSLIPathHelper
|
||||||
{
|
{
|
||||||
|
public const string READONLY_TAB_EXTENSION = " (Read Only)";
|
||||||
|
public const string EXPANDED_TAB_EXTENSION = " (Expanded LSL)";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if a filename is LSLI
|
/// Checks if a filename is LSLI
|
||||||
|
@ -79,12 +80,22 @@ namespace LSLEditor.Helpers
|
||||||
return nameCollapsed;
|
return nameCollapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes only the last extension
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename"></param>
|
||||||
|
/// <returns></returns>
|
||||||
private static string RemoveExtension(string filename)
|
private static string RemoveExtension(string filename)
|
||||||
{
|
{
|
||||||
filename = TrimStarsAndWhiteSpace(filename.Remove(filename.LastIndexOf(Path.GetExtension(filename))));
|
filename = TrimStarsAndWhiteSpace(filename.Remove(filename.LastIndexOf(Path.GetExtension(filename))));
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes the .expanded in a filename
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static string RemoveExpandedSubExtension(string filename)
|
public static string RemoveExpandedSubExtension(string filename)
|
||||||
{
|
{
|
||||||
if (filename.Contains(LSLIConverter.EXPANDED_SUBEXT))
|
if (filename.Contains(LSLIConverter.EXPANDED_SUBEXT))
|
||||||
|
@ -136,6 +147,11 @@ namespace LSLEditor.Helpers
|
||||||
return PutDotInFrontOfFilename(TrimStarsAndWhiteSpace(nameExpanded));
|
return PutDotInFrontOfFilename(TrimStarsAndWhiteSpace(nameExpanded));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Puts dot in front of a filename, e.g. "path/file.lsl" to "path/.file.lsl"
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename"></param>
|
||||||
|
/// <returns></returns>
|
||||||
private static string PutDotInFrontOfFilename(string filename)
|
private static string PutDotInFrontOfFilename(string filename)
|
||||||
{
|
{
|
||||||
int afterLastIndexOfSeperator = (filename.LastIndexOf('\\') > filename.LastIndexOf('/') ? filename.LastIndexOf('\\') : filename.LastIndexOf('/')) + 1;
|
int afterLastIndexOfSeperator = (filename.LastIndexOf('\\') > filename.LastIndexOf('/') ? filename.LastIndexOf('\\') : filename.LastIndexOf('/')) + 1;
|
||||||
|
@ -149,6 +165,11 @@ namespace LSLEditor.Helpers
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If found, removes the dot in front of a filename.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static string RemoveDotInFrontOfFilename(string filename)
|
public static string RemoveDotInFrontOfFilename(string filename)
|
||||||
{
|
{
|
||||||
int afterLastIndexOfSeperator = (filename.LastIndexOf('\\') > filename.LastIndexOf('/') ? filename.LastIndexOf('\\') : filename.LastIndexOf('/')) + 1;
|
int afterLastIndexOfSeperator = (filename.LastIndexOf('\\') > filename.LastIndexOf('/') ? filename.LastIndexOf('\\') : filename.LastIndexOf('/')) + 1;
|
||||||
|
@ -183,6 +204,11 @@ namespace LSLEditor.Helpers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Trims the "dirty" stars and whitespace in a string. E.g. "file*.lsl " to "file.lsl"
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static string TrimStarsAndWhiteSpace(string str)
|
public static string TrimStarsAndWhiteSpace(string str)
|
||||||
{
|
{
|
||||||
return str.Trim(' ').TrimEnd('*');
|
return str.Trim(' ').TrimEnd('*');
|
||||||
|
@ -196,10 +222,19 @@ namespace LSLEditor.Helpers
|
||||||
public static string GetExpandedTabName(string path)
|
public static string GetExpandedTabName(string path)
|
||||||
{
|
{
|
||||||
if (path == null) return "";
|
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)
|
/// <summary>
|
||||||
|
/// Turns a LSLI readonly script name into a string to be displayed as the tab name
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetReadOnlyTabName(string filename)
|
||||||
|
{
|
||||||
|
if (filename == null) return "";
|
||||||
|
return CreateCollapsedPathAndScriptName(filename) + READONLY_TAB_EXTENSION;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a relative path between two paths
|
/// Creates a relative path between two paths
|
||||||
|
|
BIN
trunk/ImagesSolutionExplorer/LSLIScript.gif
Normal file
BIN
trunk/ImagesSolutionExplorer/LSLIScript.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 170 B |
|
@ -356,7 +356,7 @@ namespace LSLEditor
|
||||||
{
|
{
|
||||||
EditForm editForm = (EditForm)this.ActiveMdiForm;
|
EditForm editForm = (EditForm)this.ActiveMdiForm;
|
||||||
string expandedWarning = "";
|
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!";
|
expandedWarning = "Warning: Editing in included sections will be erased when collapsing/saving!";
|
||||||
}
|
}
|
||||||
|
@ -599,15 +599,24 @@ namespace LSLEditor
|
||||||
DialogResult dialogresult = DialogResult.OK;
|
DialogResult dialogresult = DialogResult.OK;
|
||||||
if (editForm.FullPathName == Properties.Settings.Default.ExampleName || blnSaveAs) {
|
if (editForm.FullPathName == Properties.Settings.Default.ExampleName || blnSaveAs) {
|
||||||
SaveFileDialog saveDialog = editForm.IsScript ? this.saveScriptFilesDialog : this.saveNoteFilesDialog;
|
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();
|
dialogresult = saveDialog.ShowDialog();
|
||||||
if (dialogresult == DialogResult.OK) {
|
if (dialogresult == DialogResult.OK) {
|
||||||
editForm.FullPathName = saveDialog.FileName;
|
editForm.FullPathName = saveDialog.FileName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dialogresult == DialogResult.OK) {
|
if (dialogresult == DialogResult.OK) {
|
||||||
editForm.SaveCurrentFile();
|
editForm.SaveCurrentFile();
|
||||||
UpdateRecentFileList(editForm.FullPathName);
|
UpdateRecentFileList(editForm.FullPathName);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -753,6 +762,7 @@ namespace LSLEditor
|
||||||
|
|
||||||
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
|
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();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1160,8 +1170,19 @@ namespace LSLEditor
|
||||||
if (editForm == null || editForm.IsDisposed) {
|
if (editForm == null || editForm.IsDisposed) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (editForm.FullPathName == e.FullPathName) {
|
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.TextBox.Goto(e.Line, e.Char);
|
||||||
editForm.Focus();
|
editForm.Focus();
|
||||||
return;
|
return;
|
||||||
|
@ -1198,6 +1219,43 @@ namespace LSLEditor
|
||||||
this.SimulatorConsole = null;
|
this.SimulatorConsole = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="editForm"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
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)
|
private bool SyntaxCheck(bool Silent)
|
||||||
{
|
{
|
||||||
//TODO: What do we hide on SyntaxCheck?
|
//TODO: What do we hide on SyntaxCheck?
|
||||||
|
@ -1206,7 +1264,9 @@ namespace LSLEditor
|
||||||
|
|
||||||
foreach (Form form in this.Children) {
|
foreach (Form form in this.Children) {
|
||||||
EditForm editForm = form as EditForm;
|
EditForm editForm = form as EditForm;
|
||||||
if (editForm == null || editForm.IsDisposed) {
|
editForm = SelectEditFormToRun(editForm);
|
||||||
|
|
||||||
|
if (editForm == null || editForm.IsDisposed || !editForm.Visible || IsReadOnly(editForm)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (Properties.Settings.Default.AutoSaveOnDebug) {
|
if (Properties.Settings.Default.AutoSaveOnDebug) {
|
||||||
|
@ -1856,10 +1916,10 @@ namespace LSLEditor
|
||||||
public Form GetForm(string formName)
|
public Form GetForm(string formName)
|
||||||
{
|
{
|
||||||
EditForm desirableForm = null;
|
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];
|
Form form = Children[i];
|
||||||
if (Helpers.LSLIPathHelper.TrimStarsAndWhiteSpace(form.Text) == formName) //.TrimEnd(' ')
|
if (Helpers.LSLIPathHelper.TrimStarsAndWhiteSpace(form.Text) == formName)
|
||||||
{
|
{
|
||||||
desirableForm = (EditForm)form;
|
desirableForm = (EditForm)form;
|
||||||
}
|
}
|
||||||
|
@ -1877,7 +1937,6 @@ namespace LSLEditor
|
||||||
{
|
{
|
||||||
foreach (Control c in form.tabControl.SelectedTab.Controls)
|
foreach (Control c in form.tabControl.SelectedTab.Controls)
|
||||||
{
|
{
|
||||||
Type dfsa = c.GetType();
|
|
||||||
if (c.GetType() == typeof(SplitContainer))
|
if (c.GetType() == typeof(SplitContainer))
|
||||||
{
|
{
|
||||||
NumberedTextBox.NumberedTextBoxUC a = (NumberedTextBox.NumberedTextBoxUC)((SplitContainer)c).ActiveControl;
|
NumberedTextBox.NumberedTextBoxUC a = (NumberedTextBox.NumberedTextBoxUC)((SplitContainer)c).ActiveControl;
|
||||||
|
@ -1898,7 +1957,6 @@ namespace LSLEditor
|
||||||
{
|
{
|
||||||
foreach (Control c in form.tabControl.SelectedTab.Controls)
|
foreach (Control c in form.tabControl.SelectedTab.Controls)
|
||||||
{
|
{
|
||||||
Type dfsa = c.GetType();
|
|
||||||
if (c.GetType() == typeof(SplitContainer))
|
if (c.GetType() == typeof(SplitContainer))
|
||||||
{
|
{
|
||||||
NumberedTextBox.NumberedTextBoxUC a = (NumberedTextBox.NumberedTextBoxUC)((SplitContainer)c).ActiveControl;
|
NumberedTextBox.NumberedTextBoxUC a = (NumberedTextBox.NumberedTextBoxUC)((SplitContainer)c).ActiveControl;
|
||||||
|
@ -1914,33 +1972,27 @@ namespace LSLEditor
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void expandToLSLToolStripMenuItem_Click(object sender, EventArgs e)
|
/// <summary>
|
||||||
|
/// Expands an editform and opens it. Hides the LSLI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="editForm"></param>
|
||||||
|
public void ExpandForm(EditForm editForm)
|
||||||
{
|
{
|
||||||
EditForm editForm = this.ActiveMdiForm as EditForm;
|
if (editForm != null && Helpers.LSLIPathHelper.IsLSLI(editForm.ScriptName))
|
||||||
|
|
||||||
if (editForm != null && Helpers.LSLIPathHelper.IsLSLI(editForm.Text))
|
|
||||||
{
|
{
|
||||||
Helpers.LSLIConverter converter = new Helpers.LSLIConverter();
|
Helpers.LSLIConverter converter = new Helpers.LSLIConverter();
|
||||||
string lsl = converter.ExpandToLSL(editForm);
|
string lsl = converter.ExpandToLSL(editForm);
|
||||||
string file = Helpers.LSLIPathHelper.CreateExpandedPathAndScriptName(editForm.FullPathName);
|
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.
|
// 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.SourceCode = lsl;
|
||||||
//oldExpandedForm.TabIndex = editForm.TabIndex; // TODO: Keep tabIndex when expanding/collapsing the same
|
//oldExpandedForm.TabIndex = editForm.TabIndex; // TODO: Keep tabIndex when expanding/collapsing the same
|
||||||
oldExpandedForm.Show();
|
oldExpandedForm.Show();
|
||||||
SetReadOnly(oldExpandedForm, false);
|
SetReadOnly(oldExpandedForm, false);
|
||||||
oldExpandedForm.Dirty = editForm.Dirty;
|
oldExpandedForm.Dirty = editForm.Dirty;
|
||||||
|
|
||||||
if (editForm.Dirty)
|
|
||||||
{
|
|
||||||
oldExpandedForm.Text = Helpers.LSLIPathHelper.GetExpandedTabName(editForm.Text) + "*";
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
oldExpandedForm.Text = Helpers.LSLIPathHelper.GetExpandedTabName(editForm.Text);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // If not already open
|
{ // If not already open
|
||||||
|
@ -1950,7 +2002,7 @@ namespace LSLEditor
|
||||||
{
|
{
|
||||||
sw.Write(lsl);
|
sw.Write(lsl);
|
||||||
}
|
}
|
||||||
|
|
||||||
Helpers.LSLIPathHelper.HideFile(file);
|
Helpers.LSLIPathHelper.HideFile(file);
|
||||||
|
|
||||||
EditForm expandedForm = (EditForm)GetForm(Helpers.LSLIPathHelper.CreateExpandedScriptName(Path.GetFileName(file)));
|
EditForm expandedForm = (EditForm)GetForm(Helpers.LSLIPathHelper.CreateExpandedScriptName(Path.GetFileName(file)));
|
||||||
|
@ -1963,16 +2015,20 @@ namespace LSLEditor
|
||||||
OpenFile(file);
|
OpenFile(file);
|
||||||
EditForm lslForm = (EditForm)GetForm(Helpers.LSLIPathHelper.GetExpandedTabName(file));
|
EditForm lslForm = (EditForm)GetForm(Helpers.LSLIPathHelper.GetExpandedTabName(file));
|
||||||
lslForm.Dirty = editForm.Dirty;
|
lslForm.Dirty = editForm.Dirty;
|
||||||
//lslForm.Text = Helpers.LSLIPathHelper.GetExpandedTabName(editForm.Text);
|
|
||||||
}
|
}
|
||||||
editForm.Hide();
|
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;
|
EditForm editForm = this.ActiveMdiForm as EditForm;
|
||||||
|
ExpandForm(editForm);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CollapseForm(EditForm editForm)
|
||||||
|
{
|
||||||
if (editForm != null && Helpers.LSLIPathHelper.IsExpandedLSL(editForm.ScriptName))
|
if (editForm != null && Helpers.LSLIPathHelper.IsExpandedLSL(editForm.ScriptName))
|
||||||
{
|
{
|
||||||
Helpers.LSLIConverter converter = new Helpers.LSLIConverter();
|
Helpers.LSLIConverter converter = new Helpers.LSLIConverter();
|
||||||
|
@ -1981,7 +2037,7 @@ namespace LSLEditor
|
||||||
|
|
||||||
string lsli = converter.CollapseToLSLIFromEditform(editForm);
|
string lsli = converter.CollapseToLSLIFromEditform(editForm);
|
||||||
string file = Helpers.LSLIPathHelper.CreateCollapsedPathAndScriptName(editForm.FullPathName);
|
string file = Helpers.LSLIPathHelper.CreateCollapsedPathAndScriptName(editForm.FullPathName);
|
||||||
|
|
||||||
// Check if the LSLI form is already open (but hidden)
|
// Check if the LSLI form is already open (but hidden)
|
||||||
if (GetForm(Path.GetFileName(file)) != null)
|
if (GetForm(Path.GetFileName(file)) != null)
|
||||||
{
|
{
|
||||||
|
@ -1996,17 +2052,26 @@ namespace LSLEditor
|
||||||
{
|
{
|
||||||
OpenFile(file);
|
OpenFile(file);
|
||||||
EditForm LSLIform = (EditForm)GetForm(Path.GetFileName(file));
|
EditForm LSLIform = (EditForm)GetForm(Path.GetFileName(file));
|
||||||
|
LSLIform.SourceCode = lsli;
|
||||||
LSLIform.Dirty = editForm.Dirty;
|
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();
|
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)
|
private void viewLSLIToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
EditForm editForm = this.ActiveMdiForm as EditForm;
|
EditForm editForm = this.ActiveMdiForm as EditForm;
|
||||||
|
@ -2021,7 +2086,7 @@ namespace LSLEditor
|
||||||
string pathOfLSLI = Helpers.LSLIPathHelper.CreateCollapsedPathAndScriptName(editForm.FullPathName);
|
string pathOfLSLI = Helpers.LSLIPathHelper.CreateCollapsedPathAndScriptName(editForm.FullPathName);
|
||||||
|
|
||||||
if (File.Exists(pathOfLSLI)) {
|
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
|
// If old LSLI readonly is open
|
||||||
Form OldReadOnlyLSLIform = GetForm(tabText);
|
Form OldReadOnlyLSLIform = GetForm(tabText);
|
||||||
|
@ -2072,6 +2137,7 @@ namespace LSLEditor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// New LSLI script button (Ctrl+M)
|
||||||
private void lSLIScriptToolStripMenuItem_Click(object sender, EventArgs e)
|
private void lSLIScriptToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
NewFile(true);
|
NewFile(true);
|
||||||
|
|
|
@ -70,7 +70,7 @@ using System.Runtime.InteropServices;
|
||||||
// You can specify all the values or you can default the Revision and Build Numbers
|
// You can specify all the values or you can default the Revision and Build Numbers
|
||||||
// by using the '*' as shown below:
|
// 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
|
// 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: AssemblyDelaySign(false)]
|
||||||
//[assembly: AssemblyKeyName("")]
|
//[assembly: AssemblyKeyName("")]
|
||||||
[assembly: ComVisibleAttribute(false)]
|
[assembly: ComVisibleAttribute(false)]
|
||||||
[assembly: AssemblyFileVersionAttribute("2.55.0.825")]
|
[assembly: AssemblyFileVersionAttribute("2.55.0.1054")]
|
||||||
|
|
|
@ -5,15 +5,17 @@
|
||||||
|
|
||||||
|
|
||||||
<Words name="Strings" color="#A0A0A0" slcolor="#003300">
|
<Words name="Strings" color="#A0A0A0" slcolor="#003300">
|
||||||
<Word name="regex">
|
<Word name="regex">
|
||||||
"[^"\\]* (?>\\.[^"\\]*)*"
|
"[^"\\]* (?>\\.[^"\\]*)*"
|
||||||
</Word>
|
</Word>
|
||||||
<Word name="//@BEGIN">
|
|
||||||
</Word>
|
|
||||||
<Word name="//@END">
|
|
||||||
</Word>
|
|
||||||
</Words>
|
</Words>
|
||||||
|
|
||||||
|
<Words name="Includes" color="#A0A0A0" slcolor="#003300">
|
||||||
|
<Word name="//#BEGIN">
|
||||||
|
</Word>
|
||||||
|
<Word name="//#END">
|
||||||
|
</Word>
|
||||||
|
</Words>
|
||||||
|
|
||||||
<Words name="Operators" color="#777700" slcolor="#000000">
|
<Words name="Operators" color="#777700" slcolor="#000000">
|
||||||
<Word name="regex">
|
<Word name="regex">
|
||||||
|
|
|
@ -38,16 +38,16 @@
|
||||||
// </summary>
|
// </summary>
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
|
||||||
using System.Xml;
|
|
||||||
using System.Text;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.Xml;
|
||||||
|
|
||||||
namespace LSLEditor.Solution
|
namespace LSLEditor.Solution
|
||||||
{
|
{
|
||||||
public partial class SolutionExplorer : ToolWindow
|
public partial class SolutionExplorer : ToolWindow
|
||||||
{
|
{
|
||||||
public enum TypeSL : int
|
public enum TypeSL : int
|
||||||
{
|
{
|
||||||
|
@ -89,6 +89,7 @@ namespace LSLEditor.Solution
|
||||||
Snapshot = 25,
|
Snapshot = 25,
|
||||||
|
|
||||||
Script = 26,
|
Script = 26,
|
||||||
|
LSLIScript = 42,
|
||||||
Sound = 27,
|
Sound = 27,
|
||||||
Texture = 28,
|
Texture = 28,
|
||||||
|
|
||||||
|
@ -137,6 +138,7 @@ namespace LSLEditor.Solution
|
||||||
TypeSL.Snapshot,
|
TypeSL.Snapshot,
|
||||||
TypeSL.Object,
|
TypeSL.Object,
|
||||||
TypeSL.Script,
|
TypeSL.Script,
|
||||||
|
TypeSL.LSLIScript,
|
||||||
TypeSL.Sound,
|
TypeSL.Sound,
|
||||||
TypeSL.Texture
|
TypeSL.Texture
|
||||||
};
|
};
|
||||||
|
@ -222,7 +224,7 @@ namespace LSLEditor.Solution
|
||||||
|
|
||||||
imageList1 = new ImageList();
|
imageList1 = new ImageList();
|
||||||
imageList1.TransparentColor = Color.Transparent;
|
imageList1.TransparentColor = Color.Transparent;
|
||||||
for (int intI = 0; intI <= 41; intI++)
|
for (int intI = 0; intI <= 42; intI++)//41
|
||||||
{
|
{
|
||||||
TypeSL typeSL = (TypeSL)intI;
|
TypeSL typeSL = (TypeSL)intI;
|
||||||
imageList1.Images.Add(intI.ToString(), new Bitmap(typeof(LSLEditorForm), "ImagesSolutionExplorer." + typeSL.ToString().Replace("_", " ") + ".gif"));
|
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;
|
RealTag rt = (RealTag)e.Node.Tag;
|
||||||
|
string oldName = rt.Name;
|
||||||
rt.Name = e.Node.Text;
|
rt.Name = e.Node.Text;
|
||||||
e.Node.Tag = rt; // save name
|
e.Node.Tag = rt; // save name
|
||||||
EditForm editForm = GetEditForm(rt.Guid);
|
EditForm editForm = GetEditForm(rt.Guid);
|
||||||
|
@ -594,7 +597,33 @@ namespace LSLEditor.Solution
|
||||||
editForm.FullPathName = strDestination; // GetFullPath(e.Node);
|
editForm.FullPathName = strDestination; // GetFullPath(e.Node);
|
||||||
editForm.SaveCurrentFile();
|
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
|
// rename directory
|
||||||
|
@ -1008,7 +1037,10 @@ namespace LSLEditor.Solution
|
||||||
{
|
{
|
||||||
case TypeSL.Script:
|
case TypeSL.Script:
|
||||||
strExtension = ".lsl";
|
strExtension = ".lsl";
|
||||||
break;
|
break;
|
||||||
|
case TypeSL.LSLIScript:
|
||||||
|
strExtension = ".lsli";
|
||||||
|
break;
|
||||||
case TypeSL.Notecard:
|
case TypeSL.Notecard:
|
||||||
strExtension = ".txt";
|
strExtension = ".txt";
|
||||||
break;
|
break;
|
||||||
|
@ -1043,10 +1075,13 @@ namespace LSLEditor.Solution
|
||||||
|
|
||||||
switch (typeFile)
|
switch (typeFile)
|
||||||
{
|
{
|
||||||
case TypeSL.Script:
|
case TypeSL.Script:
|
||||||
sw.Write(AutoFormatter.ApplyFormatting(0,Helpers.GetTemplate.Source()));
|
sw.Write(AutoFormatter.ApplyFormatting(0,Helpers.GetTemplate.Source()));
|
||||||
break;
|
break;
|
||||||
case TypeSL.Notecard:
|
case TypeSL.LSLIScript:
|
||||||
|
sw.Write(AutoFormatter.ApplyFormatting(0, Helpers.GetTemplate.Source()));
|
||||||
|
break;
|
||||||
|
case TypeSL.Notecard:
|
||||||
sw.Write("notecard");
|
sw.Write("notecard");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1057,11 +1092,11 @@ namespace LSLEditor.Solution
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeNode newFile = new TreeNode(strNewName, (int)typeFile, (int)typeFile);
|
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.Nodes.Add(newFile);
|
||||||
parent.Expand();
|
parent.Expand();
|
||||||
|
|
||||||
this.m_dirty = true;
|
this.m_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddExistingFile(TreeNode parent, string strName, Guid guid)
|
private void AddExistingFile(TreeNode parent, string strName, Guid guid)
|
||||||
|
@ -1694,7 +1729,7 @@ namespace LSLEditor.Solution
|
||||||
tn.BeginEdit();
|
tn.BeginEdit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CutAction(TreeNode tn)
|
private void CutAction(TreeNode tn)
|
||||||
{
|
{
|
||||||
if (CutObject != null)
|
if (CutObject != null)
|
||||||
CutObject.ForeColor = Color.Empty;
|
CutObject.ForeColor = Color.Empty;
|
||||||
|
@ -1736,7 +1771,7 @@ namespace LSLEditor.Solution
|
||||||
{
|
{
|
||||||
if(editForm.Visible)
|
if(editForm.Visible)
|
||||||
{
|
{
|
||||||
editForm.Focus();
|
editForm.Focus();
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
// Check if there's a related expanded lsl or lsli opened. If so, focus it. Else open the lsli.
|
// 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
|
else
|
||||||
{
|
{
|
||||||
// Open a new one
|
// 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);
|
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
|
// 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)) {
|
if (Helpers.LSLIPathHelper.IsLSLI(path)) {
|
||||||
// Check if there's a related expanded lsl opened. If so, focus it. Else open the lsli.
|
// 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
|
} else
|
||||||
{
|
{
|
||||||
// Open a new one
|
// 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);
|
this.parent.OpenFile(GetFullPath(e.Node), guid, true);
|
||||||
}
|
}
|
||||||
|
@ -1793,7 +1828,7 @@ namespace LSLEditor.Solution
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
// Open a new one
|
// 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);
|
this.parent.OpenFile(GetFullPath(e.Node), guid, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,22 +29,24 @@
|
||||||
<SignAssembly>false</SignAssembly>
|
<SignAssembly>false</SignAssembly>
|
||||||
<Win32Resource>C:\Users\User\Desktop\Workspace_Jasper\LSL_editor\lsleditor-code\trunk\LSLEditor.RES</Win32Resource>
|
<Win32Resource>C:\Users\User\Desktop\Workspace_Jasper\LSL_editor\lsleditor-code\trunk\LSLEditor.RES</Win32Resource>
|
||||||
<OldToolsVersion>3.5</OldToolsVersion>
|
<OldToolsVersion>3.5</OldToolsVersion>
|
||||||
<IsWebBootstrapper>true</IsWebBootstrapper>
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||||
<TargetFrameworkProfile />
|
<TargetFrameworkProfile />
|
||||||
<PublishUrl>http://localhost/LSLEditor/</PublishUrl>
|
<PublishUrl>C:\Users\User\Desktop\Workspace_Jasper\LSL_editor\Published LSLEditor\</PublishUrl>
|
||||||
<Install>true</Install>
|
<Install>true</Install>
|
||||||
<InstallFrom>Web</InstallFrom>
|
<InstallFrom>Disk</InstallFrom>
|
||||||
<UpdateEnabled>true</UpdateEnabled>
|
<UpdateEnabled>false</UpdateEnabled>
|
||||||
<UpdateMode>Foreground</UpdateMode>
|
<UpdateMode>Foreground</UpdateMode>
|
||||||
<UpdateInterval>7</UpdateInterval>
|
<UpdateInterval>7</UpdateInterval>
|
||||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||||
<UpdatePeriodically>false</UpdatePeriodically>
|
<UpdatePeriodically>false</UpdatePeriodically>
|
||||||
<UpdateRequired>false</UpdateRequired>
|
<UpdateRequired>false</UpdateRequired>
|
||||||
<MapFileExtensions>true</MapFileExtensions>
|
<MapFileExtensions>true</MapFileExtensions>
|
||||||
<ApplicationRevision>0</ApplicationRevision>
|
<AutorunEnabled>true</AutorunEnabled>
|
||||||
|
<ApplicationRevision>10</ApplicationRevision>
|
||||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||||
<UseApplicationTrust>false</UseApplicationTrust>
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
|
<PublishWizardCompleted>true</PublishWizardCompleted>
|
||||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
@ -100,6 +102,9 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ManifestCertificateThumbprint>5CBB20152EC70EC13542B336790AF2E7AB2E1DEB</ManifestCertificateThumbprint>
|
<ManifestCertificateThumbprint>5CBB20152EC70EC13542B336790AF2E7AB2E1DEB</ManifestCertificateThumbprint>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<GenerateManifests>true</GenerateManifests>
|
||||||
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System">
|
<Reference Include="System">
|
||||||
<Name>System</Name>
|
<Name>System</Name>
|
||||||
|
@ -971,6 +976,7 @@
|
||||||
<EmbeddedResource Include="Images\Vars.gif" />
|
<EmbeddedResource Include="Images\Vars.gif" />
|
||||||
<EmbeddedResource Include="Images\States.gif" />
|
<EmbeddedResource Include="Images\States.gif" />
|
||||||
<None Include="Resources\export_file-32.png" />
|
<None Include="Resources\export_file-32.png" />
|
||||||
|
<EmbeddedResource Include="ImagesSolutionExplorer\LSLIScript.gif" />
|
||||||
<Content Include="Resource\App.ico" />
|
<Content Include="Resource\App.ico" />
|
||||||
<Content Include="Images\logo.gif" />
|
<Content Include="Images\logo.gif" />
|
||||||
<Content Include="LSLEditor.rc" />
|
<Content Include="LSLEditor.rc" />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue