From: krakjoe Date: Fri, 29 Nov 2013 08:57:29 +0000 (+0000) Subject: add ANSI colour support to output pane X-Git-Tag: php-5.6.0alpha1~110^2~30^2~50 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=883f34f4870627eac2706c71b4880e4960bc5953;p=php add ANSI colour support to output pane --- diff --git a/tutorials/java/build/built-jar.properties b/tutorials/java/build/built-jar.properties index 79923e55d4..3a123e3581 100644 --- a/tutorials/java/build/built-jar.properties +++ b/tutorials/java/build/built-jar.properties @@ -1,4 +1,4 @@ -#Thu, 28 Nov 2013 22:53:51 +0000 +#Fri, 29 Nov 2013 08:22:06 +0000 -/home/joe/NetBeansProjects/phpdbg-ui= +/usr/src/phpdbg/tutorials/java= diff --git a/tutorials/java/build/classes/DBGThread.class b/tutorials/java/build/classes/DBGThread.class deleted file mode 100644 index 4bf0a8f9f5..0000000000 Binary files a/tutorials/java/build/classes/DBGThread.class and /dev/null differ diff --git a/tutorials/java/build/classes/Main$1.class b/tutorials/java/build/classes/Main$1.class deleted file mode 100644 index 8e19c106e1..0000000000 Binary files a/tutorials/java/build/classes/Main$1.class and /dev/null differ diff --git a/tutorials/java/build/classes/Main$2.class b/tutorials/java/build/classes/Main$2.class deleted file mode 100644 index df1dd09e78..0000000000 Binary files a/tutorials/java/build/classes/Main$2.class and /dev/null differ diff --git a/tutorials/java/build/classes/Main$3$1.class b/tutorials/java/build/classes/Main$3$1.class deleted file mode 100644 index 6d285e65e7..0000000000 Binary files a/tutorials/java/build/classes/Main$3$1.class and /dev/null differ diff --git a/tutorials/java/build/classes/Main$3.class b/tutorials/java/build/classes/Main$3.class deleted file mode 100644 index 4004150309..0000000000 Binary files a/tutorials/java/build/classes/Main$3.class and /dev/null differ diff --git a/tutorials/java/build/classes/Main$4.class b/tutorials/java/build/classes/Main$4.class deleted file mode 100644 index 0008d127fe..0000000000 Binary files a/tutorials/java/build/classes/Main$4.class and /dev/null differ diff --git a/tutorials/java/build/classes/Main.class b/tutorials/java/build/classes/Main.class deleted file mode 100644 index 2d965ed816..0000000000 Binary files a/tutorials/java/build/classes/Main.class and /dev/null differ diff --git a/tutorials/java/dist/phpdbg-ui.jar b/tutorials/java/dist/phpdbg-ui.jar index fc4e9d125c..c4dbea33ad 100644 Binary files a/tutorials/java/dist/phpdbg-ui.jar and b/tutorials/java/dist/phpdbg-ui.jar differ diff --git a/tutorials/java/nbproject/project.properties b/tutorials/java/nbproject/project.properties index c1f3c54997..00f726cfd9 100644 --- a/tutorials/java/nbproject/project.properties +++ b/tutorials/java/nbproject/project.properties @@ -55,7 +55,7 @@ javadoc.splitindex=true javadoc.use=true javadoc.version=false javadoc.windowtitle= -main.class=Main +main.class=phpdbg.ui.Main manifest.file=manifest.mf meta.inf.dir=${src.dir}/META-INF mkdist.disabled=false diff --git a/tutorials/java/src/DBGThread.java b/tutorials/java/src/DBGThread.java deleted file mode 100644 index 73e2dc4f91..0000000000 --- a/tutorials/java/src/DBGThread.java +++ /dev/null @@ -1,90 +0,0 @@ - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.Socket; - -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - -/** - * Manage input and output data - * @author krakjoe - */ -public class DBGThread extends Socket implements Runnable { - private final Boolean reader; - private final Main main; - private Boolean quit; - - public DBGThread(final String host, final Integer port, final Main main, Boolean reader) throws IOException { - super(host, port); - - this.main = main; - this.reader = reader; - this.quit = false; - - main.setConnected(true); - } - - public void quit() { - synchronized(this) { - quit = true; - this.notifyAll(); - } - } - - @Override public void run() { - try { - synchronized(this) { - do { - if (reader) { - String command; - OutputStream output = getOutputStream(); - - this.wait(); - - command = main.getInputField().getText(); - /* send command to stdin socket */ - if (command != null) { - output.write( - command.getBytes()); - output.write("\n".getBytes()); - output.flush(); - } - main.getInputField().setText(null); - } else { - InputStream input = getInputStream(); - /* get data from stdout socket */ - byte[] bytes = new byte[1]; - do { - /* this is some of the laziest programming I ever done */ - if (input.available() == 0) { - this.wait(666); - continue; - } - - if (input.read(bytes, 0, 1) > -1) { - main.getOutputField().setCaretPosition( - main.getOutputField().getText().length()); - main.getOutputField().append(new String(bytes)); - } - } while (!quit); - } - } while(!quit); - } - } catch (IOException | InterruptedException ex) { - if (!quit) { - main.messageBox(ex.getMessage()); - } - } finally { - try { - close(); - } catch (IOException ex) { /* naughty me */ } finally { - main.setConnected(false); - } - } - } -} diff --git a/tutorials/java/src/History.java b/tutorials/java/src/History.java deleted file mode 100644 index a7521d2c60..0000000000 --- a/tutorials/java/src/History.java +++ /dev/null @@ -1,47 +0,0 @@ - -import java.util.ArrayList; - -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - -/** - * Implement a simple history list for command input - * @author krakjoe - */ -public class History extends ArrayList { - private Integer position = new Integer(0); - - public History() { - super(); - } - - @Override public boolean add(String text) { - String last = last(); - if (text != null) { - if (last == null || !last.equals(text)) { - if (super.add(text)) { - position = size(); - return true; - } - } - } - return false; - } - - public String last() { - if (position >= 1) { - position--; - return get(position); - } else return new String(); - } - - public String next() { - if (position+1 < size()) { - position++; - return get(position); - } else return new String(); - } -} \ No newline at end of file diff --git a/tutorials/java/src/Main.form b/tutorials/java/src/Main.form deleted file mode 100644 index a5cb28ee2e..0000000000 --- a/tutorials/java/src/Main.form +++ /dev/null @@ -1,188 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tutorials/java/src/Main.java b/tutorials/java/src/Main.java deleted file mode 100644 index 84d0f137ea..0000000000 --- a/tutorials/java/src/Main.java +++ /dev/null @@ -1,366 +0,0 @@ - -import static java.awt.event.KeyEvent.VK_DOWN; -import static java.awt.event.KeyEvent.VK_ENTER; -import static java.awt.event.KeyEvent.VK_UP; -import java.io.IOException; -import java.util.ArrayList; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.swing.JOptionPane; -import javax.swing.JTextArea; -import javax.swing.JTextField; - -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - -/** - * - * @author krakjoe - */ -public class Main extends javax.swing.JDialog { - /** - * Creates user interface - * @param parent - * @param modal - */ - public Main(java.awt.Frame parent, boolean modal) { - super(parent, modal); - initComponents(); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - stdoutPopupMenu = new javax.swing.JPopupMenu(); - resetStdout = new javax.swing.JMenuItem(); - mainSplit = new javax.swing.JSplitPane(); - input = new javax.swing.JTextField(); - outScrollPane = new javax.swing.JScrollPane(); - output = new javax.swing.JTextArea(); - host = new javax.swing.JTextField(); - stdoutPort = new javax.swing.JTextField(); - stdinCheckBox = new javax.swing.JCheckBox(); - stdoutCheckBox = new javax.swing.JCheckBox(); - openButton = new javax.swing.JButton(); - stdinPort = new javax.swing.JTextField(); - hostLabel = new javax.swing.JLabel(); - - resetStdout.setText("Clear"); - resetStdout.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - resetStdoutActionPerformed(evt); - } - }); - stdoutPopupMenu.add(resetStdout); - - setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - setTitle("phpdbg jui"); - - mainSplit.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); - mainSplit.setToolTipText(""); - - input.setToolTipText(""); - input.setEnabled(false); - input.addKeyListener(new java.awt.event.KeyAdapter() { - public void keyReleased(java.awt.event.KeyEvent evt) { - inputKeyReleased(evt); - } - }); - mainSplit.setLeftComponent(input); - - output.setEditable(false); - output.setColumns(20); - output.setFont(new java.awt.Font("DialogInput", 0, 12)); // NOI18N - output.setRows(5); - output.setComponentPopupMenu(stdoutPopupMenu); - outScrollPane.setViewportView(output); - - mainSplit.setRightComponent(outScrollPane); - - host.setText("127.0.0.1"); - host.setToolTipText("Set the hostname, or IPv4 address of the machine running the phpdbg remote console server"); - - stdoutPort.setText("8000"); - stdoutPort.setToolTipText(""); - - stdinCheckBox.setSelected(true); - stdinCheckBox.setText("stdin:"); - stdinCheckBox.setToolTipText("Set the port for stdin, or uncheck to disable stdin"); - - stdoutCheckBox.setSelected(true); - stdoutCheckBox.setText("stdout:"); - stdoutCheckBox.setToolTipText("Set the port for stdout, or unset to disable stdout"); - - openButton.setActionCommand("open"); - openButton.setLabel("open"); - openButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - openButtonActionPerformed(evt); - } - }); - - stdinPort.setText("4000"); - stdinPort.setToolTipText(""); - - hostLabel.setText("Hostname:"); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(mainSplit) - .addGroup(layout.createSequentialGroup() - .addComponent(hostLabel) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(host, javax.swing.GroupLayout.DEFAULT_SIZE, 359, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(stdinCheckBox) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(stdinPort, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(18, 18, 18) - .addComponent(stdoutCheckBox) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(stdoutPort, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(openButton))) - .addContainerGap()) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addComponent(mainSplit, javax.swing.GroupLayout.DEFAULT_SIZE, 428, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE, false) - .addComponent(stdoutPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(stdinCheckBox) - .addComponent(stdoutCheckBox) - .addComponent(stdinPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(host, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(openButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(hostLabel)) - .addContainerGap()) - ); - - pack(); - }// //GEN-END:initComponents - - private void inputKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_inputKeyReleased - switch (evt.getKeyCode()) { - case VK_ENTER: { - if (in != null) { - history.add(input.getText()); - synchronized(in) { - in.notifyAll(); - } - } - } break; - - case VK_UP: { - String last = history.last(); - if (last.length() > 0) { - input.setText(last); - } - } break; - - case VK_DOWN: { - String next = history.next(); - if (next.length() > 0) { - input.setText(next); - } - } break; - } - }//GEN-LAST:event_inputKeyReleased - - private void openButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openButtonActionPerformed - try { - if (!connected) { - Integer ports[] = new Integer[2]; - String address = getHost(); - - if (address != null) { - ports[0] = stdinCheckBox.isSelected() ? getStdinPort() : -1; - ports[1] = stdoutCheckBox.isSelected() ? getStdoutPort() : -1; - - if (ports[0] != 0 && ports[1] != 0) { - if (stdinCheckBox.isSelected()) { - if (ports[0] > 0) { - in = new DBGThread( - address, ports[0], this, true); - new Thread(in).start(); - } - } - - if (stdoutCheckBox.isSelected()) { - if (ports[1] > 0) { - out = new DBGThread( - address, ports[1], this, false); - new Thread(out).start(); - } - } - } - } - } else { - if (in != null) { - in.quit(); - } - if (out != null) { - out.quit(); - } - } - } catch (IOException ex) { - messageBox(ex.getMessage()); - } - }//GEN-LAST:event_openButtonActionPerformed - - private void resetStdoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resetStdoutActionPerformed - // TODO add your handling code here: - output.setText(null); - }//GEN-LAST:event_resetStdoutActionPerformed - - - public void setConnected(Boolean isConnected) { - synchronized(this) { - if (isConnected) { - connected = true; - openButton.setText("Disconnect"); - host.setEnabled(false); - stdinPort.setEnabled(false); - stdinCheckBox.setEnabled(false); - if (stdinCheckBox.isSelected()) { - input.setEnabled(true); - } else input.setEnabled(false); - stdoutPort.setEnabled(false); - stdoutCheckBox.setEnabled(false); - } else { - connected = false; - openButton.setText("Connect"); - host.setEnabled(true); - stdinPort.setEnabled(true); - input.setEnabled(false); - stdinCheckBox.setEnabled(true); - stdoutPort.setEnabled(true); - stdoutCheckBox.setEnabled(true); - } - } - } - - public JTextField getInputField() { return input; } - public JTextArea getOutputField() { return output; } - - public String getHost() { - String address = host.getText(); - if (address != null && address.length() > 0) { - return address; - } else { - messageBox("Invalid hostname provided !"); - } - - return null; - } - - public Integer getStdinPort() { - try { - return Integer.parseInt(stdinPort.getText()); - } catch (NumberFormatException ex) { - messageBox("Invalid stdin port provided !"); - } - - return 0; - } - - public Integer getStdoutPort() { - try { - return Integer.parseInt(stdoutPort.getText()); - } catch (NumberFormatException ex) { - messageBox("Invalid stdout port provided !"); - } - - return 0; - } - - public synchronized void messageBox(String message) { - JOptionPane.showMessageDialog(this, message); - } - /** - * @param args the command line arguments - */ - public static void main(final String args[]) { - /* Set the Nimbus look and feel */ - // - /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. - * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html - */ - try { - for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { - if ("Nimbus".equals(info.getName())) { - javax.swing.UIManager.setLookAndFeel(info.getClassName()); - break; - } - } - } catch (ClassNotFoundException ex) { - java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (InstantiationException ex) { - java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (IllegalAccessException ex) { - java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (javax.swing.UnsupportedLookAndFeelException ex) { - java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } - // - - /* Create and display the dialog */ - java.awt.EventQueue.invokeLater(new Runnable() { - @Override public void run() { - dialog = new Main(new javax.swing.JFrame(), true); - dialog.addWindowListener(new java.awt.event.WindowAdapter() { - @Override - public void windowClosing(java.awt.event.WindowEvent e) { - if (in != null) - in.quit(); - - if (out != null) - out.quit(); - - System.exit(0); - } - }); - dialog.setVisible(true); - } - }); - } - - private static DBGThread in; - private static DBGThread out; - private static Main dialog; - private static Boolean connected = false; - private static History history = new History(); - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JTextField host; - private javax.swing.JLabel hostLabel; - private javax.swing.JTextField input; - private javax.swing.JSplitPane mainSplit; - private javax.swing.JButton openButton; - private javax.swing.JScrollPane outScrollPane; - private javax.swing.JTextArea output; - private javax.swing.JMenuItem resetStdout; - private javax.swing.JCheckBox stdinCheckBox; - private javax.swing.JTextField stdinPort; - private javax.swing.JCheckBox stdoutCheckBox; - private javax.swing.JPopupMenu stdoutPopupMenu; - private javax.swing.JTextField stdoutPort; - // End of variables declaration//GEN-END:variables -}