Browse Source

Changed IPositionable interface and FileService.JumpToFilePosition to work with 1-based line and column numbers.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3984 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 17 years ago
parent
commit
25814ec485
  1. 2
      src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/SetupDialogErrorListViewItem.cs
  2. 4
      src/AddIns/BackendBindings/WixBinding/Test/Gui/AddDialogsToSetupDialogListTestFixture.cs
  3. 17
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs
  4. 2
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs
  5. 2
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XPathQueryControl.cs
  6. 2
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs
  7. 4
      src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageControl.cs
  8. 2
      src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageMethodTreeNode.cs
  9. 2
      src/AddIns/Misc/UnitTesting/Src/UnitTestCommands.cs
  10. 4
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/Caret.cs
  11. 12
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/TextViewPosition.cs
  12. 4
      src/Main/Base/Project/Src/Commands/CustomStringTagProvider.cs
  13. 8
      src/Main/Base/Project/Src/Gui/ContentInterfaces/IPositionable.cs
  14. 79
      src/Main/Base/Project/Src/Gui/FormLocationHelper.cs
  15. 2
      src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/ClassNode.cs
  16. 2
      src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/MemberNode.cs
  17. 10
      src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/FileLineReference.cs
  18. 10
      src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/OutputTextLineParser.cs
  19. 2
      src/Main/Base/Project/Src/Gui/Pads/DefinitionViewPad.cs
  20. 2
      src/Main/Base/Project/Src/Gui/Pads/SearchResultPad/Nodes/SearchResultNode.cs
  21. 6
      src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskView.cs
  22. 2
      src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs
  23. 4
      src/Main/Base/Project/Src/Services/File/FileService.cs
  24. 4
      src/Main/Base/Project/Src/Services/RefactoringService/FindReferencesAndRenameHelper.cs
  25. 2
      src/Main/Base/Project/Src/Services/RefactoringService/RefactoringMenuBuilder.cs
  26. 8
      src/Main/Base/Project/Src/Services/Tasks/Task.cs
  27. 2
      src/Main/Base/Project/Src/TextEditor/Actions.cs
  28. 2
      src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/BookmarkPad.cs
  29. 2
      src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/Nodes/BookmarkNode.cs
  30. 2
      src/Main/Base/Project/Src/TextEditor/Commands/ClassBookmarkMenuBuilder.cs
  31. 8
      src/Main/Base/Project/Src/TextEditor/Gui/Dialogs/GotoDialog.cs
  32. 6
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/ErrorDrawer.cs
  33. 8
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorBasedPad.cs
  34. 32
      src/Main/Base/Project/Src/Util/ExtensionMethods.cs
  35. 12
      src/Main/Base/Test/OutputTextLineParserTestFixture.cs

2
src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/SetupDialogErrorListViewItem.cs

@ -18,7 +18,7 @@ namespace ICSharpCode.WixBinding
int column; int column;
public SetupDialogErrorListViewItem(string fileName, XmlException ex) public SetupDialogErrorListViewItem(string fileName, XmlException ex)
: this(fileName, ex.LineNumber - 1, ex.LinePosition - 1) : this(fileName, ex.LineNumber, ex.LinePosition)
{ {
} }

4
src/AddIns/BackendBindings/WixBinding/Test/Gui/AddDialogsToSetupDialogListTestFixture.cs

@ -155,13 +155,13 @@ namespace WixBinding.Tests.Gui
[Test] [Test]
public void XmlErrorDialogItemErrorLine() public void XmlErrorDialogItemErrorLine()
{ {
Assert.AreEqual(9, xmlErrorDialogErrorLine); Assert.AreEqual(10, xmlErrorDialogErrorLine);
} }
[Test] [Test]
public void XmlErrorDialogItemErrorColumn() public void XmlErrorDialogItemErrorColumn()
{ {
Assert.AreEqual(4, xmlErrorDialogErrorColumn); Assert.AreEqual(5, xmlErrorDialogErrorColumn);
} }
[Test] [Test]

17
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs

@ -15,7 +15,7 @@ using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.AvalonEdit.AddIn namespace ICSharpCode.AvalonEdit.AddIn
{ {
public class AvalonEditViewContent : AbstractViewContent, IEditable, IMementoCapable, ITextEditorProvider public class AvalonEditViewContent : AbstractViewContent, IEditable, IMementoCapable, ITextEditorProvider, IPositionable
{ {
readonly CodeEditor codeEditor = new CodeEditor(); readonly CodeEditor codeEditor = new CodeEditor();
@ -145,5 +145,20 @@ namespace ICSharpCode.AvalonEdit.AddIn
return null; return null;
} }
#endregion #endregion
#region IPositionable
public int Line {
get { return codeEditor.TextArea.Caret.Line; }
}
public int Column {
get { return codeEditor.TextArea.Caret.Column; }
}
public void JumpTo(int line, int column)
{
codeEditor.TextArea.Caret.Position = new ICSharpCode.AvalonEdit.Gui.TextViewPosition(line, column);
}
#endregion
} }
} }

2
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs

