wxMaxima
Loading...
Searching...
No Matches
MaximaManual.h
Go to the documentation of this file.
1// -*- mode: c++; c-file-style: "linux"; c-basic-offset: 2; indent-tabs-mode: nil -*-
2//
3// Copyright (C) 2009-2015 Andrej Vodopivec <andrej.vodopivec@gmail.com>
4// Copyright (C) 2015 Gunter Königsmann <wxMaxima@physikbuch.de>
5//
6// This program is free software; you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation; either version 2 of the License, or
9// (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16//
17// You should have received a copy of the GNU General Public License
18// along with this program; if not, write to the Free Software
19// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20//
21// SPDX-License-Identifier: GPL-2.0+
22
30#ifndef MAXIMAMANUAL_H
31#define MAXIMAMANUAL_H
32
33#include <atomic>
34#include <thread>
35#include <mutex>
36#include <memory>
37#include <vector>
38#include <wx/dir.h>
39#include <wx/wx.h>
40#include <wx/arrstr.h>
41#include <wx/regex.h>
42#include <wx/xml/xml.h>
43#include <wx/filename.h>
44#include "precomp.h"
45#include "Configuration.h"
46#include "Version.h"
47#include <unordered_map>
48
49/* The autocompletion logic
50
51 The wordlists for autocompletion for keywords come from several sources:
52
53 - wxMaxima::ReadLoadSymbols receive the contents of maxima's variables
54 "values" and "functions" after a package is loaded.
55 - all words that appear in the worksheet
56 - and a list of maxima's builtin commands.
57*/
59{
60public:
61 explicit MaximaManual(Configuration *configuration);
62 typedef std::unordered_map <wxString, wxString, wxStringHash> HelpFileAnchors;
63 HelpFileAnchors GetHelpfileAnchors();
64 void FindMaximaHtmlDir(const wxString &docDir);
65 wxString GetHelpfileAnchorName(wxString keyword);
66 wxString GetHelpfileUrl_Singlepage(const wxString &keyword);
67 wxString GetHelpfileUrl_FilePerChapter(const wxString &keyword);
68 wxString GetHelpfileURL(const wxString &keyword);
70 void LoadHelpFileAnchors(const wxString &docdir, const wxString &maximaVersion);
72 void CompileHelpFileAnchors(const wxString &maximaHtmlDir,
73 const wxString &maximaVersion,
74 const wxString &saveName);
78 bool LoadManualAnchorsFromXML(const wxXmlDocument &xmlDocument, bool checkManualVersion = true);
82 void SaveManualAnchorsToCache(const wxString &maximaHtmlDir,
83 const wxString &maximaVersion,
84 const wxString &saveName);
85 virtual ~MaximaManual();
86private:
87 std::atomic_bool m_abortBackgroundTask;
89 static void AnchorAliasses(HelpFileAnchors &anchors);
91 class GetHTMLFiles : public wxDirTraverser
92 {
93 public:
94 explicit GetHTMLFiles(std::vector<wxString>& files, const wxString &prefix = wxEmptyString) :
95 m_files(files), m_prefix(prefix) { }
96 virtual wxDirTraverseResult OnFile(const wxString& filename) override;
97 virtual wxDirTraverseResult OnDir(const wxString& dirname) override;
98 std::vector<wxString>& GetResult() const {return m_files;}
99 protected:
100 std::vector<wxString>& m_files;
101 wxString m_prefix;
102 };
103 class GetHTMLFiles_Recursive : public wxDirTraverser
104 {
105 public:
106 explicit GetHTMLFiles_Recursive(std::vector<wxString>& files,
107 const wxString &prefix = wxEmptyString) :
108 m_files(files), m_prefix(prefix) { }
109 virtual wxDirTraverseResult OnFile(const wxString& filename) override;
110 virtual wxDirTraverseResult OnDir(const wxString& dirname) override;
111 std::vector<wxString>& GetResult() const {return m_files;}
112 protected:
113 std::vector<wxString>& m_files;
114 wxString m_prefix;
115 };
116
117 // m_configuration.MaximaShareDir(dir);
118
120 jthread m_helpfileanchorsThread;
121 std::mutex m_helpFileAnchorsLock;
123 Configuration *m_configuration = NULL;
125
126 HelpFileAnchors m_helpFileURLs_singlePage;
128 HelpFileAnchors m_helpFileURLs_filePerChapter;
130 HelpFileAnchors m_helpFileAnchors;
131 wxString m_maximaHtmlDir;
132 wxString m_maximaVersion;
133};
134
135#endif // MAXIMAMANUAL_H
The configuration storage for the current worksheet.
Definition: Configuration.h:85
Definition: MaximaManual.h:59
bool LoadManualAnchorsFromCache()
Load the result from the last CompileHelpFileAnchors from the disk cache.
Definition: MaximaManual.cpp:99
void LoadHelpFileAnchors(const wxString &docdir, const wxString &maximaVersion)
Search maxima's help file for command and variable names.
Definition: MaximaManual.cpp:524
void SaveManualAnchorsToCache(const wxString &maximaHtmlDir, const wxString &maximaVersion, const wxString &saveName)
Save the list of help file anchors to the cache.
Definition: MaximaManual.cpp:310
void CompileHelpFileAnchors(const wxString &maximaHtmlDir, const wxString &maximaVersion, const wxString &saveName)
Collect all keyword anchors in the help file.
Definition: MaximaManual.cpp:148
bool LoadManualAnchorsFromXML(const wxXmlDocument &xmlDocument, bool checkManualVersion=true)
Load the help file anchors from an wxXmlDocument.
Definition: MaximaManual.cpp:377
bool LoadBuiltInManualAnchors()
Load the help file anchors from the built-in list.
Definition: MaximaManual.cpp:88