Add font size in Settings, Editor and Shell both honor it now

master
skylarmt 9 years ago
parent 98d1470e30
commit 5d2ce564dc

@ -88,6 +88,8 @@ public class Editor extends javax.swing.JInternalFrame {
private File filedata;
private int font_size = 12;
/**
* @param python If true sets to Python
*/
@ -102,7 +104,6 @@ public class Editor extends javax.swing.JInternalFrame {
fc.addChoosableFileFilter(new FileNameExtensionFilter(
"Plain Text (txt, text)", "txt", "text"));
int font_size = 12;
try {
font_size = Integer.valueOf(PrefStorage.getSetting("editfont"));
} catch (Exception ex) {
@ -196,8 +197,12 @@ public class Editor extends javax.swing.JInternalFrame {
private void setEditorTheme(String themeName) {
try {
Theme theme = Theme.load(Editor.class
.getResourceAsStream("resources/" + themeName + ".xml"));
Theme theme
= Theme.load(
Editor.class.
getResourceAsStream(
"resources/" + themeName + ".xml"),
new Font(Font.MONOSPACED, Font.PLAIN, font_size));
theme.apply(codeBox);
} catch (Exception e) {
}

@ -84,21 +84,6 @@
</MenuItem>
</SubComponents>
</Menu>
<Menu class="javax.swing.JMenu" name="jMenu2">
<Properties>
<Property name="text" type="java.lang.String" value="Options"/>
</Properties>
<SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="fontBtn">
<Properties>
<Property name="text" type="java.lang.String" value="Font size..."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="fontBtnActionPerformed"/>
</Events>
</MenuItem>
</SubComponents>
</Menu>
</SubComponents>
</Menu>
</NonVisualComponents>

@ -103,7 +103,7 @@ public class Interpreter extends javax.swing.JInternalFrame {
// Set font
int font_size = 12;
try {
font_size = Integer.valueOf(PrefStorage.getSetting("shellfontsize", "12"));
font_size = Integer.valueOf(PrefStorage.getSetting("editfont", "12"));
} catch (Exception ex) {
}
mainBox.setFont(new Font(Font.MONOSPACED, Font.PLAIN, font_size));
@ -146,8 +146,6 @@ public class Interpreter extends javax.swing.JInternalFrame {
javascriptMenu = new javax.swing.JRadioButtonMenuItem();
pythonMenu = new javax.swing.JRadioButtonMenuItem();
setDefaultLang = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
fontBtn = new javax.swing.JMenuItem();
setClosable(true);
setIconifiable(true);
@ -271,18 +269,6 @@ public class Interpreter extends javax.swing.JInternalFrame {
jMenuBar1.add(langMenu);
jMenu2.setText("Options");
fontBtn.setText("Font size...");
fontBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
fontBtnActionPerformed(evt);
}
});
jMenu2.add(fontBtn);
jMenuBar1.add(jMenu2);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
@ -394,19 +380,6 @@ public class Interpreter extends javax.swing.JInternalFrame {
formMouseClicked(evt);
}//GEN-LAST:event_runBtnMouseClicked
private void fontBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fontBtnActionPerformed
FontOptions fo = new FontOptions(mainBox.getFont().getSize());
JOptionPane.showInternalMessageDialog(this,
fo,
"Font Size",
JOptionPane.PLAIN_MESSAGE);
if (fo.isModified()) {
mainBox.setFont(new Font(Font.MONOSPACED, Font.PLAIN, fo.getResult()));
inputBox.setFont(new Font(Font.MONOSPACED, Font.PLAIN, fo.getResult()));
PrefStorage.saveSetting("shellfontsize", String.valueOf(fo.getResult()));
}
}//GEN-LAST:event_fontBtnActionPerformed
private void exportHistoryBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportHistoryBtnActionPerformed
JFileChooser fc = new JFileChooser();
FileFilter filter;
@ -546,11 +519,9 @@ public class Interpreter extends javax.swing.JInternalFrame {
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JMenuItem clearBtn;
private javax.swing.JMenuItem exportHistoryBtn;
private javax.swing.JMenuItem fontBtn;
private javax.swing.JTextField inputBox;
private javax.swing.JLabel jLabel1;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenu jMenu3;
private javax.swing.JMenu jMenu4;
private javax.swing.JMenuBar jMenuBar1;

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
<NonVisualComponents>
<Component class="javax.swing.ButtonGroup" name="themeGroup">
</Component>
@ -13,13 +13,13 @@
<Image iconType="3" name="/net/apocalypselabs/symat/icons/settings.png"/>
</Property>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[390, 293]"/>
<Dimension value="[9999, 9999]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[390, 293]"/>
<Dimension value="[100, 100]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[390, 293]"/>
<Dimension value="[555, 280]"/>
</Property>
</Properties>
<SyntheticProperties>
@ -43,28 +43,27 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="jPanel1" max="32767" attributes="0"/>
<Component id="jPanel3" max="32767" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="jPanel2" max="32767" attributes="0"/>
<Component id="jPanel4" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jPanel5" min="-2" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="jPanel1" max="32767" attributes="0"/>
<Component id="jPanel3" max="32767" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="jPanel2" max="32767" attributes="0"/>
<Component id="jPanel4" max="32767" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="applyBtn" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="saveBtn" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" pref="62" max="-2" attributes="0"/>
<EmptySpace pref="90" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -72,21 +71,25 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="jPanel2" max="32767" attributes="0"/>
<Component id="jPanel1" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="jPanel3" alignment="1" max="32767" attributes="0"/>
<Component id="jPanel4" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="applyBtn" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="saveBtn" alignment="3" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="jPanel5" max="32767" attributes="0"/>
<Component id="jPanel2" max="32767" attributes="0"/>
<Component id="jPanel1" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="jPanel3" alignment="1" max="32767" attributes="0"/>
<Component id="jPanel4" max="32767" attributes="0"/>
</Group>
</Group>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="saveBtn" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="applyBtn" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" pref="40" max="-2" attributes="0"/>
<EmptySpace pref="56" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -302,5 +305,44 @@
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel5">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Font Size"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="22" max="-2" attributes="0"/>
<Component id="fontSizeSpinner" min="-2" pref="67" max="-2" attributes="0"/>
<EmptySpace pref="30" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="22" max="-2" attributes="0"/>
<Component id="fontSizeSpinner" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JSpinner" name="fontSizeSpinner">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="12" maximum="48" minimum="5" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

@ -83,14 +83,16 @@ public class Settings extends javax.swing.JInternalFrame {
jPanel4 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
nameBox = new javax.swing.JTextField();
jPanel5 = new javax.swing.JPanel();
fontSizeSpinner = new javax.swing.JSpinner();
setClosable(true);
setIconifiable(true);
setTitle("Settings");
setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/settings.png"))); // NOI18N
setMaximumSize(new java.awt.Dimension(390, 293));
setMinimumSize(new java.awt.Dimension(390, 293));
setPreferredSize(new java.awt.Dimension(390, 293));
setMaximumSize(new java.awt.Dimension(9999, 9999));
setMinimumSize(new java.awt.Dimension(100, 100));
setPreferredSize(new java.awt.Dimension(555, 280));
addComponentListener(new java.awt.event.ComponentAdapter() {
public void componentShown(java.awt.event.ComponentEvent evt) {
formComponentShown(evt);
@ -225,44 +227,67 @@ public class Settings extends javax.swing.JInternalFrame {
.addGap(0, 0, Short.MAX_VALUE))
);
jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Font Size"));
fontSizeSpinner.setModel(new javax.swing.SpinnerNumberModel(12, 5, 48, 1));
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGap(22, 22, 22)
.addComponent(fontSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(30, Short.MAX_VALUE))
);
jPanel5Layout.setVerticalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGap(22, 22, 22)
.addComponent(fontSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
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, false)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(0, 0, 0)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(0, 0, 0)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(applyBtn)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(saveBtn)))
.addGap(62, 62, 62))
.addContainerGap(90, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(applyBtn)
.addComponent(saveBtn))
.addGap(40, 40, 40))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(saveBtn)
.addComponent(applyBtn)))
.addContainerGap(56, Short.MAX_VALUE))
);
pack();
@ -288,6 +313,11 @@ public class Settings extends javax.swing.JInternalFrame {
skipUpdates.setSelected(
PrefStorage.getSetting("skipupdates", "").equals("yes"));
nameBox.setText(PrefStorage.getSetting("author", ""));
try {
fontSizeSpinner.setValue(Integer.parseInt(PrefStorage.getSetting("editfont", "12")));
} catch (Exception ex) {
fontSizeSpinner.setValue(12);
}
}//GEN-LAST:event_formComponentShown
private void saveBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveBtnActionPerformed
@ -301,6 +331,7 @@ public class Settings extends javax.swing.JInternalFrame {
PrefStorage.saveSetting("quickstart", quickStart.isSelected() ? "yes" : "");
PrefStorage.saveSetting("skipupdates", skipUpdates.isSelected() ? "yes" : "");
PrefStorage.saveSetting("author", nameBox.getText());
PrefStorage.saveSetting("editfont", fontSizeSpinner.getValue().toString());
PrefStorage.save();
Main.updateDisplay();
}
@ -317,11 +348,13 @@ public class Settings extends javax.swing.JInternalFrame {
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton applyBtn;
private javax.swing.JButton clrRecentBtn;
private javax.swing.JSpinner fontSizeSpinner;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JPanel jPanel5;
private javax.swing.JTextField nameBox;
private javax.swing.JCheckBox quickStart;
private javax.swing.JButton saveBtn;

Loading…
Cancel
Save