156 lines
5.1 KiB
C++
156 lines
5.1 KiB
C++
// Copyright 2021, Paul Mosier
|
|
//
|
|
// This file is part of Scriptura, a ncurses-based Bible study
|
|
// software for the libsword backend.
|
|
//
|
|
// Scriptura is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, under version 2 of the License.
|
|
//
|
|
// Scriptura is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with Scriptura. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
// scabbard.h -- header for Scabbard
|
|
|
|
|
|
#ifndef SCABBARD
|
|
#define SCABBARD
|
|
|
|
#include <swmgr.h>
|
|
#include <swmodule.h>
|
|
#include <swconfig.h>
|
|
#include <swbuf.h>
|
|
#include <versekey.h>
|
|
#include <treekey.h>
|
|
#include <installmgr.h>
|
|
|
|
#include <osisredletterwords.h>
|
|
#include <osisstrongs.h>
|
|
#include <osisfootnotes.h>
|
|
#include <gbfredletterwords.h>
|
|
#include <gbffootnotes.h>
|
|
// unimplemented extras
|
|
//#include <osismorph.h>
|
|
//#include <osislemma.h>
|
|
//#include <osisheadings.h>
|
|
|
|
#include "free.h"
|
|
|
|
|
|
/*! Structure for associating a Sword module type (Bibles,
|
|
* commentaries, etc) to a list of modules. */
|
|
typedef struct {
|
|
char label[25]; //!< the module type
|
|
int keytype; //!< 0 - versekey, 1 - treekey, 2 - direct/alpha
|
|
int modlen; //!< length of module list
|
|
sword::SWModule ** modlist; //!< list of modules
|
|
} modtype;
|
|
|
|
|
|
//! Handles the interface to the Sword library.
|
|
class scabbard {
|
|
|
|
//! Sword manager structure
|
|
sword::SWMgr swrd;
|
|
|
|
/*! Sword iterator for module parsing.
|
|
* Module data fields of interest:
|
|
* name - internal name
|
|
* description - full text name
|
|
* type - class of module */
|
|
sword::ModMap::iterator iter;
|
|
|
|
int nummods; //!< number of module types that contain modules
|
|
int markred; //!< flag for returning red letter output
|
|
int markstrongs; //!< flag for returning Strong's numbers
|
|
int markfoot; //!< flag for returning footnotes
|
|
|
|
/*! Parse a list of verses (Gen 1:1,3; Eph 1:5-10, etc)
|
|
* \returns the full text of the verses requested as one long string */
|
|
const char* parseVerses(sword::SWModule *text, //!< the source to reference
|
|
sword::ListKey lk //!< list of verses to get
|
|
);
|
|
|
|
/*! Helper to the search function for non-versekeyed modules.
|
|
* \returns the closest (or exact) match to a search term */
|
|
const char* directSearch(sword::SWModule *text,
|
|
//!< the module to search on
|
|
modkey mod
|
|
//!< modkey containing the search term
|
|
);
|
|
|
|
//! Construct the internal list of modules used in the selection menu.
|
|
void constructModlist();
|
|
|
|
public:
|
|
//! Takes as input various preferences on text markup from our config file
|
|
scabbard();
|
|
|
|
/*! Struct to hold listing of different modules - each modtype corresponds
|
|
* to a different type of module - see comments for modtype */
|
|
modtype modules[5];
|
|
|
|
/*! Get all module types loaded in and accessible by Sword.
|
|
* \returns the module types loaded into an array */
|
|
starray getModClassifications();
|
|
|
|
/*! Get the full text names of all modules of a given type (Bibles,
|
|
* commentaries, etc.)
|
|
* \returns all module text names in an array */
|
|
starray getModDescriptions(int type //!< from getModClassifications()
|
|
);
|
|
|
|
/*! Get the internal module name for a specific module.
|
|
* \returns the name requested */
|
|
const char* getModName(int modt, //!< from getModClassifications()
|
|
int mod //!< from getModDescriptions()
|
|
);
|
|
|
|
/*! Get the full text name for a module identified by menu indices.
|
|
* \returns the module description */
|
|
const char* getModDescription(int modt, //!< from getModClassifications()
|
|
int mod //!< from getModDescriptions()
|
|
);
|
|
|
|
/*! Get the full text name for a module identified by key name. Vulnerable
|
|
* to malicious input.
|
|
* \returns the module description */
|
|
const char* getModDescription(const char* modname //!< module internal name
|
|
);
|
|
|
|
//! Return an array of all module names.
|
|
starray getModules();
|
|
|
|
/*! Given a text name for a module, determine if it exists.
|
|
*/
|
|
int modExists(const char* modname //!< module internal name
|
|
);
|
|
|
|
/*! Determine how a module is keyed/indexed.
|
|
* \returns the proper keytype; see the keytype field for modkey */
|
|
int getKeyType(int modt //!< return value from getModClassifications()
|
|
);
|
|
|
|
/*! Do a passage or text lookup.
|
|
* \returns the passage or text referenced in the modkey */
|
|
const char* getSpan(modkey mod //!< the modkey supplied by the pane
|
|
);
|
|
|
|
/*! Search for a term or passage.
|
|
* \returns the text requested, or in the case of a non-versekeyed text,
|
|
* the nearest alphabetical entry to the search term supplied */
|
|
const char* search(modkey mod //!< the modkey supplied by the pane
|
|
);
|
|
|
|
//! Install KJVA from ftp.crosswire.org.
|
|
void installKJVA();
|
|
|
|
};
|
|
|
|
#endif
|