@ -596,7 +596,7 @@ namespace ICSharpCode.FormsDesigner
if (FileUtility.IsEqualFileName(file, this.primaryViewContent.PrimaryFileName)) { if (FileUtility.IsEqualFileName(file, this.primaryViewContent.PrimaryFileName)) {
ShowSourceCode(position); ShowSourceCode(position);
} else { } else {
FileService.JumpToFilePosition(file, position - 1, 0); FileService.JumpToFilePosition(file, position, 0);
} }
} }
} }

2
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XPathQueryControl.cs

@ -581,7 +581,7 @@ namespace ICSharpCode.XmlEditor
void JumpTo(string fileName, int line, int column) void JumpTo(string fileName, int line, int column)
{ {
FileService.JumpToFilePosition(fileName, line, column); FileService.JumpToFilePosition(fileName, line + 1, column + 1);
} }
/// <summary> /// <summary>

2
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs

@ -461,7 +461,7 @@ namespace ICSharpCode.XmlEditor
// Open schema. // Open schema.
if (schemaObject != null && schemaObject.SourceUri != null && schemaObject.SourceUri.Length > 0) { if (schemaObject != null && schemaObject.SourceUri != null && schemaObject.SourceUri.Length > 0) {
string fileName = schemaObject.SourceUri.Replace("file:///", String.Empty); string fileName = schemaObject.SourceUri.Replace("file:///", String.Empty);
FileService.JumpToFilePosition(fileName, schemaObject.LineNumber - 1, schemaObject.LinePosition - 1); FileService.JumpToFilePosition(fileName, schemaObject.LineNumber, schemaObject.LinePosition);
} }
} }

4
src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageControl.cs

@ -298,7 +298,7 @@ namespace ICSharpCode.CodeCoverage
if (listView.SelectedItems.Count > 0) { if (listView.SelectedItems.Count > 0) {
CodeCoverageSequencePoint sequencePoint = (CodeCoverageSequencePoint)listView.SelectedItems[0].Tag; CodeCoverageSequencePoint sequencePoint = (CodeCoverageSequencePoint)listView.SelectedItems[0].Tag;
if (sequencePoint.Document.Length > 0) { if (sequencePoint.Document.Length > 0) {
FileService.JumpToFilePosition(sequencePoint.Document, sequencePoint.Line - 1, sequencePoint.Column - 1); FileService.JumpToFilePosition(sequencePoint.Document, sequencePoint.Line, sequencePoint.Column);
} }
} }
} }
@ -517,7 +517,7 @@ namespace ICSharpCode.CodeCoverage
string fileName = textEditorControl.FileName; string fileName = textEditorControl.FileName;
if (fileName != null) { if (fileName != null) {
Caret caret = textEditorControl.ActiveTextAreaControl.Caret; Caret caret = textEditorControl.ActiveTextAreaControl.Caret;
FileService.JumpToFilePosition(fileName, caret.Line, caret.Column); FileService.JumpToFilePosition(fileName, caret.Line + 1, caret.Column + 1);
} }
} }

2
src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageMethodTreeNode.cs

@ -41,7 +41,7 @@ namespace ICSharpCode.CodeCoverage
} }
} }
FileService.JumpToFilePosition(firstSequencePoint.Document, line - 1, column - 1); FileService.JumpToFilePosition(firstSequencePoint.Document, line, column);
} else if (Parent != null) { } else if (Parent != null) {
((ExtTreeNode)Parent).ActivateItem(); ((ExtTreeNode)Parent).ActivateItem();

2
src/AddIns/Misc/UnitTesting/Src/UnitTestCommands.cs

@ -73,7 +73,7 @@ namespace ICSharpCode.UnitTesting
if (filePosition.Position.IsEmpty) { if (filePosition.Position.IsEmpty) {
FileService.OpenFile(filePosition.FileName); FileService.OpenFile(filePosition.FileName);
} else { } else {
FileService.JumpToFilePosition(filePosition.FileName, filePosition.Line - 1, filePosition.Column - 1); FileService.JumpToFilePosition(filePosition.FileName, filePosition.Line, filePosition.Column);
} }
} }
} }

4
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/Caret.cs

@ -89,7 +89,7 @@ namespace ICSharpCode.AvalonEdit.Gui
public int Line { public int Line {
get { return position.Line; } get { return position.Line; }
set { set {
this.Position = new TextViewPosition(new TextLocation(value, position.Column)); this.Position = new TextViewPosition(value, position.Column);
} }
} }
@ -99,7 +99,7 @@ namespace ICSharpCode.AvalonEdit.Gui
public int Column { public int Column {
get { return position.Column; } get { return position.Column; }
set { set {
this.Position = new TextViewPosition(new TextLocation(position.Line, value)); this.Position = new TextViewPosition(position.Line, value);
} }
} }

12
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/TextViewPosition.cs

@ -53,6 +53,14 @@ namespace ICSharpCode.AvalonEdit.Gui
this.visualColumn = visualColumn; this.visualColumn = visualColumn;
} }
/// <summary>
/// Creates a new TextViewPosition instance.
/// </summary>
public TextViewPosition(int line, int column)
: this(line, column, -1)
{
}
/// <summary> /// <summary>
/// Creates a new TextViewPosition instance. /// Creates a new TextViewPosition instance.
/// </summary> /// </summary>
@ -67,10 +75,8 @@ namespace ICSharpCode.AvalonEdit.Gui
/// Creates a new TextViewPosition instance. /// Creates a new TextViewPosition instance.
/// </summary> /// </summary>
public TextViewPosition(TextLocation location) public TextViewPosition(TextLocation location)
: this(location, -1)
{ {
this.line = location.Line;
this.column = location.Column;
this.visualColumn = -1;
} }
/// <inheritdoc/> /// <inheritdoc/>

