//********************************************************************************
//* File       : AcEdit.hpp                                                      *
//* Author     : Mahlon R. Smith                                                 *
//*              Copyright (c) 2023-2026 Mahlon R. Smith, The Software Samurai   *
//*                 GNU GPL copyright notice below                               *
//* Date       : 04-Apr-2026                                                     *
//* Version    : (see AppVersion string in AcEdit.cpp)                           *
//*                                                                              *
//* Description: AcEdit class definition.                                        *
//*                                                                              *
//*                                                                              *
//********************************************************************************

//****************
//* Header Files *
//****************
#ifndef ACEDIT_DEFINED
#define ACEDIT_DEFINED        //* Be sure file is included only once

using namespace std ;         //* C++ Scope quailfier
#include <fstream>            //* File I/O streams
#include "gString.hpp"        //* gString class definition
#include "AnsiCmd.hpp"        //* AnsiCmd class definition
#include "AnsiCmdWin.hpp"     //* ACWin class definition
#include "AcEditFile.hpp"     //* File management definitions

//* ------------------------------------------------------ *
//* Enable/disable application-level debugging information.*
//* ------------------------------------------------------ *
#define DEBUG_ACE (1)
#if DEBUG_ACE != 0
#define DEBUG_EVIS (0)           // window remains visible on exit
#define DEBUG_PSRC (0)           // protect source files from overwrite
#define DEBUG_DUMP_WINFO (0)     // write winInfo data to terminal OR to log file
#define DEBUG_DUMP_FINFO (0)     // write FileMan data to terminal OR to log file
#define DEBUG_EXT_TESTS (1)      // enable extended tests in Sandbox()
const short DD2WIN_ROW = 2 ;     // terminal offsets for data dump
const short DD2WIN_COL = 99 ;
#endif   // DEBUG_ACE


//***************************
//* General constant values *
//***************************
const wchar_t* const appVersion = L"0.0.05" ;
const wchar_t* const crYears    = L"2023-2026" ;
const char*    const titleTemplate =  
                     "AcEdit (ace) v:%S (c) %S  The Software Samurai" ;

typedef double dbl_t ;              // alias for 'double' type
typedef long double ldbl_t ;        // alias for 'long double' type

const short ROW_DFLT  = 1 ;         // default position (row)
const short COL_DFLT  = 1 ;         // default position (column)
// If main edit field min==24x80, the app would be: 24+3 x 80+6 == 27x86
const short HGT_MIN   = 27 ;        // minimum window height (rows)
const short WID_MIN   = 86 ;        // minimum window width (columns)
const short HGT_DFLT  = HGT_MIN ;   // default window height (rows)
const short WID_DFLT  = 96 ;        // default window width (columns)
const short MAX_FILES = 16 ;        // maximum number of files simultaneously under edit
const short MAX_FMANS = MAX_FILES + 2 ; // size of the array of FileMan objects
const short TAB_DFLT  = 3 ;         // default width of tab character emulation
const short TAB_MAX   = KEYPUSH_MAX - 2 ; // maximum width of tab character emulation

//* Names of field indices *
enum fldIndex : short
{
   fiLINEvl  = ZERO,       // line number field (vertical left), for fiTEXTfw && fiTEXTvl
   fiLINEvr  =  1,         // line number field (vertical center) for fiTEXTvr
   fiLINEhu  =  2,         // line number field (horizontal upper) for fiTEXThu
   fiLINEhl  =  3,         // line number field (horizontal lower) for fiTEXThl
   fiTEXTfw  =  4,         // primary text edit field (full window)
   fiTEXTvl  =  5,         // vertical text-field pair (Left)
   fiTEXTvr  =  6,         // vertical text-field pair (Right)
   fiTEXThu  =  7,         // horizontal text-field pair (Upper)
   fiTEXThl  =  8,         // horizontal text-field pair (Lower)
   fiHDIV    =  9,         // horizontal-field separator (view-only)
   fiGUTTER  = 10,         // gutter field
   fiMENUBAR = 11,         // menu bar
   fiM_FILE  = 12,         // file menu
   fiM_EDIT  = 13,         // edit menu
   fiM_VIEW  = 14,         // view menu
   fiM_UTIL  = 15,         // util menu
   fiM_HELP  = 16,         // help menu
   fiFIELDS                // number of fields defined
} ;

