mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-16 11:21:18 +03:00
Fixing help menu links, integrating copy as html, and modifying EditorToolbar labels (Run -> Verify, Export -> Upload).
This commit is contained in:
@ -1637,6 +1637,15 @@ public class Base {
|
|||||||
openURL(referenceFile.getAbsolutePath());
|
openURL(referenceFile.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public void showGettingStarted() {
|
||||||
|
if (Base.isMacOS()) {
|
||||||
|
Base.showReference("Guide_MacOSX.html");
|
||||||
|
} else if (Base.isWindows()) {
|
||||||
|
Base.showReference("Guide_Windows.html");
|
||||||
|
} else {
|
||||||
|
Base.openURL("http://www.arduino.cc/playground/Learning/Linux");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static public void showReference() {
|
static public void showReference() {
|
||||||
showReference("index.html");
|
showReference("index.html");
|
||||||
@ -1644,7 +1653,7 @@ public class Base {
|
|||||||
|
|
||||||
|
|
||||||
static public void showEnvironment() {
|
static public void showEnvironment() {
|
||||||
showReference("environment" + File.separator + "index.html");
|
showReference("Guide_Environment.html");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1654,7 +1663,12 @@ public class Base {
|
|||||||
|
|
||||||
|
|
||||||
static public void showTroubleshooting() {
|
static public void showTroubleshooting() {
|
||||||
showReference("troubleshooting" + File.separator + "index.html");
|
showReference("Guide_Troubleshooting.html");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static public void showFAQ() {
|
||||||
|
showReference("faq.html");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -981,7 +981,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
item = new JMenuItem("Getting Started");
|
item = new JMenuItem("Getting Started");
|
||||||
item.addActionListener(new ActionListener() {
|
item.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
Base.openURL("http://processing.org/learning/gettingstarted/");
|
Base.showGettingStarted();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
menu.add(item);
|
menu.add(item);
|
||||||
@ -1023,15 +1023,15 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
item = new JMenuItem("Frequently Asked Questions");
|
item = new JMenuItem("Frequently Asked Questions");
|
||||||
item.addActionListener(new ActionListener() {
|
item.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
Base.openURL("http://processing.org/faq.html");
|
Base.showFAQ();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
menu.add(item);
|
menu.add(item);
|
||||||
|
|
||||||
item = newJMenuItem("Visit Processing.org", '5');
|
item = new JMenuItem("Visit Arduino.cc");
|
||||||
item.addActionListener(new ActionListener() {
|
item.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
Base.openURL("http://processing.org/");
|
Base.openURL("http://arduino.cc/");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
menu.add(item);
|
menu.add(item);
|
||||||
@ -1039,7 +1039,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
// macosx already has its own about menu
|
// macosx already has its own about menu
|
||||||
if (!Base.isMacOS()) {
|
if (!Base.isMacOS()) {
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
item = new JMenuItem("About Processing");
|
item = new JMenuItem("About Arduino");
|
||||||
item.addActionListener(new ActionListener() {
|
item.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
base.handleAbout();
|
base.handleAbout();
|
||||||
@ -1089,7 +1089,19 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
// SwingUtilities.invokeLater(new Runnable() {
|
// SwingUtilities.invokeLater(new Runnable() {
|
||||||
// public void run() {
|
// public void run() {
|
||||||
new DiscourseFormat(Editor.this).show();
|
new DiscourseFormat(Editor.this, false).show();
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
menu.add(item);
|
||||||
|
|
||||||
|
item = newJMenuItemAlt("Copy as HTML", 'C');
|
||||||
|
item.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
// SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
// public void run() {
|
||||||
|
new DiscourseFormat(Editor.this, true).show();
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
@ -1560,7 +1572,12 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
|
|
||||||
|
|
||||||
protected void handleDiscourseCopy() {
|
protected void handleDiscourseCopy() {
|
||||||
new DiscourseFormat(Editor.this).show();
|
new DiscourseFormat(Editor.this, false).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void handleHTMLCopy() {
|
||||||
|
new DiscourseFormat(Editor.this, true).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2367,6 +2384,14 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
});
|
});
|
||||||
this.add(discourseItem);
|
this.add(discourseItem);
|
||||||
|
|
||||||
|
discourseItem = new JMenuItem("Copy as HTML");
|
||||||
|
discourseItem.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
handleHTMLCopy();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.add(discourseItem);
|
||||||
|
|
||||||
item = new JMenuItem("Paste");
|
item = new JMenuItem("Paste");
|
||||||
item.addActionListener(new ActionListener() {
|
item.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
@ -35,7 +35,7 @@ import javax.swing.event.*;
|
|||||||
public class EditorToolbar extends JComponent implements MouseInputListener {
|
public class EditorToolbar extends JComponent implements MouseInputListener {
|
||||||
|
|
||||||
static final String title[] = {
|
static final String title[] = {
|
||||||
"Run", "Stop", "New", "Open", "Save", "Export"
|
"Verify", "Stop", "New", "Open", "Save", "Upload"
|
||||||
};
|
};
|
||||||
|
|
||||||
static final int BUTTON_COUNT = title.length;
|
static final int BUTTON_COUNT = title.length;
|
||||||
|
@ -55,6 +55,7 @@ public class DiscourseFormat {
|
|||||||
Editor editor;
|
Editor editor;
|
||||||
// JTextArea of the actual Editor
|
// JTextArea of the actual Editor
|
||||||
JEditTextArea textarea;
|
JEditTextArea textarea;
|
||||||
|
boolean html;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -62,9 +63,10 @@ public class DiscourseFormat {
|
|||||||
* from the actual Processing Tab ready to send to the processing discourse
|
* from the actual Processing Tab ready to send to the processing discourse
|
||||||
* web (copy & paste)
|
* web (copy & paste)
|
||||||
*/
|
*/
|
||||||
public DiscourseFormat(Editor editor) {
|
public DiscourseFormat(Editor editor, boolean html) {
|
||||||
this.editor = editor;
|
this.editor = editor;
|
||||||
this.textarea = editor.getTextArea();
|
this.textarea = editor.getTextArea();
|
||||||
|
this.html = html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -73,7 +75,7 @@ public class DiscourseFormat {
|
|||||||
*/
|
*/
|
||||||
public void show() {
|
public void show() {
|
||||||
// [code] tag cancels other tags, using [quote]
|
// [code] tag cancels other tags, using [quote]
|
||||||
StringBuffer cf = new StringBuffer("[quote]\n");
|
StringBuffer cf = new StringBuffer(html ? "<pre>\n" : "[quote]\n");
|
||||||
|
|
||||||
int selStart = textarea.getSelectionStart();
|
int selStart = textarea.getSelectionStart();
|
||||||
int selStop = textarea.getSelectionStop();
|
int selStop = textarea.getSelectionStop();
|
||||||
@ -97,7 +99,7 @@ public class DiscourseFormat {
|
|||||||
appendFormattedLine(cf, i);
|
appendFormattedLine(cf, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
cf.append("\n[/quote]");
|
cf.append(html ? "\n</pre>" : "\n[/quote]");
|
||||||
|
|
||||||
StringSelection formatted = new StringSelection(cf.toString());
|
StringSelection formatted = new StringSelection(cf.toString());
|
||||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||||
@ -107,8 +109,9 @@ public class DiscourseFormat {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
editor.statusNotice("Code formatted for processing.org/discourse " +
|
editor.statusNotice("Code formatted for " +
|
||||||
"has been copied to the clipboard.");
|
(html ? "HTML" : "the Arduino forum ") +
|
||||||
|
" has been copied to the clipboard.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -178,12 +181,12 @@ public class DiscourseFormat {
|
|||||||
// fm = painter.getFontMetrics();
|
// fm = painter.getFontMetrics();
|
||||||
} else {
|
} else {
|
||||||
// Place open tags []
|
// Place open tags []
|
||||||
cf.append("[color=#");
|
cf.append(html ? "<span style=\"color: #" : "[color=#");
|
||||||
cf.append(PApplet.hex(styles[id].getColor().getRGB() & 0xFFFFFF, 6));
|
cf.append(PApplet.hex(styles[id].getColor().getRGB() & 0xFFFFFF, 6));
|
||||||
cf.append("]");
|
cf.append(html ? ";\">" : "]");
|
||||||
|
|
||||||
if (styles[id].isBold())
|
if (styles[id].isBold())
|
||||||
cf.append("[b]");
|
cf.append(html ? "<b>" : "[b]");
|
||||||
|
|
||||||
// fm = styles[id].getFontMetrics(defaultFont);
|
// fm = styles[id].getFontMetrics(defaultFont);
|
||||||
}
|
}
|
||||||
@ -193,7 +196,7 @@ public class DiscourseFormat {
|
|||||||
char c = segmentArray[segmentOffset + offset + j];
|
char c = segmentArray[segmentOffset + offset + j];
|
||||||
if (offset == 0 && c == ' ') {
|
if (offset == 0 && c == ' ') {
|
||||||
// Works on Safari but not Camino 1.6.3 or Firefox 2.x on OS X.
|
// Works on Safari but not Camino 1.6.3 or Firefox 2.x on OS X.
|
||||||
cf.append('\u00A0'); //
|
cf.append(html ? " " : '\u00A0'); //
|
||||||
// if ((j % 2) == 1) {
|
// if ((j % 2) == 1) {
|
||||||
// cf.append("[b]\u00A0[/b]");
|
// cf.append("[b]\u00A0[/b]");
|
||||||
// } else {
|
// } else {
|
||||||
@ -204,9 +207,9 @@ public class DiscourseFormat {
|
|||||||
}
|
}
|
||||||
// Place close tags [/]
|
// Place close tags [/]
|
||||||
if (j == (length - 1) && id != Token.NULL && styles[id].isBold())
|
if (j == (length - 1) && id != Token.NULL && styles[id].isBold())
|
||||||
cf.append("[/b]");
|
cf.append(html ? "</b>" : "[/b]");
|
||||||
if (j == (length - 1) && id != Token.NULL)
|
if (j == (length - 1) && id != Token.NULL)
|
||||||
cf.append("[/color]");
|
cf.append(html ? "</span>" : "[/color]");
|
||||||
// int charWidth;
|
// int charWidth;
|
||||||
// if (c == '\t') {
|
// if (c == '\t') {
|
||||||
// charWidth = (int) painter
|
// charWidth = (int) painter
|
||||||
|
Reference in New Issue
Block a user