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
105 void ReadPrompt(const wxString &data);
106
109 void ReadStdErr();
110
114 void ReadVariables(const wxXmlDocument &xmldoc);
115
118 void ReadAddVariables(const wxXmlDocument &xmldoc);
119
120private:
128 void EnterLdbMode();
129
132 wxMaxima &m_wxMaxima;
133
134 // --- Per-variable actions -------------------------------------------------
135 // Run by ReadVariables() when Maxima advertises the value (or undefined-ness)
136 // of one of the variables wxMaxima watches. Registered in the dispatch
137 // tables below by RegisterVariableActions().
138
140 void VariableActionDisplay2d_Unicode(const wxString &value);
142 void VariableActionHtmlHelp(const wxString &value);
144 void VariableActionSinnpiflag(const wxString &value);
146 void VariableActionSinnpiflagUndefined();
148 void VariableActionUserDir(const wxString &value);
150 void VariableActionTempDir(const wxString &value);
152 void VariableActionAutoconfVersion(const wxString &value);
154 void VariableActionAutoconfHost(const wxString &value);
156 void VariableActionMaximaInfodir(const wxString &value);
158 void VariableActionMaximaHtmldir(const wxString &value);
160 void VariableActionGnuplotCommand(const wxString &value);
162 void VariableActionMaximaSharedir(const wxString &value);
164 void VariableActionMaximaDemodir(const wxString &value);
166 void VariableActionLispName(const wxString &value);
168 void VariableActionLispVersion(const wxString &value);
170 void VariableActionWxLoadFileName(const wxString &value);
172 void VariableActionDisplay2D(const wxString &value);
174 void VariableActionAltDisplay2D(const wxString &value);
176 void VariableActionEngineeringFormat(const wxString &value);
178 void VariableActionOperators(const wxString &value);
183 void UpdateDisplayMode();
184
186 void RegisterVariableActions();
187
188 typedef void (MaximaResponseReader::*VarReadFunction)(const wxString &value);
189 typedef void (MaximaResponseReader::*VarUndefinedFunction)();
190 typedef std::unordered_map <wxString, VarReadFunction, wxStringHash> VarReadFunctionHash;
191 typedef std::unordered_map <wxString, VarUndefinedFunction,
192 wxStringHash> VarUndefinedFunctionHash;
194 static VarReadFunctionHash m_variableReadActions;
196 static VarUndefinedFunctionHash m_variableUndefinedActions;
197};
198
199#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:365
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:256
void ReadMath(const wxXmlDocument &xml)
Appends a new chunk of typeset math Maxima sent to the worksheet.
Definition: MaximaResponseReader.cpp:174
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:190
void ReadVariables(const wxXmlDocument &xmldoc)
Handles a <variables> document: updates the variables sidebar, the table-synced menus and runs the pe...
Definition: MaximaResponseReader.cpp:716
void ReadStatusBar(const wxXmlDocument &xmldoc)
Handles a <statusbar> document: shows its text in wxMaxima's status bar.
Definition: MaximaResponseReader.cpp:37
void ReadFirstPrompt(const wxString &data)
Handles Maxima's very first prompt after startup (banner, PID, readiness).
Definition: MaximaResponseReader.cpp:195
void ReadPrompt(const wxString &data)
Handles a new input/question prompt: advances the evaluation queue or surfaces the question,...
Definition: MaximaResponseReader.cpp:385
void ReadStdErr()
Reads and reports whatever Maxima forwarded on its stdout/stderr streams (most prominently the gnuplo...
Definition: MaximaResponseReader.cpp:605
void ReadSuppressedOutput(const wxString &data)
Handles output Maxima marked as suppressed; also the startup authentication handshake (the <wxxml-key...
Definition: MaximaResponseReader.cpp:331
void ReadWorksheetExport(const wxXmlDocument &xmldoc)
Handles a <worksheetexport> document: exports the worksheet to a file.
Definition: MaximaResponseReader.cpp:58
void ReadAddVariables(const wxXmlDocument &xmldoc)
Handles a <watch_variables_add> document: adds the named variables to the variables-sidebar watch lis...
Definition: MaximaResponseReader.cpp:1023
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:121
Definition: wxMaxima.h:75