wxMaxima
Loading...
Searching...
No Matches
SymbolShortcuts.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 SYMBOLSHORTCUTS_H
35#define SYMBOLSHORTCUTS_H
36
37#include <wx/string.h>
38#include <vector>
39
40class wxKeyEvent;
41
42namespace wxm {
43
53std::vector<wxString> SplitIntoSymbols(const wxString &text);
54
61wxString JoinSymbols(const std::vector<wxString> &symbols);
62
65{
66 wxString symbol;
72 wxString shortcut;
73 bool operator==(const SymbolShortcut &) const = default;
74};
75
81std::vector<SymbolShortcut> ParseSymbolShortcuts(const wxString &stored);
83wxString SerializeSymbolShortcuts(const std::vector<SymbolShortcut> &shortcuts);
84
90wxString NormalizeShortcut(const wxString &shortcut);
91
97bool IsUsableShortcut(int flags, int keyCode);
98
104wxString ShortcutFromKeyEvent(const wxKeyEvent &event);
105
107bool SameShortcut(const wxString &a, const wxString &b);
108
110wxString ShortcutForDisplay(const wxString &rawShortcut);
111
117wxString SymbolForKeyEvent(const std::vector<SymbolShortcut> &shortcuts,
118 const wxKeyEvent &event);
119
120} // namespace wxm
121
122#endif // SYMBOLSHORTCUTS_H
bool IsUsableShortcut(int flags, int keyCode)
Would this shortcut leave ordinary typing alone?
Definition: SymbolShortcuts.cpp:146
std::vector< wxString > SplitIntoSymbols(const wxString &text)
Splits text into the symbols a sidebar shows as one button each.
Definition: SymbolShortcuts.cpp:87
wxString NormalizeShortcut(const wxString &shortcut)
Brings a shortcut a human typed into the raw form we store.
Definition: SymbolShortcuts.cpp:152
wxString SerializeSymbolShortcuts(const std::vector< SymbolShortcut > &shortcuts)
The inverse of ParseSymbolShortcuts().
Definition: SymbolShortcuts.cpp:136
wxString SymbolForKeyEvent(const std::vector< SymbolShortcut > &shortcuts, const wxKeyEvent &event)
The symbol whose shortcut the key event is, or an empty string.
Definition: SymbolShortcuts.cpp:200
std::vector< SymbolShortcut > ParseSymbolShortcuts(const wxString &stored)
Reads the shortcuts list the configuration stores.
Definition: SymbolShortcuts.cpp:122
wxString ShortcutFromKeyEvent(const wxKeyEvent &event)
The shortcut a key press is, in raw form, or an empty string.
Definition: SymbolShortcuts.cpp:161
bool SameShortcut(const wxString &a, const wxString &b)
Do the two raw shortcuts name the same key combination?
Definition: SymbolShortcuts.cpp:187
wxString ShortcutForDisplay(const wxString &rawShortcut)
The shortcut in the user's language, for display ("Strg+Alt+T").
Definition: SymbolShortcuts.cpp:193
wxString JoinSymbols(const std::vector< wxString > &symbols)
Joins symbols into a string SplitIntoSymbols() splits into the same symbols.
Definition: SymbolShortcuts.cpp:109
A symbol and the keyboard shortcut that types it.
Definition: SymbolShortcuts.h:65
wxString shortcut
The shortcut, as wxAcceleratorEntry::ToRawString() writes it ("Ctrl+Alt+T").
Definition: SymbolShortcuts.h:72