//* This value in the 'tindx' and/or the 'lindx' member of a FileMan object    *
//* indicates that the object is not associated with an TextEdit control.      *
//* If the FileMan record is displayed, those members will be reported as "--".*
const fldIndex IDLE_BUFF = fiHDIV ;

//* Constant indices referencing the "active" and "inactive" FileMan records *
const short AREC = MAX_FMANS - 2 ;  // index of "active" FileMan record
const short IREC = MAX_FMANS - 1 ;  // index of "inactive: FileMan record

const char* const configName = "ace.cfg" ; // default configuration file

//* Supported user-interface languages *
enum UILang : short
{
   uilEN = ZERO,  // English
   uilZH,         // Zhongwen (Chinese, simplified - mainland)
   uilENV         // Taken from terminal environment (default)
} ;

//* Indicates which (if any) dialog is open and needs    *
//* callback support. Note that only certain complex     *
//* dialogs use callbacks. See dlgCallback() for details.*
enum ActiveDlg : short
{
   adNONE,           // No dialog currently requiring callback support
   adOpen,           // select4Edit()
   adSaveAs,         // saveFileAs()
   adCompare,        // CompareFiles()
   adOrphan,         // orphanDialog()
} ;

//* Return values for GetCommandLineArgs(). ( 'userOption' ) *
enum clArgs : short 
{ clQuickHelp, clHelp, clHelpless, clVersion, clVersiona, clTermSize, clOpen } ;

//*********************************************
//* Gather and process command-line arguments *
//*********************************************
class commArgs
{
   public:
      //* Initialization constructor *
   commArgs ( int argc, char** argv, char** argenv ) :
               argCount(argc), argList(argv), envList(argenv)
   {
      this->winRow  = ROW_DFLT ;          // set default values for all parameters
      this->winCol  = COL_DFLT ;
      this->winHgt  = HGT_DFLT ;
      this->winWid  = WID_DFLT ;
      this->winBdr  = ltSINGLE ;
      this->bdrAttr = acaUSEDFLT ;
      this->intAttr = acaUSEDFLT ;
      this->txtAttr = acaUSEDFLT ;
      this->hilAttr = acaUSEDFLT ;
      this->mnuAttr = acaUSEDFLT ;
      this->dlgAttr = acaUSEDFLT ;
      this->auxAttr = acaUSEDFLT ;
      this->trmAttr = acaUSEDFLT ;
      this->tabWid  = TAB_DFLT ;
      this->cfgFile[0] = NULLCHAR ;
      this->locale[0] = NULLCHAR ;
      this->sysclip = true ;
      this->verFlag = this->helpFlag = false ;
      this->testnum = -1 ;                // no test specified, display test menu
   }

   //** Public Data Members **
   short    argCount ;           // application's 'argc'
   char**   argList ;            // application's 'argv'
   char**   envList ;            // application's 'argenv'

   short    winRow ;             // Origin row of main window (1-based)
   short    winCol ;             // Origin column of main window (1-based)
   short    winHgt ;             // Height of main window (rows)
   short    winWid ;             // Width of main window (columns)
   LineType winBdr ;             // Window border line type (ltSINGLE | ltDUAL)
   acAttr   bdrAttr ;            // color attributes for window border
   acAttr   intAttr ;            // color attributes for window interior
   acAttr   txtAttr ;            // color attributes for text fields
   acAttr   hilAttr ;            // color attributes for highlighted text
   acAttr   mnuAttr ;            // color attributes for menu fields
   acAttr   dlgAttr ;            // color attributes for dialog sub-windows
   acAttr   auxAttr ;            // color attributes for auxilliary fields
   acAttr   trmAttr ;            // terminal window attributes
   short    tabWid ;             // number of spaces assigned to tab character
   char     locale[LOCALE_LEN] ; // locale filename
   char     cfgFile[MAX_PATH] ;  // filespec of configuration file
   gString  gsErr ;              // receives formatted error message(s)
   short    testnum ;            // test number (for debugging only)
   bool     sysclip ;            // set if request system clipboard connection

