protected override LayoutWrapper RenderLine(long line) { Pango.Layout layout = new Pango.Layout(Editor.PangoContext); layout.FontDescription = Editor.Options.Font; StringBuilder sb = new StringBuilder(); long startOffset = line * Editor.BytesInRow; long endOffset = System.Math.Min(startOffset + Editor.BytesInRow, Data.Length); byte[] lineBytes = Data.GetBytes(startOffset, (int)(endOffset - startOffset)); for (int i = 0; i < lineBytes.Length; i++) { byte b = lineBytes[i]; char ch = (char)b; if (b < 128 && (Char.IsLetterOrDigit(ch) || Char.IsPunctuation(ch))) { sb.Append(ch); } else { sb.Append("."); } } layout.SetText(sb.ToString()); char[] lineChars = layout.Text.ToCharArray(); Margin.LayoutWrapper result = new LayoutWrapper(layout); uint curIndex = 0, byteIndex = 0; if (Data.IsSomethingSelected) { ISegment selection = Data.MainSelection.Segment; HandleSelection(selection.Offset, selection.EndOffset, startOffset, endOffset, null, delegate(long start, long end) { Pango.AttrForeground selectedForeground = new Pango.AttrForeground(Style.Selection.Red, Style.Selection.Green, Style.Selection.Blue); selectedForeground.StartIndex = TranslateToUTF8Index(lineChars, (uint)(start - startOffset), ref curIndex, ref byteIndex); selectedForeground.EndIndex = TranslateToUTF8Index(lineChars, (uint)(end - startOffset), ref curIndex, ref byteIndex); result.Add(selectedForeground); Pango.AttrBackground attrBackground = new Pango.AttrBackground(Style.SelectionBg.Red, Style.SelectionBg.Green, Style.SelectionBg.Blue); attrBackground.StartIndex = selectedForeground.StartIndex; attrBackground.EndIndex = selectedForeground.EndIndex; result.Add(attrBackground); }); } result.SetAttributes(); return(result); }
protected override LayoutWrapper RenderLine(long line) { Pango.Layout layout = new Pango.Layout(Editor.PangoContext); layout.FontDescription = Editor.Options.Font; layout.Tabs = tabArray; StringBuilder sb = new StringBuilder(); long startOffset = line * Editor.BytesInRow; long endOffset = System.Math.Min(startOffset + Editor.BytesInRow, Data.Length); byte[] lineBytes = Data.GetBytes(startOffset, (int)(endOffset - startOffset)); for (int i = 0; i < lineBytes.Length; i++) { sb.Append(string.Format("{0:X2}", lineBytes[i])); if (i % Editor.Options.GroupBytes == 0) { sb.Append("\t"); } } layout.SetText(sb.ToString()); char[] lineChars = sb.ToString().ToCharArray(); Margin.LayoutWrapper result = new LayoutWrapper(layout); uint curIndex = 0, byteIndex = 0; if (Data.IsSomethingSelected) { ISegment selection = Data.MainSelection.Segment; HandleSelection(selection.Offset, selection.EndOffset, startOffset, endOffset, null, delegate(long start, long end) { Pango.AttrForeground selectedForeground = new Pango.AttrForeground(Style.Selection.Red, Style.Selection.Green, Style.Selection.Blue); selectedForeground.StartIndex = TranslateToUTF8Index(lineChars, TranslateColumn(start - startOffset), ref curIndex, ref byteIndex); selectedForeground.EndIndex = TranslateToUTF8Index(lineChars, TranslateColumn(end - startOffset) - 1, ref curIndex, ref byteIndex); result.Add(selectedForeground); Pango.AttrBackground attrBackground = new Pango.AttrBackground(Style.SelectionBg.Red, Style.SelectionBg.Green, Style.SelectionBg.Blue); attrBackground.StartIndex = selectedForeground.StartIndex; attrBackground.EndIndex = selectedForeground.EndIndex; result.Add(attrBackground); }); } result.SetAttributes(); return(result); }
protected override LayoutWrapper RenderLine (long line) { Pango.Layout layout = new Pango.Layout (Editor.PangoContext); layout.FontDescription = Editor.Options.Font; layout.Tabs = tabArray; StringBuilder sb = new StringBuilder (); long startOffset = line * Editor.BytesInRow; long endOffset = System.Math.Min (startOffset + Editor.BytesInRow, Data.Length); byte[] lineBytes = Data.GetBytes (startOffset, (int)(endOffset - startOffset)); for (int i = 0; i < lineBytes.Length; i++) { sb.Append (string.Format ("{0:X2}", lineBytes[i])); if (i % Editor.Options.GroupBytes == 0) sb.Append ("\t"); } layout.SetText (sb.ToString ()); char[] lineChars = sb.ToString ().ToCharArray (); Margin.LayoutWrapper result = new LayoutWrapper (layout); uint curIndex = 0, byteIndex = 0; if (Data.IsSomethingSelected) { ISegment selection = Data.MainSelection.Segment; HandleSelection (selection.Offset, selection.EndOffset, startOffset, endOffset, null, delegate(long start, long end) { Pango.AttrForeground selectedForeground = new Pango.AttrForeground (Style.Selection.Red, Style.Selection.Green, Style.Selection.Blue); selectedForeground.StartIndex = TranslateToUTF8Index (lineChars, TranslateColumn (start - startOffset), ref curIndex, ref byteIndex); selectedForeground.EndIndex = TranslateToUTF8Index (lineChars, TranslateColumn (end - startOffset) - 1, ref curIndex, ref byteIndex); result.Add (selectedForeground); Pango.AttrBackground attrBackground = new Pango.AttrBackground (Style.SelectionBg.Red, Style.SelectionBg.Green, Style.SelectionBg.Blue); attrBackground.StartIndex = selectedForeground.StartIndex; attrBackground.EndIndex = selectedForeground.EndIndex; result.Add (attrBackground); }); } result.SetAttributes (); return result; }
protected override LayoutWrapper RenderLine (long line) { Pango.Layout layout = new Pango.Layout (Editor.PangoContext); layout.FontDescription = Editor.Options.Font; StringBuilder sb = new StringBuilder (); long startOffset = line * Editor.BytesInRow; long endOffset = System.Math.Min (startOffset + Editor.BytesInRow, Data.Length); byte[] lineBytes = Data.GetBytes (startOffset, (int)(endOffset - startOffset)); for (int i = 0; i < lineBytes.Length; i++) { byte b = lineBytes[i]; char ch = (char)b; if (b < 128 && (Char.IsLetterOrDigit (ch) || Char.IsPunctuation (ch))) { sb.Append (ch); } else { sb.Append ("."); } } layout.SetText (sb.ToString ()); char[] lineChars = layout.Text.ToCharArray (); Margin.LayoutWrapper result = new LayoutWrapper (layout); uint curIndex = 0, byteIndex = 0; if (Data.IsSomethingSelected) { ISegment selection = Data.MainSelection.Segment; HandleSelection (selection.Offset, selection.EndOffset, startOffset, endOffset, null, delegate(long start, long end) { Pango.AttrForeground selectedForeground = new Pango.AttrForeground (Style.Selection.Red, Style.Selection.Green, Style.Selection.Blue); selectedForeground.StartIndex = TranslateToUTF8Index (lineChars, (uint)(start - startOffset), ref curIndex, ref byteIndex); selectedForeground.EndIndex = TranslateToUTF8Index (lineChars, (uint)(end - startOffset), ref curIndex, ref byteIndex); result.Add (selectedForeground); Pango.AttrBackground attrBackground = new Pango.AttrBackground (Style.SelectionBg.Red, Style.SelectionBg.Green, Style.SelectionBg.Blue); attrBackground.StartIndex = selectedForeground.StartIndex; attrBackground.EndIndex = selectedForeground.EndIndex; result.Add (attrBackground); }); } result.SetAttributes (); return result; }