Skip to content

Commit

Permalink
Change auto-generated search keywords to #mark is "mark".
Browse files Browse the repository at this point in the history
NeoLuna focus to editor-control after opened.
Neoluna initiate with navigating bar disabled.
  • Loading branch information
nobody committed Dec 8, 2024
1 parent 1b953ba commit 095f42c
Show file tree
Hide file tree
Showing 7 changed files with 1,662 additions and 1,623 deletions.
45 changes: 31 additions & 14 deletions Plugins/NeoLua/Controllers/FormEditorCtrl/AutoCompleteCtrl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,24 @@ string GetAllTextExceptCurLine()
return sb.ToString();
}

void SetNavigationComboBoxEnableState(JObject ast)
{
var enabled = false;
if (ast != null)
{
foreach (var kv in ast)
{
if (kv.Value.Count() > 0)
{
enabled = true;
break;
}
}
}
cboxVarList.Enabled = enabled;
cboxFunctionList.Enabled = enabled;
}

JObject currentCodeAst = null;

void AnalizeScriptWorker()
Expand Down Expand Up @@ -267,6 +285,10 @@ void AnalizeScriptWorker()
{
currentCodeAst = ast;
}
VgcApis.Misc.UI.Invoke(() =>
{
SetNavigationComboBoxEnableState(ast);
});

// var debug = ast.ToString();

Expand Down Expand Up @@ -461,6 +483,7 @@ private void InitControls()
luaAcm = CreateAcm(editor);
miEanbleCodeAnalyzeEx.Checked = false;
smiLbCodeanalyze.Enabled = false;
SetNavigationComboBoxEnableState(null);
}

void ReleaseEvents()
Expand Down Expand Up @@ -554,13 +577,10 @@ private void OnCboxFunctionListDropDownHandler(object sender, EventArgs args)
}
funcDefTable = funcs;

VgcApis.Misc.UI.Invoke(() =>
{
var items = cboxFunctionList.Items;
items.Clear();
items.AddRange(funcs.Keys.OrderBy(x => x).ToArray());
VgcApis.Misc.UI.ResetComboBoxDropdownMenuWidth(cboxFunctionList);
});
var items = cboxFunctionList.Items;
items.Clear();
items.AddRange(funcs.Keys.OrderBy(x => x).ToArray());
VgcApis.Misc.UI.ResetComboBoxDropdownMenuWidth(cboxFunctionList);
}

bool ScrollToVariable(string v)
Expand Down Expand Up @@ -617,13 +637,10 @@ private void OnCboxVarListDropDownHandler(object sender, EventArgs args)
}
}

VgcApis.Misc.UI.Invoke(() =>
{
var items = cboxVarList.Items;
items.Clear();
items.AddRange(vars.OrderBy(x => x).ToArray());
VgcApis.Misc.UI.ResetComboBoxDropdownMenuWidth(cboxVarList);
});
var items = cboxVarList.Items;
items.Clear();
items.AddRange(vars.OrderBy(x => x).ToArray());
VgcApis.Misc.UI.ResetComboBoxDropdownMenuWidth(cboxVarList);
}

#endregion
Expand Down
67 changes: 40 additions & 27 deletions Plugins/NeoLua/Controllers/FormEditorCtrl/ButtonCtrl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ public void KeyBoardShortcutHandler(KeyEventArgs keyEvent)
tboxGoto.Focus();
tboxGoto.SelectAll();
break;
case Keys.Tab:
cboxScriptName.Focus();
break;
case Keys.F:
case Keys.H:
ShowFormSearchHandler(this, EventArgs.Empty);
Expand All @@ -139,37 +142,47 @@ public void KeyBoardShortcutHandler(KeyEventArgs keyEvent)
case Keys.N:
ClearEditorHandler(this, EventArgs.Empty);
break;
default:
// pass down key event
return;
}
return;
}

switch (keyCode)
else
{
case Keys.Escape:
VgcApis.Misc.UI.CloseFormIgnoreError(formSearch);
break;
case Keys.F2:
formSearch?.SearchPrevious();
break;
case Keys.F3:
formSearch?.SearchNext();
break;
case Keys.F4:
formSearch?.SearchFirst(true);
break;
case Keys.F5:
btnRunScript.PerformClick();
break;
case Keys.F6:
btnStopLuaCore.PerformClick();
break;
case Keys.F7:
btnKillLuaCore.PerformClick();
break;
case Keys.F8:
btnClearOutput.PerformClick();
break;
switch (keyCode)
{
case Keys.Escape:
VgcApis.Misc.UI.CloseFormIgnoreError(formSearch);
break;
case Keys.F2:
formSearch?.SearchPrevious();
break;
case Keys.F3:
formSearch?.SearchNext();
break;
case Keys.F4:
formSearch?.SearchFirst(true);
break;
case Keys.F5:
btnRunScript.PerformClick();
break;
case Keys.F6:
btnStopLuaCore.PerformClick();
break;
case Keys.F7:
btnKillLuaCore.PerformClick();
break;
case Keys.F8:
btnClearOutput.PerformClick();
break;
default:
// pass down key event
return;
}
}
keyEvent.Handled = true;
keyEvent.SuppressKeyPress = true;
return;
}

public bool IsChanged() => editor.Text != preScriptContent;
Expand Down
1 change: 1 addition & 0 deletions Plugins/NeoLua/Views/WinForms/FormEditor.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Plugins/NeoLua/Views/WinForms/FormEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ private void FormEditor_Load(object sender, System.EventArgs e)
this.KeyDown += KeyDownHandler;
}

private void FormEditor_Shown(object sender, System.EventArgs e)
{
editor.Focus();
}

#region private methods
void KeyDownHandler(object sender, KeyEventArgs a)
{
Expand Down
Loading

0 comments on commit 095f42c

Please sign in to comment.