   bool     verFlag ;            // --version: 'true' if display command-line version
   bool     helpFlag ;           // -H option: 'true' if display command-line help
} ;   // commArgs

//* Application exit codes returned to shell. *
//* Used to display warning messages.         *
enum xCode : int
{
   xcGOOD = ZERO,    // success
   xcFNF  = -1,      // target file not found
   xcOOR  = -2,      // value out-of-range
   xcSYN  = -3,      // syntax error for command-line argument
   xcCFG  = -4,      // bad format for config file entry
} ;

//* Context (chapter or section) for opening the documentation *
enum contextCode : short
{
   cxtMAIN = ZERO,               // top menu
   cxtANSICMD,                   // AnsiCmd library documentation
   cxtACWIN,                     // ACWin class documentation
   cxtGSTRING,                   // gString class documentation
   cxtEPOINTS,                   // EarthPoints demo app
   cxtCSVVIEW,                   // CsvView demo app
   cxtACEDIT,                    // AcEdit demo app
   cxtINDEX,                     // documentation index
} ;

//* Options for calling 'updateText' method. *
enum utOption : short
{
   utReset,       // delete any existing data and reset line-number field
   utInit,        // initialize the target field with specified data
   utSynch,       // update line-number field to synch with text
} ;

const short SHORT_KEYS = 20 ;             // number of shortcut keys defined
extern const wchar_t ShortkeyDflt[] ;     // shortcut key default keycodes
extern const char* const ShortkeyName[] ; // shortcut key display names
extern const char* const ShortkeyDesc[] ; // shortcut key descriptions

class ShortKeys               // Shortcut-key definition class
{
   public:
   ~ShortKeys ( void ) { /* nothing to do */ }
   ShortKeys ( void )
   {
      this->reset() ;
   }

   //* Compare the specified keycode to each of the defined shortcut keys. *
   //* If a match found, the _default_ shortcut keycode for that command   *
   //* is returned in 'sckey' .                                            *
   //* Note that a few keycodes will automatically accept alternate values.*
   //* This is done in case the system or terminal has captured it before  *
   //* being seen by app (or to compensate for ingrained user habits).     *
   //* Input :: wkey  : keycode entered by user                            *
   //*          sckey : (by reference) if a match found, receives the      *
   //*                  default command key for matching operation.        *
   //*                  - If no match, value is not modified.              *
   //* Returns: 'true' if matching keycode found, else 'false'             *
   bool is_skey ( wchar_t wkey, wchar_t& sckey )
   {
      bool isMatch = false ;
      if ( wkey == wcsALT_0 )      { wkey = wcsALT_1 ; }
      else if ( wkey == wcsAUP )   { wkey = wcsCAPGUP ; }
      else if ( wkey == wcsADOWN ) { wkey = wcsCAPGDN ; }
      for ( short k = ZERO ; k < SHORT_KEYS ; ++k )
      {
         if ( wkey == this->ukey[k] )
         { sckey = this->dkey[k] ; isMatch = true ; break ; }
      }
      return isMatch ;
   }

   //* Private methods and data *
   private:
   void reset ( void )
   {
      //* User definition members are initialized *
      //* to default keycode values.              *
      for ( short i = ZERO ; i < SHORT_KEYS ; ++i )
         this->dkey[i] = this->ukey[i] = ShortkeyDflt[i] ;
   }

   //* Public Data Members *
   public:
   wchar_t dkey[SHORT_KEYS] ;    // default keycodes
   wchar_t ukey[SHORT_KEYS] ;    // user-defined keycodes

} ;

