Skip to content

Commit 8d43ef6

Browse files
author
DevKevYT
committed
WIP 1.9.13
1 parent 087aba7 commit 8d43ef6

7 files changed

Lines changed: 127 additions & 2 deletions

File tree

changelog.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ NOTICE:
1212
- Relative paths (*/lib.jar for example) can either be:
1313
The folder of a script file that is being executed
1414
OR the folder of the script host, if no file is being loaded
15+
- The editor now looks a little more fancier with some additional options to rerun scripts or terminate a script without closing the window
16+
- Added some additional commands to resize the console window or to clean the window
17+
- gui.clear
18+
- gui.setSize [sizeX] [sizeY]
19+
- gui.fullscreen [true/false]
20+
(The command "clearConsole" is still available but will be removed in future releases by the "window.clear" command)
1521

1622
1.9.12:
1723
- DevScript can now property handle the null variable $null. (="undefined")

icon/rerun-active.png

198 Bytes
Loading

icon/rerun-inactive.png

198 Bytes
Loading

icon/terminate-active.png

174 Bytes
Loading

icon/terminate-inactive.png

174 Bytes
Loading

src/com/devkev/gui/Console.java

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
package com.devkev.gui;
2+
3+
import javax.swing.JFrame;
4+
import javax.swing.JPanel;
5+
import javax.swing.border.EmptyBorder;
6+
import javax.swing.JButton;
7+
import java.awt.Font;
8+
import javax.swing.JScrollPane;
9+
import java.awt.event.ActionListener;
10+
import java.awt.event.ComponentEvent;
11+
import java.awt.event.ComponentListener;
12+
import java.awt.event.KeyEvent;
13+
import java.awt.event.KeyListener;
14+
import java.awt.event.WindowEvent;
15+
import java.awt.event.WindowListener;
16+
import java.awt.event.ActionEvent;
17+
import javax.swing.JTextArea;
18+
import javax.swing.ImageIcon;
19+
20+
public class Console extends JFrame {
21+
22+
private static final long serialVersionUID = 1L;
23+
private JPanel contentPane;
24+
private com.devkev.devscript.raw.Process p;
25+
private Window parent;
26+
27+
volatile boolean waitForEnter = false;
28+
volatile int inputStart = 0;
29+
30+
public Console(com.devkev.devscript.raw.Process p, Window parent) {
31+
this.p = p;
32+
this.parent = parent;
33+
init();
34+
}
35+
36+
private void init() {
37+
setFont(new Font("Consolas", Font.PLAIN, 12));
38+
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
39+
setBounds(100, 100, 500, 239);
40+
41+
contentPane = new JPanel();
42+
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
43+
44+
setContentPane(contentPane);
45+
contentPane.setLayout(null);
46+
47+
JButton terminate = new JButton("");
48+
terminate.setIcon(new ImageIcon("C:\\Users\\Philipp\\Desktop\\terminate-active.png"));
49+
terminate.addActionListener(new ActionListener() {
50+
public void actionPerformed(ActionEvent arg0) {
51+
}
52+
});
53+
terminate.setBounds(451, 166, 23, 23);
54+
contentPane.add(terminate);
55+
56+
JButton rerun = new JButton("");
57+
rerun.setIcon(new ImageIcon("C:\\Users\\Philipp\\Desktop\\rerun-active.png"));
58+
rerun.setBounds(418, 166, 23, 23);
59+
contentPane.add(rerun);
60+
61+
JScrollPane scrollPane = new JScrollPane();
62+
scrollPane.setBounds(10, 11, 464, 144);
63+
contentPane.add(scrollPane);
64+
65+
JTextArea console = new JTextArea();
66+
scrollPane.setViewportView(console);
67+
68+
addKeyListener(new KeyListener() {
69+
70+
@Override
71+
public void keyTyped(KeyEvent e) {
72+
}
73+
74+
@Override
75+
public void keyReleased(KeyEvent e) {
76+
if(p.isRunning()) {
77+
p.setVariable("keyCode", "", false, false);
78+
}
79+
}
80+
81+
@Override
82+
public void keyPressed(KeyEvent e) {
83+
if(p.isRunning()) {
84+
//Set the variable "keyPressed" to the char that is pressed
85+
p.setVariable("keyCode", e.getKeyChar(), false, false);
86+
}
87+
}
88+
});
89+
90+
addWindowListener(new WindowListener() {
91+
public void windowClosed(WindowEvent arg0) {}
92+
public void windowOpened(WindowEvent arg0) {}
93+
public void windowIconified(WindowEvent arg0) {}
94+
public void windowDeiconified(WindowEvent arg0) {}
95+
public void windowDeactivated(WindowEvent arg0) {}
96+
public void windowClosing(WindowEvent arg0) {
97+
if(p.isRunning()) {
98+
System.out.println("Closing running instance");
99+
p.kill(p.getMain(), "Interrupted by program");
100+
}
101+
parent.window.setEnabled(true);
102+
inputStart = 0;
103+
parent.input.flush(null);
104+
console.setText("");
105+
}
106+
public void windowActivated(WindowEvent arg0) {}
107+
});
108+
109+
addComponentListener(new ComponentListener() {
110+
@Override
111+
public void componentResized(ComponentEvent e) {
112+
console.setSize(parent.window.getRootPane().getWidth() - 10, parent.window.getRootPane().getHeight()-parent.bar.getHeight() - 10);
113+
console.updateUI();
114+
}
115+
public void componentShown(ComponentEvent e) {}
116+
public void componentMoved(ComponentEvent e) {}
117+
public void componentHidden(ComponentEvent e) {}
118+
});
119+
120+
}
121+
}

src/com/devkev/gui/Window.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,6 @@ public void done(int exitCode) {
175175
});
176176

177177
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher() {
178-
179-
180178
@Override
181179
public boolean dispatchKeyEvent(KeyEvent e) {
182180
if(e.getKeyCode() == KeyEvent.VK_ENTER && input.inputRequested() && waitForEnter && e.getID() == KeyEvent.KEY_RELEASED) {

0 commit comments

Comments
 (0)