4
src/Main/Base/Project/Src/Commands/CustomStringTagProvider.cs

@ -98,14 +98,14 @@ namespace ICSharpCode.SharpDevelop.Commands
{ {
IPositionable positionable = WorkbenchSingleton.Workbench.ActiveViewContent as IPositionable; IPositionable positionable = WorkbenchSingleton.Workbench.ActiveViewContent as IPositionable;
if (positionable != null) if (positionable != null)
return (positionable.Line + 1).ToString(); return positionable.Line.ToString();
break; break;
} }
case "CURCOL": case "CURCOL":
{ {
IPositionable positionable = WorkbenchSingleton.Workbench.ActiveViewContent as IPositionable; IPositionable positionable = WorkbenchSingleton.Workbench.ActiveViewContent as IPositionable;
if (positionable != null) if (positionable != null)
return (positionable.Column + 1).ToString(); return positionable.Column.ToString();
break; break;
} }
case "CURTEXT": case "CURTEXT":

8
src/Main/Base/Project/Src/Gui/ContentInterfaces/IPositionable.cs

@ -15,20 +15,20 @@ namespace ICSharpCode.SharpDevelop.Gui
public interface IPositionable public interface IPositionable
{ {
/// <summary> /// <summary>
/// Sets the 'caret' to the position pos, where pos.Y is the line (starting from 0). /// Sets the 'caret' to the position pos, where pos.Y is the line (starting from 1).
/// And pos.X is the column (starting from 0 too). /// And pos.X is the column (starting from 1 too).
/// </summary> /// </summary>
void JumpTo(int line, int column); void JumpTo(int line, int column);
/// <summary> /// <summary>
/// gets the 'caret' position line (starting from 0) /// gets the 'caret' position line (starting from 1)
/// </summary> /// </summary>
int Line { int Line {
get; get;
} }
/// <summary> /// <summary>
/// gets the 'caret' position column (starting from 0) /// gets the 'caret' position column (starting from 1)
/// </summary> /// </summary>
int Column { int Column {
get; get;

79
src/Main/Base/Project/Src/Gui/FormLocationHelper.cs

@ -6,7 +6,7 @@
// </file> // </file>
using System; using System;
using System.Drawing; using System.Windows;
using System.Windows.Forms; using System.Windows.Forms;
using ICSharpCode.Core; using ICSharpCode.Core;
@ -37,13 +37,40 @@ namespace ICSharpCode.SharpDevelop.Gui
} }
}; };
} }
static Rectangle Validate(Rectangle bounds)
public static void ApplyWindow(Window window, string propertyName, bool isResizable)
{
window.WindowStartupLocation = WindowStartupLocation.Manual;
if (isResizable) {
Rect bounds = Validate(PropertyService.Get(propertyName, GetDefaultBounds(window)));
window.Left = bounds.X;
window.Top = bounds.Y;
window.Width = bounds.Width;
window.Height = bounds.Height;
} else {
Size size = new Size(window.ActualWidth, window.ActualHeight);
Point location = Validate(PropertyService.Get(propertyName, GetDefaultLocation(window)), size);
window.Left = location.X;
window.Top = location.Y;
}
window.Closing += delegate {
if (isResizable) {
if (window.WindowState == System.Windows.WindowState.Normal) {
PropertyService.Set(propertyName, new Rect(window.Left, window.Top, window.ActualWidth, window.ActualHeight));
}
} else {
PropertyService.Set(propertyName, new Point(window.Left, window.Top));
}
};
}
static Rect Validate(Rect bounds)
{ {
// Check if form is outside the screen and get it back if necessary. // Check if form is outside the screen and get it back if necessary.
// This is important when the user uses multiple screens, a window stores its location // This is important when the user uses multiple screens, a window stores its location
// on the secondary monitor and then the secondary monitor is removed. // on the secondary monitor and then the secondary monitor is removed.
Rectangle screen1 = Screen.FromPoint(new Point(bounds.X, bounds.Y)).WorkingArea; Rect screen1 = Screen.FromPoint(bounds.TopLeft.ToSystemDrawing()).WorkingArea.ToWpf();
Rectangle screen2 = Screen.FromPoint(new Point(bounds.X + bounds.Width, bounds.Y)).WorkingArea; Rect screen2 = Screen.FromPoint(bounds.TopRight.ToSystemDrawing()).WorkingArea.ToWpf();
if (bounds.Y < screen1.Y - 5 && bounds.Y < screen2.Y - 5) if (bounds.Y < screen1.Y - 5 && bounds.Y < screen2.Y - 5)
bounds.Y = screen1.Y - 5; bounds.Y = screen1.Y - 5;
if (bounds.X < screen1.X - bounds.Width / 2) if (bounds.X < screen1.X - bounds.Width / 2)
@ -55,23 +82,49 @@ namespace ICSharpCode.SharpDevelop.Gui
static Point Validate(Point location, Size size) static Point Validate(Point location, Size size)
{ {
return Validate(new Rectangle(location, size)).Location; return Validate(new Rect(location, size)).Location;
}
static System.Drawing.Rectangle Validate(System.Drawing.Rectangle bounds)
{
return Validate(bounds.ToWpf()).ToSystemDrawing();
}
static System.Drawing.Point Validate(System.Drawing.Point location, System.Drawing.Size size)
{
return Validate(location.ToWpf(), size.ToWpf()).ToSystemDrawing();
}
static System.Drawing.Rectangle GetDefaultBounds(Form form)
{
return new System.Drawing.Rectangle(GetDefaultLocation(form.Size.ToWpf()).ToSystemDrawing(), form.Size);
}
static Rect GetDefaultBounds(Window window)
{
Size size = new Size(window.Width, window.Height);
return new Rect(GetDefaultLocation(size), size);
}
static System.Drawing.Point GetDefaultLocation(Form form)
{
return GetDefaultLocation(form.Size.ToWpf()).ToSystemDrawing();
} }
static Rectangle GetDefaultBounds(Form form) static Point GetDefaultLocation(Window window)
{ {
return new Rectangle(GetDefaultLocation(form), form.Size); Size size = new Size(window.Width, window.Height);
return GetDefaultLocation(size);
} }
static Point GetDefaultLocation(Form form) static Point GetDefaultLocation(Size formSize)
{ {
var mainWindow = WorkbenchSingleton.MainWindow; var mainWindow = WorkbenchSingleton.MainWindow;
Rectangle parent = new Rectangle( Rect parent = new Rect(
(int)mainWindow.Left, (int)mainWindow.Top, (int)mainWindow.Width, (int)mainWindow.Height mainWindow.Left, mainWindow.Top, mainWindow.Width, mainWindow.Height
); );
Size size = form.Size; return new Point(parent.Left + (parent.Width - formSize.Width) / 2,
return new Point(parent.Left + (parent.Width - size.Width) / 2, parent.Top + (parent.Height - formSize.Height) / 2);
parent.Top + (parent.Height - size.Height) / 2);
} }
} }
} }