//***********************************************************
//* File Management for file under edit                     *
//* A FileMan-class object manages the interactions among   *
//* the source file, the backup file, the temp buffer and   *
//* the associated Textbox field's text data.               *
//***********************************************************
const int FM_MINBYTES = gsALLOCMIN ;   // minimum allocation for 'scrdata'
class FileMan
{
   public:
   ~FileMan ( void )             // destructor
   {
//      if ( this->scrdata != NULL ) // Not yet defined
//      { delete [] this->scrdata ; this->scrdata = NULL ; }
   }
   FileMan ( void )              // default constructor
   {
      this->reset () ;
   }
   int32_t wbAlloc ( int32_t buffBytes )
   {
//      if ( buffBytes < FM_MINBYTES )
//         buffBytes = FM_MINBYTES ;
//      if ( this->scrdata != NULL ) { delete [] this->scrdata ; }
//      this->scrdata = new char[buffBytes] ;
//      this->scrCnt  = buffBytes ;
      return ( this->scrCnt ) ;
   }

   void operator= ( const FileMan* fmptr )
   {  // Called primarily to remove duplicated records.
      this->tnf = fmptr->tnf ;
      gString gs( fmptr->srcSpec ) ;
      gs.copy( this->srcSpec, MAX_PATH ) ;
      gs = fmptr->wrkSpec ;
      gs.copy( this->wrkSpec, MAX_PATH ) ;
      this->tindx = fmptr->tindx ;
      this->lindx = fmptr->lindx ;
      //srcdata[] - not yet defined
      scrCnt        = fmptr->scrCnt ;
      this->vtop    = fmptr->vtop ;
      this->voff    = fmptr->voff ;
      this->hoff    = fmptr->hoff ;
      this->sindx   = fmptr->sindx ;
      this->open    = fmptr->open ;
      this->mods    = fmptr->mods ;
      this->wmods   = fmptr->wmods ;
      this->active  = fmptr->active ;
   }

   void reset ( void )
   {
//      if ( this->scrdata != NULL )        // release dynamic memory
//      { delete [] this->scrdata ; this->scrdata = NULL ; }
      this->scrCnt = ZERO ;
      this->tindx = this->lindx = IDLE_BUFF ;
      this->tnf.reset () ;                // reset file stats data
      this->srcSpec[0] = this->wrkSpec[0] = NULLCHAR ;
      this->vtop = this->voff = this->hoff = ZERO ;
      this->sindx = -1 ;
      this->mods = this->wmods = this->open = this->active = false ;
      this->edtime = ZERO ;
   }

   //*************************
   //** Public Data Members **
   //*************************
   tnFName tnf ;                 // source file stats
   char    srcSpec[MAX_PATH] ;   // filespec for source file
   char    wrkSpec[MAX_PATH] ;   // filespec for working copy of source file
   fldIndex tindx ;              // index of TextEdit control where data are displayed
   fldIndex lindx ;              // index of LineNumber control associated with TextEdit control
 //char    *scrdata ; // NOT YET DEFINED - see mmap() library function undo/redo, etc.
   int      scrCnt ;             // size of dynaminc allocation for 'scrbuff' (bytes)
   int      vtop ;               // index if first visible data line
   int      voff ;               // offset (line count) from 'vtop' to cursor line
   int      hoff ;               // offset (char count) from head of cursor line to IP
   int      sindx ;              // index of record from which active record was taken
   bool     open ;               // set if file is open (or to be opened on startup)
   bool     mods ;               // 'true' if mods not yet saved to source file
   bool     wmods ;              // 'true' if auto-save pending (TextEdit data newer than working copy)
/* DEPRECATED */ bool active ; // 'true' when object contains live (displayed) data
// 'active' applies only to the AREC and IREC
   int64_t  edtime ;             // saved mod time of file (epoch time)
   // See documentatio for a fuller description of each FileMan data member.

} ;   // FileMan class

//********************************
//* Application class definition *
//********************************
class AcEdit
{
   public:
   ~AcEdit ( void ) ;               // destructor
   AcEdit ( commArgs& ca ) ;        // constructor

   //* Define the position, dimensions, and other attributes of the main window. *
   bool DefineWindow ( commArgs& ca ) ;
   //* Called by non-member callback function during user interaction.*
   wchar_t Callback ( short ctrlIndex, wchar_t wkey, bool firstTime = false ) ;
   wchar_t dlgCallback ( short ctrlIndex, wchar_t wkey, bool firstTime = false ) ;
   xCode GetExitCode ( void ) ;     // report the exit code for the class

