mirror of
https://github.com/SuspiciousActivity/ByteEdit.git
synced 2026-08-13 17:56:17 +00:00
Added a dark theme
This commit is contained in:
1 parent
0538d3f588
commit
b4d16385cb
6 files changed
+127
-19
No files matched your search
@@ -19,3 +19,5 @@ To (un-)escape unicode characters, press CTRL + U.
|
||||
To rename a field/method with attention to references in the selected line, press CTRL + R.
|
||||
|
||||
To quickly compile some java code, press CTRL + E.
|
||||
|
||||
To switch between light and dark theme, press CTRL + B.
|
||||
@@ -56,7 +56,7 @@ public class CompilationBox extends JFrame {
|
||||
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 400),
|
||||
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 200), 800, 400);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBackground(Color.GRAY);
|
||||
contentPane.setBackground(Main.dark ? Color.DARK_GRAY : Color.GRAY);
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(new BorderLayout(0, 0));
|
||||
@@ -65,13 +65,13 @@ public class CompilationBox extends JFrame {
|
||||
textArea.setEditable(true);
|
||||
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
|
||||
textArea.setCodeFoldingEnabled(true);
|
||||
textArea.setBackground(Color.LIGHT_GRAY);
|
||||
textArea.setBackground(Main.dark ? Color.DARK_GRAY : Color.LIGHT_GRAY);
|
||||
|
||||
RTextScrollPane scrollPane = new RTextScrollPane();
|
||||
scrollPane.setViewportView(textArea);
|
||||
scrollPane.setLineNumbersEnabled(true);
|
||||
scrollPane.setFoldIndicatorEnabled(true);
|
||||
scrollPane.getGutter().setBackground(Color.LIGHT_GRAY);
|
||||
scrollPane.getGutter().setBackground(Main.dark ? Color.DARK_GRAY : Color.LIGHT_GRAY);
|
||||
contentPane.add(scrollPane);
|
||||
|
||||
KeyStroke ctrlS = KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_DOWN_MASK);
|
||||
@@ -106,8 +106,10 @@ public class CompilationBox extends JFrame {
|
||||
}
|
||||
|
||||
compiler.getTask(outWriter, null, null,
|
||||
Arrays.asList("-d", tmpFolder.getAbsolutePath(), "-classpath",
|
||||
Main.jarFile.getAbsolutePath()),
|
||||
Main.jarFile != null
|
||||
? Arrays.asList("-d", tmpFolder.getAbsolutePath(), "-classpath",
|
||||
Main.jarFile.getAbsolutePath())
|
||||
: Arrays.asList("-d", tmpFolder.getAbsolutePath()),
|
||||
null, Arrays.asList(new JavaSourceFromString("Compiled", source))).call();
|
||||
String res = out.toString();
|
||||
if (res.isEmpty()) {
|
||||
|
||||
@@ -61,7 +61,7 @@ public class CompilationSuccess extends JFrame {
|
||||
setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 400),
|
||||
(int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 200), 800, 400);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBackground(Color.GRAY);
|
||||
contentPane.setBackground(Main.dark ? Color.DARK_GRAY : Color.GRAY);
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(new BorderLayout(0, 0));
|
||||
@@ -70,13 +70,13 @@ public class CompilationSuccess extends JFrame {
|
||||
textArea.setEditable(true);
|
||||
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA_DISASSEMBLE);
|
||||
textArea.setCodeFoldingEnabled(true);
|
||||
textArea.setBackground(Color.LIGHT_GRAY);
|
||||
textArea.setBackground(Main.dark ? Color.DARK_GRAY : Color.LIGHT_GRAY);
|
||||
|
||||
RTextScrollPane scrollPane = new RTextScrollPane();
|
||||
scrollPane.setViewportView(textArea);
|
||||
scrollPane.setLineNumbersEnabled(true);
|
||||
scrollPane.setFoldIndicatorEnabled(true);
|
||||
scrollPane.getGutter().setBackground(Color.LIGHT_GRAY);
|
||||
scrollPane.getGutter().setBackground(Main.dark ? Color.DARK_GRAY : Color.LIGHT_GRAY);
|
||||
contentPane.add(scrollPane);
|
||||
}
|
||||
}
|
||||
@@ -187,13 +187,20 @@ public class Main extends JFrame {
|
||||
return provider;
|
||||
}
|
||||
|
||||
public static boolean dark = true;
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public Main() {
|
||||
INSTANCE = this;
|
||||
File light = new File(System.getProperty("java.io.tmpdir") + File.pathSeparator + "ByteEditLight.conf");
|
||||
if (light.exists()) {
|
||||
dark = false;
|
||||
}
|
||||
try {
|
||||
theme = Theme.load(getClass().getClassLoader().getResourceAsStream("org/fife/eclipse.xml"));
|
||||
theme = Theme.load(getClass().getClassLoader()
|
||||
.getResourceAsStream(dark ? "org/fife/eclipse_dark.xml" : "org/fife/eclipse.xml"));
|
||||
} catch (IOException e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
@@ -214,12 +221,12 @@ public class Main extends JFrame {
|
||||
e.printStackTrace();
|
||||
}
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBackground(Color.GRAY);
|
||||
contentPane.setBackground(dark ? Color.DARK_GRAY : Color.GRAY);
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(new GridLayout(0, 1, 0, 0));
|
||||
JSplitPane splitPane = new JSplitPane();
|
||||
splitPane.setBackground(Color.GRAY);
|
||||
splitPane.setBackground(dark ? Color.DARK_GRAY : Color.GRAY);
|
||||
splitPane.setResizeWeight(0.2);
|
||||
contentPane.add(splitPane);
|
||||
JScrollPane scrollPane = new JScrollPane();
|
||||
@@ -275,13 +282,13 @@ public class Main extends JFrame {
|
||||
}
|
||||
});
|
||||
tree.setFont(new Font("Verdana", Font.PLAIN, 11));
|
||||
tree.setBackground(Color.LIGHT_GRAY);
|
||||
tree.setBackground(dark ? Color.DARK_GRAY : Color.LIGHT_GRAY);
|
||||
if (tree.getCellRenderer() instanceof DefaultTreeCellRenderer) {
|
||||
final DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) (tree.getCellRenderer());
|
||||
renderer.setBackgroundNonSelectionColor(Color.LIGHT_GRAY);
|
||||
renderer.setBackgroundNonSelectionColor(dark ? Color.DARK_GRAY : Color.LIGHT_GRAY);
|
||||
renderer.setBackgroundSelectionColor(Color.GRAY);
|
||||
renderer.setTextNonSelectionColor(Color.BLACK);
|
||||
renderer.setTextSelectionColor(Color.BLACK);
|
||||
renderer.setTextNonSelectionColor(dark ? new Color(0xeeeeee) : Color.BLACK);
|
||||
renderer.setTextSelectionColor(dark ? new Color(0xeeeeee) : Color.BLACK);
|
||||
}
|
||||
scrollPane.setViewportView(tree);
|
||||
tree.addTreeSelectionListener(new TreeSelectionListener() {
|
||||
@@ -400,7 +407,25 @@ public class Main extends JFrame {
|
||||
KeyStroke ctrlU = KeyStroke.getKeyStroke(KeyEvent.VK_U, KeyEvent.CTRL_DOWN_MASK);
|
||||
KeyStroke ctrlR = KeyStroke.getKeyStroke(KeyEvent.VK_R, KeyEvent.CTRL_DOWN_MASK);
|
||||
KeyStroke ctrlE = KeyStroke.getKeyStroke(KeyEvent.VK_E, KeyEvent.CTRL_DOWN_MASK);
|
||||
KeyStroke ctrlB = KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_DOWN_MASK);
|
||||
// global
|
||||
txtByteEditView.registerKeyboardAction(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (light.exists())
|
||||
light.delete();
|
||||
else
|
||||
try {
|
||||
light.createNewFile();
|
||||
} catch (IOException e1) {
|
||||
}
|
||||
dark = !dark;
|
||||
JOptionPane.showMessageDialog(Main.this,
|
||||
"Theme switched to " + (dark ? "Dark" : "Light") + ".\nPlease restart ByteEdit.",
|
||||
"Theme changed", JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
}, ctrlB, JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
txtByteEditView.registerKeyboardAction(new ActionListener() {
|
||||
|
||||
@Override
|
||||
@@ -493,11 +518,11 @@ public class Main extends JFrame {
|
||||
theme.apply(txtByteEditView);
|
||||
|
||||
splitPane.setRightComponent(scrollPane_ByteEdit);
|
||||
txtByteEditView.setBackground(Color.LIGHT_GRAY);
|
||||
txtByteEditView.setBackground(dark ? Color.DARK_GRAY : Color.LIGHT_GRAY);
|
||||
scrollPane_ByteEdit.setViewportView(txtByteEditView);
|
||||
scrollPane_ByteEdit.setLineNumbersEnabled(true);
|
||||
scrollPane_ByteEdit.setFoldIndicatorEnabled(true);
|
||||
scrollPane_ByteEdit.getGutter().setBackground(Color.LIGHT_GRAY);
|
||||
scrollPane_ByteEdit.getGutter().setBackground(dark ? Color.DARK_GRAY : Color.LIGHT_GRAY);
|
||||
}
|
||||
|
||||
private final Pattern jumpableInstructionPattern = Pattern.compile("^\t\t(?!//|\t+).+ .+");
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<!-- General editor colors. -->
|
||||
<background color="ffffff"/>
|
||||
<caret color="000000"/>
|
||||
<selection bg="default" fg="default"/>
|
||||
<selection bg="dddddd" fg="000000"/>
|
||||
<currentLineHighlight color="dddddd" fade="false"/>
|
||||
<marginLine fg="b0b4b9"/>
|
||||
<markAllHighlight color="6b8189"/> <!-- TODO: Fix me -->
|
||||
@@ -39,7 +39,7 @@
|
||||
<style token="RESERVED_WORD" fg="7f0055" bold="true"/>
|
||||
<style token="RESERVED_WORD_2" fg="7f0055" bold="true"/>
|
||||
<style token="ANNOTATION" fg="808080"/>
|
||||
<style token="COMMENT_DOCUMENTATION" fg="3f5fbf"/>
|
||||
<style token="COMMENT_DOCUMENTATION" fg="3f7f5f"/>
|
||||
<style token="COMMENT_EOL" fg="3f7f5f"/>
|
||||
<style token="COMMENT_MULTILINE" fg="3f7f5f"/>
|
||||
<style token="COMMENT_KEYWORD" fg="7F9FBF" bold="true"/>
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE RSyntaxTheme SYSTEM "theme.dtd">
|
||||
|
||||
<!--
|
||||
Theme that mimics Eclipse's defaults.
|
||||
See theme.dtd and org.fife.ui.rsyntaxtextarea.Theme for more information.
|
||||
-->
|
||||
<RSyntaxTheme version="1.0">
|
||||
|
||||
<!-- Omitting baseFont will use a system-appropriate monospaced. -->
|
||||
<!--<baseFont family="..." size="13"/>-->
|
||||
<baseFont size="12"/>
|
||||
|
||||
<!-- General editor colors. -->
|
||||
<background color="000000"/>
|
||||
<caret color="eeeeee"/>
|
||||
<selection bg="222222" fg="eeeeee"/>
|
||||
<currentLineHighlight color="222222" fade="false"/>
|
||||
<marginLine fg="4f4b46"/>
|
||||
<markAllHighlight color="947e76"/> <!-- TODO: Fix me -->
|
||||
<markOccurrencesHighlight color="2b2b2b" border="false"/>
|
||||
<matchedBracket fg="3f3f3f" highlightBoth="false" animate="false"/>
|
||||
<hyperlinks fg="0000ff"/>
|
||||
<secondaryLanguages>
|
||||
<language index="1" bg="fff0cc"/>
|
||||
<language index="2" bg="dafeda"/>
|
||||
<language index="3" bg="ffe0f0"/>
|
||||
</secondaryLanguages>
|
||||
|
||||
<!-- Gutter styling. -->
|
||||
<gutterBorder color="222222"/>
|
||||
<lineNumbers fg="878787"/>
|
||||
<foldIndicator fg="7f7f7f" iconBg="000000"/>
|
||||
<iconRowHeader activeLineRange="cc6600"/>
|
||||
|
||||
<!-- Syntax tokens. -->
|
||||
<tokenStyles>
|
||||
<style token="IDENTIFIER" fg="eeeeee"/>
|
||||
<style token="RESERVED_WORD" fg="dd02d6" bold="true"/>
|
||||
<style token="RESERVED_WORD_2" fg="dd02d6" bold="true"/>
|
||||
<style token="ANNOTATION" fg="808080"/>
|
||||
<style token="COMMENT_DOCUMENTATION" fg="279627"/>
|
||||
<style token="COMMENT_EOL" fg="279627"/>
|
||||
<style token="COMMENT_MULTILINE" fg="279627"/>
|
||||
<style token="COMMENT_KEYWORD" fg="806040" bold="true"/>
|
||||
<style token="COMMENT_MARKUP" fg="808060"/>
|
||||
<style token="DATA_TYPE" fg="dd02d6" bold="true"/>
|
||||
<style token="FUNCTION" fg="eeeeee"/>
|
||||
<style token="LITERAL_BOOLEAN" fg="dd02d6" bold="true"/>
|
||||
<style token="LITERAL_NUMBER_DECIMAL_INT" fg="eeeeee"/>
|
||||
<style token="LITERAL_NUMBER_FLOAT" fg="eeeeee"/>
|
||||
<style token="LITERAL_NUMBER_HEXADECIMAL" fg="eeeeee"/>
|
||||
<style token="LITERAL_STRING_DOUBLE_QUOTE" fg="00aeff"/>
|
||||
<style token="LITERAL_CHAR" fg="00aeff"/>
|
||||
<style token="LITERAL_BACKQUOTE" fg="00aeff"/>
|
||||
<style token="MARKUP_TAG_DELIMITER" fg="008080"/>
|
||||
<style token="MARKUP_TAG_NAME" fg="3f7f7f"/>
|
||||
<style token="MARKUP_TAG_ATTRIBUTE" fg="7f007f"/>
|
||||
<style token="MARKUP_TAG_ATTRIBUTE_VALUE" fg="2a00ff" italic="true"/>
|
||||
<style token="MARKUP_COMMENT" fg="c0a040"/>
|
||||
<style token="MARKUP_DTD" fg="008080"/>
|
||||
<style token="MARKUP_PROCESSING_INSTRUCTION" fg="808080"/>
|
||||
<style token="MARKUP_CDATA" fg="eeeeee"/>
|
||||
<style token="MARKUP_CDATA_DELIMITER" fg="008080"/>
|
||||
<style token="MARKUP_ENTITY_REFERENCE" fg="2a00ff"/>
|
||||
<style token="OPERATOR" fg="eeeeee"/>
|
||||
<style token="PREPROCESSOR" fg="808080"/>
|
||||
<style token="REGEX" fg="008040"/>
|
||||
<style token="SEPARATOR" fg="eeeeee"/>
|
||||
<style token="VARIABLE" fg="ff9900" bold="true"/>
|
||||
<style token="WHITESPACE" fg="eeeeee"/>
|
||||
|
||||
<style token="ERROR_IDENTIFIER" fg="eeeeee" bg="ffcccc"/>
|
||||
<style token="ERROR_NUMBER_FORMAT" fg="eeeeee" bg="ffcccc"/>
|
||||
<style token="ERROR_STRING_DOUBLE" fg="eeeeee" bg="ffcccc"/>
|
||||
<style token="ERROR_CHAR" fg="eeeeee" bg="ffcccc"/>
|
||||
</tokenStyles>
|
||||
|
||||
</RSyntaxTheme>
|
||||
Reference in new issue
Block a user