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
100 void ReadPrompt(const wxString &data);
101
104 void ReadStdErr();
105
109 void ReadVariables(const wxXmlDocument &xmldoc);
110
113 void ReadAddVariables(const wxXmlDocument &xmldoc);
114
115private:
123 void EnterLdbMode();
124
127 wxMaxima &m_wxMaxima;
128
129 // --- Per-variable actions -------------------------------------------------
130 // Run by ReadVariables() when Maxima advertises the value (or undefined-ness)
131 // of one of the variables wxMaxima watches. Registered in the dispatch
132 // tables below by RegisterVariableActions().
133
135 void VariableActionDisplay2d_Unicode(const wxString &value);
137 void VariableActionHtmlHelp(const wxString &value);
139 void VariableActionSinnpiflag(const wxString &value);
141 void VariableActionSinnpiflagUndefined();
143 void VariableActionUserDir(const wxString &value);
145 void VariableActionTempDir(const wxString &value);
147 void VariableActionAutoconfVersion(const wxString &value);
149 void VariableActionAutoconfHost(const wxString &value);
151 void VariableActionMaximaInfodir(const wxString &value);
153 void VariableActionMaximaHtmldir(const wxString &value);
155 void VariableActionGnuplotCommand(const wxString &value);
157 void VariableActionMaximaSharedir(const wxString &value);
159 void VariableActionMaximaDemodir(const wxString &value);
161 void VariableActionLispName(const wxString &value);
163 void VariableActionLispVersion(const wxString &value);
165 void VariableActionWxLoadFileName(const wxString &value);
167 void VariableActionDisplay2D(const wxString &value);
169 void VariableActionAltDisplay2D(const wxString &value);
171 void VariableActionEngineeringFormat(const wxString &value);
173 void VariableActionOperators(const wxString &value);
178 void UpdateDisplayMode();
179
181 void RegisterVariableActions();
182
183 typedef void (MaximaResponseReader::*VarReadFunction)(const wxString &value);
184 typedef void (MaximaResponseReader::*VarUndefinedFunction)();
185 typedef std::unordered_map <wxString, VarReadFunction, wxStringHash> VarReadFunctionHash;
186 typedef std::unordered_map <wxString, VarUndefinedFunction,
187 wxStringHash> VarUndefinedFunctionHash;
189 static VarReadFunctionHash m_variableReadActions;
191 static VarUndefinedFunctionHash m_variableUndefinedActions;
192};
193
194#endif // MAXIMARESPONSEREADER_H
The Maxima-response handlers extracted from the wxMaxima god class.
Definition: MaximaResponseReader.h:58
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:255
void ReadMath(const wxXmlDocument &xml)
Appends a new chunk of typeset math Maxima sent to the worksheet.
Definition: MaximaResponseReader.cpp:173
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:189
void ReadVariables(const wxXmlDocument &xmldoc)
Handles a <variables> document: updates the variables sidebar, the table-synced menus and runs the pe...
Definition: MaximaResponseReader.cpp:663
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:194
void ReadPrompt(const wxString &data)
Handles a new input/question prompt: advances the evaluation queue or surfaces the question,...
Definition: MaximaResponseReader.cpp:364
void ReadStdErr()
Reads and reports whatever Maxima forwarded on its stdout/stderr streams (most prominently the gnuplo...
Definition: MaximaResponseReader.cpp:552
void ReadSuppressedOutput(const wxString &data)
Handles output Maxima marked as suppressed; also the startup authentication handshake (the <wxxml-key...
Definition: MaximaResponseReader.cpp:330
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:970
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:120
Definition: wxMaxima.h:75