diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2013-08-13 09:31:10 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2013-08-13 09:31:33 +0400 |
commit | e3233c4788e6b2a41819406287aaa6071b9dde10 (patch) | |
tree | 0e74dd292759f82556e4d07d385dcdb59aa26310 /main/src/addins/MonoDevelop.HexEditor | |
parent | 12bc9971a041914d22e5adb9fb5c18fd64b3a04b (diff) |
[HexEditor] Fixed some issues with small files.
Diffstat (limited to 'main/src/addins/MonoDevelop.HexEditor')
3 files changed, 20 insertions, 17 deletions
diff --git a/main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Data/HexEditorData.cs b/main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Data/HexEditorData.cs index ad11ed4f45..091e09268b 100644 --- a/main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Data/HexEditorData.cs +++ b/main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Data/HexEditorData.cs @@ -95,8 +95,10 @@ namespace Mono.MHex.Data byte[] nodeBytes = node.value.GetBytes (this, nodeOffset, offset, (int)(nodeEndOffset - offset)); byte[] result = new byte[count]; - nodeBytes.CopyTo (result, 0); - GetBytes (offset + nodeBytes.Length, count - nodeBytes.Length).CopyTo (result, nodeBytes.Length); + if (nodeBytes.Length > 0) { + nodeBytes.CopyTo (result, 0); + GetBytes (offset + nodeBytes.Length, count - nodeBytes.Length).CopyTo (result, nodeBytes.Length); + } return result; } diff --git a/main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Rendering/GutterMargin.cs b/main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Rendering/GutterMargin.cs index a960cb47a1..12475739be 100644 --- a/main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Rendering/GutterMargin.cs +++ b/main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Rendering/GutterMargin.cs @@ -72,12 +72,14 @@ namespace Mono.MHex.Rendering ctx.SetColor (Style.HexOffsetBg); ctx.Fill (); - LayoutWrapper layout = GetLayout (line); - var sz = layout.Layout.GetSize (); - ctx.SetColor (line != Caret.Line ? Style.HexOffset : Style.HexOffsetHighlighted); - ctx.DrawTextLayout (layout.Layout, x + Width - sz.Width - 4, y); - if (layout.IsUncached) - layout.Dispose (); + if (line * Editor.BytesInRow < Data.Length) { + LayoutWrapper layout = GetLayout (line); + var sz = layout.Layout.GetSize (); + ctx.SetColor (line != Caret.Line ? Style.HexOffset : Style.HexOffsetHighlighted); + ctx.DrawTextLayout (layout.Layout, x + Width - sz.Width - 4, y); + if (layout.IsUncached) + layout.Dispose (); + } } internal protected override void MousePressed (MarginMouseEventArgs args) diff --git a/main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Rendering/TextEditorMargin.cs b/main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Rendering/TextEditorMargin.cs index d37bd22583..e4198d3359 100644 --- a/main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Rendering/TextEditorMargin.cs +++ b/main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Rendering/TextEditorMargin.cs @@ -92,7 +92,6 @@ namespace Mono.MHex.Rendering internal protected override void Draw (Context ctx, Rectangle area, long line, double x, double y) { - ctx.Rectangle (x, y, Width, Editor.LineHeight); ctx.SetColor (Style.HexDigitBg); ctx.Fill (); @@ -113,15 +112,15 @@ namespace Mono.MHex.Rendering public double CalculateCaretXPos (out char ch) { - byte b = Data.GetByte (Caret.Offset); - ch = (char)b; - if (b < 128 && (Char.IsLetterOrDigit (ch) || Char.IsPunctuation (ch))) { - // ok - } else { - ch = '.'; - } + var layout = GetLayout (Data.Caret.Line); + ch = (char)Data.GetByte (Caret.Offset); + + var rectangle = layout.Layout.GetCoordinateFromIndex ((int)(Caret.Offset % BytesInRow)); + + if (layout.IsUncached) + layout.Dispose (); - return XOffset + (Caret.Offset % BytesInRow) * charWidth; + return XOffset + rectangle.X / 1024.0; // FIX XWT !!!! Pango.Scale bug } internal protected override void MousePressed (MarginMouseEventArgs args) |