--to-acip-text and --to-wylie-text added; these get you text files,
not RTF files like --to-acip and --to-wylie do. The GUI converter doesn't yet allow you to get text files.
This commit is contained in:
parent
cc615f34df
commit
4abbf6db37
3 changed files with 49 additions and 9 deletions
|
@ -56,6 +56,7 @@ public class ConverterGUI implements FontConversion, FontConverterConstants {
|
||||||
ps = new PrintStream(new FileOutputStream(newFile),
|
ps = new PrintStream(new FileOutputStream(newFile),
|
||||||
false),
|
false),
|
||||||
whichConversion,
|
whichConversion,
|
||||||
|
false, // DLC FIXME add a checkbox
|
||||||
warningLevel);
|
warningLevel);
|
||||||
ps.close();
|
ps.close();
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
|
|
|
@ -76,6 +76,9 @@ public class TibetanConverter implements FontConverterConstants {
|
||||||
boolean findAllNonTMWMode = false;
|
boolean findAllNonTMWMode = false;
|
||||||
boolean findSomeNonTMMode = false;
|
boolean findSomeNonTMMode = false;
|
||||||
boolean findAllNonTMMode = false;
|
boolean findAllNonTMMode = false;
|
||||||
|
|
||||||
|
boolean textOutput = false;
|
||||||
|
|
||||||
// Process arguments:
|
// Process arguments:
|
||||||
if ((args.length != 1 && args.length != 2)
|
if ((args.length != 1 && args.length != 2)
|
||||||
|| (args.length == 1
|
|| (args.length == 1
|
||||||
|
@ -96,8 +99,14 @@ public class TibetanConverter implements FontConverterConstants {
|
||||||
= args[0].equals("--to-unicode"))
|
= args[0].equals("--to-unicode"))
|
||||||
|| (convertToWylieMode
|
|| (convertToWylieMode
|
||||||
= args[0].equals("--to-wylie"))
|
= args[0].equals("--to-wylie"))
|
||||||
|
|| (convertToWylieMode
|
||||||
|
= textOutput
|
||||||
|
= args[0].equals("--to-wylie-text"))
|
||||||
|| (convertToACIPMode
|
|| (convertToACIPMode
|
||||||
= args[0].equals("--to-acip"))
|
= args[0].equals("--to-acip"))
|
||||||
|
|| (convertToACIPMode
|
||||||
|
= textOutput
|
||||||
|
= args[0].equals("--to-acip-text"))
|
||||||
|| (findSomeNonTMWMode
|
|| (findSomeNonTMWMode
|
||||||
= args[0].equals("--find-some-non-tmw"))
|
= args[0].equals("--find-some-non-tmw"))
|
||||||
|| (findSomeNonTMMode
|
|| (findSomeNonTMMode
|
||||||
|
@ -107,7 +116,8 @@ public class TibetanConverter implements FontConverterConstants {
|
||||||
))) {
|
))) {
|
||||||
out.println("TibetanConverter --find-all-non-tmw | --find-some-non-tmw");
|
out.println("TibetanConverter --find-all-non-tmw | --find-some-non-tmw");
|
||||||
out.println(" | --to-tibetan-machine | --to-tibetan-machine-web");
|
out.println(" | --to-tibetan-machine | --to-tibetan-machine-web");
|
||||||
out.println(" | --to-unicode | --to-wylie | --to-acip RTF_file");
|
out.println(" | --to-unicode | --to-wylie | --to-acip");
|
||||||
|
out.println(" | --to-wylie-text | --to-acip-text RTF_file");
|
||||||
out.println(" | TibetanConverter --acip-to-unicode | --acip-to-tmw TXT_file");
|
out.println(" | TibetanConverter --acip-to-unicode | --acip-to-tmw TXT_file");
|
||||||
out.println(" | TibetanConverter [--version | -v | --help | -h]");
|
out.println(" | TibetanConverter [--version | -v | --help | -h]");
|
||||||
out.println("");
|
out.println("");
|
||||||
|
@ -124,9 +134,13 @@ public class TibetanConverter implements FontConverterConstants {
|
||||||
out.println("");
|
out.println("");
|
||||||
out.println(" --to-tibetan-machine-web to convert TibetanMachine to TibetanMachineWeb");
|
out.println(" --to-tibetan-machine-web to convert TibetanMachine to TibetanMachineWeb");
|
||||||
out.println("");
|
out.println("");
|
||||||
out.println(" --to-wylie to convert TibetanMachineWeb to THDL Extended Wylie");
|
out.println(" --to-wylie to convert TibetanMachineWeb to THDL Extended Wylie in RTF");
|
||||||
out.println("");
|
out.println("");
|
||||||
out.println(" --to-acip to convert TibetanMachineWeb to ACIP");
|
out.println(" --to-wylie-text to convert TibetanMachineWeb to THDL Extended Wylie in text");
|
||||||
|
out.println("");
|
||||||
|
out.println(" --to-acip to convert TibetanMachineWeb to ACIP in RTF");
|
||||||
|
out.println("");
|
||||||
|
out.println(" --to-acip-text to convert TibetanMachineWeb to ACIP in text");
|
||||||
out.println("");
|
out.println("");
|
||||||
out.println(" --acip-to-unicode to convert ACIP text file to Unicode text file");
|
out.println(" --acip-to-unicode to convert ACIP text file to Unicode text file");
|
||||||
out.println("");
|
out.println("");
|
||||||
|
@ -207,7 +221,8 @@ public class TibetanConverter implements FontConverterConstants {
|
||||||
conversionTag = TMW_TO_TM;
|
conversionTag = TMW_TO_TM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return reallyConvert(in, out, conversionTag, "Most" // DLC make me configurable
|
return reallyConvert(in, out, conversionTag, textOutput,
|
||||||
|
"Most" // DLC make me configurable
|
||||||
);
|
);
|
||||||
} catch (ThdlLazyException e) {
|
} catch (ThdlLazyException e) {
|
||||||
out.println("TibetanConverter has a BUG:");
|
out.println("TibetanConverter has a BUG:");
|
||||||
|
@ -226,7 +241,7 @@ public class TibetanConverter implements FontConverterConstants {
|
||||||
return code so that TibetanConverter's usage message is
|
return code so that TibetanConverter's usage message is
|
||||||
honored. */
|
honored. */
|
||||||
static int reallyConvert(InputStream in, PrintStream out, String ct,
|
static int reallyConvert(InputStream in, PrintStream out, String ct,
|
||||||
String warningLevel) {
|
boolean textOutput, String warningLevel) {
|
||||||
if (ACIP_TO_UNI == ct || ACIP_TO_TMW == ct) {
|
if (ACIP_TO_UNI == ct || ACIP_TO_TMW == ct) {
|
||||||
try {
|
try {
|
||||||
ArrayList al = ACIPTshegBarScanner.scanStream(in, null,
|
ArrayList al = ACIPTshegBarScanner.scanStream(in, null,
|
||||||
|
@ -377,10 +392,18 @@ public class TibetanConverter implements FontConverterConstants {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write to standard output the result:
|
// Write to standard output the result:
|
||||||
try {
|
if (textOutput) {
|
||||||
tdoc.writeRTFOutputStream(out);
|
try {
|
||||||
} catch (IOException e) {
|
tdoc.writeTextOutput(new BufferedWriter(new OutputStreamWriter(out)));
|
||||||
exitCode = 40;
|
} catch (IOException e) {
|
||||||
|
exitCode = 40;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
tdoc.writeRTFOutputStream(out);
|
||||||
|
} catch (IOException e) {
|
||||||
|
exitCode = 40;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (out.checkError())
|
if (out.checkError())
|
||||||
exitCode = 41;
|
exitCode = 41;
|
||||||
|
|
|
@ -129,6 +129,22 @@ public class TibetanDocument extends DefaultStyledDocument {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Saves the contents of this RTF document as text on out. If
|
||||||
|
* any TM or TMW is in the document, the output will be
|
||||||
|
* garbage. */
|
||||||
|
public void writeTextOutput(BufferedWriter out) throws IOException {
|
||||||
|
// DLC FIXME: try getting blocks of text; I bet it's a huge
|
||||||
|
// speedup.
|
||||||
|
try {
|
||||||
|
for (int i = 0; i < getLength(); i++) {
|
||||||
|
out.write(getText(i,1));
|
||||||
|
}
|
||||||
|
} catch (BadLocationException e) {
|
||||||
|
throw new Error("can't happen");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts Tibetan text into the document. The font size is applied automatically,
|
* Inserts Tibetan text into the document. The font size is applied automatically,
|
||||||
* according to the current Tibetan font size.
|
* according to the current Tibetan font size.
|
||||||
|
|
Loading…
Reference in a new issue