proper import
git-svn-id: https://lsleditor.svn.sourceforge.net/svnroot/lsleditor@9 3f4676ac-adda-40fd-8265-58d1435b1672
This commit is contained in:
parent
66730fd649
commit
3151e1e342
454 changed files with 57577 additions and 0 deletions
109
trunk/Plugins/Generic.cs
Normal file
109
trunk/Plugins/Generic.cs
Normal file
|
@ -0,0 +1,109 @@
|
|||
// /**
|
||||
// ********
|
||||
// *
|
||||
// * ORIGIONAL CODE BASE IS Copyright (C) 2006-2010 by Alphons van der Heijden
|
||||
// * The code was donated on 4/28/2010 by Alphons van der Heijden
|
||||
// * To Brandon'Dimentox Travanti' Husbands & Malcolm J. Kudra which in turn Liscense under the GPLv2.
|
||||
// * In agreement to Alphons van der Heijden wishes.
|
||||
// *
|
||||
// * The community would like to thank Alphons for all of his hard work, blood sweat and tears.
|
||||
// * Without his work the community would be stuck with crappy editors.
|
||||
// *
|
||||
// * The source code in this file ("Source Code") is provided by The LSLEditor Group
|
||||
// * to you under the terms of the GNU General Public License, version 2.0
|
||||
// * ("GPL"), unless you have obtained a separate licensing agreement
|
||||
// * ("Other License"), formally executed by you and The LSLEditor Group. Terms of
|
||||
// * the GPL can be found in the gplv2.txt document.
|
||||
// *
|
||||
// ********
|
||||
// * GPLv2 Header
|
||||
// ********
|
||||
// * LSLEditor, a External editor for the LSL Language.
|
||||
// * Copyright (C) 2010 The LSLEditor Group.
|
||||
//
|
||||
// * This program is free software; you can redistribute it and/or
|
||||
// * modify it under the terms of the GNU General Public License
|
||||
// * as published by the Free Software Foundation; either version 2
|
||||
// * of the License, or (at your option) any later version.
|
||||
// *
|
||||
// * This program is distributed in the hope that it will be useful,
|
||||
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// * GNU General Public License for more details.
|
||||
// *
|
||||
// * You should have received a copy of the GNU General Public License
|
||||
// * along with this program; if not, write to the Free Software
|
||||
// * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
// ********
|
||||
// *
|
||||
// * The above copyright notice and this permission notice shall be included in all
|
||||
// * copies or substantial portions of the Software.
|
||||
// *
|
||||
// ********
|
||||
// */
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.Reflection;
|
||||
|
||||
namespace LSLEditor.Plugins
|
||||
{
|
||||
class Generic
|
||||
{
|
||||
private delegate void RunDelegate(string strFilePath, RichTextBox tb);
|
||||
|
||||
public Generic(LSLEditorForm parent, string strPluginName)
|
||||
{
|
||||
EditForm editForm = parent.ActiveMdiForm as EditForm;
|
||||
if (editForm == null)
|
||||
return;
|
||||
|
||||
string strFilePath = editForm.FullPathName;
|
||||
RichTextBox tb = editForm.TextBox as RichTextBox;
|
||||
|
||||
string strDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
string strPluginsDirectory = Path.Combine(strDirectory, "Plugins");
|
||||
string strProgram = Path.Combine(strPluginsDirectory, strPluginName + ".exe");
|
||||
|
||||
Assembly assembly = null;
|
||||
|
||||
try
|
||||
{
|
||||
assembly = Assembly.LoadFrom(strProgram);
|
||||
}
|
||||
catch
|
||||
{
|
||||
MessageBox.Show("Not a valid plugin, see http://www.lsleditor.org/help/Plugins.aspx", "Plugins", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
if (assembly == null)
|
||||
return;
|
||||
|
||||
object[] args = new object[] { strFilePath, tb };
|
||||
|
||||
foreach (Type t in assembly.GetTypes())
|
||||
{
|
||||
if (t.BaseType.Name == "Form")
|
||||
{
|
||||
Form form = assembly.CreateInstance(t.FullName, false,
|
||||
BindingFlags.Public|BindingFlags.Instance|BindingFlags.CreateInstance,
|
||||
null,args,null,null) as Form;
|
||||
if (form != null)
|
||||
{
|
||||
parent.AddForm(form);
|
||||
return;
|
||||
}
|
||||
}
|
||||
MethodInfo info = t.GetMethod("Run",
|
||||
BindingFlags.Public |
|
||||
BindingFlags.NonPublic |
|
||||
BindingFlags.Static);
|
||||
|
||||
if (info == null)
|
||||
continue;
|
||||
|
||||
info.Invoke(null, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
189
trunk/Plugins/LSLint.cs
Normal file
189
trunk/Plugins/LSLint.cs
Normal file
|
@ -0,0 +1,189 @@
|
|||
// /**
|
||||
// ********
|
||||
// *
|
||||
// * ORIGIONAL CODE BASE IS Copyright (C) 2006-2010 by Alphons van der Heijden
|
||||
// * The code was donated on 4/28/2010 by Alphons van der Heijden
|
||||
// * To Brandon'Dimentox Travanti' Husbands & Malcolm J. Kudra which in turn Liscense under the GPLv2.
|
||||
// * In agreement to Alphons van der Heijden wishes.
|
||||
// *
|
||||
// * The community would like to thank Alphons for all of his hard work, blood sweat and tears.
|
||||
// * Without his work the community would be stuck with crappy editors.
|
||||
// *
|
||||
// * The source code in this file ("Source Code") is provided by The LSLEditor Group
|
||||
// * to you under the terms of the GNU General Public License, version 2.0
|
||||
// * ("GPL"), unless you have obtained a separate licensing agreement
|
||||
// * ("Other License"), formally executed by you and The LSLEditor Group. Terms of
|
||||
// * the GPL can be found in the gplv2.txt document.
|
||||
// *
|
||||
// ********
|
||||
// * GPLv2 Header
|
||||
// ********
|
||||
// * LSLEditor, a External editor for the LSL Language.
|
||||
// * Copyright (C) 2010 The LSLEditor Group.
|
||||
//
|
||||
// * This program is free software; you can redistribute it and/or
|
||||
// * modify it under the terms of the GNU General Public License
|
||||
// * as published by the Free Software Foundation; either version 2
|
||||
// * of the License, or (at your option) any later version.
|
||||
// *
|
||||
// * This program is distributed in the hope that it will be useful,
|
||||
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// * GNU General Public License for more details.
|
||||
// *
|
||||
// * You should have received a copy of the GNU General Public License
|
||||
// * along with this program; if not, write to the Free Software
|
||||
// * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
// ********
|
||||
// *
|
||||
// * The above copyright notice and this permission notice shall be included in all
|
||||
// * copies or substantial portions of the Software.
|
||||
// *
|
||||
// ********
|
||||
// */
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using System.Text;
|
||||
/*
|
||||
<p>
|
||||
- Added: <b>Plugin support</b><br />
|
||||
At this moment only lslint.exe is supported! (get the windows version from <a href="http://w-hat.com/lslint/">http://w-hat.com/lslint/</a>)<br />
|
||||
Create a subdirectory 'plugins' in the directory where LSLEditor.exe resides<br />
|
||||
Copy lslint.exe into this plugins directory<br />
|
||||
Menu Tools - Options - Environment - Plugins - Check lslint checkbox<br />
|
||||
When hitting the OK button, Menu - Tools - lslint should appear<br />
|
||||
</p>
|
||||
|
||||
*/
|
||||
namespace LSLEditor.Plugins
|
||||
{
|
||||
class LSLint
|
||||
{
|
||||
public string ExceptionMessage;
|
||||
public bool HasErrors;
|
||||
|
||||
public LSLint()
|
||||
{
|
||||
ExceptionMessage = "";
|
||||
}
|
||||
private string Execute(string strSourceCode)
|
||||
{
|
||||
string strAll = "";
|
||||
try
|
||||
{
|
||||
string strPluginName = "lslint";
|
||||
string strArguments = "";
|
||||
Process process = new Process();
|
||||
|
||||
string strDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
string strPluginsDirectory = Path.Combine(strDirectory, "Plugins");
|
||||
string strProgram = Path.Combine(strPluginsDirectory, strPluginName + ".exe");
|
||||
|
||||
process.StartInfo.UseShellExecute = false;
|
||||
process.StartInfo.RedirectStandardOutput = true;
|
||||
process.StartInfo.RedirectStandardError = true;
|
||||
process.StartInfo.RedirectStandardInput = true;
|
||||
process.StartInfo.CreateNoWindow = true;
|
||||
process.StartInfo.FileName = strProgram;
|
||||
process.StartInfo.Arguments = strArguments;
|
||||
process.Start();
|
||||
process.StandardInput.Write(strSourceCode);
|
||||
process.StandardInput.Close();
|
||||
strAll = process.StandardError.ReadToEnd();
|
||||
process.WaitForExit();
|
||||
}
|
||||
catch(Exception exception)
|
||||
{
|
||||
this.ExceptionMessage += exception.Message + "\r\n";
|
||||
}
|
||||
return strAll;
|
||||
}
|
||||
|
||||
private void RunOnce(ListView listView, EditForm editForm)
|
||||
{
|
||||
// ProjectName, ScriptName,
|
||||
string strErrors = Execute(editForm.SourceCode);
|
||||
StringReader sr = new StringReader(strErrors);
|
||||
int intNr = 1;
|
||||
while (true)
|
||||
{
|
||||
string strLine = sr.ReadLine();
|
||||
if (strLine == null)
|
||||
break;
|
||||
strLine = strLine.Trim();
|
||||
|
||||
if (strLine.StartsWith("TOTAL"))
|
||||
continue;
|
||||
|
||||
string strLineNr = "";
|
||||
string strColumnNr = "";
|
||||
string strErrorNr = "";
|
||||
|
||||
int intImageIndex = -1;
|
||||
if (strLine.StartsWith("WARN"))
|
||||
intImageIndex = 1;
|
||||
|
||||
if (strLine.StartsWith("ERR"))
|
||||
intImageIndex = 0;
|
||||
|
||||
int intI = strLine.IndexOf("::");
|
||||
if (intI > 0)
|
||||
{
|
||||
strLine = strLine.Substring(intI + 2).Trim();
|
||||
intI = strLine.IndexOf(":");
|
||||
if (intI > 0)
|
||||
{
|
||||
string strLineColumn = strLine.Substring(0, intI).Replace("(", "").Replace(")", "").Replace(" ", "");
|
||||
string[] LineColumn = strLineColumn.Split(new char[] { ',' });
|
||||
if (LineColumn.Length > 1)
|
||||
{
|
||||
int intLine = 0;
|
||||
int intColumn = 0;
|
||||
|
||||
int.TryParse(LineColumn[0], out intLine);
|
||||
int.TryParse(LineColumn[1], out intColumn);
|
||||
|
||||
strLineNr = intLine.ToString();
|
||||
strColumnNr = intColumn.ToString();
|
||||
strErrorNr = intNr.ToString();
|
||||
}
|
||||
strLine = strLine.Substring(intI + 1).Trim();
|
||||
}
|
||||
}
|
||||
|
||||
ListViewItem lvi = new ListViewItem(new string[] {
|
||||
"", // 0
|
||||
strErrorNr, // 1
|
||||
strLine, // 2
|
||||
editForm.ScriptName, // 3
|
||||
strLineNr, // 4
|
||||
strColumnNr, // 5
|
||||
editForm.ProjectName , // 6
|
||||
editForm.FullPathName, // 7
|
||||
editForm.guid.ToString(), // 8
|
||||
editForm.IsScript.ToString()// 9
|
||||
} , intImageIndex);
|
||||
listView.Items.Add(lvi);
|
||||
if(strErrorNr!="")
|
||||
intNr++;
|
||||
}
|
||||
}
|
||||
|
||||
public bool SyntaxCheck(LSLEditorForm parent)
|
||||
{
|
||||
foreach (Form form in parent.Children)
|
||||
{
|
||||
EditForm editForm = form as EditForm;
|
||||
if (editForm == null || editForm.IsDisposed)
|
||||
continue;
|
||||
RunOnce(parent.SyntaxErrors.ListView, editForm);
|
||||
}
|
||||
this.HasErrors = (parent.SyntaxErrors.ListView.Items.Count != 0);
|
||||
return (ExceptionMessage == "");
|
||||
}
|
||||
}
|
||||
}
|
74
trunk/Plugins/Particles.cs
Normal file
74
trunk/Plugins/Particles.cs
Normal file
|
@ -0,0 +1,74 @@
|
|||
// /**
|
||||
// ********
|
||||
// *
|
||||
// * ORIGIONAL CODE BASE IS Copyright (C) 2006-2010 by Alphons van der Heijden
|
||||
// * The code was donated on 4/28/2010 by Alphons van der Heijden
|
||||
// * To Brandon'Dimentox Travanti' Husbands & Malcolm J. Kudra which in turn Liscense under the GPLv2.
|
||||
// * In agreement to Alphons van der Heijden wishes.
|
||||
// *
|
||||
// * The community would like to thank Alphons for all of his hard work, blood sweat and tears.
|
||||
// * Without his work the community would be stuck with crappy editors.
|
||||
// *
|
||||
// * The source code in this file ("Source Code") is provided by The LSLEditor Group
|
||||
// * to you under the terms of the GNU General Public License, version 2.0
|
||||
// * ("GPL"), unless you have obtained a separate licensing agreement
|
||||
// * ("Other License"), formally executed by you and The LSLEditor Group. Terms of
|
||||
// * the GPL can be found in the gplv2.txt document.
|
||||
// *
|
||||
// ********
|
||||
// * GPLv2 Header
|
||||
// ********
|
||||
// * LSLEditor, a External editor for the LSL Language.
|
||||
// * Copyright (C) 2010 The LSLEditor Group.
|
||||
//
|
||||
// * This program is free software; you can redistribute it and/or
|
||||
// * modify it under the terms of the GNU General Public License
|
||||
// * as published by the Free Software Foundation; either version 2
|
||||
// * of the License, or (at your option) any later version.
|
||||
// *
|
||||
// * This program is distributed in the hope that it will be useful,
|
||||
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// * GNU General Public License for more details.
|
||||
// *
|
||||
// * You should have received a copy of the GNU General Public License
|
||||
// * along with this program; if not, write to the Free Software
|
||||
// * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
// ********
|
||||
// *
|
||||
// * The above copyright notice and this permission notice shall be included in all
|
||||
// * copies or substantial portions of the Software.
|
||||
// *
|
||||
// ********
|
||||
// */
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.Reflection;
|
||||
|
||||
namespace LSLEditor.Plugins
|
||||
{
|
||||
class Particles
|
||||
{
|
||||
public Particles(LSLEditorForm parent)
|
||||
{
|
||||
if (parent.IsMdiContainer)
|
||||
{
|
||||
string strPluginName = "Particles";
|
||||
//string strArguments = "";
|
||||
|
||||
string strDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
string strPluginsDirectory = Path.Combine(strDirectory, "Plugins");
|
||||
string strProgram = Path.Combine(strPluginsDirectory, strPluginName + ".exe");
|
||||
|
||||
Assembly assembly = Assembly.LoadFrom(strProgram);
|
||||
Form frmMain = assembly.CreateInstance("Particles.frmMain") as Form;
|
||||
parent.AddForm(frmMain);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("This plugin does not run in tabbed mode", "Particles plugin", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
148
trunk/Plugins/Svn.cs
Normal file
148
trunk/Plugins/Svn.cs
Normal file
|
@ -0,0 +1,148 @@
|
|||
// /**
|
||||
// ********
|
||||
// *
|
||||
// * ORIGIONAL CODE BASE IS Copyright (C) 2006-2010 by Alphons van der Heijden
|
||||
// * The code was donated on 4/28/2010 by Alphons van der Heijden
|
||||
// * To Brandon'Dimentox Travanti' Husbands & Malcolm J. Kudra which in turn Liscense under the GPLv2.
|
||||
// * In agreement to Alphons van der Heijden wishes.
|
||||
// *
|
||||
// * The community would like to thank Alphons for all of his hard work, blood sweat and tears.
|
||||
// * Without his work the community would be stuck with crappy editors.
|
||||
// *
|
||||
// * The source code in this file ("Source Code") is provided by The LSLEditor Group
|
||||
// * to you under the terms of the GNU General Public License, version 2.0
|
||||
// * ("GPL"), unless you have obtained a separate licensing agreement
|
||||
// * ("Other License"), formally executed by you and The LSLEditor Group. Terms of
|
||||
// * the GPL can be found in the gplv2.txt document.
|
||||
// *
|
||||
// ********
|
||||
// * GPLv2 Header
|
||||
// ********
|
||||
// * LSLEditor, a External editor for the LSL Language.
|
||||
// * Copyright (C) 2010 The LSLEditor Group.
|
||||
//
|
||||
// * This program is free software; you can redistribute it and/or
|
||||
// * modify it under the terms of the GNU General Public License
|
||||
// * as published by the Free Software Foundation; either version 2
|
||||
// * of the License, or (at your option) any later version.
|
||||
// *
|
||||
// * This program is distributed in the hope that it will be useful,
|
||||
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// * GNU General Public License for more details.
|
||||
// *
|
||||
// * You should have received a copy of the GNU General Public License
|
||||
// * along with this program; if not, write to the Free Software
|
||||
// * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
// ********
|
||||
// *
|
||||
// * The above copyright notice and this permission notice shall be included in all
|
||||
// * copies or substantial portions of the Software.
|
||||
// *
|
||||
// ********
|
||||
// */
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Microsoft.Win32;
|
||||
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace LSLEditor
|
||||
{
|
||||
class Svn
|
||||
{
|
||||
public string Output;
|
||||
public string Error;
|
||||
|
||||
// HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\App Paths\svn.exe
|
||||
// HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App Paths\svn.exe
|
||||
public static string Executable
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
string strKey = @"Software\Microsoft\Windows\CurrentVersion\App Paths\svn.exe";
|
||||
RegistryKey key = Registry.CurrentUser.OpenSubKey(strKey, false);
|
||||
if (key == null)
|
||||
return null;
|
||||
string strExe = key.GetValue("").ToString();
|
||||
key.Close();
|
||||
return strExe;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsInstalled
|
||||
{
|
||||
get
|
||||
{
|
||||
return (Svn.Executable != null);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Execute(string Arguments, bool ShowOutput, bool ShowError)
|
||||
{
|
||||
this.Error = "";
|
||||
this.Output = "";
|
||||
|
||||
Process p = new Process();
|
||||
StreamWriter sw;
|
||||
StreamReader sr;
|
||||
StreamReader err;
|
||||
|
||||
p.StartInfo.FileName = Properties.Settings.Default.SvnExe;
|
||||
p.StartInfo.Arguments = Arguments;
|
||||
p.StartInfo.RedirectStandardError = true;
|
||||
p.StartInfo.RedirectStandardInput = true;
|
||||
p.StartInfo.RedirectStandardOutput = true;
|
||||
p.StartInfo.UseShellExecute = false;
|
||||
p.StartInfo.CreateNoWindow = true;
|
||||
|
||||
p.Start();
|
||||
|
||||
sw = p.StandardInput;
|
||||
sr = p.StandardOutput;
|
||||
err = p.StandardError;
|
||||
|
||||
sw.AutoFlush = true;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
while (sr.Peek() >= 0)
|
||||
{
|
||||
char[] buffer = new char[1024];
|
||||
sr.Read(buffer, 0, buffer.Length);
|
||||
sb.Append(new string(buffer));
|
||||
}
|
||||
sw.Close();
|
||||
this.Output = sb.ToString();
|
||||
|
||||
sb = new StringBuilder();
|
||||
while (err.Peek() >= 0)
|
||||
{
|
||||
char[] buffer = new char[4096];
|
||||
err.Read(buffer, 0, buffer.Length);
|
||||
sb.Append(new string(buffer));
|
||||
}
|
||||
this.Error = sb.ToString();
|
||||
|
||||
if (this.Error != "" && ShowError)
|
||||
MessageBox.Show(this.Error, "SVN Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
||||
if (this.Output != "" && ShowOutput)
|
||||
MessageBox.Show(this.Output, "SVN Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
|
||||
return (this.Error == "");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue