Skip to content

Commit

Permalink
v1.4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nobody committed May 31, 2020
2 parents 22beaf2 + cd97d19 commit c31f208
Show file tree
Hide file tree
Showing 64 changed files with 4,630 additions and 712 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/exp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
verStr: '1.3.x.x'
boxAppend: box
v2rayCorePkgName: 'v2ray-windows-32.zip'
v2rayCoreVer: 'v4.23.1'
v2rayCoreVer: 'v4.23.2'
# https://github.com/v2ray/v2ray-core/releases/download/v4.20.0/v2ray-windows-32.zip
v2rayCoreUrl: 'https://github.com/v2ray/v2ray-core/releases/download'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
verStr: '1.3.x'
boxAppend: box
v2rayCorePkgName: 'v2ray-windows-32.zip'
v2rayCoreVer: 'v4.23.1'
v2rayCoreVer: 'v4.23.2'
# https://github.com/v2ray/v2ray-core/releases/download/v4.20.0/v2ray-windows-32.zip
v2rayCoreUrl: 'https://github.com/v2ray/v2ray-core/releases/download'

Expand Down
44 changes: 34 additions & 10 deletions Plugins/Luna/Controllers/FormEditorCtrl/AutoCompleteCtrl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal sealed class AutoCompleteCtrl
string KEY_FUNCTION = "funcs";
string KEY_VARS = "vars";
string KEY_MODULES = "modules";
// string KEY_LINE_NUM = "line"; // line number
string KEY_LINE_NUM = "line"; // line number
string KEY_METHODS = "methods";
string KEY_SUB_FUNCS = "subs";
#endregion
Expand Down Expand Up @@ -537,8 +537,24 @@ string RemoveLocalPrefix(string text, bool trimFunctionPrefix)
}

bool ScrollToFunction(string text)
{
var funcs = funcDefTable;
if (funcs.ContainsKey(text))
{
ScrollToLine(funcs[text]);
return true;
}

return FallbackScrollToFunction(text);
}

bool FallbackScrollToFunction(string text)
{
text = text?.Replace(":", ".")?.Replace(" ", "")
?.Replace("['", ".")
?.Replace("[\"", ".")
?.Replace("\"]", "")
?.Replace("']", "")
?.Split('(')?.FirstOrDefault();

if (string.IsNullOrWhiteSpace(text))
Expand All @@ -549,9 +565,9 @@ bool ScrollToFunction(string text)
foreach (var line in editor.Lines)
{
var t = line.Text;
if (string.IsNullOrWhiteSpace(t) || !t.Contains("function"))
{
continue;
if (string.IsNullOrWhiteSpace(t) || !t.Contains("function"))
{
continue;
}

var trimed = RemoveLocalPrefix(t, true)
Expand Down Expand Up @@ -600,9 +616,9 @@ void ScrollToDefinition(string text)
return;
}

if (ScrollToFunction(text) || ScrollToVariable(text))
{
return;
if (ScrollToFunction(text) || ScrollToVariable(text))
{
return;
}

foreach (var line in editor.Lines)
Expand Down Expand Up @@ -695,6 +711,8 @@ void BindEvents()

}

Dictionary<string, int> funcDefTable = new Dictionary<string, int>();

private void OnCboxFunctionListDropDownHandler(object sender, EventArgs args)
{
history.Add(editor.CurrentLine);
Expand All @@ -708,25 +726,29 @@ private void OnCboxFunctionListDropDownHandler(object sender, EventArgs args)
KEY_METHODS,
};

List<string> funcs = new List<string>();
Dictionary<string, int> funcs = new Dictionary<string, int>();

foreach (var key in keys)
{
if (ast != null && ast[key] is JObject)
{
foreach (var kv in ast[key] as JObject)
{
var ps = (kv.Value as JObject)[KEY_PARAMS] as JArray;
var luaLineNumber = (kv.Value as JObject)[KEY_LINE_NUM].Value<int>();
var sps = string.Join(", ", ps);
funcs.Add($"{kv.Key}({sps})");
var fn = $"{kv.Key}({sps})";
funcs.Add(fn, luaLineNumber - 1);
}
}
}
funcDefTable = funcs;

VgcApis.Misc.UI.Invoke(() =>
{
var items = cboxFunctionList.Items;
items.Clear();
items.AddRange(funcs.OrderBy(x => x).ToArray());
items.AddRange(funcs.Keys.OrderBy(x => x).ToArray());
VgcApis.Misc.UI.ResetComboBoxDropdownMenuWidth(cboxFunctionList);
});
}
Expand Down Expand Up @@ -770,6 +792,8 @@ bool ScrollToVariable(string v)
return false;
}



private void OnCboxVarListDropDownHandler(object sender, EventArgs args)
{
history.Add(editor.CurrentLine);
Expand Down
20 changes: 14 additions & 6 deletions Plugins/Luna/Controllers/FormEditorCtrl/ButtonCtrl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ public void Run(
}

#region public methods
public void LoadScript(string name)
{
if (!string.IsNullOrEmpty(name))
{
cboxScriptName.Text = name;
CboxScriptNameChangedHandler(this, EventArgs.Empty);
}
}

public bool isLoadClrLib;

public void KeyBoardShortcutHandler(KeyEventArgs keyEvent)
Expand Down Expand Up @@ -218,13 +227,13 @@ public void SetCurFileName(string filename)
}

public void SetCurrentEditorContent(string content) =>
VgcApis.Misc.UI.Invoke(() => editor.Text = content);

VgcApis.Misc.UI.Invoke(() => editor.Text = content);

#endregion


#region Scintilla




void Scintilla_DoubleClick(object sender, EventArgs e)
{
var keyword = VgcApis.Misc.Utils.GetWordFromCurPos(editor);
Expand Down Expand Up @@ -448,7 +457,6 @@ private void BindEvents()
cboxScriptName.DropDown += (s, a) => ReloadScriptName();

cboxScriptName.SelectedValueChanged += CboxScriptNameChangedHandler;

}

private void OnBtnSaveScriptClickHandler(bool showResult)
Expand Down
27 changes: 23 additions & 4 deletions Plugins/Luna/Controllers/FormEditorCtrl/MenuCtrl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,24 @@ public MenuCtrl(
}

public void Run(
Services.FormMgrSvc formMgrService)
Services.FormMgrSvc formMgrService,
Models.Data.LuaCoreSetting initialCoreSettings)
{
InitControls();
BindEvents(formMgrService);

if (initialCoreSettings != null)
{
var name = initialCoreSettings.name;
if (!string.IsNullOrEmpty(name))
{
editorCtrl.LoadScript(name);
}

var enabled = initialCoreSettings.isLoadClr;
UpdateClrControlsEanbledState(enabled);
editorCtrl.isLoadClrLib = enabled;
}
}

#region private method
Expand All @@ -71,9 +85,7 @@ private void BindEvents(FormMgrSvc formMgrService)
miLoadClrLib.Click += (s, a) =>
{
var enable = !miLoadClrLib.Checked;
miLoadClrLib.Checked = enable;
smiLbClrLib.Enabled = enable;
editorCtrl.isLoadClrLib = enable;
UpdateClrControlsEanbledState(enable);
};

miNewWindow.Click += (s, a) =>
Expand Down Expand Up @@ -130,6 +142,13 @@ private void BindEvents(FormMgrSvc formMgrService)
}
};
}

private void UpdateClrControlsEanbledState(bool enable)
{
miLoadClrLib.Checked = enable;
smiLbClrLib.Enabled = enable;
editorCtrl.isLoadClrLib = enable;
}
#endregion
}
}
11 changes: 8 additions & 3 deletions Plugins/Luna/Controllers/FormMainCtrl/TabGeneralCtrl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@ public TabGeneralCtrl(

#region public methods
Services.LuaServer luaServer;
Services.FormMgrSvc formMgrSvc;

public void Run(Services.LuaServer luaServer)
public void Run(
Services.LuaServer luaServer,
Services.FormMgrSvc formMgrSvc)
{
this.luaServer = luaServer;
this.formMgrSvc = formMgrSvc;

BindEvents(luaServer);
BindDragDropEvent();

Expand Down Expand Up @@ -221,8 +226,8 @@ void AddLuaCoreCtrlToPanel()
var ctrls = luaServer.GetAllLuaCoreCtrls();
foreach (var c in ctrls)
{
var ui = new Views.UserControls.LuaUI(
luaServer, c);
var ui = new LuaUI(
luaServer, formMgrSvc, c);
flyLuaUiPanel.Controls.Add(ui);
}
}
Expand Down
10 changes: 5 additions & 5 deletions Plugins/Luna/Controllers/LuaCoreCtrl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ public bool isRunning
}
}


