protected void DisplaySelectedRow()

in src/common/details/console/gui/controls/TextViewerControl.cs [121:181]


        protected void DisplaySelectedRow(int row)
        {
            var text = GetDisplayText(row);

            var selX1 = SelectedColumn;
            var selX2 = selX1 + SelectedColumnWidth - 1;

            var normal = Colors;
            var highlight = SelectedColors;
            var error = ColorHelpers.GetErrorColors(normal.Foreground, normal.Background);

            var highlightOn = false;

            var x = 0;
            var cchSkips = 0;
            var cchSelected = 0;
            for (int i = 0; i < text.Length; i++)
            {
                if (text[i] == '`')
                {
                    cchSkips++;
                    if (!highlightOn && i + 1 < text.Length && text[i + 1] == '#')
                    {
                        var at = text.IndexOf(';', i + 1);
                        if (at > 0)
                        {
                            i = at;
                        }
                    }
                    highlightOn = !highlightOn;
                    continue;
                }

                if (i < ColumnOffset) continue;

                var selectedOn = (i - cchSkips) >= selX1 && (i - cchSkips) <= selX2;
                if (selectedOn) cchSelected++;

                if (selectedOn && highlightOn)
                {
                    WriteClientChar(error, x++, row, text[i]);
                }
                else if (selectedOn || highlightOn)
                {
                    WriteClientChar(highlight, x++, row, text[i]);
                }
                else
                {
                    WriteClientChar(normal, x++, row, text[i]);
                }
            }

            if (x < ClientRect.Width)
            {
                if (cchSelected == 0 && SelectedColumnWidth > 0)
                {
                    WriteClientChar(SelectedColors, x++, row, ' ');
                }
                WriteClientChar(Colors, x, row, ' ', ClientRect.Width - x);
            }
        }