Fix bug show include errors

This commit is contained in:
User 2017-12-21 10:47:55 +01:00
parent b7911a5b87
commit 123808c7d5
9 changed files with 373 additions and 153 deletions

View file

@ -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;

View file

@ -34,6 +34,8 @@
//
// <summary>
// This class is used to convert LSLI to LSL and the other way around.
// Created by Jasper Wiggerink
// 13-11-2017
// </summary>
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<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 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;
// }
// }
// }
//}
/// <summary>
/// Searches for a file with one of the validExtensions based on a name or path. Also searches in the IncludeDirectories
/// </summary>
/// <param name="file"></param>
/// <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)
{
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 "";
}
/// <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>
/// Finds all indexes of a value in a string
/// </summary>
@ -176,16 +190,34 @@ namespace LSLEditor.Helpers
/// <returns></returns>
public static List<int> AllIndexesOf(string str, string 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)
if (!String.IsNullOrEmpty(value))
{
index = str.IndexOf(value, index);
if (index == -1)
return indexes;
indexes.Add(index);
List<int> indexes = new List<int>();
for (int index = 0; ; index += value.Length)
{
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>
@ -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
/// <param name="includeDepth"></param>
/// <param name="OneLess"></param>
/// <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 = "";
if(OneLess && includeDepth != 0)
@ -299,14 +330,22 @@ namespace LSLEditor.Helpers
/// <returns></returns>
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
}
/// <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>
/// <param name="includeLine"></param>
/// <param name="includeDepth"></param>
@ -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;
}
/// <summary>
@ -424,7 +498,7 @@ namespace LSLEditor.Helpers
}
/// <summary>
/// Imports scripts from //@include statements
/// Imports scripts from //#include statements
/// </summary>
/// <param name="strC">Sourcecode</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 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
/// <returns>LSL</returns>
public string ExpandToLSL(EditForm editForm, bool ShowBeginEnd = true)
{
editForm.verboseQueue = new List<string>();
this.editForm = editForm;
string strC = editForm.SourceCode;
string fullPathName = editForm.FullPathName;

View file

@ -34,18 +34,19 @@
//
// <summary>
// This class is used to help with paths and LSLI files.
// Created by Jasper Wiggerink
// 13-11-2017
// </summary>
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)";
/// <summary>
/// Checks if a filename is LSLI
@ -79,12 +80,22 @@ namespace LSLEditor.Helpers
return nameCollapsed;
}
/// <summary>
/// Removes only the last extension
/// </summary>
/// <param name="filename"></param>
/// <returns></returns>
private static string RemoveExtension(string filename)
{
filename = TrimStarsAndWhiteSpace(filename.Remove(filename.LastIndexOf(Path.GetExtension(filename))));
return filename;
}
/// <summary>
/// Removes the .expanded in a filename
/// </summary>
/// <param name="filename"></param>
/// <returns></returns>
public static string RemoveExpandedSubExtension(string filename)
{
if (filename.Contains(LSLIConverter.EXPANDED_SUBEXT))
@ -136,6 +147,11 @@ namespace LSLEditor.Helpers
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)
{
int afterLastIndexOfSeperator = (filename.LastIndexOf('\\') > filename.LastIndexOf('/') ? filename.LastIndexOf('\\') : filename.LastIndexOf('/')) + 1;
@ -149,6 +165,11 @@ namespace LSLEditor.Helpers
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)
{
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)
{
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)
/// <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>
/// Creates a relative path between two paths

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 B

View file

@ -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;
}
/// <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)
{
//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)
/// <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.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);

View file

@ -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")]

View file

@ -5,15 +5,17 @@
<Words name="Strings" color="#A0A0A0" slcolor="#003300">
<Word name="regex">
<Word name="regex">
"[^"\\]* (?>\\.[^"\\]*)*"
</Word>
<Word name="//@BEGIN">
</Word>
<Word name="//@END">
</Word>
</Words>
<Words name="Includes" color="#A0A0A0" slcolor="#003300">
<Word name="//#BEGIN">
</Word>
<Word name="//#END">
</Word>
</Words>
<Words name="Operators" color="#777700" slcolor="#000000">
<Word name="regex">

View file

@ -38,16 +38,16 @@
// </summary>
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);
}

View file

@ -29,22 +29,24 @@
<SignAssembly>false</SignAssembly>
<Win32Resource>C:\Users\User\Desktop\Workspace_Jasper\LSL_editor\lsleditor-code\trunk\LSLEditor.RES</Win32Resource>
<OldToolsVersion>3.5</OldToolsVersion>
<IsWebBootstrapper>true</IsWebBootstrapper>
<IsWebBootstrapper>false</IsWebBootstrapper>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkProfile />
<PublishUrl>http://localhost/LSLEditor/</PublishUrl>
<PublishUrl>C:\Users\User\Desktop\Workspace_Jasper\LSL_editor\Published LSLEditor\</PublishUrl>
<Install>true</Install>
<InstallFrom>Web</InstallFrom>
<UpdateEnabled>true</UpdateEnabled>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<AutorunEnabled>true</AutorunEnabled>
<ApplicationRevision>10</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@ -100,6 +102,9 @@
<PropertyGroup>
<ManifestCertificateThumbprint>5CBB20152EC70EC13542B336790AF2E7AB2E1DEB</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="System">
<Name>System</Name>
@ -971,6 +976,7 @@
<EmbeddedResource Include="Images\Vars.gif" />
<EmbeddedResource Include="Images\States.gif" />
<None Include="Resources\export_file-32.png" />
<EmbeddedResource Include="ImagesSolutionExplorer\LSLIScript.gif" />
<Content Include="Resource\App.ico" />
<Content Include="Images\logo.gif" />
<Content Include="LSLEditor.rc" />