void InvokeOnStateChangeIgnoreError()
{
try
Expand All @@ -144,7 +143,8 @@ void InvokeOnStateChangeIgnoreError()
#endregion

#region public methods
public string GetScript() => coreSetting.script;
public Models.Data.LuaCoreSetting GetCoreSettings() =>
coreSetting;

public void SetScriptName(string name)
{
Expand All @@ -169,9 +169,9 @@ public void Stop()
luaSys?.OnSignalStop();
}

public void Abort() => Killer(2000);
public void Abort() => KillCore(2000);

public void AbortNow() => Killer(1);
public void AbortNow() => KillCore(1);

public void Start()
{
Expand Down Expand Up @@ -200,7 +200,7 @@ public void Cleanup()
#endregion

#region private methods
void Killer(int timeout)
void KillCore(int timeout)
{
if (!isRunning)
{
Expand Down
24 changes: 19 additions & 5 deletions Plugins/Luna/Libs/LuaSnippet/BestMatchSnippets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public void UpdateRequireModuleSnippets(List<LuaImportClrSnippets> snippets)
#endregion

#region private methods
HashSet<string> ignoredList =
new HashSet<string>(
VgcApis.Models.Consts.Lua.LuaKeywords.Split(' '));

private IEnumerable<AutocompleteItem> BuildList()
{
Expand All @@ -69,6 +72,20 @@ private IEnumerable<AutocompleteItem> BuildList()
fragment = VgcApis.Misc.Utils.GetFragment(editor, searchPattern);
});

var snps = new List<AutocompleteItem>();
if (!ignoredList.Contains(fragment))
{
snps = CreateSnippets(fragment);
}

//return autocomplete items
foreach (var item in snps)
yield return item;
}

private List<AutocompleteItem> CreateSnippets(string fragment)
{
List<AutocompleteItem> snps;
var cache = customScriptSnippets;

List<MatchItemBase> candidates = cache
Expand All @@ -85,15 +102,12 @@ private IEnumerable<AutocompleteItem> BuildList()
}
}

var sorted = table
snps = table
.OrderBy(kv => kv.Value)
.ThenBy(kv => kv.Key.GetLowerText())
.Select(kv => kv.Key as AutocompleteItem)
.ToList();

//return autocomplete items
foreach (var item in sorted)
yield return item;
return snps;
}

List<MatchItemBase> GenCandidateList(string fragment)
Expand Down
7 changes: 1 addition & 6 deletions Plugins/Luna/Libs/LuaSnippet/SnippetsCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ public BestMatchSnippets CreateBestMatchSnippets(ScintillaNET.Scintilla editor)
#endregion

#region private methods
string GetFilteredLuaKeywords() =>
VgcApis.Models.Consts.Lua.LuaKeywords
.Replace("do", "")
.Replace("then", "")
.Replace("end", "");

List<string> GetAllNameapaces() => VgcApis.Misc.Utils.GetAllAssembliesType()
.Select(t => t.Namespace)
Expand Down Expand Up @@ -93,7 +88,7 @@ List<string> GenKeywords(
IEnumerable<string> initValues) =>
new StringBuilder(VgcApis.Models.Consts.Lua.LuaModules)
.Append(@" ")
.Append(GetFilteredLuaKeywords())
.Append(VgcApis.Models.Consts.Lua.LuaKeywords)
.ToString()
.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
.Union(initValues)
Expand Down
Loading

0 comments on commit c31f208

Please sign in to comment.