wxMaxima
Loading...
Searching...
No Matches
MaximaResponseReader.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) 2026 Gunter Königsmann <wxMaxima@physikbuch.de>
4//
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation; either version 2 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15//
16// You should have received a copy of the GNU General Public License
17// along with this program; if not, write to the Free Software
18// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19//
20// SPDX-License-Identifier: GPL-2.0+
21
40#ifndef MAXIMARESPONSEREADER_H
41#define MAXIMARESPONSEREADER_H
42
43#include <wx/string.h>
44#include <wx/xml/xml.h>
45#include <wx/hashmap.h>
46#include <unordered_map>
47
48class wxMaxima;
49
58{
59public:
60 explicit MaximaResponseReader(wxMaxima &wxm) : m_wxMaxima(wxm) {
61 RegisterVariableActions();
62 }
63
65 void ReadStatusBar(const wxXmlDocument &xmldoc);
66
74 void ReadWorksheetExport(const wxXmlDocument &xmldoc);
75
78 void ReadManualTopicNames(const wxXmlDocument &xmldoc);
79
81 void ReadMath(const wxXmlDocument &xml);
82
85 void ReadLoadSymbols(const wxXmlDocument &data);
86
88 void ReadFirstPrompt(const wxString &data);
89
92 void ReadMiscText(const wxString &data);
93
96 void ReadSuppressedOutput(const wxString &data);
100 void DistrustMaxima();
101
105 void ReadAsciiMath(const wxString &data);
106
115 void ReadAsyncOutput(const wxString &data);
116
119 void ReadPrompt(const wxString &data);
120
123 void ReadStdErr();
124
128 void ReadVariables(const wxXmlDocument &xmldoc);
129
132 void ReadAddVariables(const wxXmlDocument &xmldoc);
133
134private:
142 void EnterLdbMode();
143
146 wxMaxima &m_wxMaxima;
147
148 // --- Per-variable actions -------------------------------------------------
149 // Run by ReadVariables() when Maxima advertises the value (or undefined-ness)
150 // of one of the variables wxMaxima watches. Registered in the dispatch
151 // tables below by RegisterVariableActions().
152
154 void VariableActionDisplay2d_Unicode(const wxString &value);
156 void VariableActionHtmlHelp(const wxString &value);
158 void VariableActionSinnpiflag(const wxString &value);
160 void VariableActionSinnpiflagUndefined();
162 void VariableActionUserDir(const wxString &value);
164 void VariableActionTempDir(const wxString &value);
166 void VariableActionAutoconfVersion(const wxString &value);
168 void VariableActionAutoconfHost(const wxString &value);
170 void VariableActionMaximaInfodir(const wxString &value);
172 void VariableActionMaximaHtmldir(const wxString &value);
174 void VariableActionGnuplotCommand(const wxString &value);
176 void VariableActionMaximaSharedir(const wxString &value);
178 void VariableActionMaximaDemodir(const wxString &value);
180 void VariableActionLispName(const wxString &value);
182 void VariableActionLispVersion(const wxString &value);
184 void VariableActionInterruptChannelAvailable(const wxString &value);
186 void VariableActionWxLoadFileName(const wxString &value);
188 void VariableActionDisplay2D(const wxString &value);
190 void VariableActionAltDisplay2D(const wxString &value);
192 void VariableActionEngineeringFormat(const wxString &value);
194 void VariableActionOperators(const wxString &value);
199 void UpdateDisplayMode();
200
202 void RegisterVariableActions();
203
204 using VarReadFunction = void (MaximaResponseReader::*)(const wxString &value);
205 using VarUndefinedFunction = void (MaximaResponseReader::*)();
206 using VarReadFunctionHash = std::unordered_map<wxString, VarReadFunction, wxStringHash>;
207 using VarUndefinedFunctionHash =
208 std::unordered_map<wxString, VarUndefinedFunction, wxStringHash>;
210 static VarReadFunctionHash m_variableReadActions;
212 static VarUndefinedFunctionHash m_variableUndefinedActions;
214 wxString m_tempDirQuoteWarningShownFor;
215};
216
217#endif // MAXIMARESPONSEREADER_H
The Maxima-response handlers extracted from the wxMaxima god class.
Definition: MaximaResponseReader.h:58
void ReadAsciiMath(const wxString &data)
Handles one complete <wxxml-asciimath>...</wxxml-asciimath> block: Maxima's stock ASCII-art 2D displa...
Definition: MaximaResponseReader.cpp:428
void ReadMiscText(const wxString &data)
Handles a chunk of plain (non-XML) text Maxima sent: classifies it as output/warning/error and append...
Definition: MaximaResponseReader.cpp:298
void ReadMath(const wxXmlDocument &xml)
Appends a new chunk of typeset math Maxima sent to the worksheet.
Definition: MaximaResponseReader.cpp:180
void ReadLoadSymbols(const wxXmlDocument &data)
Hands a <wxxml-symbols> document (a new batch of auto-completable symbols) to the worksheet's autocom...
Definition: MaximaResponseReader.cpp:196
void ReadVariables(const wxXmlDocument &xmldoc)
Handles a <variables> document: updates the variables sidebar, the table-synced menus and runs the pe...
Definition: MaximaResponseReader.cpp:868
void ReadStatusBar(const wxXmlDocument &xmldoc)
Handles a <statusbar> document: shows its text in wxMaxima's status bar.
Definition: MaximaResponseReader.cpp:40
void ReadFirstPrompt(const wxString &data)
Handles Maxima's very first prompt after startup (banner, PID, readiness).
Definition: MaximaResponseReader.cpp:201
void ReadPrompt(const wxString &data)
Handles a new input/question prompt: advances the evaluation queue or surfaces the question,...
Definition: MaximaResponseReader.cpp:530
void ReadStdErr()
Reads and reports whatever Maxima forwarded on its stdout/stderr streams (most prominently the gnuplo...
Definition: MaximaResponseReader.cpp:757
void ReadSuppressedOutput(const wxString &data)
Handles output Maxima marked as suppressed; also the startup authentication handshake (the <wxxml-key...
Definition: MaximaResponseReader.cpp:381
void ReadWorksheetExport(const wxXmlDocument &xmldoc)
Handles a <worksheetexport> document: exports the worksheet to a file.
Definition: MaximaResponseReader.cpp:61
void ReadAsyncOutput(const wxString &data)
Handles one complete <wxasync><id>...</id>...</wxasync> block: output from a background job,...
Definition: MaximaResponseReader.cpp:448
void ReadAddVariables(const wxXmlDocument &xmldoc)
Handles a <watch_variables_add> document: adds the named variables to the variables-sidebar watch lis...
Definition: MaximaResponseReader.cpp:1205
void MaximaAuthenticated()
Notes that Maxima has proven to be the process we started.
Definition: MaximaResponseReader.cpp:405
void DistrustMaxima()
Discards everything Maxima sends from now on, and tells the user why.
Definition: MaximaResponseReader.cpp:410
void ReadManualTopicNames(const wxXmlDocument &xmldoc)
Handles a <html-manual-keywords> document: opens the manual on the keyword(s) Maxima resolved a help ...
Definition: MaximaResponseReader.cpp:124
Definition: wxMaxima.h:76