Browse Source

Text markers can now specify foreground color.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@68 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Mike Krüger 21 years ago
parent
commit
d266a7a7c5
  1. 6
      src/AddIns/BackendBindings/VBNetBinding/Project/VBNetBinding.csproj
  2. 2
      src/AddIns/BackendBindings/VBNetBinding/Project/VBNetBinding.csproj.user
  3. 4
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs
  4. 24
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/MarkerStrategy/TextMarker.cs
  5. 40
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaMouseHandler.cs
  6. 29
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextView.cs
  7. 17
      src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs

6
src/AddIns/BackendBindings/VBNetBinding/Project/VBNetBinding.csproj

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@ -59,7 +59,7 @@ @@ -59,7 +59,7 @@
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Src\OptionPanels\BuildOptions.cs">
<SubType>Form</SubType>
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Src\OptionPanels\DebugOptions.cs">
<SubType>UserControl</SubType>
@ -101,6 +101,8 @@ @@ -101,6 +101,8 @@
<Name>ICSharpCode.Core</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Src\PrettyPrinter\Gui\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />

2
src/AddIns/BackendBindings/VBNetBinding/Project/VBNetBinding.csproj.user

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<StartProgram>..\..\..\..\..\bin\SharpDevelop.exe</StartProgram>
</PropertyGroup>

4
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs

@ -54,7 +54,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -54,7 +54,7 @@ namespace ICSharpCode.SharpDevelop.Services
class BreakpointMarker: TextMarker
{
public BreakpointMarker(int offset, int length, TextMarkerType textMarkerType, Color color):base(offset, length, textMarkerType, color)
public BreakpointMarker(int offset, int length, TextMarkerType textMarkerType, Color color, Color fgColor) : base(offset, length, textMarkerType, color, fgColor)
{
}
}
@ -412,7 +412,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -412,7 +412,7 @@ namespace ICSharpCode.SharpDevelop.Services
foreach (DebuggerLibrary.Breakpoint b in NDebugger.Instance.Breakpoints) {
if (b.SourcecodeSegment.SourceFullFilename.ToLower() == textEditor.FileName.ToLower()) {
LineSegment lineSeg = document.GetLineSegment((int)b.SourcecodeSegment.StartLine - 1);
document.MarkerStrategy.TextMarker.Add(new BreakpointMarker(lineSeg.Offset, lineSeg.Length , TextMarkerType.SolidBlock, Color.Red));
document.MarkerStrategy.TextMarker.Add(new BreakpointMarker(lineSeg.Offset, lineSeg.Length , TextMarkerType.SolidBlock, Color.Red, Color.White));
}
}
// Perform editor update

24
src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/MarkerStrategy/TextMarker.cs

@ -25,7 +25,9 @@ namespace ICSharpCode.TextEditor.Document @@ -25,7 +25,9 @@ namespace ICSharpCode.TextEditor.Document
{
TextMarkerType textMarkerType;
Color color;
Color foreColor;
string toolTip = null;
bool overrideForeColor = false;
public TextMarkerType TextMarkerType {
get {
@ -39,6 +41,18 @@ namespace ICSharpCode.TextEditor.Document @@ -39,6 +41,18 @@ namespace ICSharpCode.TextEditor.Document
}
}
public Color ForeColor {
get {
return foreColor;
}
}
public bool OverrideForeColor {
get {
return overrideForeColor;
}
}
public string ToolTip {
get {
return toolTip;
@ -59,5 +73,15 @@ namespace ICSharpCode.TextEditor.Document @@ -59,5 +73,15 @@ namespace ICSharpCode.TextEditor.Document
this.textMarkerType = textMarkerType;
this.color = color;
}
public TextMarker(int offset, int length, TextMarkerType textMarkerType, Color color, Color foreColor)
{
this.offset = offset;
this.length = length;
this.textMarkerType = textMarkerType;
this.color = color;
this.foreColor = foreColor;
this.overrideForeColor = true;
}
}
}

40
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaMouseHandler.cs

