wxMaxima
Loading...
Searching...
No Matches
MaximaSessionInfo.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
34#ifndef MAXIMASESSIONINFO_H
35#define MAXIMASESSIONINFO_H
36
37#include <wx/string.h>
38#include <wx/hashmap.h>
39#include <unordered_map>
40
48{
49public:
52 {
53 // The list elements are plain string literals: a `const wxString &`
54 // loop variable would bind to a temporary constructed per element,
55 // which gcc's -Wrange-loop-construct rejects under -Werror.
56 for (const wxChar *op : {
57 wxS("("), wxS("/"), wxS("{"), wxS("-"), wxS("^"), wxS("#"),
58 wxS("="), wxS(":"), wxS("["), wxS("'"), wxS("!"), wxS("+"),
59 wxS("*"), wxS("or"), wxS("and"), wxS("do_in"), wxS(">"),
60 wxS("$SUBVAR"), wxS("<"), wxS("if"), wxS("::="), wxS("::"),
61 wxS("@"), wxS("."), wxS("-->"), wxS("^^"), wxS("not"),
62 wxS("<="), wxS(":="), wxS(">="), wxS("$BFLOAT"), wxS("do")})
63 m_operators[op] = 1;
64 wxString operators(wxS("\u221A\u22C0\u22C1\u22BB\u22BC\u22BD\u00AC\u222b"
65 "\u2264\u2265\u2211\u2260+-*/^:=#'!()[]{}"));
66 for (const auto ch : operators)
67 m_operators[wxString(ch)] = 1;
68 }
69
71 bool IsOperator(const wxString &name) const
72 { return m_operators.contains(name); }
74 void AddOperator(const wxString &name) { m_operators[name] = 1; }
75
77 wxString GetMaximaVersion() const { return m_maximaVersion; }
79 void SetMaximaVersion(const wxString &version) { m_maximaVersion = version; }
81 wxString GetMaximaArch() const { return m_maximaArch; }
83 void SetMaximaArch(const wxString &arch) { m_maximaArch = arch; }
85 wxString GetLispVersion() const { return m_lispVersion; }
87 void SetLispVersion(const wxString &version) { m_lispVersion = version; }
89 wxString GetLispType() const { return m_lispType; }
91 void SetLispType(const wxString &type) { m_lispType = type; }
92
94 wxString GetWorkingDirectory() const { return m_workingDirectory; }
96 void SetWorkingDirectory(wxString dir) { m_workingDirectory = std::move(dir); }
98 wxString ShareDir() const { return m_shareDir; }
100 void ShareDir(wxString dir) { m_shareDir = std::move(dir); }
102 wxString DemoDir() const { return m_demoDir; }
104 void DemoDir(wxString dir) { m_demoDir = std::move(dir); }
105
107 bool InLispMode() const { return m_inLispMode; }
109 void InLispMode(bool lisp) { m_inLispMode = lisp; }
110
111private:
113 std::unordered_map<wxString, int, wxStringHash> m_operators;
115 wxString m_maximaVersion;
117 wxString m_maximaArch;
119 wxString m_lispVersion;
121 wxString m_lispType;
123 wxString m_workingDirectory;
125 wxString m_shareDir;
127 wxString m_demoDir;
129 bool m_inLispMode = false;
130};
131
132#endif // MAXIMASESSIONINFO_H
What we know about the Maxima instance we are talking to.
Definition: MaximaSessionInfo.h:48
wxString GetWorkingDirectory() const
Maxima's working directory.
Definition: MaximaSessionInfo.h:94
bool InLispMode() const
Is maxima currently in lisp mode (where commands need no trailing ";")?
Definition: MaximaSessionInfo.h:107
void SetLispType(const wxString &type)
Sets the type of the lisp the connected Maxima runs on.
Definition: MaximaSessionInfo.h:91
void SetMaximaArch(const wxString &arch)
Sets the processor architecture the connected Maxima runs on.
Definition: MaximaSessionInfo.h:83
wxString GetMaximaArch() const
The processor architecture the connected Maxima runs on.
Definition: MaximaSessionInfo.h:81
void InLispMode(bool lisp)
Tells us whether maxima currently is in lisp mode.
Definition: MaximaSessionInfo.h:109
wxString GetLispVersion() const
The version of the lisp the connected Maxima runs on.
Definition: MaximaSessionInfo.h:85
wxString DemoDir() const
The directory maxima's demo files live in.
Definition: MaximaSessionInfo.h:102
void AddOperator(const wxString &name)
Registers name as an operator known to maxima.
Definition: MaximaSessionInfo.h:74
void SetWorkingDirectory(wxString dir)
Sets maxima's working directory.
Definition: MaximaSessionInfo.h:96
wxString ShareDir() const
The directory maxima's shared files (e.g. the manual) live in.
Definition: MaximaSessionInfo.h:98
void DemoDir(wxString dir)
Sets the directory maxima's demo files live in.
Definition: MaximaSessionInfo.h:104
wxString GetLispType() const
The type of the lisp the connected Maxima runs on.
Definition: MaximaSessionInfo.h:89
void ShareDir(wxString dir)
Sets the directory maxima's shared files live in.
Definition: MaximaSessionInfo.h:100
void SetMaximaVersion(const wxString &version)
Sets the version of the connected Maxima.
Definition: MaximaSessionInfo.h:79
void SetLispVersion(const wxString &version)
Sets the version of the lisp the connected Maxima runs on.
Definition: MaximaSessionInfo.h:87
wxString GetMaximaVersion() const
The version of the connected Maxima.
Definition: MaximaSessionInfo.h:77
MaximaSessionInfo()
Constructs the session info with the built-in operator names seeded.
Definition: MaximaSessionInfo.h:51
bool IsOperator(const wxString &name) const
Is this name an operator known to maxima?
Definition: MaximaSessionInfo.h:71