Skip to content
This repository has been archived by the owner on Apr 3, 2018. It is now read-only.

Commit

Permalink
LANG: support for dark theme. prefs constants refactoring.
Browse files Browse the repository at this point in the history
Fixes #131
  • Loading branch information
bruno-medeiros committed Sep 23, 2015
1 parent b037b35 commit 2905f60
Show file tree
Hide file tree
Showing 20 changed files with 156 additions and 104 deletions.
4 changes: 4 additions & 0 deletions documentation/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
## release ChangeLog

### (NextVersion)
* Added support for Eclipse dark theme (#131). Namely:
* Syntax/source coloring now have different settings for dark theme.
* Fixed tools console colors, as well as content assist pop-up colors.

* Fixed: Unindent (Shift-Tab) broken, does nothing after empty lines in selection.
* Fixed Outline broken, due to error "CommonException: Invalid line, out of bounds". (#156)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@
package melnorme.lang.ide.ui.editor.text;

import static melnorme.utilbox.core.Assert.AssertNamespace.assertTrue;
import melnorme.lang.ide.core.text.BlockHeuristicsScannner;
import melnorme.lang.ide.core.text.SamplePartitionScanner;
import melnorme.lang.ide.core.text.Scanner_BaseTest;
import melnorme.lang.ide.ui.CodeFormatterConstants;
import melnorme.lang.ide.ui.CodeFormatterConstants.IndentMode;
import melnorme.lang.ide.ui.editor.text.LangAutoEditPreferenceConstants;
import melnorme.lang.ide.ui.editor.text.LangAutoEditStrategy;
import melnorme.lang.ide.ui.text.util.LangAutoEditUtils;
import melnorme.utilbox.misc.MiscUtil;

import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document;
Expand All @@ -29,6 +20,15 @@
import org.eclipse.swt.SWT;
import org.junit.Test;

import melnorme.lang.ide.core.text.BlockHeuristicsScannner;
import melnorme.lang.ide.core.text.SamplePartitionScanner;
import melnorme.lang.ide.core.text.Scanner_BaseTest;
import melnorme.lang.ide.ui.CodeFormatterConstants;
import melnorme.lang.ide.ui.CodeFormatterConstants.IndentMode;
import melnorme.lang.ide.ui.LangAutoEditPreferenceConstants;
import melnorme.lang.ide.ui.text.util.LangAutoEditUtils;
import melnorme.utilbox.misc.MiscUtil;

public class LangAutoEditStrategyTest extends Scanner_BaseTest {

public static final String NEUTRAL_SRCX;
Expand Down
8 changes: 8 additions & 0 deletions plugin_ide.ui/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -618,4 +618,12 @@
</shortcut>
</extension>

<!-- ============ Dark Theme ============= -->

<extension point="org.eclipse.e4.ui.css.swt.theme">
<stylesheet uri="/resources/e4-dark_sourcehighlighting.css">
<themeid refid="org.eclipse.e4.ui.css.theme.e4_dark" />
</stylesheet>
</extension>

</plugin>
45 changes: 45 additions & 0 deletions plugin_ide.ui/resources/e4-dark_sourcehighlighting.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*******************************************************************************
* Copyright (c) 2015 Bruno Medeiros and other Contributors.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Bruno Medeiros - initial API and implementation
*******************************************************************************/

IEclipsePreferences#com-googlecode-goclipse-ui {
preferences:

'syntax_highlighting_text=255,255,255'
'syntax_highlighting_keyword=127,0,85'
'syntax_highlighting_value=127,0,85'
'syntax_highlighting_primitive=127,0,85'
'syntax_highlighting_builtin_function=255,255,255'
'syntax_highlighting_operator=255,255,255'
'syntax_highlighting_syntax_chars=255,255,255'

'syntax_highlighting_character=0,75,200'
'syntax_highlighting_string=0,75,200'
'syntax_highlighting_multiline_string=230,75,0'

'syntax_highlighting_comment=63,127,95'


'matchingBracketsColor=102,112,125'

'content_assist_proposals_background=52,57,61'
'content_assist_proposals_foreground=238,238,238'
'content_assist_parameters_background=52,57,61'
'content_assist_parameters_foreground=238,238,238'


/* Console colors */

'console.info_color=150,190,220'
'console.stderr_color=255,0,0'
'console.stdout_color=255,255,255'
'console.background_color=0,215,0' /* Not actually used */

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@
*******************************************************************************/
package _org.eclipse.jdt.internal.ui.text.java.hover;

import melnorme.lang.ide.core.text.LangDocumentPartitionerSetup;
import melnorme.lang.ide.ui.EditorPreferences;
import melnorme.lang.ide.ui.EditorSettings_Actual;
import melnorme.lang.ide.ui.LangUIPlugin;
import melnorme.lang.ide.ui.editor.LangSourceViewer;

import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
Expand Down Expand Up @@ -52,6 +46,11 @@
import org.eclipse.ui.texteditor.AbstractTextEditor;

import _org.eclipse.cdt.ui.text.IColorManager;
import melnorme.lang.ide.core.text.LangDocumentPartitionerSetup;
import melnorme.lang.ide.ui.EditorSettings_Actual;
import melnorme.lang.ide.ui.EditorSettings_Actual.EditorPrefConstants;
import melnorme.lang.ide.ui.LangUIPlugin;
import melnorme.lang.ide.ui.editor.LangSourceViewer;

/**
* Source viewer based implementation of <code>IInformationControl</code>.
Expand Down Expand Up @@ -249,10 +248,10 @@ protected static RGB blend(RGB bg, RGB fg, float factor) {
protected void initializeColors() {
IPreferenceStore store= LangUIPlugin.getInstance().getPreferenceStore();
RGB bgRGB;
if (store.getBoolean(EditorPreferences.SOURCE_HOVER_BACKGROUND_COLOR_UseSystemDefault.key)) {
if (store.getBoolean(EditorPrefConstants.SOURCE_HOVER_BACKGROUND_COLOR_UseSystemDefault.key)) {
bgRGB= getVisibleBackgroundColor(fShell.getDisplay());
} else {
bgRGB= PreferenceConverter.getColor(store, EditorPreferences.SOURCE_HOVER_BACKGROUND_COLOR_rgb.key);
bgRGB= PreferenceConverter.getColor(store, EditorPrefConstants.SOURCE_HOVER_BACKGROUND_COLOR_rgb.key);
}
if (bgRGB != null) {
fBackgroundColor= new Color(fShell.getDisplay(), bgRGB);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2014, 2014 Bruno Medeiros and other Contributors.
* Copyright (c) 2015 Bruno Medeiros and other Contributors.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand All @@ -12,28 +12,26 @@

import melnorme.lang.ide.core.utils.prefs.BooleanPreference;



public interface LangAutoEditPreferenceConstants_Actual {
interface LangAutoEditPreferenceConstants_Default {

public static final String QUALIFIER = LangUIPlugin.PLUGIN_ID;

BooleanPreference AE_CLOSE_STRINGS =
public static BooleanPreference AE_CLOSE_STRINGS =
new BooleanPreference(QUALIFIER, "EDITOR_CLOSE_STRINGS", true);
BooleanPreference AE_CLOSE_BRACKETS =
public static BooleanPreference AE_CLOSE_BRACKETS =
new BooleanPreference(QUALIFIER, "EDITOR_CLOSE_BRACKETS", true);
BooleanPreference AE_CLOSE_BRACES =
public static BooleanPreference AE_CLOSE_BRACES =
new BooleanPreference(QUALIFIER, "EDITOR_CLOSE_BRACES", true);

BooleanPreference AE_SMART_INDENT =
public static BooleanPreference AE_SMART_INDENT =
new BooleanPreference(QUALIFIER, "autoedit.editorSmartIndent", true);
BooleanPreference AE_SMART_DEINDENT =
public static BooleanPreference AE_SMART_DEINDENT =
new BooleanPreference(QUALIFIER, "autoedit.smart_deindent", true);
BooleanPreference AE_PARENTHESES_AS_BLOCKS =
public static BooleanPreference AE_PARENTHESES_AS_BLOCKS =
new BooleanPreference(QUALIFIER, "autoedit.parentheses_as_blocks", true);

// Not used currently?
BooleanPreference AE_SMART_PASTE =
public static BooleanPreference AE_SMART_PASTE =
new BooleanPreference(QUALIFIER, "autoedit.smartPaste", true);

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
package melnorme.lang.ide.ui;


import melnorme.lang.ide.ui.EditorSettings_Actual.EditorPrefConstants;

import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.StringConverter;
import org.eclipse.swt.graphics.RGB;

import melnorme.lang.ide.ui.EditorSettings_Actual.EditorPrefConstants;

public abstract class LangUIPreferencesInitializer extends AbstractPreferenceInitializer
implements EditorPrefConstants, ContentAssistConstants {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
*******************************************************************************/
package melnorme.lang.ide.ui.editor.text;

import org.eclipse.swt.graphics.RGB;

import melnorme.lang.ide.core.utils.prefs.BooleanPreference;
import melnorme.lang.ide.ui.LangUIPlugin;
import melnorme.lang.ide.ui.EditorSettings_Actual.EditorPrefConstants;
import melnorme.lang.ide.ui.preferences.ColorPreference;

/**
* This interface should not be accessed by name directly,
Expand All @@ -19,15 +24,16 @@
*/
public interface EditorPrefConstants_Common {

String MATCHING_BRACKETS= "matchingBrackets";
String MATCHING_BRACKETS_COLOR= "matchingBracketsColor";
String HIGHLIGHT_BRACKET_AT_CARET_LOCATION= "highlightBracketAtCaretLocation";
String MATCHING_BRACKETS = "editor.matchingBrackets";
String MATCHING_BRACKETS_COLOR = "editor.matchingBracketsColor";
String HIGHLIGHT_BRACKET_AT_CARET_LOCATION = "editor.highlightBracketAtCaretLocation";
String ENCLOSING_BRACKETS = "editor.enclosingBrackets";


BooleanPreference SOURCE_HOVER_BACKGROUND_COLOR_UseSystemDefault =
new BooleanPreference(LangUIPlugin.PLUGIN_ID, "SourceHover.bg_color.useSystemDefault", true);

/**
* Preference key for enclosing brackets.
*
* @since 3.8
*/
String ENCLOSING_BRACKETS= "enclosingBrackets";
ColorPreference SOURCE_HOVER_BACKGROUND_COLOR_rgb =
new ColorPreference(LangUIPlugin.PLUGIN_ID, "SourceHover.bg_color.rgb", new RGB(255, 255, 255));

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import static melnorme.utilbox.core.CoreUtil.array;
import melnorme.lang.ide.core.text.BlockHeuristicsScannner;
import melnorme.lang.ide.core.text.BlockHeuristicsScannner.BlockTokenRule;
import melnorme.lang.ide.ui.LangAutoEditPreferenceConstants;
import melnorme.utilbox.misc.ArrayUtil;

import org.eclipse.jface.text.BadLocationException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import melnorme.lang.ide.ui.CodeFormatterConstants;
import melnorme.lang.ide.ui.CodeFormatterConstants.IndentMode;
import melnorme.lang.ide.ui.LangAutoEditPreferenceConstants;
import melnorme.lang.ide.ui.text.util.AutoEditUtils;

// Originally was RubyPreferencesInterpreter from DLTK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,23 @@
*******************************************************************************/
package melnorme.lang.ide.ui.preferences;

import melnorme.lang.ide.core.utils.prefs.PreferenceHelper;
import melnorme.lang.ide.core.utils.prefs.PreferencesLookupHelper;
import melnorme.util.swt.jface.text.ColorManager;

import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.jface.resource.StringConverter;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;

import melnorme.lang.ide.core.utils.prefs.PreferenceHelper;
import melnorme.lang.ide.core.utils.prefs.PreferencesLookupHelper;
import melnorme.lang.ide.ui.LangUIPlugin;
import melnorme.util.swt.jface.text.ColorManager;

/**
* Helper to work with a color preference.
*/
public class ColorPreference extends PreferenceHelper<RGB> {

public ColorPreference(String key, RGB defaultValue) {
super(key, defaultValue);
super(LangUIPlugin.PLUGIN_ID, key, defaultValue);
}
public ColorPreference(String pluginId, String key, RGB defaultValue) {
super(pluginId, key, defaultValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@
* Contributors:
* IBM Corporation - initial API and implementation (JDT)
* DLTK team ? - DLTK modifications
* Bruno Medeiros - Lang modifications
* Bruno Medeiros - Lang rewrite
*******************************************************************************/
package melnorme.lang.ide.ui.preferences;

import melnorme.lang.ide.ui.ContentAssistConstants;
import melnorme.lang.ide.ui.EditorSettings_Actual.EditorPrefConstants;
import melnorme.lang.ide.ui.preferences.EditorAppearanceColorsComponent.EditorColorItem;
import melnorme.lang.ide.ui.preferences.common.AbstractComponentsPrefPage;
import melnorme.lang.ide.ui.preferences.common.AbstractPreferencesBlock;
import melnorme.util.swt.components.fields.CheckBoxField;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;

//originally from DLTK version 5.0.0
public class LangEditorConfigurationBlock extends AbstractPreferencesBlock {

public LangEditorConfigurationBlock(AbstractComponentsPrefPage mainPreferencePage) {
Expand All @@ -36,6 +39,10 @@ protected void createContents(Composite topControl) {
}

protected void createAppearanceGroup(Composite parent) {
createBooleanField(parent,
EditorPrefConstants.MATCHING_BRACKETS,
new CheckBoxField(PreferencesMessages.EditorPreferencePage_matchingBrackets));

createEditorAppearanceColorsComponent(parent);
}

Expand All @@ -50,7 +57,22 @@ protected void createEditorAppearanceColorsComponent(Composite parent) {
}

protected EditorColorItem[] createEditorAppearanceColorEntries() {
return new EditorColorItem[] { };
return new EditorColorItem[] {
new EditorColorItem(
PreferencesMessages.EditorPreferencePage_matchingBracketsHighlightColor,
EditorPrefConstants.MATCHING_BRACKETS_COLOR),
new EditorColorItem(
PreferencesMessages.EditorPreferencePage_backgroundForMethodParameters,
ContentAssistConstants.PARAMETERS_BACKGROUND),
new EditorColorItem(
PreferencesMessages.EditorPreferencePage_foregroundForMethodParameters,
ContentAssistConstants.PARAMETERS_FOREGROUND),
new EditorColorItem(
PreferencesMessages.EditorPreferencePage_sourceHoverBackgroundColor,
EditorPrefConstants.SOURCE_HOVER_BACKGROUND_COLOR_rgb.key,
EditorPrefConstants.SOURCE_HOVER_BACKGROUND_COLOR_UseSystemDefault.key,
SWT.COLOR_INFO_BACKGROUND),
};
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@

import static melnorme.utilbox.core.CoreUtil.areEqual;
import static melnorme.utilbox.core.CoreUtil.array;

import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.swt.widgets.Composite;

import melnorme.lang.ide.ui.CodeFormatterConstants;
import melnorme.lang.ide.ui.editor.text.LangAutoEditPreferenceConstants;
import melnorme.lang.ide.ui.LangAutoEditPreferenceConstants;
import melnorme.lang.ide.ui.preferences.common.AbstractComponentsPrefPage;
import melnorme.lang.ide.ui.preferences.common.AbstractPreferencesBlock;
import melnorme.util.swt.components.fields.CheckBoxField;
Expand All @@ -22,9 +26,6 @@
import melnorme.utilbox.core.DevelopmentCodeMarkers;
import melnorme.utilbox.fields.IFieldValueListener;

import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.swt.widgets.Composite;

public class LangEditorTypingConfigurationBlock extends AbstractPreferencesBlock {

public LangEditorTypingConfigurationBlock(AbstractComponentsPrefPage prefPage) {
Expand Down
Loading

0 comments on commit 2905f60

Please sign in to comment.