Skip to content

Commit

Permalink
Added common right-click options to script editor
Browse files Browse the repository at this point in the history
  • Loading branch information
markdwags committed Dec 19, 2021
1 parent bbaf4d1 commit ca1f5c6
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Set AssemblyInfo
uses: dannevesdantas/set-version-assemblyinfo@v.1.0.0
with:
version: '1.7.2.${{ github.run_number }}'
version: '1.7.3.${{ github.run_number }}'

- name: Build Razor
run: msbuild $env:Solution_Name /t:Build /p:Configuration=$env:Configuration
Expand Down
50 changes: 50 additions & 0 deletions Razor/UI/Razor.cs
Expand Up @@ -6602,8 +6602,24 @@ private void scriptEditor_MouseDown(object sender, System.Windows.Forms.MouseEve
{
ContextMenuStrip menu = new ContextMenuStrip();

menu.Items.Add("Cut", null, OnScriptCut);
menu.Items.Add("Copy", null, OnScriptCopy);
menu.Items.Add("Paste", null, OnScriptPaste);
menu.Items.Add("Delete", null, OnScriptDelete);
menu.Items.Add("-");
menu.Items.Add("Select All", null, OnScriptSelectAll);
menu.Items.Add("-");

menu.Items[0].Enabled = false;
menu.Items[1].Enabled = false;
menu.Items[3].Enabled = false;

if (!string.IsNullOrEmpty(scriptEditor.SelectedText))
{
menu.Items[0].Enabled = true;
menu.Items[1].Enabled = true;
menu.Items[3].Enabled = true;

menu.Items.Add("Comment", null, OnScriptComment);
menu.Items.Add("Uncomment", null, OnScriptUncomment);

Expand Down Expand Up @@ -6648,6 +6664,40 @@ private void scriptEditor_MouseDown(object sender, System.Windows.Forms.MouseEve
}
}

private void OnScriptSelectAll(object sender, EventArgs e)
{
scriptEditor.SelectAll();
}

private void OnScriptDelete(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(scriptEditor.SelectedText))
{
scriptEditor.SelectedText = string.Empty;
}
}

private void OnScriptPaste(object sender, EventArgs e)
{
scriptEditor.Paste();
}

private void OnScriptCopy(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(scriptEditor.SelectedText))
{
scriptEditor.Copy();
}
}

private void OnScriptCut(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(scriptEditor.SelectedText))
{
scriptEditor.Cut();
}
}

private void OnScriptHideTreeView(object sender, EventArgs e)
{
scriptSplitContainer.Panel1Collapsed = !scriptSplitContainer.Panel1Collapsed;
Expand Down
50 changes: 50 additions & 0 deletions Razor/UI/RazorScriptEditor.cs
Expand Up @@ -183,8 +183,24 @@ private void scriptEditor_MouseDown(object sender, MouseEventArgs e)
{
ContextMenuStrip menu = new ContextMenuStrip();

menu.Items.Add("Cut", null, OnScriptCut);
menu.Items.Add("Copy", null, OnScriptCopy);
menu.Items.Add("Paste", null, OnScriptPaste);
menu.Items.Add("Delete", null, OnScriptDelete);
menu.Items.Add("-");
menu.Items.Add("Select All", null, OnScriptSelectAll);

menu.Items[0].Enabled = false;
menu.Items[1].Enabled = false;
menu.Items[3].Enabled = false;

if (!string.IsNullOrEmpty(scriptEditor.SelectedText))
{
menu.Items[0].Enabled = true;
menu.Items[1].Enabled = true;
menu.Items[3].Enabled = true;

menu.Items.Add("-");
menu.Items.Add("Comment", null, OnScriptComment);
menu.Items.Add("Uncomment", null, OnScriptUncomment);

Expand Down Expand Up @@ -220,6 +236,40 @@ private void scriptEditor_MouseDown(object sender, MouseEventArgs e)
}
}

private void OnScriptSelectAll(object sender, EventArgs e)
{
scriptEditor.SelectAll();
}

private void OnScriptDelete(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(scriptEditor.SelectedText))
{
scriptEditor.SelectedText = string.Empty;
}
}

private void OnScriptPaste(object sender, EventArgs e)
{
scriptEditor.Paste();
}

private void OnScriptCopy(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(scriptEditor.SelectedText))
{
scriptEditor.Copy();
}
}

private void OnScriptCut(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(scriptEditor.SelectedText))
{
scriptEditor.Cut();
}
}

private void OnScriptComment(object sender, System.EventArgs e)
{
string[] lines = scriptEditor.SelectedText.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
Expand Down

0 comments on commit ca1f5c6

Please sign in to comment.