Browse Source

Fixed "copy/cut/paste" in context menus.

Fixed ExpressionFinder bug with identifiers containing underscores.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@448 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
022170d1a1
  1. 40
      AddIns/ICSharpCode.SharpDevelop.addin
  2. 2
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Parser/ExpressionFinder.cs
  3. 7
      src/AddIns/BackendBindings/CSharpBinding/Test/ExpressionFinder.cs
  4. 30
      src/AddIns/DisplayBindings/ResourceEditor/Project/ResourceEditor.addin
  5. 1
      src/AddIns/DisplayBindings/ResourceEditor/Project/ResourceEditor.csproj
  6. 27
      src/AddIns/DisplayBindings/ResourceEditor/Project/Src/Commands/DeleteEntryCommand.cs
  7. 12
      src/Main/Base/Project/Src/Commands/EditCommands.cs
  8. 107
      src/Main/Base/Project/Src/Gui/Dialogs/WordCountDialog.cs
  9. 24
      src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs

40
AddIns/ICSharpCode.SharpDevelop.addin

@ -525,17 +525,8 @@ @@ -525,17 +525,8 @@
</Path>
<Path name = "/SharpDevelop/Pads/CompilerMessageView/ContextMenu">
<MenuItem id = "Copy"
label = "${res:XML.MainMenu.EditMenu.Copy}"
icon = "Icons.16x16.CopyIcon"
type = "Item"
shortcut = "Control|C"
class = "ICSharpCode.SharpDevelop.Commands.Copy"/>
<MenuItem id = "SelectAll"
label = "${res:XML.MainMenu.EditMenu.SelectAll}"
type = "Item"
shortcut = "Control|A"
class = "ICSharpCode.SharpDevelop.Commands.SelectAll"/>
<Include id = "Cut" item = "/SharpDevelop/Workbench/MainMenu/Edit/Cut"/>
<Include id = "SelectAll" item = "/SharpDevelop/Workbench/MainMenu/Edit/SelectAll"/>
<MenuItem id = "Clear"
icon = "OutputPad.Toolbar.ClearOutputWindow"
label = "Clear All"
@ -1473,29 +1464,10 @@ @@ -1473,29 +1464,10 @@
<Path name = "/SharpDevelop/ViewContent/DefaultTextEditor/ContextMenu">
<MenuItem id = "Refactoring" type = "Builder" class = "ICSharpCode.SharpDevelop.Refactoring.RefactoringMenuBuilder"/>
<MenuItem id = "Cut"
label = "${res:XML.TextAreaContextMenu.Cut}"
type = "Item"
icon = "Icons.16x16.CutIcon"
shortcut = "Control|X"
class = "ICSharpCode.SharpDevelop.Commands.Cut"/>
<MenuItem id = "Copy"
label = "${res:XML.TextAreaContextMenu.Copy}"
type = "Item"
icon = "Icons.16x16.CopyIcon"
shortcut = "Control|C"
class = "ICSharpCode.SharpDevelop.Commands.Copy"/>
<MenuItem id = "Paste"
label = "${res:XML.TextAreaContextMenu.Paste}"
type = "Item"
icon = "Icons.16x16.PasteIcon"
shortcut = "Control|V"
class = "ICSharpCode.SharpDevelop.Commands.Paste"/>
<MenuItem id = "Delete"
label = "${res:XML.MainMenu.EditMenu.Delete}"
type = "Item"
icon = "Icons.16x16.DeleteIcon"
class = "ICSharpCode.SharpDevelop.Commands.Delete"/>
<Include id = "Cut" item = "/SharpDevelop/Workbench/MainMenu/Edit/Cut"/>
<Include id = "Copy" item = "/SharpDevelop/Workbench/MainMenu/Edit/Copy"/>
<Include id = "Paste" item = "/SharpDevelop/Workbench/MainMenu/Edit/Paste"/>
<Include id = "Delete" item = "/SharpDevelop/Workbench/MainMenu/Edit/Delete"/>
<MenuItem id = "Separator1" type = "Separator" />
<MenuItem id = "Save"
label = "${res:XML.MainMenu.FileMenu.Save}"

2
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Parser/ExpressionFinder.cs

@ -216,7 +216,7 @@ namespace CSharpBinding.Parser @@ -216,7 +216,7 @@ namespace CSharpBinding.Parser
bool wordFollowing = false;
for (int i = offset + 1; i < inText.Length; ++i) {
char c = inText[i];
if (Char.IsLetterOrDigit(c)) {
if (Char.IsLetterOrDigit(c) || c == '_') {
if (Char.IsWhiteSpace(inText, i - 1)) {
wordFollowing = true;
break;

7
src/AddIns/BackendBindings/CSharpBinding/Test/ExpressionFinder.cs

@ -32,6 +32,7 @@ class Main<T> : BaseType @@ -32,6 +32,7 @@ class Main<T> : BaseType
const string program2 = @"using System;
class Main {
string under_score_field;
void Method() {
foreach (TypeName varName in ((CastTo)castTarget).PropertyOnCastExpression) {
@ -114,5 +115,11 @@ class Main { @@ -114,5 +115,11 @@ class Main {
{
FindFull(program2, "pertyOnCastExpression", "((CastTo)castTarget).PropertyOnCastExpression", ExpressionContext.Default);
}
[Test]
public void Underscore()
{
FindFull(program2, "der_score_field", "under_score_field", ExpressionContext.Default);
}
}
}

30
src/AddIns/DisplayBindings/ResourceEditor/Project/ResourceEditor.addin

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<AddIn name = "Resource Editor"
<AddIn name = "Resource Editor"
author = "Mike Krueger"
copyright = "GPL"
url = "http://www.icsharpcode.net"
@ -40,33 +40,17 @@ @@ -40,33 +40,17 @@
<MenuItem id="CopyResourceName"
label="${res:ResourceEditor.ResourceEdit.ContextMenu.CopyResourceName}"
class="ResourceEditor.CopyResourceNameCommand" />
<MenuItem id="Delete"
label="${res:ResourceEditor.ResourceEdit.ContextMenu.Delete}"
class="ResourceEditor.DeleteEntryCommand"
shortcut="Delete" />
<MenuItem id="Separator2"
type = "Separator" />
<MenuItem id="Cut"
label="${res:XML.MainMenu.EditMenu.Cut}"
class="ICSharpCode.SharpDevelop.Commands.Cut" />
<MenuItem id="Copy"
label="${res:XML.MainMenu.EditMenu.Copy}"
class="ICSharpCode.SharpDevelop.Commands.Copy" />
</Condition>
<MenuItem id="Paste"
label="${res:XML.MainMenu.EditMenu.Paste}"
class="ICSharpCode.SharpDevelop.Commands.Paste" />
<Include id = "Delete" item = "/SharpDevelop/Workbench/MainMenu/Edit/Delete"/>
<MenuItem id = "Separator2" type = "Separator"/>
<Include id = "Cut" item = "/SharpDevelop/Workbench/MainMenu/Edit/Cut"/>
<Include id = "Copy" item = "/SharpDevelop/Workbench/MainMenu/Edit/Copy"/>
<Include id = "Paste" item = "/SharpDevelop/Workbench/MainMenu/Edit/Paste"/>
<MenuItem id="Separator3"
type = "Separator" />
<MenuItem id="SelectAll"
label="${res:XML.MainMenu.EditMenu.SelectAll}"
class="ICSharpCode.SharpDevelop.Commands.SelectAll"
shortcut="Control|A" />
<Include id = "SelectAll" item = "/SharpDevelop/Workbench/MainMenu/Edit/SelectAll"/>
</Path>
</AddIn>

1
src/AddIns/DisplayBindings/ResourceEditor/Project/ResourceEditor.csproj

@ -37,7 +37,6 @@ @@ -37,7 +37,6 @@
<Compile Include="Src\Commands\AddStringEntryCommand.cs" />
<Compile Include="Src\Commands\ClipboardCommands.cs" />
<Compile Include="Src\Commands\CopyResourceNameCommand.cs" />
<Compile Include="Src\Commands\DeleteEntryCommand.cs" />
<Compile Include="Src\Commands\RenameEntryCommand.cs" />
<Compile Include="Src\Commands\SaveEntryAsCommand.cs" />
<Compile Include="Src\DisplayDefinition.cs" />

27
src/AddIns/DisplayBindings/ResourceEditor/Project/Src/Commands/DeleteEntryCommand.cs

@ -1,27 +0,0 @@ @@ -1,27 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="none" email=""/>
// <version>$Revision$</version>
// </file>
using System;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop;
namespace ResourceEditor
{
class DeleteEntryCommand : AbstractMenuCommand
{
public override void Run()
{
IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
ResourceEditWrapper editor = (ResourceEditWrapper)window.ViewContent;
editor.Delete();
}
}
}

12
src/Main/Base/Project/Src/Commands/EditCommands.cs

@ -158,13 +158,11 @@ namespace ICSharpCode.SharpDevelop.Commands @@ -158,13 +158,11 @@ namespace ICSharpCode.SharpDevelop.Commands
public override void Run()
{
if (IsEnabled) {
IClipboardHandler editable = WorkbenchSingleton.Workbench.ActiveContent as IClipboardHandler;
if (editable == null)
editable = GetClipboardHandlerWrapper(WorkbenchSingleton.ActiveControl);
if (editable != null) {
Run(editable);
}
IClipboardHandler editable = WorkbenchSingleton.Workbench.ActiveContent as IClipboardHandler;
if (editable == null)
editable = GetClipboardHandlerWrapper(WorkbenchSingleton.ActiveControl);
if (editable != null) {
Run(editable);
}
}
}

107
src/Main/Base/Project/Src/Gui/Dialogs/WordCountDialog.cs

@ -12,7 +12,6 @@ using System.ComponentModel; @@ -12,7 +12,6 @@ using System.ComponentModel;
using System.Windows.Forms;
using System.Collections;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.Core;
@ -57,25 +56,30 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -57,25 +56,30 @@ namespace ICSharpCode.SharpDevelop.Gui
}
Report GetReport(string filename)
{
if (!File.Exists(filename)) return null;
using (StreamReader sr = new StreamReader(filename)) {
return GetReport(filename, sr);
}
}
Report GetReport(string filename, TextReader reader)
{
long numLines = 0;
long numWords = 0;
long numChars = 0;
if (!File.Exists(filename)) return null;
FileStream istream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
StreamReader sr = new StreamReader(istream);
string line = sr.ReadLine();
string line = reader.ReadLine();
while (line != null) {
++numLines;
numChars += line.Length;
string[] words = line.Split(null);
numWords += words.Length;
line = sr.ReadLine();
line = reader.ReadLine();
}
sr.Close();
return new Report(filename, numChars, numWords, numLines);
}
@ -85,61 +89,50 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -85,61 +89,50 @@ namespace ICSharpCode.SharpDevelop.Gui
total = null;
switch (((ComboBox)ControlDictionary["locationComboBox"]).SelectedIndex) {
case 0: {// current file
IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
if (window != null) {
if (window.ViewContent.FileName == null) {
MessageService.ShowWarning("${res:Dialog.WordCountDialog.SaveTheFileWarning}");
} else {
Report r = GetReport(window.ViewContent.FileName);
if (r != null) items.Add(r);
// ((ListView)ControlDictionary["resultListView"]).Items.Add(r.ToListItem());
case 0: {// current file
IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
if (window != null) {
IEditable editable = window.ViewContent as IEditable;
if (editable == null) {
MessageService.ShowWarning("${res:Dialog.WordCountDialog.IsNotTextFile}");
} else {
Report r = GetReport(window.ViewContent.IsUntitled ? window.ViewContent.UntitledName : window.ViewContent.FileName,
new StringReader(editable.Text));
if (r != null) items.Add(r);
}
}
break;
}
break;
}
case 1: {// all open files
if (WorkbenchSingleton.Workbench.ViewContentCollection.Count > 0) {
bool dirty = false;
total = new Report(StringParser.Parse("${res:Dialog.WordCountDialog.TotalText}"), 0, 0, 0);
foreach (IViewContent content in WorkbenchSingleton.Workbench.ViewContentCollection) {
if (content.FileName == null) {
MessageService.ShowWarning("${res:Dialog.WordCountDialog.SaveAllFileWarning}");
continue;
} else {
Report r = GetReport(content.FileName);
if (r != null) {
if (content.IsDirty) dirty = true;
total += r;
items.Add(r);
// ((ListView)ControlDictionary["resultListView"]).Items.Add(r.ToListItem());
case 1: {// all open files
if (WorkbenchSingleton.Workbench.ViewContentCollection.Count > 0) {
total = new Report(StringParser.Parse("${res:Dialog.WordCountDialog.TotalText}"), 0, 0, 0);
foreach (IViewContent content in WorkbenchSingleton.Workbench.ViewContentCollection) {
IEditable editable = content as IEditable;
if (editable != null) {
Report r = GetReport(content.IsUntitled ? content.UntitledName : content.FileName,
new StringReader(editable.Text));
if (r != null) {
total += r;
items.Add(r);
}
}
}
}
break;
}
if (dirty) {
MessageService.ShowWarning("${res:Dialog.WordCountDialog.DirtyWarning}");
}
// ((ListView)ControlDictionary["resultListView"]).Items.Add(new ListViewItem(""));
// ((ListView)ControlDictionary["resultListView"]).Items.Add(all.ToListItem());
}
break;
}
case 2: {// whole project
if (ProjectService.OpenSolution == null) {
MessageService.ShowError("${res:Dialog.WordCountDialog.MustBeInProtectedModeWarning}");
case 2: {// whole project
if (ProjectService.OpenSolution == null) {
MessageService.ShowError("${res:Dialog.WordCountDialog.MustBeInProtectedModeWarning}");
break;
}
total = new Report(StringParser.Parse("${res:Dialog.WordCountDialog.TotalText}"), 0, 0, 0);
CountCombine(ProjectService.OpenSolution, ref total);
// ((ListView)ControlDictionary["resultListView"]).Items.Add(new ListViewItem(""));
// ((ListView)ControlDictionary["resultListView"]).Items.Add(all.ToListItem());
break;
}
total = new Report(StringParser.Parse("${res:Dialog.WordCountDialog.TotalText}"), 0, 0, 0);
CountCombine(ProjectService.OpenSolution, ref total);
// ((ListView)ControlDictionary["resultListView"]).Items.Add(new ListViewItem(""));
// ((ListView)ControlDictionary["resultListView"]).Items.Add(all.ToListItem());
break;
}
}
UpdateList(0);
}
@ -187,12 +180,12 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -187,12 +180,12 @@ namespace ICSharpCode.SharpDevelop.Gui
endupdate:
((ListView)ControlDictionary["resultListView"]).EndUpdate();
}
}
internal class ReportComparer : IComparer
{
int sortKey;
public ReportComparer(int SortKey)
{
sortKey = SortKey;

24
src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs

@ -39,24 +39,32 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -39,24 +39,32 @@ namespace ICSharpCode.SharpDevelop.Gui
return dockPanel.ActiveDocument as IWorkbenchWindow;
}
}
// prevent setting ActiveContent to null when application loses focus (e.g. because of context menu popup)
DockContent lastActiveContent;
public object ActiveContent {
get {
if (dockPanel == null || dockPanel.ActiveContent == null) {
return null;
DockContent activeContent;
if (dockPanel == null) {
activeContent = lastActiveContent;
} else {
activeContent = dockPanel.ActiveContent ?? lastActiveContent;
}
lastActiveContent = activeContent;
if (dockPanel.ActiveContent.IsDisposed) {
if (activeContent == null || activeContent.IsDisposed) {
return null;
}
if (dockPanel.ActiveContent is IWorkbenchWindow) {
return ((IWorkbenchWindow)dockPanel.ActiveContent).ActiveViewContent;
if (activeContent is IWorkbenchWindow) {
return ((IWorkbenchWindow)activeContent).ActiveViewContent;
}
if (dockPanel.ActiveContent is PadContentWrapper) {
return ((PadContentWrapper)dockPanel.ActiveContent).PadContent;
if (activeContent is PadContentWrapper) {
return ((PadContentWrapper)activeContent).PadContent;
}
return dockPanel.ActiveContent;
return activeContent;
}
}

Loading…
Cancel
Save