-
Notifications
You must be signed in to change notification settings - Fork 149
Make Terminal operate on and cache colors instead of RGB values #2481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,6 @@ | |
| import org.eclipse.swt.graphics.GC; | ||
| import org.eclipse.swt.graphics.Image; | ||
| import org.eclipse.swt.graphics.Point; | ||
| import org.eclipse.swt.graphics.RGB; | ||
| import org.eclipse.terminal.connector.Logger; | ||
| import org.eclipse.terminal.internal.control.impl.TerminalPlugin; | ||
| import org.eclipse.terminal.model.ITerminalTextDataReadOnly; | ||
|
|
@@ -86,8 +85,8 @@ public void drawLine(ITextCanvasModel model, GC gc, int line, int x, int y, int | |
| int colStart = line == hsStart.y ? hsStart.x : 0; | ||
| int colEnd = line == hsEnd.y ? hsEnd.x : getTerminalText().getWidth(); | ||
| if (colStart < colEnd) { | ||
| RGB defaultFg = fStyleMap.getForegrondRGB(null); | ||
| doubleBufferGC.setForeground(new Color(doubleBufferGC.getDevice(), defaultFg)); | ||
| Color defaultFg = fStyleMap.getForegroundColor(null); | ||
| doubleBufferGC.setForeground(defaultFg); | ||
|
Comment on lines
+88
to
+89
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as we have This would prevent repeating the code used here and in setupGC
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not a repetition as here it's about the default color (style == null) and in setupGC its the style-specific color. We can of course introduce additional methods like |
||
| drawUnderline(doubleBufferGC, colStart, colEnd); | ||
| } | ||
| } | ||
|
|
@@ -133,8 +132,7 @@ private void fillBackground(GC gc, int x, int y, int width, int height) { | |
|
|
||
| @Override | ||
| public Color getDefaultBackgroundColor() { | ||
| RGB backgroundRGB = fStyleMap.getBackgroundRGB(null); | ||
| return new Color(backgroundRGB); | ||
| return fStyleMap.getBackgroundColor(null); | ||
| } | ||
|
|
||
| private void drawCursor(ITextCanvasModel model, GC gc, int row, int x, int y, int colFirst) { | ||
|
|
@@ -196,10 +194,10 @@ private void drawUnderline(GC gc, int colStart, int colEnd) { | |
| } | ||
|
|
||
| private void setupGC(GC gc, TerminalStyle style) { | ||
| RGB foregrondColor = fStyleMap.getForegrondRGB(style); | ||
| gc.setForeground(new Color(gc.getDevice(), foregrondColor)); | ||
| RGB backgroundColor = fStyleMap.getBackgroundRGB(style); | ||
| gc.setBackground(new Color(gc.getDevice(), backgroundColor)); | ||
| Color foregroundColor = fStyleMap.getForegroundColor(style); | ||
| gc.setForeground(foregroundColor); | ||
| Color backgroundColor = fStyleMap.getBackgroundColor(style); | ||
| gc.setBackground(backgroundColor); | ||
|
|
||
| Font f = fStyleMap.getFont(style); | ||
| if (f != gc.getFont()) { | ||
|
|
@@ -217,7 +215,7 @@ public void updateFont(String fontName) { | |
| } | ||
|
|
||
| @Override | ||
| public void updateColors(Map<TerminalColor, RGB> map) { | ||
| public void updateColors(Map<TerminalColor, Color> map) { | ||
| fStyleMap.updateColors(map); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here as well ...