Ejemplo n.º 1
0
        public void DrawCaret(Context ctx, Rectangle area)
        {
            if (!caretBlink || HexEditorData.IsSomethingSelected)
            {
                return;
            }
            long   caretY = HexEditorData.Caret.Line * LineHeight - (long)HexEditorData.VAdjustment.Value;
            double caretX;
            char   ch;

            if (HexEditorData.Caret.InTextEditor)
            {
                caretX = textEditorMargin.CalculateCaretXPos(out ch);
            }
            else
            {
                caretX = hexEditorMargin.CalculateCaretXPos(out ch);
            }

            if (!area.Contains(caretX, (int)caretY))
            {
                return;
            }

            if (HexEditorData.Caret.IsInsertMode)
            {
                ctx.Rectangle(caretX, (int)caretY, 2, LineHeight);
            }
            else
            {
                ctx.Rectangle(caretX, (int)caretY, textEditorMargin.charWidth, LineHeight);
            }

            ctx.SetColor(HexEditorStyle.HexDigit);
            ctx.Fill();

            if (!HexEditorData.Caret.IsInsertMode)
            {
                using (var layout = new TextLayout(this)) {
                    layout.Font = Options.Font;
                    layout.Text = ch.ToString();
                    ctx.SetColor(HexEditorStyle.HexDigitBg);
                    ctx.DrawTextLayout(layout, caretX, caretY);
                }
            }
        }
Ejemplo n.º 2
0
        public void DrawCaret(Gdk.Drawable win, Gdk.Rectangle area)
        {
            if (Settings.Default.CursorBlink && !caretBlink || HexEditorData.IsSomethingSelected)
            {
                return;
            }
            if (caretGc == null)
            {
                caretGc            = new Gdk.GC(win);
                caretGc.RgbFgColor = new Color(255, 255, 255);
                caretGc.Function   = Gdk.Function.Xor;
            }
            long caretY = HexEditorData.Caret.Line * LineHeight - (long)HexEditorData.VAdjustment.Value;
            int  caretX;

            if (HexEditorData.Caret.InTextEditor)
            {
                caretX = textEditorMargin.CalculateCaretXPos();
            }
            else
            {
                caretX = hexEditorMargin.CalculateCaretXPos();
            }

            if (!area.Contains(caretX, (int)caretY))
            {
                return;
            }

            if (HexEditorData.Caret.IsInsertMode)
            {
                win.DrawRectangle(caretGc, true, new Gdk.Rectangle(caretX, (int)caretY, 2, LineHeight));
            }
            else
            {
                win.DrawRectangle(caretGc, true, new Gdk.Rectangle(caretX, (int)caretY, textEditorMargin.charWidth, LineHeight));
            }
        }