89 lines
2.9 KiB
C
89 lines
2.9 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/>.
|
|
|
|
// free.h - free functions / globals
|
|
|
|
#ifndef SCRIPT_GLOBAL
|
|
#define SCRIPT_GLOBAL
|
|
|
|
#include <swconfig.h>
|
|
#include <swbuf.h>
|
|
|
|
|
|
// preprocessor directives - for some compiler-constant expressions
|
|
#define PAGELIMIT 5 // the maximum number of pages allowed
|
|
#define NUMPANES 2 // the max number of panes allowed -- this value
|
|
// as is in other places of the code
|
|
|
|
//! Structure to make managing arrays easier. Who doesn't like arrays?
|
|
typedef struct {
|
|
int length; //!< number of elements
|
|
const char ** strings; //!< list of strings
|
|
} starray;
|
|
|
|
|
|
/*! Structure to hold a module ID, search key, and related search parameters.
|
|
* One is stored by each pane. */
|
|
typedef struct {
|
|
const char* modname; //!< name of module
|
|
const char* searchkey; /*!< search key for module - if NULL or empty, the
|
|
* struct is considered empty */
|
|
int keytype; //!< 0 - versekey, 1 - treekey, 2 - direct
|
|
int searchtype; //!< type of search to be performed, if any
|
|
const char* scope; //!< scope of search, if any
|
|
} modkey;
|
|
|
|
//! String giving all in-program key commands. Displayed in the help window.
|
|
extern char HELPTEXT[];
|
|
|
|
//! String giving the informative text on the command line, for '-h'
|
|
extern char CLITEXT[];
|
|
|
|
//! Value of default searchtype for lookups keyed to verse
|
|
extern int DEFSEARCH;
|
|
|
|
//! Value of default keytype for lookups
|
|
extern int DEFKEY;
|
|
|
|
//! Global copy of the program's configuration file settings.
|
|
extern sword::SWConfig config;
|
|
|
|
/*! Close out of ncurses gracefully, display an exit message if we have one, and
|
|
* quit. */
|
|
void wrapup(int exitval, const char* str);
|
|
|
|
//! Trim trailing whitespace for a string.
|
|
void trim(char* str);
|
|
|
|
//! parse through a configuration setting from SWConfig
|
|
int parseConf(sword::SWBuf buf);
|
|
|
|
/*! Determine if a substring is present at either the beginning of a string or
|
|
* at any point within it, depending on a toggle for a flag -- return integer
|
|
* of matching index. */
|
|
//int strmatch(wchar_t text[], const wchar_t* key, int matchnow);
|
|
int strmatch(char text[], const char* key, int matchnow);
|
|
|
|
//! Append a new string to a starray.
|
|
starray stappend(starray arr, const char* newstr);
|
|
|
|
//! Initialize a new starray.
|
|
starray stinit(starray arr);
|
|
|
|
|
|
#endif
|