Skip to content

TextView does not allow changing of read-only text background #4069

@Error-String-Expected-Got-Nil

Description

Non-standard bug report format because I'm not entirely sure this is a bug, but would be surprised if it isn't. I've already found the offending code snippet, but want to check this is actually a bug before making a PR or anything.

In TextView:

Attribute? cellAttribute = line [idxCol].Attribute is { } ? line [idxCol].Attribute : ColorScheme?.Disabled;
Attribute attribute;
if (cellAttribute!.Value.Foreground == cellAttribute.Value.Background)
{
attribute = new (cellAttribute.Value.Foreground, cellAttribute.Value.Background);
}
else
{
attribute = new (cellAttribute.Value.Foreground, ColorScheme!.Focus.Background);
}
SetAttribute (attribute);

This is in the OnDrawReadOnlyColor() method, which fires when drawing read-only text. This triggers the DrawReadOnlyColor event, which allows you to modify the attributes of drawn Cells to change the color.

The problem is that this leaves no way to manually set both the foreground and background colors at the same time: If they are different, the foreground will be kept, but the background will be set to correspond with the TextView's ColorScheme. If they are the same, you can change the background color, but then of course the text is illegible.

The other color selection methods simply check if the attribute was null, set it to a default if it was, and use it as-is otherwise. I'm not sure why that isn't the case here as well, and it doesn't feel like this is intentional, as it means the only way to change the read only text color is to derive the class and override the function, which isn't necessary for any other color choices.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Status

    ✅ Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions