From bdd140b94a4ef868eebee76c66af55a32450a5e2 Mon Sep 17 00:00:00 2001 From: Paul Mosier Date: Thu, 1 Dec 2022 17:56:00 -0500 Subject: [PATCH] Search & config file bugfixes. Doc updates. --- README.md | 5 ++--- scriptura.cpp | 43 +++++++++++++++++++++++++++++++++---------- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 837a435..b1fee8b 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ To install scriptura (into /usr/local by default): > > sudo make install -On first run, scriptura assumes that a King James module is intalled and available. Many modules from CrossWire are [available here](https://www.crosswire.org/ftpmirror/pub/sword/packages/rawzip/) and other frontends have their own repos. To install them from the command line: +On first run, scriptura assumes that the King James with Apocrypha module is intalled and available. Many modules from CrossWire are [available here](https://www.crosswire.org/ftpmirror/pub/sword/packages/rawzip/) and other frontends have their own repos. To install them from the command line: > mkdir -p $HOME/.sword/ > > cd $HOME/.sword/ @@ -30,7 +30,7 @@ On first run, scriptura assumes that a King James module is intalled and availab > > unzip KJVA.zip -A configuration file will be created at $HOME/.config/scriptura.ini. You can see the sample config file in the codebase for available options. +A configuration file will be created at $HOME/.config/scriptura.ini. You can see the sample config file in the codebase for available options. Just about everything you can modify from inside the program, with the sole exception of the 'panels' entry under [layout]. This determines if you want the two panes to stack horizontal ("h") or vertical ("v") and must be changed manually. When the software is running, the '?' key will give you the list of commands available. Open any module you have installed and you can go to or search any text. @@ -48,7 +48,6 @@ Other means of contact [can be found here](https://keyoxide.org/hkp/paladin1%40s This project is basically a one-man operation. If you'd like to show your support financially, you can contribute via: - _Paypal - paladin1_ at _sdf.org_ -- _BTC - bc1q9dfau346z38jth35gkaxacd3fljvfgw6cqcyyv_ ## Disclaimer diff --git a/scriptura.cpp b/scriptura.cpp index 70f7715..8908c34 100644 --- a/scriptura.cpp +++ b/scriptura.cpp @@ -207,14 +207,24 @@ int main(int argc, char** argv) { config.load(); // ensure some needed config settings are in place + if (! strcmp(config["layout"]["panels"], "")) + config["layout"]["panels"] = "v"; if (! strcmp(config["defaults"]["scope"], "")) config["defaults"]["scope"] = "Gen 1:1 - Rev 22:21"; if (! strcmp(config["defaults"]["searchkey"], "")) - config["defaults"]["searchkey"] = "2 Tim 1:;7"; + config["defaults"]["searchkey"] = "2 Tim 1:7"; if (! strcmp(config["defaults"]["module"], "")) config["defaults"]["module"] = "KJV"; - if (! strcmp(config["defaults"]["searchtype"], "")) - config["defaults"]["searchtype"] = DEFSEARCH; + if (! strcmp(config["defaults"]["searchtype"], "")) { + char* temp; + asprintf(&temp, "%d", DEFSEARCH); + config["defaults"]["searchtype"] = temp; + free(temp); + } + if (! strcmp(config["page0-0"]["searchkey"], "")) + config["page0-0"]["searchkey"] = "2 Tim 1:7"; + if (! strcmp(config["page0-1"]["searchkey"], "")) + config["page0-1"]["searchkey"] = "2 Tim 1:7"; saveit(); // NOTE -- anything after this point must use our defined exit wrapup() @@ -261,18 +271,18 @@ int main(int argc, char** argv) { /* with no searchkey, if this is the first pane then stop linking here; * otherwise we can get by with setting the searchkey to the default */ if (! strcmp(config[pages[i][j]]["searchkey"], "")) { - if (j == 0) linking = 0;; - config[pages[i][j]]["searchkey"] = config["defaults"]["searchkey"]; + (j == 0 ? linking = 0 : + config[pages[i][j]]["searchkey"] = config["defaults"]["searchkey"]); } if (linking && (! strcmp(config[pages[i][j]]["module"], ""))) config[pages[i][j]]["module"] = config["defaults"]["module"]; if (linking && (! strcmp(config[pages[i][j]]["keytype"], ""))) - config[pages[i][j]]["keytype"] = DEFKEY; + config[pages[i][j]]["keytype"] = config["defaults"]["keytype"]; if (linking && (! strcmp(config[pages[i][j]]["searchtype"], ""))) - config[pages[i][j]]["searchtype"] = DEFSEARCH; + config[pages[i][j]]["searchtype"] = config["defaults"]["searchtype"]; if (linking && (! strcmp(config[pages[i][j]]["scope"], ""))) config[pages[i][j]]["scope"] = config["defaults"]["scope"]; @@ -296,7 +306,7 @@ int main(int argc, char** argv) { for (int i = 0; i < NUMPANES; i++) { modkey mod = getModkey(i); - // XXX -- assumes NUMPANES, for future work + // NOTE -- assumes NUMPANES, for future work int starty, startx; starty = (i == 0 ? starty1 : starty2); startx = (i == 0 ? startx1 : startx2); @@ -468,13 +478,17 @@ int main(int argc, char** argv) { config[pages[currentpage][infocus]]["module"] = scab.getModName(modclass, mod); - config[pages[currentpage][infocus]]["keytype"] = - scab.getKeyType(modclass); + + char* temp; + asprintf(&temp, "%d", scab.getKeyType(modclass)); + config[pages[currentpage][infocus]]["keytype"] = temp; + free(temp); focustab->setModule(scab.getModDescription(modclass, mod), scab.getModName(modclass, mod), scab.getKeyType(modclass)); focustab->loadText(scab.getSpan(getModkey(infocus))); + saveit(); wipeit(p); break; } @@ -549,6 +563,15 @@ int main(int argc, char** argv) { newscope = config["defaults"]["scope"]; } + // update both pane modkey & config file to keep consistency + config[pages[currentpage][infocus]]["searchkey"] = (ret.strings)[i]; + config[pages[currentpage][infocus]]["scope"] = newscope; + + char* temp; + asprintf(&temp, "%d", i * -1); + config[pages[currentpage][infocus]]["searchtype"] = temp; + free(temp); + focustab->setKey((ret.strings)[i]); focustab->setSearch(i * -1, newscope); break;