Skip to content

Compute foreground and background colours for setEnabled and setEditable in StyledText#3154

Open
elsazac wants to merge 1 commit intoeclipse-platform:masterfrom
elsazac:StyledTextenhancement
Open

Compute foreground and background colours for setEnabled and setEditable in StyledText#3154
elsazac wants to merge 1 commit intoeclipse-platform:masterfrom
elsazac:StyledTextenhancement

Conversation

@elsazac
Copy link
Copy Markdown
Member

@elsazac elsazac commented Mar 27, 2026

This PR adds consistent handling of both foreground and background colors for both setEnabled and setEditable functions

The foreground and background colors were computed only for setEnabled. This has to be done for setEditable as
well to achieve consistency. Both the functions setEditable and setEnabled now recomputes foreground and background colour (earlier only applied in setEnabled)
This commit also adds a distinct foreground and background colour combination. Earlier the editable and non-editable state showed no difference. This now improves visual differentiation in StyledText.

Test Snippet : Test.txt

The StyledText behaviour in non editable state is shown below :

Before :
image

After :
image

Fixes: #3132, Fixes: #230

@elsazac elsazac force-pushed the StyledTextenhancement branch from 8363d1c to 18583c9 Compare March 27, 2026 15:03
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 27, 2026

Test Results

  170 files  ±0    170 suites  ±0   27m 38s ⏱️ + 1m 14s
4 678 tests ±0  4 657 ✅ ±0   21 💤 ±0  0 ❌ ±0 
6 586 runs  ±0  6 431 ✅ ±0  155 💤 ±0  0 ❌ ±0 

Results for commit 032bd55. ± Comparison against base commit b829b31.

♻️ This comment has been updated with latest results.

@elsazac elsazac force-pushed the StyledTextenhancement branch 2 times, most recently from 67d983f to d4c145b Compare March 30, 2026 06:20
@BeckerWdf
Copy link
Copy Markdown
Member

Does this still work fine when CSS styling is used in the IDE?

@sratz
Copy link
Copy Markdown
Member

sratz commented Mar 30, 2026

This is going to resolve, #230, correct?

@iloveeclipse iloveeclipse requested a review from Copilot March 30, 2026 07:36
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes StyledText apply consistent foreground/background color recomputation for both setEnabled(...) and setEditable(...), and introduces a distinct visual style for the non-editable (but enabled) state.

Changes:

  • Added a shared updateColors(enabled, editable) helper and invoked it from both setEnabled and setEditable.
  • Introduced new system color choices for the enabled-but-non-editable state to improve visual differentiation.
  • Guarded resetCache(...) / caret recomputation in setBackground/setForeground when content is not yet initialized.

setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DISABLED_FOREGROUND));
} else if (!editable) {
if (!customBackground)
setBackground(display.getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SWT.COLOR_TITLE_INACTIVE_BACKGROUND is semantically a title-bar color and can render inconsistently across platforms/themes when used as a text background. For an enabled-but-non-editable text area, consider using text/widget-related system colors (or a derived variant of the normal text background) to better track platform theming and maintain consistent look-and-feel.

Suggested change
setBackground(display.getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));

Copilot uses AI. Check for mistakes.
@elsazac elsazac force-pushed the StyledTextenhancement branch from d4c145b to e2635ea Compare March 30, 2026 09:57
@elsazac
Copy link
Copy Markdown
Member Author

elsazac commented Mar 30, 2026

Both editable and enabled are true :

Screenshot 2026-03-30 at 3 21 51 PM

When editable is true and enabled is false :

image

When editable is false and enabled is true :

image

when editable and enabled are both false :

image

@elsazac
Copy link
Copy Markdown
Member Author

elsazac commented Mar 30, 2026

This is going to resolve, #230, correct?

The enabled case wasn’t handled earlier, but it is now covered with most recent changes
Screenshot 2026-03-30 at 3 30 10 PM

@elsazac elsazac force-pushed the StyledTextenhancement branch from e2635ea to 3e90179 Compare March 31, 2026 18:27
This commit adds the foreground and background color computation for
setEditable. Earlier this was handled only for setEnabled. This commit
also adds a different foreground and background color for StyledText
when background is not editable.

Fixes :eclipse-platform#3132
@elsazac elsazac force-pushed the StyledTextenhancement branch from 3e90179 to 032bd55 Compare March 31, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants