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);
97
101 void ReadAsciiMath(const wxString &data);
102
111 void ReadAsyncOutput(const wxString &data);
112
115 void ReadPrompt(const wxString &data);
116
119 void ReadStdErr();
120
124 void ReadVariables(const wxXmlDocument &xmldoc);
125
128 void ReadAddVariables(const wxXmlDocument &xmldoc);
129
130private:
138 void EnterLdbMode();
139
142 wxMaxima &m_wxMaxima;
143
144 // --- Per-variable actions -------------------------------------------------
145 // Run by ReadVariables() when Maxima advertises the value (or undefined-ness)
146 // of one of the variables wxMaxima watches. Registered in the dispatch
147 // tables below by RegisterVariableActions().
148
150 void VariableActionDisplay2d_Unicode(const wxString &value);
152 void VariableActionHtmlHelp(const wxString &value);
154 void VariableActionSinnpiflag(const wxString &value);
156 void VariableActionSinnpiflagUndefined();
158 void VariableActionUserDir(const wxString &value);
160 void VariableActionTempDir(const wxString &value);
162 void VariableActionAutoconfVersion(const wxString &value);
164 void VariableActionAutoconfHost(const wxString &value);
166 void VariableActionMaximaInfodir(const wxString &value);
168 void VariableActionMaximaHtmldir(const wxString &value);
170 void VariableActionGnuplotCommand(const wxString &value);
172 void VariableActionMaximaSharedir(const wxString &value);
174 void VariableActionMaximaDemodir(const wxString &value);
176 void VariableActionLispName(const wxString &value);
178 void VariableActionLispVersion(const wxString &value);
180 void VariableActionWxLoadFileName(const wxString &value);
182 void VariableActionDisplay2D(const wxString &value);
184 void VariableActionAltDisplay2D(const wxString &value);
186 void VariableActionEngineeringFormat(const wxString &value);
188 void VariableActionOperators(const wxString &value);
193 void UpdateDisplayMode();
194
196 void RegisterVariableActions();
197
198 using VarReadFunction = void (MaximaResponseReader::*)(const wxString &value);
199 using VarUndefinedFunction = void (MaximaResponseReader::*)();
200 using VarReadFunctionHash = std::unordered_map<wxString, VarReadFunction, wxStringHash>;
201 using VarUndefinedFunctionHash =
202 std::unordered_map<wxString, VarUndefinedFunction, wxStringHash>;
204 static VarReadFunctionHash m_variableReadActions;
206 static VarUndefinedFunctionHash m_variableUndefinedActions;
207};
208
209#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:376
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:267
void ReadMath(const wxXmlDocument &xml)
Appends a new chunk of typeset math Maxima sent to the worksheet.
Definition: MaximaResponseReader.cpp:176
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:192
void ReadVariables(const wxXmlDocument &xmldoc)
Handles a <variables> document: updates the variables sidebar, the table-synced menus and runs the pe...
Definition: MaximaResponseReader.cpp:809
void ReadStatusBar(const wxXmlDocument &xmldoc)
Handles a <statusbar> document: shows its text in wxMaxima's status bar.
Definition: MaximaResponseReader.cpp:39
void ReadFirstPrompt(const wxString &data)
Handles Maxima's very first prompt after startup (banner, PID, readiness).
Definition: MaximaResponseReader.cpp:197
void ReadPrompt(const wxString &data)
Handles a new input/question prompt: advances the evaluation queue or surfaces the question,...
Definition: MaximaResponseReader.cpp:478
void ReadStdErr()
Reads and reports whatever Maxima forwarded on its stdout/stderr streams (most prominently the gnuplo...
Definition: MaximaResponseReader.cpp:698
void ReadSuppressedOutput(const wxString &data)
Handles output Maxima marked as suppressed; also the startup authentication handshake (the <wxxml-key...
Definition: MaximaResponseReader.cpp:342
void ReadWorksheetExport(const wxXmlDocument &xmldoc)
Handles a <worksheetexport> document: exports the worksheet to a file.
Definition: MaximaResponseReader.cpp:60
void ReadAsyncOutput(const wxString &data)
Handles one complete <wxasync><id>...</id>...</wxasync> block: output from a background job,...
Definition: MaximaResponseReader.cpp:396
void ReadAddVariables(const wxXmlDocument &xmldoc)
Handles a <watch_variables_add> document: adds the named variables to the variables-sidebar watch lis...
Definition: MaximaResponseReader.cpp:1116
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:123
Definition: wxMaxima.h:75