Alsing.Windows.Forms.SyntaxBox.Painter.NativePainter.RenderCaret C# (CSharp) Method

RenderCaret() private method

private RenderCaret ( int RowIndex, int ypos ) : void
RowIndex int
ypos int
return void
        private void RenderCaret(int RowIndex, int ypos)
        {
            int StartRow = -1;
            int cr = Control.Caret.Position.Y;

            if (cr >= 0 && cr <= Control.Document.Count - 1)
            {
                Row r = Control.Document[cr];
                if (r.expansion_EndSpan != null)
                {
                    if (r.expansion_EndSpan.Expanded == false)
                    {
                        r = r.expansion_EndSpan.StartRow;
                        StartRow = r.Index;
                    }
                }
            }

            bool Collapsed = (RowIndex == StartRow);


            if (RowIndex != cr && RowIndex != StartRow)
                return;

            if (Control.View.Action == EditAction.DragText)
            {
                //drop Control.Caret
                Row xtr = Control.Document[cr];

                int pos = MeasureRow(xtr, Control.Caret.Position.X).Width + 1;

                if (Collapsed)
                {
                    pos += xtr.Expansion_PixelStart;
                    pos -= MeasureRow(xtr, xtr.Expansion_StartChar).Width;
                }

                GFX.BackBuffer.InvertRect(pos + Control.View.TextMargin - Control.View.ClientAreaStart - 1, 0, 3, Control.View.RowHeight);
                GFX.BackBuffer.InvertRect(pos + Control.View.TextMargin - Control.View.ClientAreaStart, 1, 1, Control.View.RowHeight - 2);
            }
            else
            {
                //normal Control.Caret

                Row xtr = Control.Document[cr];
                if (!Control.OverWrite)
                {
                    int pos = Control.View.TextMargin - Control.View.ClientAreaStart;
                    pos += MeasureRow(xtr, Control.Caret.Position.X).Width + 1;
                    if (Collapsed)
                    {
                        pos += xtr.Expansion_PixelStart;
                        pos -= MeasureRow(xtr, xtr.Expansion_StartChar).Width;
                    }

                    int wdh = Control.View.CharWidth/12 + 1;
                    if (wdh < 2)
                        wdh = 2;

                    if (Control.Caret.Blink)
                    {
                        GFX.BackBuffer.InvertRect(pos, 0, wdh, Control.View.RowHeight);
                    }

                    if (Control.IMEWindow == null)
                    {
                        Control.IMEWindow = new IMEWindow(Control.Handle, Control.FontName, Control.FontSize);
                        InitIMEWindow();
                    }
                    Control.IMEWindow.Loation = new Point(pos, ypos);
                }
                else
                {
                    int pos1 = MeasureRow(xtr, Control.Caret.Position.X).Width;
                    int pos2 = MeasureRow(xtr, Control.Caret.Position.X + 1).Width;
                    int wdh = pos2 - pos1;
                    if (Collapsed)
                    {
                        pos1 += xtr.Expansion_PixelStart;
                        pos1 -= MeasureRow(xtr, xtr.Expansion_StartChar).Width;
                    }

                    int pos = pos1 + Control.View.TextMargin - Control.View.ClientAreaStart;
                    if (Control.Caret.Blink)
                    {
                        GFX.BackBuffer.InvertRect(pos, 0, wdh, Control.View.RowHeight);
                    }
                    Control.IMEWindow.Loation = new Point(pos, ypos);
                }
            }
        }

Same methods

NativePainter::RenderCaret ( Graphics g ) : void