I've had a good refactor of it, and I think it is at least beta worthy.
Please have a go.
https://github.com/rowlesmr/cifstr/raw/main/distribution/cifstr.exe
If you put it in your topas directory, then you can alter the jedit TAInsertCIF.bsh file as follows:
TAInsertCIF(v) {
t = v.getTextArea();
b = t.getBuffer();
jEdit.setProperty("vfs.browser.last-filter", "*.cif");
w_path = jEdit.getProperty("ta.last_cif_path");
String w_ta_main_dir = jEdit.getProperty("ta.main.dir");
if (w_path == null) {
w_path = w_ta_main_dir + "cif\\";
}
jEdit.setProperty("vfs.browser.last-path", w_path);
VFSFileChooserDialog chooser = new VFSFileChooserDialog(v, w_path, VFSBrowser.OPEN_DIALOG, true);
String[] files = chooser.getSelectedFiles();
if (files != null) {
StringBuffer sb = new StringBuffer();
for(int i = 0; i < files.length; i++) {
sb.append("\"" + files[i] + "\" ");
}
String filesstr = sb.toString();
b.beginCompoundEdit();
runInSystemShell(v, "\"" + w_ta_main_dir + "\"");
waitForConsole(v);
runInSystemShell(v, "cifstr -sa -v 2 " + filesstr + " " + w_ta_main_dir + "output.str");
waitForConsole(v);
t.goToEndOfLine(false);
b.insert(t.getCaretPosition(), "\n");
b.insertFile(v, w_ta_main_dir + "output.str");
VFSManager.waitForRequests();
b.insert(t.getCaretPosition(), "\n");
b.endCompoundEdit();
jEdit.setProperty("ta.last_cif_path", files[0]);
}
}
TAInsertCIF(view);