   //** Protected Methods and Data Members **
   protected:

   //* Methods of the Editor Group *
   void Editor ( void ) ;
   bool openFile4Edit ( short fmIndx ) ;
   bool closeRecord ( short fmIndx ) ;
   bool newFile2Edit ( bool setActive = true ) ;
   bool loadField ( short fmSrc, fldIndex fldTrg, bool setFocus = true ) ;
   bool selectBuffer ( wchar_t selOpt ) ;
   bool undo ( short fIndx ) ;
   bool redo ( short fIndx ) ;
   bool save ( short fIndx, bool updateSrc = false ) ;
   void updateWindow ( fldIndex fIndx = fiFIELDS ) ;
   bool updateFocus ( fldIndex trgIndx, wchar_t hKey = NULLCHAR ) ;
   void updateAuxData ( bool ln_only = false, bool alt_fld = false ) ;
   void updateLinenum ( fldIndex lnIndx, int topline = -1 ) ;
   void updateGutter ( bool stats = true, const wchar_t *wmsg = NULL, 
                       bool warn = false, short blink = ZERO ) ;
   void tabEmulator ( void ) ;

   //*****************************
   //* Methods of the Menu Group *
   //*****************************
   bool gotoLine ( void ) ;
   bool findSubstring ( wchar_t& wkey, uint16_t* setup = NULL ) ;
   bool findDelimMatch ( void ) ;
   bool findTagMatch ( void ) ;
   void clipboardInfo ( void ) ;
   bool reportOpenFiles ( short& selRec ) ;
   void reportRecentFiles ( void ) ;
   skForm* repdlgFmt ( short dlgOpt, short fCnt, short dlgHgt, short dlgWid, 
                       const char* fldText ) ;
   //* Display terminal window and application window configurations.*                                                        *
   void reportTermWinUser ( void ) ;
   //* Initialize "active" FileMan record.*
   void setActiveFileMan ( short srcIndx = -1 ) ;
   //* Swap (exchange) the data in the "active" and "inactive" FileMan records.*
   void swapActiveFileMan ( void ) ;
   //* Copy FileMan record back to its "source" record.*
   void saveFileMan ( bool activeRec = true ) ;
   //* Save TextEdit data to the working copy of the file.*
   bool autoSave ( short fmIndx = AREC ) ;
   //* Update the source file for a file currently under edit.*
   bool fullSave ( short fmIndx = AREC ) ;
   //* Save file under a new name.*
   bool saveFileAs ( void ) ;
   //* Scan the list of 'open' files, and do updates.*
   bool saveAll ( void ) ;

   //* Display file stats for file under edit (field with focus).*
   void reportFileStats ( const FileMan* fmPtr ) ;
//   bool saveFile ( void ) ;
   wchar_t s4eCallback ( short ctrlIndex, wchar_t wkey, bool firstTime ) ;
   wchar_t sfaCallback ( short ctrlIndex, wchar_t wkey, bool firstTime ) ;
   wchar_t cmpCallback ( short ctrlIndex, wchar_t wkey, bool firstTime ) ;
   wchar_t rorCallback ( short ctrlIndex, wchar_t wkey, bool firstTime ) ;
   void reportKeycodes ( void ) ;
   void select4Edit ( fldIndex fi ) ;
   void CompareFiles ( void ) ;
   void HelpAbout ( void ) ;
   bool ContextHelp ( contextCode ccode ) ;
   bool HtmlDocs ( void ) ;
   void docsNotFound ( void ) ;
   int  LaunchDefaultApplication ( const char* targFile, bool redirect = true ) ;
   void DisplayHelp ( clArgs userOption ) ;
   void DisplayVersion ( bool verbose ) ;