@ -250,26 +250,30 @@ namespace ICSharpCode.TextEditor @@ -250,26 +250,30 @@ namespace ICSharpCode.TextEditor
doubleclick = false;
return;
}
gotmousedown = true;
button = e.Button;
if ((DateTime.Now - lastTime).Milliseconds < SystemInformation.DoubleClickTime) {
int deltaX = Math.Abs(lastmousedownpos.X - e.X);
int deltaY = Math.Abs(lastmousedownpos.Y - e.Y);
if (deltaX <= SystemInformation.DoubleClickSize.Width &&
deltaY <= SystemInformation.DoubleClickSize.Height) {
DoubleClickSelectionExtend();
lastTime = DateTime.Now;
lastmousedownpos = new Point(e.X, e.Y);
return;
}
}
minSelection = nilPoint;
maxSelection = nilPoint;
lastTime = DateTime.Now;
lastmousedownpos = mousedownpos = new Point(e.X, e.Y);
if (textArea.TextView.DrawingPosition.Contains(mousepos.X, mousepos.Y)) {
gotmousedown = true;
button = e.Button;
if ((DateTime.Now - lastTime).Milliseconds < SystemInformation.DoubleClickTime) {
int deltaX = Math.Abs(lastmousedownpos.X - e.X);
int deltaY = Math.Abs(lastmousedownpos.Y - e.Y);
if (deltaX <= SystemInformation.DoubleClickSize.Width &&
deltaY <= SystemInformation.DoubleClickSize.Height) {
DoubleClickSelectionExtend();
lastTime = DateTime.Now;
lastmousedownpos = new Point(e.X, e.Y);
return;
}
}
minSelection = nilPoint;
maxSelection = nilPoint;
lastTime = DateTime.Now;
lastmousedownpos = mousedownpos = new Point(e.X, e.Y);
if (button == MouseButtons.Left) {
FoldMarker marker = textArea.TextView.GetFoldMarkerFromPosition(mousepos.X - textArea.TextView.DrawingPosition.X,
mousepos.Y - textArea.TextView.DrawingPosition.Y);

29
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextView.cs

@ -307,11 +307,14 @@ namespace ICSharpCode.TextEditor @@ -307,11 +307,14 @@ namespace ICSharpCode.TextEditor
/// <param name="offset">The offset.</param>
/// <param name="length">The length.</param>
/// <returns>The Brush or null when no marker was found.</returns>
Brush GetMarkerBrushAt(int offset, int length)
Brush GetMarkerBrushAt(int offset, int length, ref Color foreColor)
{
List<TextMarker> markers = Document.MarkerStrategy.GetMarkers(offset, length);
foreach (TextMarker marker in markers) {
if (marker.TextMarkerType == TextMarkerType.SolidBlock) {
if (marker.OverrideForeColor) {
foreColor = marker.ForeColor;
}
return BrushRegistry.GetBrush(marker.Color);
}
}
@ -385,11 +388,11 @@ namespace ICSharpCode.TextEditor @@ -385,11 +388,11 @@ namespace ICSharpCode.TextEditor
RectangleF spaceRectangle = new RectangleF(physicalXPos, lineRectangle.Y, (float)Math.Ceiling(spaceWidth), lineRectangle.Height);
Brush spaceBackgroundBrush;
Color spaceMarkerForeColor = spaceMarkerColor.Color;
if (ColumnRange.WholeColumn.Equals(selectionRange) || logicalColumn >= selectionRange.StartColumn && logicalColumn < selectionRange.EndColumn) {
spaceBackgroundBrush = selectionBackgroundBrush;
} else {
Brush markerBrush = GetMarkerBrushAt(currentLine.Offset + logicalColumn, 1);
Brush markerBrush = GetMarkerBrushAt(currentLine.Offset + logicalColumn, 1, ref spaceMarkerForeColor);
if (!drawLineMarker && markerBrush != null) {
spaceBackgroundBrush = markerBrush;
} else if (!drawLineMarker && currentWord.SyntaxColor != null && currentWord.SyntaxColor.HasBackground) {
@ -401,7 +404,7 @@ namespace ICSharpCode.TextEditor @@ -401,7 +404,7 @@ namespace ICSharpCode.TextEditor
g.FillRectangle(spaceBackgroundBrush, spaceRectangle);
if (TextEditorProperties.ShowSpaces) {
DrawSpaceMarker(g, spaceMarkerColor.Color, physicalXPos, lineRectangle.Y);
DrawSpaceMarker(g, spaceMarkerForeColor, physicalXPos, lineRectangle.Y);
}
foreach (TextMarker marker in markers) {
DrawMarker(g, marker, spaceRectangle);
@ -420,11 +423,12 @@ namespace ICSharpCode.TextEditor @@ -420,11 +423,12 @@ namespace ICSharpCode.TextEditor
physicalColumn = (physicalColumn / TextEditorProperties.TabIndent) * TextEditorProperties.TabIndent;
float tabWidth = (physicalColumn - oldPhysicalColumn) * spaceWidth;
RectangleF tabRectangle = new RectangleF(physicalXPos, lineRectangle.Y, (float)Math.Ceiling(tabWidth), lineRectangle.Height);
Color tabMarkerForeColor = tabMarkerColor.Color;
if (ColumnRange.WholeColumn.Equals(selectionRange) || logicalColumn >= selectionRange.StartColumn && logicalColumn <= selectionRange.EndColumn - 1) {
spaceBackgroundBrush = selectionBackgroundBrush;
} else {
Brush markerBrush = GetMarkerBrushAt(currentLine.Offset + logicalColumn, 1);
Brush markerBrush = GetMarkerBrushAt(currentLine.Offset + logicalColumn, 1, ref tabMarkerForeColor);
if (!drawLineMarker && markerBrush != null) {
spaceBackgroundBrush = markerBrush;
} else if (!drawLineMarker && currentWord.SyntaxColor != null && currentWord.SyntaxColor.HasBackground) {
@ -436,7 +440,7 @@ namespace ICSharpCode.TextEditor @@ -436,7 +440,7 @@ namespace ICSharpCode.TextEditor
g.FillRectangle(spaceBackgroundBrush, tabRectangle);
if (TextEditorProperties.ShowTabs) {
DrawTabMarker(g, tabMarkerColor.Color, physicalXPos, lineRectangle.Y);
DrawTabMarker(g, tabMarkerForeColor, physicalXPos, lineRectangle.Y);
}
foreach (TextMarker marker in markers) {
@ -452,7 +456,8 @@ namespace ICSharpCode.TextEditor @@ -452,7 +456,8 @@ namespace ICSharpCode.TextEditor
string word = currentWord.Word;
float lastPos = physicalXPos;
Brush bgMarkerBrush = GetMarkerBrushAt(currentLine.Offset + logicalColumn, word.Length);
Color wordForeColor = currentWord.Color;
Brush bgMarkerBrush = GetMarkerBrushAt(currentLine.Offset + logicalColumn, word.Length, ref wordForeColor);
Brush wordBackgroundBrush;
if (!drawLineMarker && bgMarkerBrush != null) {
wordBackgroundBrush = bgMarkerBrush;
@ -469,7 +474,7 @@ namespace ICSharpCode.TextEditor @@ -469,7 +474,7 @@ namespace ICSharpCode.TextEditor
word,
new Point((int)physicalXPos, lineRectangle.Y),
currentWord.Font,
selectionColor.HasForgeground ? selectionColor.Color : currentWord.Color,
selectionColor.HasForgeground ? selectionColor.Color : wordForeColor,
selectionBackgroundBrush);
} else {
if (ColumnRange.NoColumn.Equals(selectionRange) /* || selectionRange.StartColumn > logicalColumn + word.Length || selectionRange.EndColumn - 1 <= logicalColumn */) {
@ -477,7 +482,7 @@ namespace ICSharpCode.TextEditor @@ -477,7 +482,7 @@ namespace ICSharpCode.TextEditor
word,
new Point((int)physicalXPos, lineRectangle.Y),
currentWord.Font,
currentWord.Color,
wordForeColor,
wordBackgroundBrush);
} else {
int offset1 = Math.Min(word.Length, Math.Max(0, selectionRange.StartColumn - logicalColumn ));
@ -487,21 +492,21 @@ namespace ICSharpCode.TextEditor @@ -487,21 +492,21 @@ namespace ICSharpCode.TextEditor
word.Substring(0, offset1),
new Point((int)physicalXPos, lineRectangle.Y),
currentWord.Font,
currentWord.Color,
wordForeColor,
wordBackgroundBrush);
physicalXPos += DrawDocumentWord(g,
word.Substring(offset1, offset2 - offset1),
new Point((int)physicalXPos, lineRectangle.Y),
currentWord.Font,
selectionColor.HasForgeground ? selectionColor.Color : currentWord.Color,
selectionColor.HasForgeground ? selectionColor.Color : wordForeColor,
selectionBackgroundBrush);
physicalXPos += DrawDocumentWord(g,
word.Substring(offset2),
new Point((int)physicalXPos, lineRectangle.Y),
currentWord.Font,
currentWord.Color,
wordForeColor,
wordBackgroundBrush);
}
}

17
src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs

@ -63,12 +63,25 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -63,12 +63,25 @@ namespace ICSharpCode.SharpDevelop.Gui
public IBaseViewContent ActiveViewContent {
get {
if (viewTabControl != null && viewTabControl.SelectedIndex > 0) {
return (IBaseViewContent)subViewContents[viewTabControl.SelectedIndex];
if (viewTabControl != null) {
int selectedIndex = 0;
if (viewTabControl.InvokeRequired) {
selectedIndex = (int)viewTabControl.Invoke(new MyDelegate(GetSelectedIndex));
} else {
selectedIndex = GetSelectedIndex();
}
return (IBaseViewContent)subViewContents[selectedIndex];
}
return content;
}
}
delegate int MyDelegate();
int GetSelectedIndex()
{
return viewTabControl.SelectedIndex;
}
protected override Size DefaultSize {
get {

Loading…
Cancel
Save