2
src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/ClassNode.cs

@ -60,7 +60,7 @@ namespace ICSharpCode.SharpDevelop.Gui.ClassBrowser
public override void ActivateItem() public override void ActivateItem()
{ {
if (c.CompilationUnit != null) { if (c.CompilationUnit != null) {
FileService.JumpToFilePosition(c.CompilationUnit.FileName, c.Region.BeginLine - 1, c.Region.BeginColumn - 1); FileService.JumpToFilePosition(c.CompilationUnit.FileName, c.Region.BeginLine, c.Region.BeginColumn);
} }
} }

2
src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/MemberNode.cs

@ -128,7 +128,7 @@ namespace ICSharpCode.SharpDevelop.Gui.ClassBrowser
public override void ActivateItem() public override void ActivateItem()
{ {
if (FileName != null) { if (FileName != null) {
FileService.JumpToFilePosition(FileName, line - 1, column - 1); FileService.JumpToFilePosition(FileName, line, column);
} }
} }
} }

10
src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/FileLineReference.cs

@ -22,12 +22,12 @@ namespace ICSharpCode.SharpDevelop.Gui
/// <summary> /// <summary>
/// The file line. /// The file line.
/// </summary> /// </summary>
int line = 0; int line;
/// <summary> /// <summary>
/// The line column. /// The line column.
/// </summary> /// </summary>
int column = 0; int column ;
/// <summary> /// <summary>
@ -43,7 +43,8 @@ namespace ICSharpCode.SharpDevelop.Gui
} }
/// <summary> /// <summary>
/// Gets or sets the line number /// Gets or sets the line number. The first line has the number 1.
/// The value '0' means that no line information is available.
/// </summary> /// </summary>
public int Line { public int Line {
get { get {
@ -55,7 +56,8 @@ namespace ICSharpCode.SharpDevelop.Gui
} }
/// <summary> /// <summary>
/// Gets or sets the line column. /// Gets or sets the line column. The first line has the number 1.
/// The value '0' means that no column information is available.
/// </summary> /// </summary>
public int Column { public int Column {
get { get {

10
src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/OutputTextLineParser.cs

@ -34,9 +34,8 @@ namespace ICSharpCode.SharpDevelop.Gui
Match match = Regex.Match(lineText, @"\b(\w:[/\\].*?)\((\d+),(\d+)\)"); Match match = Regex.Match(lineText, @"\b(\w:[/\\].*?)\((\d+),(\d+)\)");
if (match.Success) { if (match.Success) {
try { try {
// Take off 1 for line/col since SharpDevelop is zero index based. int line = Convert.ToInt32(match.Groups[2].Value);
int line = Convert.ToInt32(match.Groups[2].Value) - 1; int col = Convert.ToInt32(match.Groups[3].Value);
int col = Convert.ToInt32(match.Groups[3].Value) - 1;
return new FileLineReference(match.Groups[1].Value, line, col); return new FileLineReference(match.Groups[1].Value, line, col);
} catch (FormatException) { } catch (FormatException) {
@ -88,7 +87,7 @@ namespace ICSharpCode.SharpDevelop.Gui
Match match = Regex.Match(lineText, @"\sin\s(.*?):line\s(\d+)?\r?$", regexOptions); Match match = Regex.Match(lineText, @"\sin\s(.*?):line\s(\d+)?\r?$", regexOptions);
while (match.Success) { while (match.Success) {
try { try {
int line = Convert.ToInt32(match.Groups[2].Value) - 1; int line = Convert.ToInt32(match.Groups[2].Value);
result = new FileLineReference(match.Groups[1].Value, line); result = new FileLineReference(match.Groups[1].Value, line);
} catch (FormatException) { } catch (FormatException) {
} catch (OverflowException) { } catch (OverflowException) {
@ -115,8 +114,7 @@ namespace ICSharpCode.SharpDevelop.Gui
if (match.Success) { if (match.Success) {
try { try {
// Take off 1 for line/pos since SharpDevelop is zero index based. int line = Convert.ToInt32(match.Groups[2].Value);
int line = Convert.ToInt32(match.Groups[2].Value) - 1;
return new FileLineReference(match.Groups[1].Value.Trim(), line); return new FileLineReference(match.Groups[1].Value.Trim(), line);
} catch (FormatException) { } catch (FormatException) {

2
src/Main/Base/Project/Src/Gui/Pads/DefinitionViewPad.cs

@ -59,7 +59,7 @@ namespace ICSharpCode.SharpDevelop.Gui
string fileName = ctl.FileName; string fileName = ctl.FileName;
if (fileName != null) { if (fileName != null) {
Caret caret = ctl.ActiveTextAreaControl.Caret; Caret caret = ctl.ActiveTextAreaControl.Caret;
FileService.JumpToFilePosition(fileName, caret.Line, caret.Column); FileService.JumpToFilePosition(fileName, caret.Line + 1, caret.Column + 1);
// refresh DefinitionView to show the definition of the expression that was double-clicked // refresh DefinitionView to show the definition of the expression that was double-clicked
UpdateTick(null); UpdateTick(null);

2
src/Main/Base/Project/Src/Gui/Pads/SearchResultPad/Nodes/SearchResultNode.cs

@ -117,7 +117,7 @@ namespace SearchAndReplace
public override void ActivateItem() public override void ActivateItem()
{ {
FileService.JumpToFilePosition(result.FileName, startPosition.Y, startPosition.X); FileService.JumpToFilePosition(result.FileName, startPosition.Y + 1, startPosition.X + 1);
} }
} }
} }

6
src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskView.cs

@ -75,10 +75,10 @@ namespace ICSharpCode.SharpDevelop.Gui
b.Append(t.FileName); b.Append(t.FileName);
if (t.Line >= 0) { if (t.Line >= 0) {
b.Append(':'); b.Append(':');
b.Append(t.Line + 1); b.Append(t.Line);
if (t.Column > 0) { if (t.Column > 1) {
b.Append(','); b.Append(',');
b.Append(t.Column + 1); b.Append(t.Column);
} }
} }
} }

2
src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs

@ -253,7 +253,7 @@ namespace ICSharpCode.SharpDevelop.Debugging
public static void JumpToCurrentLine(string SourceFullFilename, int StartLine, int StartColumn, int EndLine, int EndColumn) public static void JumpToCurrentLine(string SourceFullFilename, int StartLine, int StartColumn, int EndLine, int EndColumn)
{ {
IViewContent viewContent = FileService.JumpToFilePosition(SourceFullFilename, StartLine - 1, StartColumn - 1); IViewContent viewContent = FileService.JumpToFilePosition(SourceFullFilename, StartLine, StartColumn);
CurrentLineBookmark.SetPosition(viewContent, StartLine, StartColumn, EndLine, EndColumn); CurrentLineBookmark.SetPosition(viewContent, StartLine, StartColumn, EndLine, EndColumn);
} }

4
src/Main/Base/Project/Src/Services/File/FileService.cs

@ -465,7 +465,7 @@ namespace ICSharpCode.SharpDevelop
/// <summary> /// <summary>
/// Opens the specified file and jumps to the specified file position. /// Opens the specified file and jumps to the specified file position.
/// Warning: Unlike parser coordinates, line and column are 0-based. /// Line and column start counting at 1.
/// </summary> /// </summary>
public static IViewContent JumpToFilePosition(string fileName, int line, int column) public static IViewContent JumpToFilePosition(string fileName, int line, int column)
{ {
@ -486,7 +486,7 @@ namespace ICSharpCode.SharpDevelop
content.WorkbenchWindow.ActiveViewContent = content; content.WorkbenchWindow.ActiveViewContent = content;
NavigationService.ResumeLogging(); NavigationService.ResumeLogging();
loggingResumed = true; loggingResumed = true;
((IPositionable)content).JumpTo(Math.Max(0, line), Math.Max(0, column)); ((IPositionable)content).JumpTo(Math.Max(1, line), Math.Max(1, column));
} else { } else {
NavigationService.ResumeLogging(); NavigationService.ResumeLogging();
loggingResumed = true; loggingResumed = true;

4
src/Main/Base/Project/Src/Services/RefactoringService/FindReferencesAndRenameHelper.cs

@ -268,7 +268,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring
string fileName = cu.FileName; string fileName = cu.FileName;
if (fileName != null) { if (fileName != null) {
if (!member.Region.IsEmpty) { if (!member.Region.IsEmpty) {
viewContent = FileService.JumpToFilePosition(fileName, member.Region.BeginLine - 1, member.Region.BeginColumn - 1); viewContent = FileService.JumpToFilePosition(fileName, member.Region.BeginLine, member.Region.BeginColumn);
} else { } else {
FileService.OpenFile(fileName); FileService.OpenFile(fileName);
} }
@ -286,7 +286,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring
string fileName = cu.FileName; string fileName = cu.FileName;
if (fileName != null) { if (fileName != null) {
if (!member.Region.IsEmpty) { if (!member.Region.IsEmpty) {
viewContent = FileService.JumpToFilePosition(fileName, member.Region.EndLine, 0); viewContent = FileService.JumpToFilePosition(fileName, member.Region.EndLine + 1, 1);
} else { } else {
FileService.OpenFile(fileName); FileService.OpenFile(fileName);
} }

2
src/Main/Base/Project/Src/Services/RefactoringService/RefactoringMenuBuilder.cs

@ -272,7 +272,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring
ClassBrowserIconService.GotoArrow.Bitmap); ClassBrowserIconService.GotoArrow.Bitmap);
gotoDefinitionItem.ShortcutKeys = Keys.Control | Keys.Enter; gotoDefinitionItem.ShortcutKeys = Keys.Control | Keys.Enter;
gotoDefinitionItem.Click += delegate { gotoDefinitionItem.Click += delegate {
FileService.JumpToFilePosition(cu.FileName, region.BeginLine - 1, region.BeginColumn - 1); FileService.JumpToFilePosition(cu.FileName, region.BeginLine, region.BeginColumn);
}; };
item.DropDown.Items.Add(gotoDefinitionItem); item.DropDown.Items.Add(gotoDefinitionItem);
item.DropDown.Items.Add(new ToolStripSeparator()); item.DropDown.Items.Add(new ToolStripSeparator());

8
src/Main/Base/Project/Src/Services/Tasks/Task.cs

@ -41,7 +41,7 @@ namespace ICSharpCode.SharpDevelop
} }
/// <summary> /// <summary>
/// The line number of the task. Zero-based (text editor coordinate) /// The line number of the task. Starts counting at 1.
/// </summary> /// </summary>
public int Line { public int Line {
get { get {
@ -50,7 +50,7 @@ namespace ICSharpCode.SharpDevelop
} }
/// <summary> /// <summary>
/// The column number of the task. Zero-based (text editor coordinate) /// The column number of the task. Starts counting at 1.
/// </summary> /// </summary>
public int Column { public int Column {
get { get {
@ -114,8 +114,8 @@ namespace ICSharpCode.SharpDevelop
public Task(BuildError error) public Task(BuildError error)
{ {
type = error.IsWarning ? TaskType.Warning : TaskType.Error; type = error.IsWarning ? TaskType.Warning : TaskType.Error;
column = Math.Max(error.Column - 1, 0); column = Math.Max(error.Column, 1);
line = Math.Max(error.Line - 1, 0); line = Math.Max(error.Line, 1);
fileName = error.FileName; fileName = error.FileName;
if (string.IsNullOrEmpty(error.ErrorCode)) { if (string.IsNullOrEmpty(error.ErrorCode)) {
description = error.ErrorText; description = error.ErrorText;

2
src/Main/Base/Project/Src/TextEditor/Actions.cs

@ -70,7 +70,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Actions
if (pos.Position.IsEmpty) if (pos.Position.IsEmpty)
FileService.OpenFile(pos.FileName); FileService.OpenFile(pos.FileName);
else else
FileService.JumpToFilePosition(pos.FileName, pos.Line - 1, pos.Column - 1); FileService.JumpToFilePosition(pos.FileName, pos.Line, pos.Column);
} catch (Exception ex) { } catch (Exception ex) {
MessageService.ShowError(ex, "Error jumping to '" + pos.FileName + "'."); MessageService.ShowError(ex, "Error jumping to '" + pos.FileName + "'.");
} }

2
src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/BookmarkPad.cs

@ -152,7 +152,7 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
if (node != null) { if (node != null) {
SDBookmark mark = node.Tag as SDBookmark; SDBookmark mark = node.Tag as SDBookmark;
if (mark != null) { if (mark != null) {
FileService.JumpToFilePosition(mark.FileName, mark.LineNumber, 0); FileService.JumpToFilePosition(mark.FileName, mark.LineNumber, 1);
} }
} }
} }

2
src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/Nodes/BookmarkNode.cs

@ -96,7 +96,7 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
public override void ActivateItem() public override void ActivateItem()
{ {
FileService.JumpToFilePosition(bookmark.FileName, bookmark.LineNumber, 0); FileService.JumpToFilePosition(bookmark.FileName, bookmark.LineNumber, 1);
} }
float DrawDocumentWord(Graphics g, string word, PointF position, Font font, Color foreColor) float DrawDocumentWord(Graphics g, string word, PointF position, Font font, Color foreColor)

2
src/Main/Base/Project/Src/TextEditor/Commands/ClassBookmarkMenuBuilder.cs

@ -262,7 +262,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
if (baseClass != null) { if (baseClass != null) {
string fileName = baseClass.CompilationUnit.FileName; string fileName = baseClass.CompilationUnit.FileName;
if (fileName != null) { if (fileName != null) {
FileService.JumpToFilePosition(fileName, baseClass.Region.BeginLine - 1, baseClass.Region.BeginColumn - 1); FileService.JumpToFilePosition(fileName, baseClass.Region.BeginLine, baseClass.Region.BeginColumn);
} }
} }
} }

8
src/Main/Base/Project/Src/TextEditor/Gui/Dialogs/GotoDialog.cs

@ -40,9 +40,9 @@ namespace ICSharpCode.SharpDevelop.Gui
public GotoDialog() public GotoDialog()
{ {
InitializeComponent(); InitializeComponent();
// FormLocationHelper.Apply(this, "ICSharpCode.SharpDevelop.Gui.GotoDialog.Bounds", true); FormLocationHelper.ApplyWindow(this, "ICSharpCode.SharpDevelop.Gui.GotoDialog.Bounds", true);
textBox.Focus();
ParserService.LoadSolutionProjectsThreadEnded += ParserService_LoadSolutionProjectsThreadEnded; ParserService.LoadSolutionProjectsThreadEnded += ParserService_LoadSolutionProjectsThreadEnded;
textBox.Focus();
} }
void ParserService_LoadSolutionProjectsThreadEnded(object sender, EventArgs e) void ParserService_LoadSolutionProjectsThreadEnded(object sender, EventArgs e)
@ -390,7 +390,7 @@ namespace ICSharpCode.SharpDevelop.Gui
void GotoRegion(DomRegion region, string fileName) void GotoRegion(DomRegion region, string fileName)
{ {
if (fileName != null && !region.IsEmpty) { if (fileName != null && !region.IsEmpty) {
FileService.JumpToFilePosition(fileName, region.BeginLine - 1, region.BeginColumn - 1); FileService.JumpToFilePosition(fileName, region.BeginLine, region.BeginColumn);
} }
} }
@ -428,7 +428,7 @@ namespace ICSharpCode.SharpDevelop.Gui
if (flref.Line <= 0) { if (flref.Line <= 0) {
FileService.OpenFile(flref.FileName); FileService.OpenFile(flref.FileName);
} else { } else {
FileService.JumpToFilePosition(flref.FileName, flref.Line - 1, flref.Column); FileService.JumpToFilePosition(flref.FileName, flref.Line, flref.Column);
} }
} else { } else {
throw new NotImplementedException("Unknown tag: " + tag); throw new NotImplementedException("Unknown tag: " + tag);

6
src/Main/Base/Project/Src/TextEditor/Gui/Editor/ErrorDrawer.cs

@ -162,17 +162,17 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
if (!CheckTask(task)) return; if (!CheckTask(task)) return;
if (task.Line >= 0 && task.Line < textEditor.Document.TotalNumberOfLines) { if (task.Line >= 0 && task.Line < textEditor.Document.TotalNumberOfLines) {
LineSegment line = textEditor.Document.GetLineSegment(task.Line); LineSegment line = textEditor.Document.GetLineSegment(task.Line);
int offset = line.Offset + task.Column; int offset = line.Offset + task.Column - 1;
int length = 1; int length = 1;
if (line.Words != null) { if (line.Words != null) {
foreach (TextWord tw in line.Words) { foreach (TextWord tw in line.Words) {
if (task.Column == tw.Offset) { if (task.Column - 1 == tw.Offset) {
length = tw.Length; length = tw.Length;
break; break;
} }
} }
} }
if (length == 1 && task.Column < line.Length) { if (length == 1 && task.Column - 1 < line.Length) {
length = 2; // use minimum length length = 2; // use minimum length
} }
textEditor.Document.MarkerStrategy.AddMarker(new VisualError(offset, length, task)); textEditor.Document.MarkerStrategy.AddMarker(new VisualError(offset, length, task));

8
src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorBasedPad.cs

@ -95,25 +95,25 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
#region IPositionable implementation #region IPositionable implementation
void IPositionable.JumpTo(int line, int column) void IPositionable.JumpTo(int line, int column)
{ {
this.TextEditorControl.ActiveTextAreaControl.JumpTo(line, column); this.TextEditorControl.ActiveTextAreaControl.JumpTo(line - 1, column - 1);
// we need to delay this call here because the text editor does not know its height if it was just created // we need to delay this call here because the text editor does not know its height if it was just created
WorkbenchSingleton.SafeThreadAsyncCall( WorkbenchSingleton.SafeThreadAsyncCall(
delegate { delegate {
this.TextEditorControl.ActiveTextAreaControl.CenterViewOn( this.TextEditorControl.ActiveTextAreaControl.CenterViewOn(
line, (int)(0.3 * this.TextEditorControl.ActiveTextAreaControl.TextArea.TextView.VisibleLineCount)); line - 1, (int)(0.3 * this.TextEditorControl.ActiveTextAreaControl.TextArea.TextView.VisibleLineCount));
}); });
} }
int IPositionable.Line { int IPositionable.Line {
get { get {
return this.TextEditorControl.ActiveTextAreaControl.Caret.Line; return this.TextEditorControl.ActiveTextAreaControl.Caret.Line + 1;
} }
} }
int IPositionable.Column { int IPositionable.Column {
get { get {
return this.TextEditorControl.ActiveTextAreaControl.Caret.Column; return this.TextEditorControl.ActiveTextAreaControl.Caret.Column + 1;
} }
} }
#endregion #endregion

32
src/Main/Base/Project/Src/Util/ExtensionMethods.cs

@ -160,5 +160,37 @@ namespace ICSharpCode.SharpDevelop
contentControl.Content = content; contentControl.Content = content;
} }
} }
#region System.Drawing <-> WPF conversions
public static System.Drawing.Point ToSystemDrawing(this Point p)
{
return new System.Drawing.Point((int)p.X, (int)p.Y);
}
public static System.Drawing.Size ToSystemDrawing(this Size s)
{
return new System.Drawing.Size((int)s.Width, (int)s.Height);
}
public static System.Drawing.Rectangle ToSystemDrawing(this Rect r)
{
return new System.Drawing.Rectangle(r.TopLeft.ToSystemDrawing(), r.Size.ToSystemDrawing());
}
public static Point ToWpf(this System.Drawing.Point p)
{
return new Point(p.X, p.Y);
}
public static Size ToWpf(this System.Drawing.Size s)
{
return new Size(s.Width, s.Height);
}
public static Rect ToWpf(this System.Drawing.Rectangle rect)
{
return new Rect(rect.Location.ToWpf(), rect.Size.ToWpf());
}
#endregion
} }
} }

12
src/Main/Base/Test/OutputTextLineParserTestFixture.cs

@ -20,7 +20,7 @@ namespace ICSharpCode.SharpDevelop.Tests
string output = " at NunitFoo.Tests.FooTest.Foo() in c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs:line 22\n"; string output = " at NunitFoo.Tests.FooTest.Foo() in c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs:line 22\n";
FileLineReference lineRef = OutputTextLineParser.GetNUnitOutputFileLineReference(output, true); FileLineReference lineRef = OutputTextLineParser.GetNUnitOutputFileLineReference(output, true);
Assert.AreEqual(lineRef.FileName, "c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs"); Assert.AreEqual(lineRef.FileName, "c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs");
Assert.AreEqual(21, lineRef.Line); Assert.AreEqual(22, lineRef.Line);
Assert.AreEqual(0, lineRef.Column); Assert.AreEqual(0, lineRef.Column);
} }
@ -30,7 +30,7 @@ namespace ICSharpCode.SharpDevelop.Tests
string output = " at NunitFoo.Tests.FooTest.Foo() in c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs:line 22\r\n"; string output = " at NunitFoo.Tests.FooTest.Foo() in c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs:line 22\r\n";
FileLineReference lineRef = OutputTextLineParser.GetNUnitOutputFileLineReference(output, true); FileLineReference lineRef = OutputTextLineParser.GetNUnitOutputFileLineReference(output, true);
Assert.AreEqual(lineRef.FileName, "c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs"); Assert.AreEqual(lineRef.FileName, "c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs");
Assert.AreEqual(21, lineRef.Line); Assert.AreEqual(22, lineRef.Line);
Assert.AreEqual(0, lineRef.Column); Assert.AreEqual(0, lineRef.Column);
} }
@ -41,7 +41,7 @@ namespace ICSharpCode.SharpDevelop.Tests
" at NunitFoo.Tests.FooTest.Foo() in c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs:line 22\r\n"; " at NunitFoo.Tests.FooTest.Foo() in c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs:line 22\r\n";
FileLineReference lineRef = OutputTextLineParser.GetNUnitOutputFileLineReference(output, true); FileLineReference lineRef = OutputTextLineParser.GetNUnitOutputFileLineReference(output, true);
Assert.AreEqual(lineRef.FileName, "c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs"); Assert.AreEqual(lineRef.FileName, "c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs");
Assert.AreEqual(21, lineRef.Line); Assert.AreEqual(22, lineRef.Line);
Assert.AreEqual(0, lineRef.Column); Assert.AreEqual(0, lineRef.Column);
} }
@ -51,7 +51,7 @@ namespace ICSharpCode.SharpDevelop.Tests
string output = "c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs(22)"; string output = "c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs(22)";
FileLineReference lineRef = OutputTextLineParser.GetFileLineReference(output); FileLineReference lineRef = OutputTextLineParser.GetFileLineReference(output);
Assert.AreEqual(lineRef.FileName, "c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs"); Assert.AreEqual(lineRef.FileName, "c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs");
Assert.AreEqual(21, lineRef.Line); Assert.AreEqual(22, lineRef.Line);
Assert.AreEqual(0, lineRef.Column); Assert.AreEqual(0, lineRef.Column);
} }
@ -61,8 +61,8 @@ namespace ICSharpCode.SharpDevelop.Tests
string output = "c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs(22,10)"; string output = "c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs(22,10)";
FileLineReference lineRef = OutputTextLineParser.GetFileLineReference(output); FileLineReference lineRef = OutputTextLineParser.GetFileLineReference(output);
Assert.AreEqual(lineRef.FileName, "c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs"); Assert.AreEqual(lineRef.FileName, "c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs");
Assert.AreEqual(21, lineRef.Line); Assert.AreEqual(22, lineRef.Line);
Assert.AreEqual(9, lineRef.Column); Assert.AreEqual(10, lineRef.Column);
} }
} }
} }

Loading…
Cancel
Save