Lot's of bug fixes and features
This commit is contained in:
parent
c9baf200f7
commit
8d6b35dade
8 changed files with 332 additions and 106 deletions
|
@ -419,8 +419,17 @@ namespace LSLEditor
|
||||||
// return false;
|
// return false;
|
||||||
|
|
||||||
if (this.IsScript) {
|
if (this.IsScript) {
|
||||||
|
string lsl = SourceCode;
|
||||||
|
|
||||||
|
// If it is LSLI, it needs to import scripts first, before it recognizes imported functions
|
||||||
|
if (LSLIConverter.IsLSLI(this.FullPathName))
|
||||||
|
{
|
||||||
|
LSLIConverter converter = new LSLIConverter();
|
||||||
|
lsl = converter.ExpandToLSL(this);
|
||||||
|
}
|
||||||
|
|
||||||
LSL2CSharp translator = new LSL2CSharp(ConfLSL);
|
LSL2CSharp translator = new LSL2CSharp(ConfLSL);
|
||||||
string strCSharp = translator.Parse(SourceCode);
|
string strCSharp = translator.Parse(lsl);
|
||||||
|
|
||||||
if (System.Diagnostics.Debugger.IsAttached) {
|
if (System.Diagnostics.Debugger.IsAttached) {
|
||||||
for (int intI = this.tabControl1.TabPages.Count - 1; intI > 0; intI--) {
|
for (int intI = this.tabControl1.TabPages.Count - 1; intI > 0; intI--) {
|
||||||
|
|
|
@ -109,29 +109,6 @@ namespace LSLEditor
|
||||||
return regex.Replace(strC, new MatchEvaluator(CorrectGlobalEvaluator));
|
return regex.Replace(strC, new MatchEvaluator(CorrectGlobalEvaluator));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// WORDT NIET MEER GEBRUIKT
|
|
||||||
/// Imports scripts that are imported using //@include() syntax.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="strC"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private string ImportScripts(string strC)
|
|
||||||
{
|
|
||||||
StringBuilder sb = new StringBuilder(strC);
|
|
||||||
for (int i = strC.IndexOf("\n//@include"); i > -1; i = strC.IndexOf("\n//@include" + 1))
|
|
||||||
{
|
|
||||||
string line = Regex.Match(strC.Substring(i + 1), "^//@include\\(\".*?\"\\)").ToString();
|
|
||||||
|
|
||||||
if (line.Length > 0) {
|
|
||||||
// Found an include statement
|
|
||||||
string path = Regex.Match(line, "\".*?\"").ToString();
|
|
||||||
sb.Insert(i, "\n\tpublic void bla() { }\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return sb.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private string RemoveComments(string strC)
|
private string RemoveComments(string strC)
|
||||||
{
|
{
|
||||||
if (Properties.Settings.Default.CommentCStyle)
|
if (Properties.Settings.Default.CommentCStyle)
|
||||||
|
@ -634,8 +611,6 @@ namespace LSLEditor
|
||||||
|
|
||||||
strC = PreCorrectReservedWords(strC); // Experimental
|
strC = PreCorrectReservedWords(strC); // Experimental
|
||||||
|
|
||||||
//strC = ImportScripts(strC);
|
|
||||||
|
|
||||||
strC = MakeGlobalAndLocal(strC);
|
strC = MakeGlobalAndLocal(strC);
|
||||||
|
|
||||||
strC = CorrectJump(strC);
|
strC = CorrectJump(strC);
|
||||||
|
|
|
@ -50,27 +50,150 @@ namespace LSLEditor.Helpers
|
||||||
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 static List<string> validExtensions = new List<string>(3) { "lsl", "lsli", "LSL", "LSLI" };
|
private static List<string> validExtensions = new List<string>() { "lsl", "lsli", ".lsl", ".lsli" };
|
||||||
|
|
||||||
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";
|
||||||
|
|
||||||
|
// NEW INCLUDE REGEX MATCHES ONLY FIRST OCCURENCE OF LINE ( OLD: ([\n]|^)+//@include\\(\".*?\"\\)(\\s\\w)? )
|
||||||
|
// LAST NEW: ([\n]|^)+//@include\\(\".*?\"\\)(\\s)?
|
||||||
|
private const string INCLUDE_REGEX = "(\n|^)//@include\\(\".*?\"\\)"; // EVEN MORE SIMPLIFIED
|
||||||
|
private const string BEGIN_REGEX = "(\n|^)//@BEGIN"; // OLD: (\n|^)+//@BEGIN(\\s)*(\r|$)
|
||||||
|
private const string END_REGEX = "(\n|^)//@END"; //OLD: ([\n]|^)+//@END(\\s)*(\r|$)
|
||||||
|
|
||||||
|
private List<string> implementedIncludes = new List<string>();
|
||||||
|
|
||||||
public LSLIConverter()
|
public LSLIConverter()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if a filename is LSLI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool IsLSLI(string fileName)
|
||||||
|
{
|
||||||
|
return GetExtension(fileName) == LSLI_EXT;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new path and name from the original path and name based on the editForm.
|
/// Creates a new path and name from the original path and name based on the editForm.
|
||||||
/// E.g. turns path/to/file.lsli into path/to/file.expanded.lsl
|
/// E.g. turns path/to/file.lsli into path/to/file.expanded.lsl
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>New path and scriptname</returns>
|
/// <returns></returns>
|
||||||
public string CreateExpandedPathAndScriptName()
|
public string CreateExpandedPathAndScriptName()
|
||||||
{
|
{
|
||||||
string nameExpanded = editForm.Text.Remove(editForm.ScriptName.Length - 4, 4).TrimEnd(' ') + EXPANDED_SUBEXT + LSL_EXT;
|
return RemoveExtension(editForm.FullPathName) + EXPANDED_SUBEXT + LSL_EXT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates an expanded scriptname out of the current scriptname.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string CreateExpandedScriptName(string filename = null)
|
||||||
|
{
|
||||||
|
string nameExpanded = "";
|
||||||
|
if (filename != null)
|
||||||
|
{
|
||||||
|
nameExpanded = RemoveExtension(filename) + EXPANDED_SUBEXT + LSL_EXT;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
nameExpanded = RemoveExtension(editForm.Text) + EXPANDED_SUBEXT + LSL_EXT;
|
||||||
|
}
|
||||||
|
|
||||||
nameExpanded = nameExpanded.IndexOf('*') > -1 ? nameExpanded.Remove(nameExpanded.IndexOf('*'), 1) : nameExpanded;
|
nameExpanded = nameExpanded.IndexOf('*') > -1 ? nameExpanded.Remove(nameExpanded.IndexOf('*'), 1) : nameExpanded;
|
||||||
return editForm.FullPathName.Remove(editForm.FullPathName.Length - 4, 4) + EXPANDED_SUBEXT + LSL_EXT;
|
return nameExpanded;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new path and name from the original path and name based on the editForm.
|
||||||
|
/// E.g. turns path/to/file.expanded.lsl into path/to/file.lsli
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string CreateCollapsedPathAndScriptName()
|
||||||
|
{
|
||||||
|
return RemoveExtension(editForm.FullPathName) + LSLI_EXT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a LSLI scriptname out of the current scriptname.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string CreateCollapsedScriptName()
|
||||||
|
{
|
||||||
|
string nameExpanded = RemoveExtension(editForm.Text) + LSLI_EXT;
|
||||||
|
nameExpanded = nameExpanded.IndexOf('*') > -1 ? nameExpanded.Remove(nameExpanded.IndexOf('*'), 1) : nameExpanded;
|
||||||
|
return nameExpanded;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the extension from a string, includes '.'
|
||||||
|
/// Only returns the last extension
|
||||||
|
/// Returns empty string if the extension cannot be found
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private static string GetExtension(string filename)
|
||||||
|
{
|
||||||
|
int lastIndexOfDirectorySeperator = -1;
|
||||||
|
|
||||||
|
// If '.' after last index of \\ or /
|
||||||
|
if (filename.Contains('/') || filename.Contains('\\'))
|
||||||
|
{
|
||||||
|
lastIndexOfDirectorySeperator = filename.LastIndexOf('/') > filename.LastIndexOf('\\') ? filename.LastIndexOf('/') : filename.LastIndexOf('\\');
|
||||||
|
}
|
||||||
|
if(lastIndexOfDirectorySeperator != -1 && filename.Contains('.') && lastIndexOfDirectorySeperator < filename.LastIndexOf('.'))
|
||||||
|
{
|
||||||
|
return filename.Substring(filename.LastIndexOf('.')).TrimEnd(' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes the extension and possible expanded subextension from a filename
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private static string RemoveExtension(string filename)
|
||||||
|
{
|
||||||
|
filename = filename.Contains(EXPANDED_SUBEXT) ? filename.Replace(EXPANDED_SUBEXT, "") : filename;
|
||||||
|
return filename.Remove(filename.LastIndexOf(GetExtension(filename)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Searches for a file with one of the validExtensions based on a name or path.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="file"></param>
|
||||||
|
/// <returns>File path</returns>
|
||||||
|
private string SearchFile(string file)
|
||||||
|
{
|
||||||
|
// TODO: Check of settings IncludeFromFolder aanstaat
|
||||||
|
|
||||||
|
if (File.Exists(file))
|
||||||
|
{
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GetExtension(file) == "")
|
||||||
|
{
|
||||||
|
List<string> extensions = validExtensions.Where(e => e[0] == '.').ToList();
|
||||||
|
string pFile = "";
|
||||||
|
|
||||||
|
foreach (string extension in extensions)
|
||||||
|
{
|
||||||
|
pFile = file + extension;
|
||||||
|
|
||||||
|
if (File.Exists(pFile)) {
|
||||||
|
return pFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -81,14 +204,14 @@ namespace LSLEditor.Helpers
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private string GetRelativePath(string filespec, string folder)
|
private string GetRelativePath(string filespec, string folder)
|
||||||
{
|
{
|
||||||
filespec = Path.GetFullPath(filespec);
|
filespec = Path.GetFullPath(filespec).ToLower();
|
||||||
if(validExtensions.Contains(filespec.Substring(filespec.LastIndexOf(".") + 1)))
|
if(validExtensions.Contains(filespec.Substring(filespec.LastIndexOf(".") + 1)))
|
||||||
{
|
{
|
||||||
int lastIndexOfSeperator = filespec.LastIndexOf('\\') > filespec.LastIndexOf('/') ? filespec.LastIndexOf('\\') : filespec.LastIndexOf('/');
|
int lastIndexOfSeperator = filespec.LastIndexOf('\\') > filespec.LastIndexOf('/') ? filespec.LastIndexOf('\\') : filespec.LastIndexOf('/');
|
||||||
filespec = filespec.Remove(lastIndexOfSeperator);
|
filespec = filespec.Remove(lastIndexOfSeperator);
|
||||||
}
|
}
|
||||||
Uri pathUri = new Uri(filespec);
|
Uri pathUri = new Uri(filespec);
|
||||||
// Folders must end in a slash
|
|
||||||
if (!folder.EndsWith(Path.DirectorySeparatorChar.ToString()))
|
if (!folder.EndsWith(Path.DirectorySeparatorChar.ToString()))
|
||||||
{
|
{
|
||||||
folder += Path.DirectorySeparatorChar;
|
folder += Path.DirectorySeparatorChar;
|
||||||
|
@ -113,7 +236,9 @@ namespace LSLEditor.Helpers
|
||||||
/// <returns>Context with the new line</returns>
|
/// <returns>Context with the new line</returns>
|
||||||
private StringBuilder WriteAfterLine(StringBuilder context, string newLine, string lineBefore)
|
private StringBuilder WriteAfterLine(StringBuilder context, string newLine, string lineBefore)
|
||||||
{
|
{
|
||||||
int includeIndex = context.ToString().LastIndexOf(lineBefore) + lineBefore.Length;
|
string ctx = context.ToString();
|
||||||
|
int lastIndexOfLineBefore = ctx.LastIndexOf(lineBefore);
|
||||||
|
int includeIndex = lastIndexOfLineBefore + lineBefore.Length;
|
||||||
|
|
||||||
string hasSeperator = lineBefore.Substring(lineBefore.Length - 1, 1);
|
string hasSeperator = lineBefore.Substring(lineBefore.Length - 1, 1);
|
||||||
if (hasSeperator != "\n")
|
if (hasSeperator != "\n")
|
||||||
|
@ -128,70 +253,71 @@ namespace LSLEditor.Helpers
|
||||||
}
|
}
|
||||||
|
|
||||||
context.Insert(includeIndex, newLine);
|
context.Insert(includeIndex, newLine);
|
||||||
|
string test = context.ToString();
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Imports scripts from //@include statements
|
/// Imports scripts from //@include statements
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="strC">Sourcecode to work with</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>
|
||||||
/// <returns>Sourcecode with imported scripts</returns>
|
/// <returns>Sourcecode with imported scripts</returns>
|
||||||
private string ImportScripts(string strC, string pathOfScript)
|
private string ImportScripts(string strC, string pathOfScript)
|
||||||
{
|
{
|
||||||
|
if(GetExtension(pathOfScript).ToLower() != LSLI_EXT)
|
||||||
|
{
|
||||||
|
// If it's not LSLI extension it can't import a script
|
||||||
|
return strC;
|
||||||
|
}
|
||||||
StringBuilder sb = new StringBuilder(strC);
|
StringBuilder sb = new StringBuilder(strC);
|
||||||
string includeMatch = "([\n]|^)+//@include\\(\".*?\"\\)(\\s\\w)?"; // OLD (\n|^)+//@include\\(\".*?\"\\)(\\s?)+(\n|$) MATCHES ONLY 1 INCLUDE
|
MatchCollection mIncludes = Regex.Matches(strC, INCLUDE_REGEX); // Find includes
|
||||||
MatchCollection mIncludes = Regex.Matches(strC, includeMatch); // Find includes
|
|
||||||
foreach (Match m in mIncludes)
|
foreach (Match m in mIncludes)
|
||||||
{
|
{
|
||||||
string line = m.Value;
|
string contentAfterMatchValue = strC.Substring(m.Index + m.Value.Length);
|
||||||
|
int indexOfNewLine = contentAfterMatchValue.IndexOf('\n') + m.Index + m.Value.Length + 1; // Index of the first occurence of \n after this match
|
||||||
|
string line = strC.Substring(m.Index, indexOfNewLine - m.Index); // Get full line
|
||||||
|
|
||||||
string pathOfInclude = Regex.Match(line, "\".*?\"").Value.Trim('"');
|
string pathOfInclude = Regex.Match(line, "\".*?\"").Value.Trim('"');
|
||||||
int lastIndexOfLine = line.LastIndexOf("\n") > -1 && line.LastIndexOf("\n") > line.LastIndexOf(")")
|
string ext = GetExtension(pathOfInclude).ToLower();
|
||||||
? line.LastIndexOf("\n") + 1 : line.Length;
|
|
||||||
|
|
||||||
// Trim end of string if
|
|
||||||
if (line.Substring(line.Length - 1, 1) != "\n" && line.Substring(line.Length - 1, 1) != ")")
|
|
||||||
{
|
|
||||||
line = line.Remove(line.Length - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
string ext = pathOfInclude.Substring(pathOfInclude.LastIndexOf(".") + 1);
|
if ((validExtensions.Contains(ext) || ext == "") && !this.CreateExpandedScriptName(pathOfScript).Contains(pathOfInclude)
|
||||||
|
&& !pathOfScript.Contains(pathOfInclude))
|
||||||
if (validExtensions.Contains(ext))
|
|
||||||
{
|
{
|
||||||
// If path is relative
|
// If path is relative
|
||||||
if(!Path.IsPathRooted(pathOfInclude))
|
if (!Path.IsPathRooted(pathOfInclude))
|
||||||
{
|
{
|
||||||
pathOfInclude = GetRelativePath(pathOfScript, Environment.CurrentDirectory) + pathOfInclude;
|
pathOfInclude = GetRelativePath(pathOfScript, Environment.CurrentDirectory) + pathOfInclude;
|
||||||
}
|
}
|
||||||
|
|
||||||
sb = this.WriteAfterLine(sb, BEGIN, line);
|
pathOfInclude = SearchFile(pathOfInclude);
|
||||||
|
if (pathOfInclude != "" && !this.implementedIncludes.Contains(Path.GetFullPath(pathOfInclude)))
|
||||||
string script = "";
|
|
||||||
if (File.Exists(pathOfInclude))
|
|
||||||
{
|
{
|
||||||
|
sb = this.WriteAfterLine(sb, BEGIN, line);
|
||||||
|
|
||||||
// Insert included script
|
// Insert included script
|
||||||
|
string script = "// Empty script\n";
|
||||||
using (StreamReader sr = new StreamReader(pathOfInclude))
|
using (StreamReader sr = new StreamReader(pathOfInclude))
|
||||||
{
|
{
|
||||||
|
this.implementedIncludes.Add(Path.GetFullPath(pathOfInclude));
|
||||||
string scriptRaw = sr.ReadToEnd();
|
string scriptRaw = sr.ReadToEnd();
|
||||||
|
|
||||||
// If there are includes in the included script
|
// If there are includes in the included script
|
||||||
if (Regex.IsMatch(strC, includeMatch))
|
if (Regex.IsMatch(scriptRaw, INCLUDE_REGEX))
|
||||||
{
|
{
|
||||||
// TODO: Kijk voor alle matches, niet alleen 1 match AT: VOLGENS MIJ GEBEURD DIT AL?
|
|
||||||
//Match mInclude = Regex.Match(strC, includeMatch); // Find includes
|
|
||||||
//string IncludePath = Regex.Match(mInclude.ToString(), "\".*?\"").Value.Trim('"');
|
|
||||||
|
|
||||||
// Then import these scripts too
|
// Then import these scripts too
|
||||||
script = "\n" + ImportScripts(scriptRaw, pathOfInclude) + "\n";
|
script = "\n" + ImportScripts(scriptRaw, pathOfInclude) + "\n";
|
||||||
|
} else if(scriptRaw != "" && scriptRaw != " ")
|
||||||
|
{
|
||||||
|
script = scriptRaw + "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
this.WriteAfterLine(sb, script, BEGIN + "\n");
|
this.WriteAfterLine(sb, script, BEGIN + "\n");
|
||||||
|
|
||||||
this.WriteAfterLine(sb, END, script);
|
this.WriteAfterLine(sb, END, script);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +325,68 @@ namespace LSLEditor.Helpers
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Main function of the class. Call this to expand LSLI to LSL
|
/// Removes included scripts
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strC">Sourcecode</param>
|
||||||
|
/// <returns>Sourcecode without imported scripts</returns>
|
||||||
|
private string RemoveScripts(string strC) // TODO: DIT VALT MISS NOG TE OPTIMALISEREN MET STRINGBUILDER IPV STRING
|
||||||
|
{
|
||||||
|
//StringBuilder sb = new StringBuilder(strC);
|
||||||
|
|
||||||
|
string result = strC;
|
||||||
|
int indexOfFirstBeginStatement = -1;
|
||||||
|
uint depth = 0;
|
||||||
|
int readIndex = 0;
|
||||||
|
|
||||||
|
using(StringReader sr = new StringReader(strC))
|
||||||
|
{
|
||||||
|
int amountOfLines = strC.Split('\n').Length;
|
||||||
|
for (int i = 1; i < amountOfLines; i++)
|
||||||
|
{
|
||||||
|
string line = sr.ReadLine();
|
||||||
|
|
||||||
|
if (Regex.IsMatch(line, BEGIN_REGEX))
|
||||||
|
{
|
||||||
|
if(depth == 0)
|
||||||
|
{
|
||||||
|
indexOfFirstBeginStatement = readIndex;
|
||||||
|
}
|
||||||
|
depth++;
|
||||||
|
}
|
||||||
|
|
||||||
|
readIndex += line.Length + 1;
|
||||||
|
|
||||||
|
if (Regex.IsMatch(line, END_REGEX))
|
||||||
|
{
|
||||||
|
depth--;
|
||||||
|
|
||||||
|
if (depth == 0)
|
||||||
|
{
|
||||||
|
result = result.Remove(indexOfFirstBeginStatement, (readIndex - indexOfFirstBeginStatement));
|
||||||
|
readIndex -= readIndex - indexOfFirstBeginStatement;
|
||||||
|
indexOfFirstBeginStatement = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Call this to collapse LSL to LSLI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="editform"></param>
|
||||||
|
/// <returns>LSLI</returns>
|
||||||
|
public string CollapseToLSLI(EditForm editform)
|
||||||
|
{
|
||||||
|
this.editForm = editform;
|
||||||
|
string sourceCode = RemoveScripts(editForm.SourceCode);
|
||||||
|
return sourceCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Call this to expand LSLI to LSL
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="editForm"></param>
|
/// <param name="editForm"></param>
|
||||||
/// <returns>LSL</returns>
|
/// <returns>LSL</returns>
|
||||||
|
|
47
trunk/LSLEditorForm.Designer.cs
generated
47
trunk/LSLEditorForm.Designer.cs
generated
|
@ -103,6 +103,9 @@ namespace LSLEditor
|
||||||
this.formatSelectedTextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.formatSelectedTextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.commentInToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.commentInToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.uncommentingSelectedTextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.uncommentingSelectedTextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.toolStripSeparator10 = new System.Windows.Forms.ToolStripSeparator();
|
||||||
|
this.CollapseToLSLIToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.expandToLSLToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.viewlStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.viewlStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.solutionExplorerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.solutionExplorerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.outlineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.outlineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
@ -144,9 +147,6 @@ namespace LSLEditor
|
||||||
this.openSolutionFilesDialog = new System.Windows.Forms.OpenFileDialog();
|
this.openSolutionFilesDialog = new System.Windows.Forms.OpenFileDialog();
|
||||||
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
|
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
|
||||||
this.dockPanel = new LSLEditor.Docking.DockPanel();
|
this.dockPanel = new LSLEditor.Docking.DockPanel();
|
||||||
this.toolStripSeparator10 = new System.Windows.Forms.ToolStripSeparator();
|
|
||||||
this.CollapseToLSLIToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.expandToLSLToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.menuStrip1.SuspendLayout();
|
this.menuStrip1.SuspendLayout();
|
||||||
this.statusStrip1.SuspendLayout();
|
this.statusStrip1.SuspendLayout();
|
||||||
this.contextMenuStrip1.SuspendLayout();
|
this.contextMenuStrip1.SuspendLayout();
|
||||||
|
@ -652,6 +652,27 @@ namespace LSLEditor
|
||||||
this.uncommentingSelectedTextToolStripMenuItem.Text = "Uncommenting selected text";
|
this.uncommentingSelectedTextToolStripMenuItem.Text = "Uncommenting selected text";
|
||||||
this.uncommentingSelectedTextToolStripMenuItem.Click += new System.EventHandler(this.uncommentingSelectedTextToolStripMenuItem_Click);
|
this.uncommentingSelectedTextToolStripMenuItem.Click += new System.EventHandler(this.uncommentingSelectedTextToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
|
// toolStripSeparator10
|
||||||
|
//
|
||||||
|
this.toolStripSeparator10.Name = "toolStripSeparator10";
|
||||||
|
this.toolStripSeparator10.Size = new System.Drawing.Size(222, 6);
|
||||||
|
//
|
||||||
|
// CollapseToLSLIToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.CollapseToLSLIToolStripMenuItem.Name = "CollapseToLSLIToolStripMenuItem";
|
||||||
|
this.CollapseToLSLIToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F10;
|
||||||
|
this.CollapseToLSLIToolStripMenuItem.Size = new System.Drawing.Size(225, 22);
|
||||||
|
this.CollapseToLSLIToolStripMenuItem.Text = "Collapse to LSLI";
|
||||||
|
this.CollapseToLSLIToolStripMenuItem.Click += new System.EventHandler(this.CollapseToLSLIToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// expandToLSLToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.expandToLSLToolStripMenuItem.Name = "expandToLSLToolStripMenuItem";
|
||||||
|
this.expandToLSLToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F11;
|
||||||
|
this.expandToLSLToolStripMenuItem.Size = new System.Drawing.Size(225, 22);
|
||||||
|
this.expandToLSLToolStripMenuItem.Text = "Expand to LSL";
|
||||||
|
this.expandToLSLToolStripMenuItem.Click += new System.EventHandler(this.expandToLSLToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
// viewlStripMenuItem
|
// viewlStripMenuItem
|
||||||
//
|
//
|
||||||
this.viewlStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.viewlStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
@ -756,7 +777,7 @@ namespace LSLEditor
|
||||||
// optionsToolStripMenuItem
|
// optionsToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
|
this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
|
||||||
this.optionsToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
this.optionsToolStripMenuItem.Size = new System.Drawing.Size(125, 22);
|
||||||
this.optionsToolStripMenuItem.Text = "Options...";
|
this.optionsToolStripMenuItem.Text = "Options...";
|
||||||
this.optionsToolStripMenuItem.Click += new System.EventHandler(this.optionsToolStripMenuItem_Click);
|
this.optionsToolStripMenuItem.Click += new System.EventHandler(this.optionsToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
|
@ -972,24 +993,6 @@ namespace LSLEditor
|
||||||
this.dockPanel.Skin = dockPanelSkin1;
|
this.dockPanel.Skin = dockPanelSkin1;
|
||||||
this.dockPanel.TabIndex = 10;
|
this.dockPanel.TabIndex = 10;
|
||||||
//
|
//
|
||||||
// toolStripSeparator10
|
|
||||||
//
|
|
||||||
this.toolStripSeparator10.Name = "toolStripSeparator10";
|
|
||||||
this.toolStripSeparator10.Size = new System.Drawing.Size(222, 6);
|
|
||||||
//
|
|
||||||
// CollapseToLSLIToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.CollapseToLSLIToolStripMenuItem.Name = "CollapseToLSLIToolStripMenuItem";
|
|
||||||
this.CollapseToLSLIToolStripMenuItem.Size = new System.Drawing.Size(225, 22);
|
|
||||||
this.CollapseToLSLIToolStripMenuItem.Text = "Collapse to LSLI";
|
|
||||||
//
|
|
||||||
// expandToLSLToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.expandToLSLToolStripMenuItem.Name = "expandToLSLToolStripMenuItem";
|
|
||||||
this.expandToLSLToolStripMenuItem.Size = new System.Drawing.Size(225, 22);
|
|
||||||
this.expandToLSLToolStripMenuItem.Text = "Expand to LSL";
|
|
||||||
this.expandToLSLToolStripMenuItem.Click += new System.EventHandler(this.expandToLSLToolStripMenuItem_Click);
|
|
||||||
//
|
|
||||||
// LSLEditorForm
|
// LSLEditorForm
|
||||||
//
|
//
|
||||||
this.AllowDrop = true;
|
this.AllowDrop = true;
|
||||||
|
|
|
@ -279,7 +279,7 @@ namespace LSLEditor
|
||||||
private void Start(string[] args)
|
private void Start(string[] args)
|
||||||
{
|
{
|
||||||
string fileFilterNotes = "Notecard files (*.txt)|*.txt|All files (*.*)|*.*";
|
string fileFilterNotes = "Notecard files (*.txt)|*.txt|All files (*.*)|*.*";
|
||||||
string fileFilterScripts = "Secondlife script files (*.lsl)|*.lsl|All files (*.*)|*.*";
|
string fileFilterScripts = "Secondlife script files (*.lsl;*.lsli)|*.lsl;*.lsli|All files (*.*)|*.*";
|
||||||
string fileFilterSolutions = "LSLEditor Solution File (*.sol)|*.sol|All Files (*.*)|*.*";
|
string fileFilterSolutions = "LSLEditor Solution File (*.sol)|*.sol|All Files (*.*)|*.*";
|
||||||
|
|
||||||
this.ConfLSL = GetXmlFromResource(Properties.Settings.Default.ConfLSL);
|
this.ConfLSL = GetXmlFromResource(Properties.Settings.Default.ConfLSL);
|
||||||
|
@ -1802,9 +1802,8 @@ namespace LSLEditor
|
||||||
|
|
||||||
private void expandToLSLToolStripMenuItem_Click(object sender, EventArgs e)
|
private void expandToLSLToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// TODO: DE EXPAND FUNCTIE MAKEN. HIERVOOR MOET DE RUNTIMECONSOLE WORDEN GEIMPORTEERD
|
|
||||||
EditForm editForm = this.ActiveMdiForm as EditForm;
|
EditForm editForm = this.ActiveMdiForm as EditForm;
|
||||||
if (editForm != null && editForm.FullPathName.IndexOf(Helpers.LSLIConverter.EXPANDED_SUBEXT) < 0) // TODO: && editForm.FullPathName.IndexOf(".lsli") > -1)
|
if (editForm != null && editForm.FullPathName.IndexOf(Helpers.LSLIConverter.LSLI_EXT) > -1)
|
||||||
{
|
{
|
||||||
Helpers.LSLIConverter converter = new Helpers.LSLIConverter();
|
Helpers.LSLIConverter converter = new Helpers.LSLIConverter();
|
||||||
string lsl = converter.ExpandToLSL(editForm);
|
string lsl = converter.ExpandToLSL(editForm);
|
||||||
|
@ -1814,9 +1813,58 @@ namespace LSLEditor
|
||||||
{
|
{
|
||||||
sw.Write(lsl);
|
sw.Write(lsl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EditForm expandedForm = null;
|
||||||
|
for (int i = 0; i < Application.OpenForms.Count; i++)
|
||||||
|
{
|
||||||
|
Form form = Application.OpenForms[i];
|
||||||
|
if (form.Text.TrimEnd(' ') == converter.CreateExpandedScriptName())
|
||||||
|
{
|
||||||
|
expandedForm = (EditForm)form;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expandedForm != null)
|
||||||
|
{
|
||||||
|
expandedForm.Close();
|
||||||
|
}
|
||||||
|
editForm.Close();
|
||||||
|
OpenFile(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CollapseToLSLIToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
EditForm editForm = this.ActiveMdiForm as EditForm;
|
||||||
|
|
||||||
|
// NOTE: This checks only if there's an LSL file, not if there's a extended subextension
|
||||||
|
if (editForm != null && editForm.FullPathName.IndexOf(Helpers.LSLIConverter.LSL_EXT) > -1)
|
||||||
|
{
|
||||||
|
Helpers.LSLIConverter converter = new Helpers.LSLIConverter();
|
||||||
|
string lsli = converter.CollapseToLSLI(editForm);
|
||||||
|
string file = converter.CreateCollapsedPathAndScriptName();
|
||||||
|
|
||||||
|
using (StreamWriter sw = new StreamWriter(file))
|
||||||
|
{
|
||||||
|
sw.Write(lsli);
|
||||||
|
}
|
||||||
|
|
||||||
|
EditForm collapsedForm = null;
|
||||||
|
for (int i = 0; i < Application.OpenForms.Count; i++)
|
||||||
|
{
|
||||||
|
Form form = Application.OpenForms[i];
|
||||||
|
if (form.Text.TrimEnd(' ') == converter.CreateCollapsedScriptName())
|
||||||
|
{
|
||||||
|
collapsedForm = (EditForm)form;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (collapsedForm != null)
|
||||||
|
{
|
||||||
|
collapsedForm.Close();
|
||||||
|
}
|
||||||
|
editForm.Close();
|
||||||
OpenFile(file);
|
OpenFile(file);
|
||||||
//ActivateMdiForm();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.236")]
|
[assembly: AssemblyVersion("2.55.0.378")]
|
||||||
|
|
||||||
//
|
//
|
||||||
// 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.236")]
|
[assembly: AssemblyFileVersionAttribute("2.55.0.378")]
|
||||||
|
|
|
@ -8,6 +8,10 @@
|
||||||
<Word name="regex">
|
<Word name="regex">
|
||||||
"[^"\\]* (?>\\.[^"\\]*)*"
|
"[^"\\]* (?>\\.[^"\\]*)*"
|
||||||
</Word>
|
</Word>
|
||||||
|
<Word name="//@BEGIN">
|
||||||
|
</Word>
|
||||||
|
<Word name="//@END">
|
||||||
|
</Word>
|
||||||
</Words>
|
</Words>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -115,8 +115,7 @@ namespace LSLEditor
|
||||||
{
|
{
|
||||||
LSLIConverter lsliConverter = new LSLIConverter();
|
LSLIConverter lsliConverter = new LSLIConverter();
|
||||||
lsl = lsliConverter.ExpandToLSL(editForm);
|
lsl = lsliConverter.ExpandToLSL(editForm);
|
||||||
string nameExpanded = editForm.Text.Remove(editForm.ScriptName.Length - 4, 4).TrimEnd(' ')
|
string nameExpanded = lsliConverter.CreateExpandedScriptName();
|
||||||
+ LSLIConverter.EXPANDED_SUBEXT + LSLIConverter.LSL_EXT; // TODO: Dit is nog niet perfect
|
|
||||||
string path = lsliConverter.CreateExpandedPathAndScriptName();
|
string path = lsliConverter.CreateExpandedPathAndScriptName();
|
||||||
|
|
||||||
using (StreamWriter sw = new StreamWriter(path))
|
using (StreamWriter sw = new StreamWriter(path))
|
||||||
|
@ -124,21 +123,22 @@ namespace LSLEditor
|
||||||
sw.Write(lsl);
|
sw.Write(lsl);
|
||||||
}
|
}
|
||||||
|
|
||||||
EditForm expandedForm = null;
|
// NOTE: DE EXPANDED LSL WORDT NU IN DE ACHTERGROND GERUNT EN NIET MEER LATEN ZIEN OP 2 TABS
|
||||||
for (int i = 0; i < Application.OpenForms.Count; i++)
|
//EditForm expandedForm = null;
|
||||||
{
|
//for (int i = 0; i < Application.OpenForms.Count; i++)
|
||||||
Form form = Application.OpenForms[i];
|
//{
|
||||||
if(form.Text.TrimEnd(' ') == nameExpanded)
|
// Form form = Application.OpenForms[i];
|
||||||
{
|
// if(form.Text.TrimEnd(' ') == nameExpanded)
|
||||||
expandedForm = (EditForm)form;
|
// {
|
||||||
}
|
// expandedForm = (EditForm)form;
|
||||||
}
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
// Open the expanded file if not already open
|
//// Open the expanded file if not already open
|
||||||
if(expandedForm == null)
|
//if(expandedForm == null)
|
||||||
{
|
//{
|
||||||
mainForm.OpenFile(path, Guid.NewGuid(), true); // TODO: MOET AUTOMATISCH GAAN RUNNEN
|
// mainForm.OpenFile(path, Guid.NewGuid(), true); // TODO: MOET AUTOMATISCH GAAN RUNNEN
|
||||||
}
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue