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(stop_token stopToken,
73 const wxString &maximaHtmlDir,
74 const wxString &maximaVersion,
75 const wxString &saveName);
79 bool LoadManualAnchorsFromXML(const wxXmlDocument &xmlDocument, bool checkManualVersion = true);
83 void SaveManualAnchorsToCache(const wxString &maximaHtmlDir,
84 const wxString &maximaVersion,
85 const wxString &saveName);
86 virtual ~MaximaManual();
87private:
89 static void AnchorAliasses(HelpFileAnchors &anchors);
91 class GetHTMLFiles : public wxDirTraverser
92 {
93 public:
94 explicit GetHTMLFiles(std::vector<wxString>& files,
95 stop_token stopToken = {},
96 const wxString &prefix = wxEmptyString) :
97 m_files(files), m_stopToken(stopToken), m_prefix(prefix) { }
98 virtual wxDirTraverseResult OnFile(const wxString& filename) override;
99 virtual wxDirTraverseResult OnDir(const wxString& dirname) override;
100 std::vector<wxString>& GetResult() const {return m_files;}
101 protected:
102 std::vector<wxString>& m_files;
103 stop_token m_stopToken;
104 wxString m_prefix;
105 };
106 class GetHTMLFiles_Recursive : public wxDirTraverser
107 {
108 public:
109 explicit GetHTMLFiles_Recursive(std::vector<wxString>& files,
110 stop_token stopToken = {},
111 const wxString &prefix = wxEmptyString) :
112 m_files(files), m_stopToken(stopToken), m_prefix(prefix) { }
113 virtual wxDirTraverseResult OnFile(const wxString& filename) override;
114 virtual wxDirTraverseResult OnDir(const wxString& dirname) override;
115 std::vector<wxString>& GetResult() const {return m_files;}
116 protected:
117 std::vector<wxString>& m_files;
118 stop_token m_stopToken;
119 wxString m_prefix;
120 };
121
122 // m_configuration.MaximaShareDir(dir);
123
125 jthread m_helpfileanchorsThread;
126 std::mutex m_helpFileAnchorsLock;
128 Configuration *m_configuration = NULL;
130
131 HelpFileAnchors m_helpFileURLs_singlePage;
133 HelpFileAnchors m_helpFileURLs_filePerChapter;
135 HelpFileAnchors m_helpFileAnchors;
136 wxString m_maximaHtmlDir;
137 wxString m_maximaVersion;
138};
139
140#endif // MAXIMAMANUAL_H
The configuration storage for the current worksheet.
Definition: Configuration.h:86
Definition: MaximaManual.h:59
bool LoadManualAnchorsFromCache()
Load the result from the last CompileHelpFileAnchors from the disk cache.
Definition: MaximaManual.cpp:97
void LoadHelpFileAnchors(const wxString &docdir, const wxString &maximaVersion)
Search maxima's help file for command and variable names.
Definition: MaximaManual.cpp:525
void SaveManualAnchorsToCache(const wxString &maximaHtmlDir, const wxString &maximaVersion, const wxString &saveName)
Save the list of help file anchors to the cache.
Definition: MaximaManual.cpp:311
bool LoadManualAnchorsFromXML(const wxXmlDocument &xmlDocument, bool checkManualVersion=true)
Load the help file anchors from an wxXmlDocument.
Definition: MaximaManual.cpp:378
bool LoadBuiltInManualAnchors()
Load the help file anchors from the built-in list.
Definition: MaximaManual.cpp:86
void CompileHelpFileAnchors(stop_token stopToken, const wxString &maximaHtmlDir, const wxString &maximaVersion, const wxString &saveName)
Collect all keyword anchors in the help file.
Definition: MaximaManual.cpp:145