   //* Startup and shutdown methods *
   //* ---------------------------- *
   clArgs GetCommandLineArgs ( commArgs& ca ) ;
   bool   gclaFilespec ( const gString& gsSrc, gString& gsErr ) ; 
   bool   gclaColorEncode ( const gString& gsCmd, commArgs& ca ) ;
   void   gclaLanguage ( const gString& cmd, commArgs& ca ) ;
   void   gclaDuplicatedFiles ( void ) ;
   const  wchar_t* GetAppVersion ( const wchar_t*& years ) ;
   bool   Configure ( commArgs& ca ) ;
   void   cfgDecodeKeycode ( const gString& gsIn, gString& gsErr ) ;
   void   startupLocale ( bool enable ) ;
//   bool gclaColorScheme ( const gString& gsCmd, TermConfig& tCfg ) ;
//   void gclaSysInfo ( void ) ;
   bool   recoverOrphan ( const tnFName& tnfSrc, const tnFName& tnfBak ) ;
   //* Update the configuration file's programatically-generated data.*
   void configUpdate ( void ) ;
   //* Generate a new, default configuration file.*
   bool configGenerate ( const char* cfgName = NULL ) ;

   //* File management methods *
   //* ----------------------- *
   short GetFileStats ( tnFName& tnFile, const gString& fPath ) ;
   short GetFileStats ( tnFName& tnFile, const char* fPath ) ;
   bool  GetRealpath ( const char* rawPath, gString& fSpec, short* errnoPtr = NULL ) ;
   bool  ReadPermission ( tnFName& sStats, const gString& sPath, bool enable = false ) ;
   bool  ReadPermission ( tnFName& sStats, const char* sPath, bool enable = false ) ;
   bool  WritePermission ( tnFName& sStats, const gString& sPath, bool enable = false ) ;
   bool  WritePermission ( tnFName& sStats, const char* sPath, bool enable = false ) ;
   short GetLinkTargetStats ( const gString& lnkPath, 
                              tnFName& ltrgStats, gString& ltrgPath ) ;
   void  BrokenLinkTargetPath ( const char* linkPath, 
                                char trgPath[MAX_PATH], char trgName[MAX_FNAME] ) ;
   bool  isTextfile ( const gString& gsTrg ) ;
   bool  compareFiles ( const tnFName& primeStat, const tnFName& secStat,
                        const gString& logFile, wchar_t format ) ;
   short GetLine ( std::ifstream& ifs, gString& gsIn, bool stripnl = true ) ;
   short DeleteFile ( const char* srcPath ) ;
   short DeleteEmptyDir ( const char* dirPath ) ;
   short CopyFile ( const char* srcPath, const char* trgPath, bool no_clobber = false ) ;
   short RenameFile ( const char* srcPath, const char* trgPath ) ;
   bool  getCWD ( gString& cdir ) ;
   bool  setCWD ( const gString& gsTrg, gString* oldCwd = NULL ) ;
   bool  readCwd ( const char* cwdPath, gString& gsDNames, short& dnCnt, 
                   gString& gsFNames, short& fnCnt, int trgWid, bool incltmp = false ) ;
   short readCwd ( gString& gsList, acAttr*& acArray, short fldWid, 
                   acAttr dAttr = acaUSEDFLT, acAttr fAttr = acaUSEDFLT, 
                   bool incltmp = false ) ;
   bool  isFilename ( const gString& gsName, bool inclSlash = false, 
                      bool vfatChars = false, int* failIndx = NULL ) ;
   bool  isAlNum ( wchar_t wch, bool inclSpace = false ) ;
   void  formatTimestamp ( const localTime& lt, gString& tStamp, bool canon = false, 
                           bool secs = true, bool dow = false ) const ;
   void  epoch2Timestamp ( int64_t epoch, gString& gsTstamp, bool canon = true,
                           localTime* ltptr = NULL ) const ;
   bool  GetLocalTime ( localTime& ft ) ;
   bool  ExtractFilename ( gString& nameBuff, const gString& pfSource ) ;
   bool  ExtractFilename ( char nameBuff[MAX_FNAME], const gString& pfSource ) ;
   void  ExtractPathname ( gString& pathBuff, const gString& pfSource ) ;
   void  ExtractPathname ( char pathBuff[MAX_PATH], const gString& pfSource ) ;
   short EscapeSpecialChars ( gString& pathSpec, escGroup group, wchar_t wch = NULLCHAR ) ;

