Skip to content
Snippets Groups Projects
Commit 2f71e82a authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Don't load() tdfonts_lib.js into global scope, doesn't work with ;exec command

Use the lib as recommended.

Don't set the opt.width default value here, allowing for auto-detection.
parent af835dde
No related branches found
No related tags found
No related merge requests found
...@@ -5,12 +5,11 @@ ...@@ -5,12 +5,11 @@
* @format.tab-size 4, @format.use-tabs true * @format.tab-size 4, @format.use-tabs true
*/ */
load("tdfonts_lib.js"); var tdf = load("tdfonts_lib.js");
// Global options object (using var) // Global options object (using var)
opt = { tdf.opt = {
justify: LEFT_JUSTIFY, justify: LEFT_JUSTIFY,
width: DEFAULT_WIDTH,
random: false, random: false,
info: false info: false
}; };
...@@ -51,13 +50,13 @@ for(i = 0; i < argv.length; ++i) { ...@@ -51,13 +50,13 @@ for(i = 0; i < argv.length; ++i) {
} else if (arg === "-j" && i + 1 < argv.length) { } else if (arg === "-j" && i + 1 < argv.length) {
switch (argv[i + 1]) { switch (argv[i + 1]) {
case "l": case "l":
opt.justify = LEFT_JUSTIFY; tdf.opt.justify = LEFT_JUSTIFY;
break; break;
case "r": case "r":
opt.justify = RIGHT_JUSTIFY; tdf.opt.justify = RIGHT_JUSTIFY;
break; break;
case "c": case "c":
opt.justify = CENTER_JUSTIFY; tdf.opt.justify = CENTER_JUSTIFY;
break; break;
default: default:
alert("Invalid justification option. Use l, r, or c."); alert("Invalid justification option. Use l, r, or c.");
...@@ -65,19 +64,19 @@ for(i = 0; i < argv.length; ++i) { ...@@ -65,19 +64,19 @@ for(i = 0; i < argv.length; ++i) {
} }
++i; ++i;
} else if (arg === "-w" && i + 1 < argv.length) { } else if (arg === "-w" && i + 1 < argv.length) {
opt.width = parseInt(argv[i + 1], 10); tdf.opt.width = parseInt(argv[i + 1], 10);
++i; ++i;
} else if (arg === "-x" && i + 1 < argv.length) { } else if (arg === "-x" && i + 1 < argv.length) {
opt.index = parseInt(argv[i + 1], 10); tdf.opt.index = parseInt(argv[i + 1], 10);
++i; ++i;
} else if (arg === "-a") { } else if (arg === "-a") {
opt.ansi = true; tdf.opt.ansi = true;
} else if (arg === "-u") { } else if (arg === "-u") {
opt.utf8 = true; tdf.opt.utf8 = true;
} else if (arg === "-i") { } else if (arg === "-i") {
opt.info = true; tdf.opt.info = true;
} else if (arg === "-r") { } else if (arg === "-r") {
opt.random = true; tdf.opt.random = true;
} else if (arg === "-h") { } else if (arg === "-h") {
usage(); usage();
} else { } else {
...@@ -85,9 +84,9 @@ for(i = 0; i < argv.length; ++i) { ...@@ -85,9 +84,9 @@ for(i = 0; i < argv.length; ++i) {
} }
} }
if (!fontfile && !opt.random) if (!fontfile && !tdf.opt.random)
usage(); usage();
writeln(""); writeln("");
printstr(input_string, fontfile); tdf.printstr(input_string, fontfile);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment