This repository has been archived by the owner on Jul 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AWS Toolkit for Eclipse: v201712181839 Release.
- Loading branch information
zhangzhx
committed
Dec 18, 2017
1 parent
7f6ef6d
commit 676b728
Showing
88 changed files
with
4,852 additions
and
645 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
bundles/com.amazonaws.eclipse.core/src/com/amazonaws/eclipse/core/ansi/AnsiCommands.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.amazonaws.eclipse.core.ansi; | ||
|
||
//From Wikipedia, http://en.wikipedia.org/wiki/ANSI_escape_code | ||
public class AnsiCommands { | ||
public static final int COMMAND_ATTR_RESET = 0; // Reset / Normal (all attributes off) | ||
public static final int COMMAND_ATTR_INTENSITY_BRIGHT = 1; // Bright (increased intensity) or Bold | ||
public static final int COMMAND_ATTR_INTENSITY_FAINT = 2; // Faint (decreased intensity) (not widely supported) | ||
public static final int COMMAND_ATTR_ITALIC = 3; // Italic: on not widely supported. Sometimes treated as inverse. | ||
public static final int COMMAND_ATTR_UNDERLINE = 4; // Underline: Single | ||
public static final int COMMAND_ATTR_BLINK_SLOW = 5; // Blink: Slow (less than 150 per minute) | ||
public static final int COMMAND_ATTR_BLINK_FAST = 6; // Blink: Rapid (MS-DOS ANSI.SYS; 150 per minute or more; not widely supported) | ||
public static final int COMMAND_ATTR_NEGATIVE_ON = 7; // Image: Negative (inverse or reverse; swap foreground and background) | ||
public static final int COMMAND_ATTR_CONCEAL_ON = 8; // Conceal (not widely supported) | ||
public static final int COMMAND_ATTR_CROSSOUT_ON = 9; // Crossed-out (Characters legible, but marked for deletion. Not widely supported.) | ||
public static final int COMMAND_ATTR_UNDERLINE_DOUBLE = 21; // Bright/Bold: off or Underline: Double (bold off not widely supported, double underline hardly ever) | ||
public static final int COMMAND_ATTR_INTENSITY_NORMAL = 22; // Normal color or intensity (neither bright, bold nor faint) | ||
public static final int COMMAND_ATTR_ITALIC_OFF = 23; // Not italic, not Fraktur | ||
public static final int COMMAND_ATTR_UNDERLINE_OFF = 24; // Underline: None (not singly or doubly underlined) | ||
public static final int COMMAND_ATTR_BLINK_OFF = 25; // Blink: off | ||
public static final int COMMAND_ATTR_NEGATIVE_OFF = 27; // Image: Positive | ||
public static final int COMMAND_ATTR_CONCEAL_OFF = 28; // Reveal (conceal off) | ||
public static final int COMMAND_ATTR_CROSSOUT_OFF = 29; // Not crossed out | ||
|
||
// Extended colors. Next arguments are 5;<index_0_255> or 2;<red_0_255>;<green_0_255>;<blue_0_255> | ||
public static final int COMMAND_HICOLOR_FOREGROUND = 38; // Set text color | ||
public static final int COMMAND_HICOLOR_BACKGROUND = 48; // Set background color | ||
|
||
public static final int COMMAND_COLOR_FOREGROUND_RESET = 39; // Default text color | ||
public static final int COMMAND_COLOR_BACKGROUND_RESET = 49; // Default background color | ||
|
||
public static final int COMMAND_COLOR_FOREGROUND_FIRST = 30; // First text color | ||
public static final int COMMAND_COLOR_FOREGROUND_LAST = 37; // Last text color | ||
public static final int COMMAND_COLOR_BACKGROUND_FIRST = 40; // First background text color | ||
public static final int COMMAND_COLOR_BACKGROUND_LAST = 47; // Last background text color | ||
|
||
public static final int COMMAND_ATTR_FRAMED_ON = 51; // Framed | ||
public static final int COMMAND_ATTR_FRAMED_OFF = 54; // Not framed or encircled | ||
|
||
public static final int COMMAND_HICOLOR_FOREGROUND_FIRST = 90; // First text color | ||
public static final int COMMAND_HICOLOR_FOREGROUND_LAST = 97; // Last text color | ||
public static final int COMMAND_HICOLOR_BACKGROUND_FIRST = 100; // First background text color | ||
public static final int COMMAND_HICOLOR_BACKGROUND_LAST = 107; // Last background text color | ||
|
||
public static final int COMMAND_COLOR_INTENSITY_DELTA = 8; // Last background text color | ||
} |
170 changes: 170 additions & 0 deletions
170
...com.amazonaws.eclipse.core/src/com/amazonaws/eclipse/core/ansi/AnsiConsoleAttributes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
/** | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.amazonaws.eclipse.core.ansi; | ||
|
||
import org.eclipse.swt.SWT; | ||
import org.eclipse.swt.custom.StyleRange; | ||
import org.eclipse.swt.graphics.Color; | ||
import org.eclipse.swt.graphics.RGB; | ||
|
||
import com.amazonaws.eclipse.core.util.OsPlatformUtils; | ||
|
||
import static com.amazonaws.eclipse.core.ansi.AnsiCommands.*; | ||
|
||
public class AnsiConsoleAttributes implements Cloneable { | ||
public final static int UNDERLINE_NONE = -1; // nothing in SWT, a bit of an abuse | ||
|
||
public Integer currentBgColor; | ||
public Integer currentFgColor; | ||
public int underline; | ||
public boolean bold; | ||
public boolean italic; | ||
public boolean invert; | ||
public boolean conceal; | ||
public boolean strike; | ||
public boolean framed; | ||
|
||
public AnsiConsoleAttributes() { | ||
reset(); | ||
} | ||
|
||
public void reset() { | ||
currentBgColor = null; | ||
currentFgColor = null; | ||
underline = UNDERLINE_NONE; | ||
bold = false; | ||
italic = false; | ||
invert = false; | ||
conceal = false; | ||
strike = false; | ||
framed = false; | ||
} | ||
|
||
@Override | ||
public AnsiConsoleAttributes clone() { | ||
AnsiConsoleAttributes result = new AnsiConsoleAttributes(); | ||
result.currentBgColor = currentBgColor; | ||
result.currentFgColor = currentFgColor; | ||
result.underline = underline; | ||
result.bold = bold; | ||
result.italic = italic; | ||
result.invert = invert; | ||
result.conceal = conceal; | ||
result.strike = strike; | ||
result.framed = framed; | ||
return result; | ||
} | ||
|
||
public static Color hiliteRgbColor(Color c) { | ||
if (c == null) | ||
return new Color(null, new RGB(0xff, 0xff, 0xff)); | ||
int red = c.getRed() * 2; | ||
int green = c.getGreen() * 2; | ||
int blue = c.getBlue() * 2; | ||
|
||
if (red > 0xff) red = 0xff; | ||
if (green > 0xff) green = 0xff; | ||
if (blue > 0xff) blue = 0xff; | ||
|
||
return new Color(null, new RGB(red, green, blue)); // here | ||
} | ||
|
||
// This function maps from the current attributes as "described" by escape sequences to real, | ||
// Eclipse console specific attributes (resolving color palette, default colors, etc.) | ||
public static void updateRangeStyle(StyleRange range, AnsiConsoleAttributes attribute) { | ||
boolean useWindowsMapping = OsPlatformUtils.isWindows(); | ||
AnsiConsoleAttributes tempAttrib = attribute.clone(); | ||
|
||
boolean hilite = false; | ||
|
||
if (useWindowsMapping) { | ||
if (tempAttrib.bold) { | ||
tempAttrib.bold = false; // not supported, rendered as intense, already done that | ||
hilite = true; | ||
} | ||
if (tempAttrib.italic) { | ||
tempAttrib.italic = false; | ||
tempAttrib.invert = true; | ||
} | ||
tempAttrib.underline = UNDERLINE_NONE; // not supported on Windows | ||
tempAttrib.strike = false; // not supported on Windows | ||
tempAttrib.framed = false; // not supported on Windows | ||
} | ||
|
||
// Prepare the foreground color | ||
if (hilite) { | ||
if (tempAttrib.currentFgColor == null) { | ||
range.foreground = AnsiConsolePreferenceUtils.getDebugConsoleFgColor(); | ||
range.foreground = hiliteRgbColor(range.foreground); | ||
} else { | ||
if (tempAttrib.currentFgColor < COMMAND_COLOR_INTENSITY_DELTA) | ||
range.foreground = new Color(null, AnsiConsoleColorPalette.getColor(tempAttrib.currentFgColor + COMMAND_COLOR_INTENSITY_DELTA)); | ||
else | ||
range.foreground = new Color(null, AnsiConsoleColorPalette.getColor(tempAttrib.currentFgColor)); | ||
} | ||
} else { | ||
if (tempAttrib.currentFgColor != null) | ||
range.foreground = new Color(null, AnsiConsoleColorPalette.getColor(tempAttrib.currentFgColor)); | ||
} | ||
|
||
// Prepare the background color | ||
if (tempAttrib.currentBgColor != null) | ||
range.background = new Color(null, AnsiConsoleColorPalette.getColor(tempAttrib.currentBgColor)); | ||
|
||
// These two still mess with the foreground/background colors | ||
// We need to solve them before we use them for strike/underline/frame colors | ||
if (tempAttrib.invert) { | ||
if (range.foreground == null) | ||
range.foreground = AnsiConsolePreferenceUtils.getDebugConsoleFgColor(); | ||
if (range.background == null) | ||
range.background = AnsiConsolePreferenceUtils.getDebugConsoleBgColor(); | ||
Color tmp = range.background; | ||
range.background = range.foreground; | ||
range.foreground = tmp; | ||
} | ||
|
||
if (tempAttrib.conceal) { | ||
if (range.background == null) | ||
range.background = AnsiConsolePreferenceUtils.getDebugConsoleBgColor(); | ||
range.foreground = range.background; | ||
} | ||
|
||
range.font = null; | ||
range.fontStyle = SWT.NORMAL; | ||
// Prepare the rest of the attributes | ||
if (tempAttrib.bold) | ||
range.fontStyle |= SWT.BOLD; | ||
|
||
if (tempAttrib.italic) | ||
range.fontStyle |= SWT.ITALIC; | ||
|
||
if (tempAttrib.underline != UNDERLINE_NONE) { | ||
range.underline = true; | ||
range.underlineColor = range.foreground; | ||
range.underlineStyle = tempAttrib.underline; | ||
} | ||
else | ||
range.underline = false; | ||
|
||
range.strikeout = tempAttrib.strike; | ||
range.strikeoutColor = range.foreground; | ||
|
||
if (tempAttrib.framed) { | ||
range.borderStyle = SWT.BORDER_SOLID; | ||
range.borderColor = range.foreground; | ||
} | ||
else | ||
range.borderStyle = SWT.NONE; | ||
} | ||
} |
Oops, something went wrong.