Audacity 3.2.0
Keyboard.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 Keyboard.cpp
6
7 Dominic Mazzoni
8 Brian Gunlogson
9
10**********************************************************************/
11
12
13#include "Keyboard.h"
14
15#include <wx/event.h>
16
19{
20#if defined(__WXMAC__)
21 wxString newkey;
22 wxString temp = key;
23
24 // PRL: This is needed to parse older preference files.
25 temp.Replace(wxT("XCtrl+"), wxT("Control+"));
26
27 // PRL: RawCtrl is the proper replacement for Control, when formatting
28 // wxMenuItem, so that wxWidgets shows ^ in the menu. It is written into
29 // NEW preference files (2.2.0 and later).
30 temp.Replace(wxT("RawCtrl+"), wxT("Control+"));
31 temp.Replace(wxT("Ctrl+"), wxT("Command+"));
32
33 if (temp.Contains(wxT("Control+"))) {
34 newkey += wxT("RawCtrl+");
35 }
36
37 if (temp.Contains(wxT("Alt+")) || temp.Contains(wxT("Option+"))) {
38 newkey += wxT("Alt+");
39 }
40
41 if (temp.Contains(wxT("Shift+"))) {
42 newkey += wxT("Shift+");
43 }
44
45 if (temp.Contains(wxT("Command+"))) {
46 newkey += wxT("Ctrl+");
47 }
48
50 newkey + temp.AfterLast(wxT('+'));
51#else
53#endif
54}
55
56wxString NormalizedKeyString::Display(bool usesSpecialChars) const
57{
58 (void)usesSpecialChars;//compiler food
59 // using GET to manipulate key string as needed for macOS differences
60 // in displaying of it
61 auto newkey = this->GET();
62#if defined(__WXMAC__)
63
64 if (!usesSpecialChars) {
65 // Compose user-visible keystroke names, all ASCII
66 newkey.Replace(wxT("RawCtrl+"), wxT("Control+"));
67 newkey.Replace(wxT("Alt+"), wxT("Option+"));
68 newkey.Replace(wxT("Ctrl+"), wxT("Command+"));
69 }
70 else {
71 // Compose user-visible keystroke names, with special characters
72 newkey.Replace(wxT("Shift+"), wxT("\u21e7"));
73 newkey.Replace(wxT("RawCtrl+"), '^');
74 newkey.Replace(wxT("Alt+"), wxT("\u2325"));
75 newkey.Replace(wxT("Ctrl+"), wxT("\u2318"));
76 }
77
78#endif
79
80 return newkey;
81}
wxT("CloseDown"))
static const AudacityProject::AttachedObjects::RegisteredFactory key
const wxString & GET() const
Explicit conversion to wxString, meant to be ugly-looking and demanding of a comment why it's correct...
Definition: Identifier.h:66
Template generates different TaggedIdentifier classes that don't interconvert implicitly.
Definition: Identifier.h:113
wxString Display(bool usesSpecialChars=false) const
Definition: Keyboard.cpp:56
NormalizedKeyString()=default