   //* General support methods *
   //* ----------------------- *
   bool IdentifyUser ( void ) ;
   bool infoDialog ( const gString& gsInfo, bool uDecide, const char* title = NULL,
                     short vOff = ZERO, short hOff = -1, short timeout = ZERO ) ;
   void flashDialog ( const gString& gsInfo, short timeout, 
                      acAttr bgnd = acaUSEDFLT, bool border = false ) ;
   void ComposeTitle ( gString& gs, bool withUL = false, bool withNL = false ) ;
   void DisplayTermSize ( void ) ;

   //** Methods for Debugging **
   short Sandbox ( short op = ZERO) ;// for debugging only
   WinPos dumpWinInfo ( short outRow, short outCol, ofstream* ofsdump = NULL ) ;
   WinPos dumpTermInfo ( short outRow, short outCol, ofstream* ofsdump = NULL ) ;
   void dumpFileMan ( const FileMan* fmanPtr, bool dlg = false, bool 
                      verbose = false, const char* title = NULL ) ;
   void dumpFileMan ( short filter = ZERO, bool verbose = false, const char* title = NULL ) ;
   void dumpFileStats ( short fmIndx ) ;
   void dumpTimestamp ( const localTime& lt, const char* title = NULL, 
                        bool hdr = true, bool footer = false ) ;
   #if DEBUG_ACE != 0
   short SetFileTimestamp ( const char* pathBuff, const localTime& ft, 
                             bool updateMod = true, bool updateAcc = true ) ;
   int64_t timestamp2Epoch ( localTime& ftTime ) ;
   #if DEBUG_PSRC != 0
   short psrc ( bool set ) ;
   #endif   // DEBUG_PSRC
   #endif   // DEBUG_ACE

   void reset ( void )              // set all data members to default values
   {
      this->win = NULL ;            // not yet instantiated
      this->termAttr = acaUSEDFLT ; // terminal defaults
      this->hilAttr = acaUSEDFLT ;  // text highlight attribute
      this->dlgAttr = acaUSEDFLT ;  // dialog and window background attribute
      this->auxAttr = acaUSEDFLT ;  // linenum/gutter defaults
      this->lang = uilEN ;          // default (English) language
      this->fmcnt = ZERO ;          // no open (or recent) files
      this->focus = fiTEXTfw ;      // initial focus is on full-window TextEdit control
      this->tabWid = TAB_DFLT ;     // tab character width
      this->cfgPath[0] = NULLCHAR ; // not yet known
      this->tfm = NULL ;            // not yet created
      this->adlg = adNONE ;         // no open dialogs
      this->exitCode = xcGOOD ;     // assume success
      //* (the 'fman' array is self-initializing) *
      //* (the 'keys' object is self-initializing)*
   }

   ACWin *win ;                     // pointer to application window
   winInfo wInfo ;                  // basic window information
   acAttr termAttr ;                // terminal window attribute (outside app window)
   acAttr dlgAttr ;                 // dialog and window background attribute
   acAttr hilAttr ;                 // text highlight attribute
   acAttr auxAttr ;                 // general-purpose attribute (also static field attr)
   UILang lang ;                    // user interface language (Note: Used as an index)

   FileMan fman[MAX_FMANS] ;        // data for each target file
   short fmcnt ;                    // number of initialized records in 'fman'
   fldIndex focus ;                 // index of TextEdit control with input focus
   short tabWid ;                   // tab key emulation (column width)
   UserInfo userInfo ;              // user's file access data
   char  cfgPath[MAX_PATH] ;        // path spec of configuration file
   TFMan *tfm ;                     // temp-file management (used during start-up only)
   ActiveDlg adlg ;                 // indicates open dialog associated with callback
   ShortKeys keys ;                 // shortcut keycode coding/decoding
   xCode exitCode ;                 // application exit code

   //* Used only for testing of the AnsiCmd-class functionality.*
   dbgArgs act ;

} ;   // AcEdit class
#endif   // ACEDIT_DEFINED          //* Be sure file is included only once
