-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
116 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package de.cyklon.duckscript.ide; | ||
|
||
import fr.theshark34.swinger.Swinger; | ||
|
||
public class IDE { | ||
|
||
public static void main(String[] args) { | ||
new Main(); | ||
} | ||
|
||
} |
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,89 @@ | ||
package de.cyklon.duckscript.ide; | ||
|
||
import de.cyklon.duckscript.lang.FileHelper; | ||
import de.cyklon.duckscript.lang.exceptions.CompilerException; | ||
import de.cyklon.duckscript.lang.interpreter.Interpreter; | ||
|
||
import javax.swing.*; | ||
import javax.swing.plaf.basic.BasicScrollBarUI; | ||
import java.awt.*; | ||
import java.awt.event.ActionEvent; | ||
import java.awt.event.ActionListener; | ||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
public class Main extends JFrame { | ||
|
||
private boolean darkMode = false; | ||
private static final File temp = new File(System.getProperty("user.dir")); | ||
|
||
public Main() { | ||
int height = 600, width = 1000; | ||
|
||
Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); | ||
setLocation(d.width / 2 - width / 2, d.height / 2 - height / 2); | ||
Image duck = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/DuckIcon.png")); | ||
setIconImage(duck); | ||
setResizable(false); | ||
setSize(width, height); | ||
setTitle("DuckScript - IDE"); | ||
setLayout(null); | ||
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); | ||
|
||
JTextArea textArea = new JTextArea(); | ||
//textArea.setBounds(80, 55, 600, 450); | ||
JScrollPane scroll = new JScrollPane(textArea); | ||
scroll.setBounds(80, 55, 600, 450); | ||
|
||
JButton startButton = new JButton(); | ||
startButton.setBounds(800, 20, 20, 20); | ||
startButton.setBackground(new Color(0, 169, 3)); | ||
startButton.addActionListener(new ActionListener() { | ||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
run(textArea.getText()); | ||
} | ||
}); | ||
add(startButton); | ||
|
||
if (darkMode) { | ||
getContentPane().setBackground(new Color(40, 40, 40)); | ||
|
||
textArea.setBackground(new Color(50, 50, 50)); | ||
textArea.setForeground(new Color(200, 200, 200)); | ||
|
||
scroll.getVerticalScrollBar().setBackground(new Color(50, 50, 50)); | ||
scroll.getHorizontalScrollBar().setBackground(new Color(50, 50, 50)); | ||
scroll.getVerticalScrollBar().setUI(new BasicScrollBarUI() { | ||
@Override | ||
protected void configureScrollBarColors() { | ||
this.thumbColor = new Color(200, 200, 200); | ||
} | ||
}); | ||
scroll.getHorizontalScrollBar().setUI(new BasicScrollBarUI() { | ||
@Override | ||
protected void configureScrollBarColors() { | ||
this.thumbColor = new Color(200, 200, 200); | ||
} | ||
}); | ||
} else { | ||
getContentPane().setBackground(new Color(220, 220, 220)); | ||
|
||
textArea.setBackground(new Color(180, 180, 180)); | ||
} | ||
add(scroll); | ||
|
||
setVisible(true); | ||
} | ||
|
||
private static void run(String code) { | ||
try { | ||
File path = new File(temp, "temp.ds"); | ||
FileHelper.writeFile(code, path); | ||
Interpreter.interpret(path); | ||
} catch (IOException | CompilerException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
} |
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,16 @@ | ||
package de.cyklon.duckscript.ide.util; | ||
|
||
import java.awt.*; | ||
import java.net.URL; | ||
|
||
public class Util { | ||
|
||
public static URL getResource(String name) { | ||
return Util.class.getResource(name); | ||
} | ||
|
||
public static Image getImageResource(String name) { | ||
return Toolkit.getDefaultToolkit().getImage(getResource(name)); | ||
} | ||
|
||
} |