Add edit in external editor
This commit is contained in:
@@ -891,7 +891,17 @@ public class AudiobookRecorder extends JFrame {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
JMenuObject edit = new JMenuObject("Open in external editor", s, new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
JMenuObject o = (JMenuObject)e.getSource();
|
||||
Sentence s = (Sentence)o.getObject();
|
||||
s.openInExternalEditor();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
menu.add(rec);
|
||||
menu.addSeparator();
|
||||
@@ -899,6 +909,7 @@ public class AudiobookRecorder extends JFrame {
|
||||
menu.add(moveDown);
|
||||
menu.add(moveMenu);
|
||||
menu.addSeparator();
|
||||
menu.add(edit);
|
||||
menu.add(ins);
|
||||
menu.add(del);
|
||||
menu.addSeparator();
|
||||
@@ -1545,9 +1556,9 @@ public class AudiobookRecorder extends JFrame {
|
||||
for (int e = 0; e < book.equaliser.length; e++) {
|
||||
for (int i = 0; i < 31; i++) {
|
||||
if (prefs.getProperty(String.format("audio.eq.profiles.%d.%d", e, i)) == null) {
|
||||
book.equaliser[e].setChannel(i, Options.getFloat(String.format("audio.eq.profiles.%d.%d", e, i)));
|
||||
book.equaliser[e].setChannel(i, Options.getFloat("audio.eq." + i));
|
||||
} else {
|
||||
book.equaliser[e].setChannel(i, Utils.s2f(prefs.getProperty("audio.eq." + i)));
|
||||
book.equaliser[e].setChannel(i, Utils.s2f(prefs.getProperty(String.format("audio.eq.profiles.%d.%d", e, i))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ public class Options extends JDialog {
|
||||
|
||||
JTextField havenApiKey;
|
||||
|
||||
JTextField externalEditor;
|
||||
|
||||
Equaliser equaliser;
|
||||
|
||||
JTextArea startupScript;
|
||||
@@ -284,6 +286,10 @@ public class Options extends JDialog {
|
||||
enableParsing = addCheckBox(optionsPanel, "Enable automatic speech-to-text submission", getBoolean("process.haven.auto"));
|
||||
havenApiKey = addTextField(optionsPanel, "Haven OnDemand API Key", get("process.haven.apikey"));
|
||||
|
||||
addSeparator(optionsPanel);
|
||||
|
||||
externalEditor = addTextField(optionsPanel, "External Editor Command", get("editor.external"));
|
||||
|
||||
addSeparator(optionsPanel);
|
||||
|
||||
cacheSize = addSpinner(optionsPanel, "Cache size:", 0, 5000, 1, getInteger("cache.size"), "");
|
||||
@@ -491,6 +497,8 @@ public class Options extends JDialog {
|
||||
defaultPrefs.put("process.sphinx", "false");
|
||||
defaultPrefs.put("process.haven.apikey", "");
|
||||
|
||||
defaultPrefs.put("editor.external", "");
|
||||
|
||||
defaultPrefs.put("cache.size", "100");
|
||||
|
||||
defaultPrefs.put("audio.eq.0", "0.00");
|
||||
@@ -635,6 +643,7 @@ public class Options extends JDialog {
|
||||
set("audio.export.samplerate", ((KVPair)exportRate.getSelectedItem()).key);
|
||||
set("process.sphinx", enableParsing.isSelected());
|
||||
set("process.haven.apikey", havenApiKey.getText());
|
||||
set("editor.external", externalEditor.getText());
|
||||
set("cache.size", cacheSize.getValue());
|
||||
|
||||
set("effects.ethereal.offset", etherealOffset.getValue());
|
||||
|
||||
@@ -1053,4 +1053,43 @@ public class Sentence extends DefaultMutableTreeNode implements Cacheable {
|
||||
eqProfile = e;
|
||||
}
|
||||
|
||||
class ExternalEditor implements Runnable {
|
||||
Sentence sentence;
|
||||
ExternalEditor(Sentence s) {
|
||||
sentence = s;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
String command = Options.get("editor.external");
|
||||
if (command == null) return;
|
||||
if (command.equals("")) return;
|
||||
|
||||
String[] parts = command.split("::");
|
||||
|
||||
ArrayList<String> args = new ArrayList<String>();
|
||||
|
||||
for (String part : parts) {
|
||||
if (part.equals("%f")) {
|
||||
args.add(getFile().getAbsolutePath());
|
||||
} else {
|
||||
args.add(part);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
ProcessBuilder process = new ProcessBuilder(args);
|
||||
Process proc = process.start();
|
||||
proc.waitFor();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
clearCache();
|
||||
}
|
||||
}
|
||||
|
||||
public void openInExternalEditor() {
|
||||
ExternalEditor ed = new ExternalEditor(this);
|
||||
Thread t = new Thread(ed);
|
||||
t.start();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user