aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYour Name <you@example.com>2023-01-28 08:32:33 -0500
committerYour Name <you@example.com>2023-01-28 08:32:33 -0500
commit538b480d12231fb32565949a755f342518d7f0c1 (patch)
treeec23d887195f7e7a0a5463bf22522b27c83fccae /src
parent9d9292805d5112aaa6cc85364cafd5e702586d9a (diff)
downloadlibbible-538b480d12231fb32565949a755f342518d7f0c1.tar.gz
libbible-538b480d12231fb32565949a755f342518d7f0c1.tar.bz2
libbible-538b480d12231fb32565949a755f342518d7f0c1.zip
Added superscript capability for verse numbers
Diffstat (limited to 'src')
-rw-r--r--src/bible.cc19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/bible.cc b/src/bible.cc
index c2d93b1..ac9b189 100644
--- a/src/bible.cc
+++ b/src/bible.cc
@@ -6,6 +6,7 @@
#include <sys/ioctl.h>
#include <unistd.h>
#include <iostream>
+#include <map>
#include "utf8.h"
using namespace std;
@@ -21,6 +22,7 @@ void usage() {
printf(" --list-books list books available in the current module\n");
printf(" --list-chapters <book> list chapters available in book in the current module\n");
printf(" -o, --omit-verse-numbers when printing verse text, skip printing verse and chapter numbers\n");
+ printf(" -s, --superscript when printing verse text, print verse and chapter numbers as superscript\n");
printf(" --list-installable=<lang> list bible versions available for download and install. Default lists for all languages.\n");
printf(" --install-network <mod> install module from the network where <mod> is LANG:NAME as provided by --list-installable\n");
printf(" --install-zip <path> install module from a zip file\n");
@@ -176,6 +178,7 @@ int main(int argc, char* argv[]) {
{"list-books", no_argument, 0, 0},
{"list-chapters", required_argument, 0, 0},
{"omit-verse-numbers", no_argument, 0, 'o'},
+ {"superscript", no_argument, 0, 's'},
{"list-installable", optional_argument, 0, 0},
{"install-network", required_argument, 0, 0},
{"install-zip", required_argument, 0, 0},
@@ -184,10 +187,11 @@ int main(int argc, char* argv[]) {
int opt, option_index;
string modname;
bool omitVerseNums = false;
+ bool superscript = false;
bool doListBooks = false;
string listChaptersBook;
string option;
- while ((opt = getopt_long(argc, argv, "hm:o", long_options, &option_index)) != -1) {
+ while ((opt = getopt_long(argc, argv, "hm:os", long_options, &option_index)) != -1) {
switch(opt) {
case 'h':
usage();
@@ -198,6 +202,9 @@ int main(int argc, char* argv[]) {
case 'o':
omitVerseNums = true;
break;
+ case 's':
+ superscript = true;
+ break;
case 0:
option = string(long_options[option_index].name);
if(option == "list-modules") {
@@ -303,7 +310,15 @@ int main(int argc, char* argv[]) {
if(omitVerseNums && tex.verse != verse) {
out << " ";
} else if(!omitVerseNums && tex.verse != verse) {
- out << " (" << tex.verse << ") ";
+ if(superscript) {
+ out << " ";
+ map<char,string> d2s = {{'0', "⁰"}, {'1', "¹"}, {'2', "²"}, {'3', "³"}, {'4', "⁴"}, {'5', "⁵"}, {'6', "⁶"}, {'7', "⁷"}, {'8', "⁸"}, {'9', "⁹"}};
+ for(auto &d : to_string(tex.verse)) {
+ out << d2s[d];
+ }
+ } else {
+ out << " (" << tex.verse << ") ";
+ }
}
chapter = tex.chapter;
verse = tex.verse;