diff --git a/ColtPlugin/ColtPlugin.csproj b/ColtPlugin/ColtPlugin.csproj
index 9fa1816..f59094c 100644
--- a/ColtPlugin/ColtPlugin.csproj
+++ b/ColtPlugin/ColtPlugin.csproj
@@ -54,7 +54,7 @@
x86
- ..\..\..\FlashDevelop\Bin\Debug\Plugins\
+ ..\..\svn\FlashDevelop\Bin\Debug\Plugins\
TRACE
true
@@ -118,6 +118,10 @@
+
+ {4EBF2653-9654-4E40-880E-0046B3D6210E}
+ ASCompletion
+
{78101C01-E186-4954-B1DD-DEBB7905FAD8}
ProjectManager
diff --git a/ColtPlugin/PluginMain.cs b/ColtPlugin/PluginMain.cs
index a8a1f9e..8f69353 100644
--- a/ColtPlugin/PluginMain.cs
+++ b/ColtPlugin/PluginMain.cs
@@ -13,6 +13,9 @@
using PluginCore.Helpers;
using PluginCore;
using ProjectManager.Projects.AS3;
+using ASCompletion.Context;
+using System.Text.RegularExpressions;
+using ASCompletion.Model;
namespace ColtPlugin
{
@@ -32,6 +35,7 @@ public class PluginMain : IPlugin
private FileSystemWatcher watcher;
private String pathToLog;
private System.Timers.Timer timer;
+ private Keys MakeItLiveKeys = Keys.Control | Keys.Shift | Keys.L;
#region Required Properties
@@ -155,6 +159,24 @@ public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
case EventType.FileSave:
if (active) ClearErrors();
break;
+
+ case EventType.Keys: // shortcut pressed
+ KeyEvent ke = (KeyEvent)e;
+ if (ke.Value == MakeItLiveKeys)
+ {
+ ke.Handled = true;
+ MakeItLive();
+ }
+ break;
+
+ case EventType.Shortcut: // shortcut changed
+ DataEvent de = (DataEvent)e;
+ if (de.Action == "ColtPlugin.MakeItLive")
+ {
+ MakeItLiveKeys = (Keys)de.Data;
+ }
+ break;
+
}
}
@@ -200,11 +222,13 @@ public void InitLocalization()
///
public void AddEventHandlers()
{
- EventManager.AddEventHandler(this, EventType.Command | EventType.FileSave);
+ EventManager.AddEventHandler(this, EventType.Command | EventType.FileSave | EventType.Keys | EventType.Shortcut);
watcher = new FileSystemWatcher();
watcher.NotifyFilter = NotifyFilters.LastWrite;
watcher.Changed += new FileSystemEventHandler(OnFileChange);
+
+ PluginBase.MainForm.RegisterShortcutItem("ColtPlugin.MakeItLive", MakeItLiveKeys);
}
#endregion
@@ -350,6 +374,60 @@ private void ShowErrors()
#endregion
+ ///
+ /// Generate meta tags
+ ///
+ private void MakeItLive()
+ {
+ ScintillaNet.ScintillaControl sci = PluginBase.MainForm.CurrentDocument.SciControl;
+ if (sci == null)
+ return;
+
+ IASContext context = ASCompletion.Context.ASContext.Context;
+ if (context.CurrentClass == null || context.CurrentClass.IsVoid() || context.CurrentClass.LineFrom == 0)
+ return;
+
+ // make member live
+ int originalPos = sci.CurrentPos;
+ int pos;
+ int line;
+ string indent;
+ MemberModel member = context.CurrentMember;
+ FlagType mask = FlagType.Function | FlagType.Dynamic;
+ if (member != null && (member.Flags & mask) == mask)
+ {
+ line = context.CurrentMember.LineFrom;
+ indent = LineIndentPosition(sci, line);
+ pos = sci.PositionFromLine(line) + indent.Length;
+ string insert = "[LiveCodeUpdateListener(method=\"" + member.Name + "\")]\n" + indent;
+ sci.SetSel(pos, pos);
+ sci.ReplaceSel(insert);
+ originalPos += insert.Length;
+ }
+
+ // make class live
+ if (!Regex.IsMatch(sci.Text, "\\[Live\\]"))
+ {
+ line = context.CurrentClass.LineFrom;
+ indent = LineIndentPosition(sci, line);
+ pos = sci.PositionFromLine(line) + indent.Length;
+ string insert = "[Live]\n" + indent;
+ sci.SetSel(pos, pos);
+ sci.ReplaceSel(insert);
+ originalPos += insert.Length;
+ }
+
+ sci.SetSel(originalPos, originalPos);
+ }
+
+ private string LineIndentPosition(ScintillaNet.ScintillaControl sci, int line)
+ {
+ string txt = sci.GetLine(line);
+ for (int i = 0; i < txt.Length; i++)
+ if (txt[i] > 32) return txt.Substring(0, i);
+ return "";
+ }
+
///
/// Opens the project in COLT
///
diff --git a/ColtPlugin/obj/Debug/ColtPlugin.dll b/ColtPlugin/obj/Debug/ColtPlugin.dll
index ddf886c..0c45b53 100644
Binary files a/ColtPlugin/obj/Debug/ColtPlugin.dll and b/ColtPlugin/obj/Debug/ColtPlugin.dll differ