Skip to content

ColorScheme.SetAttribute is defunct #2286

@tig

Description

@tig

Current code:

		bool preparingScheme = false;

		Attribute SetAttribute (Attribute attribute, [CallerMemberName] string callerMemberName = null)
		{
			if (!Application._initialized && !preparingScheme)
				return attribute;

			if (preparingScheme)
				return attribute;

			preparingScheme = true;

			switch (caller) {
			case "TopLevel":
				switch (callerMemberName) {
				case "Normal":
					HotNormal = Application.Driver.MakeAttribute (HotNormal.Foreground, attribute.Background);
					break;
				case "Focus":
					HotFocus = Application.Driver.MakeAttribute (HotFocus.Foreground, attribute.Background);
					break;
....
			}
			preparingScheme = false;
			return attribute;
		}

Shouldn't preparingCode be a lock?

While I'm here, the logic in the switch statement has always confused me. I do not understand the intent! It seems arbitrary to be making style decisions in code like this. Can anyone explain clearly?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions