Browse Source

When using Ctrl+C or Ctrl+X when nothing is selected, the current line is copied/cut (patch by Martin Nordholts).

Fixed exception when typing a pipe '|' in the new project dialog.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@707 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
ab7edc9537
  1. 42
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaClipboardHandler.cs
  2. 5
      src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs
  3. 4
      src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs

42
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaClipboardHandler.cs

@ -32,13 +32,13 @@ namespace ICSharpCode.TextEditor
public bool EnableCut { public bool EnableCut {
get { get {
return textArea.SelectionManager.HasSomethingSelected; return true; //textArea.SelectionManager.HasSomethingSelected;
} }
} }
public bool EnableCopy { public bool EnableCopy {
get { get {
return textArea.SelectionManager.HasSomethingSelected; return true; //textArea.SelectionManager.HasSomethingSelected;
} }
} }
@ -75,18 +75,16 @@ namespace ICSharpCode.TextEditor
// ((DefaultWorkbench)WorkbenchSingleton.Workbench).UpdateToolbars(); // ((DefaultWorkbench)WorkbenchSingleton.Workbench).UpdateToolbars();
} }
bool CopyTextToClipboard() bool CopyTextToClipboard(string stringToCopy)
{ {
string str = textArea.SelectionManager.SelectedText; if (stringToCopy.Length > 0) {
if (str.Length > 0) {
DataObject dataObject = new DataObject(); DataObject dataObject = new DataObject();
dataObject.SetData(DataFormats.UnicodeText, true, str); dataObject.SetData(DataFormats.UnicodeText, true, stringToCopy);
// Default has no highlighting, therefore we don't need RTF output // Default has no highlighting, therefore we don't need RTF output
if (textArea.Document.HighlightingStrategy.Name != "Default") { if (textArea.Document.HighlightingStrategy.Name != "Default") {
dataObject.SetData(DataFormats.Rtf, RtfWriter.GenerateRtf(textArea)); dataObject.SetData(DataFormats.Rtf, RtfWriter.GenerateRtf(textArea));
} }
OnCopyText(new CopyTextEventArgs(str)); OnCopyText(new CopyTextEventArgs(stringToCopy));
// Work around ExternalException bug. (SD2-426) // Work around ExternalException bug. (SD2-426)
// Best reproducable inside Virtual PC. // Best reproducable inside Virtual PC.
@ -112,18 +110,40 @@ namespace ICSharpCode.TextEditor
public void Cut(object sender, EventArgs e) public void Cut(object sender, EventArgs e)
{ {
if (CopyTextToClipboard()) { if (CopyTextToClipboard(textArea.SelectionManager.SelectedText)) {
// remove text // Remove text
textArea.BeginUpdate(); textArea.BeginUpdate();
textArea.Caret.Position = textArea.SelectionManager.SelectionCollection[0].StartPosition; textArea.Caret.Position = textArea.SelectionManager.SelectionCollection[0].StartPosition;
textArea.SelectionManager.RemoveSelectedText(); textArea.SelectionManager.RemoveSelectedText();
textArea.EndUpdate(); textArea.EndUpdate();
} else {
// No text was selected, select and cut the entire line
int curLineNr = textArea.Document.GetLineNumberForOffset(textArea.Caret.Offset);
LineSegment lineWhereCaretIs = textArea.Document.GetLineSegment(curLineNr);
string caretLineText = textArea.Document.GetText(lineWhereCaretIs.Offset, lineWhereCaretIs.TotalLength);
textArea.SelectionManager.SetSelection(textArea.Document.OffsetToPosition(lineWhereCaretIs.Offset), textArea.Document.OffsetToPosition(lineWhereCaretIs.Offset + lineWhereCaretIs.TotalLength));
if (CopyTextToClipboard(caretLineText)) {
// remove line
textArea.BeginUpdate();
textArea.Caret.Position = textArea.Document.OffsetToPosition(lineWhereCaretIs.Offset);
textArea.SelectionManager.RemoveSelectedText();
textArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.PositionToEnd, new Point(0, curLineNr)));
textArea.EndUpdate();
}
} }
} }
public void Copy(object sender, EventArgs e) public void Copy(object sender, EventArgs e)
{ {
CopyTextToClipboard(); if (!CopyTextToClipboard(textArea.SelectionManager.SelectedText)) {
// No text was selected, select the entire line, copy it, and then deselect
int curLineNr = textArea.Document.GetLineNumberForOffset(textArea.Caret.Offset);
LineSegment lineWhereCaretIs = textArea.Document.GetLineSegment(curLineNr);
string caretLineText = textArea.Document.GetText(lineWhereCaretIs.Offset, lineWhereCaretIs.TotalLength);
textArea.SelectionManager.SetSelection(textArea.Document.OffsetToPosition(lineWhereCaretIs.Offset), textArea.Document.OffsetToPosition(lineWhereCaretIs.Offset + lineWhereCaretIs.TotalLength));
CopyTextToClipboard(caretLineText);
textArea.SelectionManager.ClearSelection();
}
} }
public void Paste(object sender, EventArgs e) public void Paste(object sender, EventArgs e)

5
src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs

@ -224,8 +224,9 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
solutionPath = solutionPath.Substring(0, maxLength + 3) + "..."; solutionPath = solutionPath.Substring(0, maxLength + 3) + "...";
} }
} }
} catch (Exception ex) { } catch (ArgumentException) {
MessageService.ShowError(ex); ControlDictionary["createInLabel"].Text = ResourceService.GetString("ICSharpCode.SharpDevelop.Gui.Dialogs.NewProjectDialog.IllegalProjectNameError").Replace("\n", " ").Replace("\r", "");
return;
} }
ControlDictionary["createInLabel"].Text = ResourceService.GetString("Dialog.NewProject.ProjectAtDescription")+ " " + solutionPath; ControlDictionary["createInLabel"].Text = ResourceService.GetString("Dialog.NewProject.ProjectAtDescription")+ " " + solutionPath;
} }

4
src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs

@ -46,7 +46,7 @@ namespace ICSharpCode.Core
readonly static char[] separators = { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar, Path.VolumeSeparatorChar }; readonly static char[] separators = { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar, Path.VolumeSeparatorChar };
static string sharpDevelopRootPath; static string sharpDevelopRootPath;
const string fileNameRegEx = @"^(([a-zA-Z]:)|.)[^:]*$"; const string fileNameRegEx = @"^([a-zA-Z]:)?[^:]+$";
public static string SharpDevelopRootPath { public static string SharpDevelopRootPath {
get { get {
@ -307,7 +307,7 @@ namespace ICSharpCode.Core
string nameWithoutExtension = Path.GetFileNameWithoutExtension(fileName); string nameWithoutExtension = Path.GetFileNameWithoutExtension(fileName);
if (nameWithoutExtension != null) { if (nameWithoutExtension != null) {
nameWithoutExtension = nameWithoutExtension.ToUpper(); nameWithoutExtension = nameWithoutExtension.ToUpperInvariant();
} }
if (nameWithoutExtension == "CON" || if (nameWithoutExtension == "CON" ||

Loading…
Cancel
Save