HTMLEditorKit

This commit is contained in:
Konstantin Bulenkov
2012-11-20 14:21:45 +01:00
parent 873f17d9d2
commit eba7b41d45
2 changed files with 383 additions and 2 deletions
@@ -23,15 +23,18 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.ColorUtil;
import com.intellij.util.containers.hash.HashMap;
import org.jetbrains.annotations.NotNull;
import sun.awt.AppContext;
import javax.swing.*;
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.IconUIResource;
import javax.swing.plaf.InsetsUIResource;
import javax.swing.plaf.basic.BasicLookAndFeel;
import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.StyleSheet;
import java.awt.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.*;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Properties;
@@ -80,6 +83,7 @@ public final class DarculaLaf extends BasicLookAndFeel {
final UIDefaults defaults = (UIDefaults)superMethod.invoke(base);
LafManagerImpl.initInputMapDefaults(defaults);
initIdeaDefaults(defaults);
//patchStyledEditorKit();
return defaults;
}
catch (Exception ignore) {
@@ -88,6 +92,22 @@ public final class DarculaLaf extends BasicLookAndFeel {
return super.getDefaults();
}
private void patchStyledEditorKit() {
try {
StyleSheet defaultStyles = new StyleSheet();
InputStream is = DarculaLaf.class.getResourceAsStream("darcula.css");
Reader r = new BufferedReader(new InputStreamReader(is, "UTF-8"));
defaultStyles.loadRules(r, null);
r.close();
final Field keyField = HTMLEditorKit.class.getDeclaredField("DEFAULT_STYLES_KEY");
keyField.setAccessible(true);
final Object key = keyField.get(null);
AppContext.getAppContext().put(key, defaultStyles);
} catch (Exception e) {
log(e);
}
}
private void call(String method) {
try {
final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod(method);
@@ -0,0 +1,361 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* 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.
*/
body {
background: #3c3f41;
font-size: 14pt;
font-family: Serif;
font-weight: normal;
margin-left: 0;
margin-right: 0;
color: #bbbbbb
}
p {
margin-top: 15
}
h1 {
font-size: x-large;
font-weight: bold;
margin-top: 10;
margin-bottom: 10
}
h2 {
font-size: large;
font-weight: bold;
margin-top: 10;
margin-bottom: 10
}
h3 {
font-size: medium;
font-weight: bold;
margin-top: 10;
margin-bottom: 10
}
h4 {
font-size: small;
font-weight: bold;
margin-top: 10;
margin-bottom: 10
}
h5 {
font-size: x-small;
font-weight: bold;
margin-top: 10;
margin-bottom: 10
}
h6 {
font-size: xx-small;
font-weight: bold;
margin-top: 10;
margin-bottom: 10
}
li p {
margin-top: 0;
margin-bottom: 0
}
td p {
margin-top: 0
}
menu li p {
margin-top: 0;
margin-bottom: 0
}
menu li {
margin-left: 0;
margin-right: 0;
margin-top: 0;
margin-bottom: 0
}
menu {
margin-left-ltr: 40;
margin-right-rtl: 40;
margin-top: 10;
margin-bottom: 10
}
dir li p {
margin-top: 0;
margin-bottom: 0
}
dir li {
margin-left: 0;
margin-right: 0;
margin-top: 0;
margin-bottom: 0
}
dir {
margin-left-ltr: 40;
margin-right-rtl: 40;
margin-top: 10;
margin-bottom: 10
}
dd {
margin-left-ltr: 40;
margin-right-rtl: 40;
margin-top: 0;
margin-bottom: 0
}
dd p {
margin-left: 0;
margin-rigth: 0;
margin-top: 0;
margin-bottom: 0
}
dt {
margin-top: 0;
margin-bottom: 0
}
dl {
margin-left: 0;
margin-top: 10;
margin-bottom: 10
}
ol li {
margin-left: 0;
margin-right: 0;
margin-top: 0;
margin-bottom: 0
}
ol {
margin-top: 10;
margin-bottom: 10;
margin-left-ltr: 50;
margin-right-rtl: 50;
list-style-type: decimal
}
ol li p {
margin-top: 0;
margin-bottom: 0
}
ul li {
margin-left: 0;
margin-right: 0;
margin-top: 0;
margin-bottom: 0
}
ul {
margin-top: 10;
margin-bottom: 10;
margin-left-ltr: 50;
margin-right-rtl: 50;
list-style-type: disc;
-bullet-gap: 10
}
ul li ul li {
margin-left: 0;
margin-right: 0;
margin-top: 0;
margin-bottom: 0
}
ul li ul {
list-style-type: circle;
margin-left-ltr: 25;
margin-right-rtl: 25;
}
ul li ul li ul li {
margin-left: 0;
margin-right: 0;
margin-top: 0;
margin-bottom: 0
}
ul li ul li ul {
list-style-type: square;
margin-left-ltr: 25;
margin-right-rtl: 25
}
ul li menu {
list-style-type: circle;
margin-left-ltr: 25;
margin-right-rtl: 25;
}
ul li p {
margin-top: 0;
margin-bottom: 0
}
a {
color: #5a7b88;
text-decoration: underline
}
big {
font-size: x-large
}
small {
font-size: x-small
}
samp {
font-size: small;
font-family: Monospaced
}
cite {
font-style: italic
}
code {
font-size: small;
font-family: Monospaced
}
dfn {
font-style: italic
}
em {
font-style: italic
}
i {
font-style: italic
}
b {
font-weight: bold
}
kbd {
font-size: small;
font-family: Monospaced
}
s {
text-decoration: line-through
}
strike {
text-decoration: line-through
}
strong {
font-weight: bold
}
sub {
vertical-align: sub
}
sup {
vertical-align: sup
}
tt {
font-family: Monospaced
}
u {
text-decoration: underline
}
var {
font-weight: bold;
font-style: italic
}
table {
border-color: Gray;
border-style: outset
}
tr {
text-align: left
}
td {
border-color: Gray;
border-style: inset;
padding-left: 3;
padding-right: 3;
padding-top: 3;
padding-bottom: 3
}
th {
text-align: center;
font-weight: bold;
border-color: Gray;
border-style: inset;
padding-left: 3;
padding-right: 3;
padding-top: 3;
padding-bottom: 3
}
address {
color: #5a7b88;
font-style: italic
}
blockquote {
margin-top: 5;
margin-bottom: 5;
margin-left: 35;
margin-right: 35
}
center {
text-align: center
}
pre {
margin-top: 5;
margin-bottom: 5;
font-family: Monospaced
}
pre p {
margin-top: 0
}
caption {
caption-side: top;
text-align: center
}
nobr {
white-space: nowrap
}