Audacity  2.2.2
HelpText.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  HelpText.cpp
6 
7  James Crook
8 
9 ********************************************************************//********************************************************************/
14 
15 #include <wx/string.h>
16 #include <wx/intl.h>
17 
18 #include "Audacity.h"
19 #include "HelpText.h"
20 #include "FileNames.h"
21 #include "AboutDialog.h"
22 #include "AllThemeResources.h"
23 #include "Internat.h"
24 
25 
26 wxString HtmlColourOfIndex( int i ){
27  wxColour c = theTheme.Colour(i);
28  return wxString::Format("\"#%02X%02X%02X\"",
29  c.Red(), c.Green(), c.Blue() );
30 }
31 
32 static wxString WrapText( const wxString & Text )
33 {
34  return wxString(wxT(""))+
35  wxT("<html><head></head>") +
36  wxT("<body bgcolor=") + HtmlColourOfIndex(clrTrackInfo) + wxT(">") +
37  wxT("<font color=") + HtmlColourOfIndex(clrTrackPanelText) + wxT(">") +
38  wxT("<p>") + Text +
39  wxT("</font>")+
40  wxT("</body></html>");
41 }
42 
43 static wxString InnerLink( const wxString &Key, const wxString& Text )
44 {
45  return wxString(wxT("")) +
46  wxT("<a href='innerlink:") +
47  Key +
48  wxT("'>") +
49  Text +
50  wxT("</a>");
51 }
52 
53 static wxString WikiLink( const wxString &Key, const wxString& Text )
54 {
55  return wxString(wxT("")) +
56  wxT("<a href='https://www.audacityteam.org/wiki/index.php?title=") +
57  Key +
58  wxT("'>") +
59  Text +
60  wxT("</a>");
61 }
62 
63 static wxString FileLink( const wxString &Key, const wxString& Text )
64 {
65  return wxString(wxT("")) +
66  wxT("<a href='") +
67  wxT("file:") +
69  Key +
70  wxT("'>") +
71  Text +
72  wxT("</a>");
73 }
74 
75 static wxString TypedLink( const wxString &Key, const wxString& Text )
76 {
77  return wxString(wxT("")) +
78  wxT("<a href='") +
79  Key +
80  wxT("'>") +
81  Text +
82  wxT("</a>");
83 }
84 
85 static wxString LinkExpand( const wxString & Text )
86 {
87  wxString Temp = Text;
88  int i,j,k;
89  while( (i=Temp.First( wxT("[[") ))!= wxNOT_FOUND )
90  {
91  wxString Key = Temp.Mid(i+2);
92  j = Key.First( wxT("|") );
93  if( j==wxNOT_FOUND )
94  return Temp;
95  wxString LinkText = Key.Mid( j+1);
96  k = LinkText.First( wxT("]]") );
97  if( k==wxNOT_FOUND )
98  return Temp;
99  Key = Key.Mid( 0, j );
100  LinkText = LinkText.Mid( 0, k );
101 
102  LinkText=wxString("<font color=") + HtmlColourOfIndex(clrSample) + wxT(">") +LinkText+"</font>";
103  wxString Replacement;
104  if( Key.StartsWith( wxT("wiki:") ))
105  {
106  Replacement = WikiLink( Key.Mid( 5 ), LinkText );
107  }
108  else if( Key.StartsWith( wxT("file:") ))
109  {
110  Replacement = FileLink( Key.Mid( 5 ), LinkText );
111  }
112  else if( Key.StartsWith( wxT("http:") ))
113  {
114  Replacement = TypedLink( Key, LinkText );
115  }
116  else if( Key.StartsWith( wxT("https:") ))
117  {
118  Replacement = TypedLink( Key, LinkText );
119  }
120  else if( Key.StartsWith( wxT("mailto:") ))
121  {
122  Replacement = TypedLink( Key, LinkText );
123  }
124  else if( Key.StartsWith( wxT("*URL*") ))
125  {
126  Replacement = TypedLink( Key, LinkText );
127  }
128  else
129  {
130  Replacement = InnerLink( Key, LinkText );
131  }
132 
133 
134  Temp = Temp.Mid( 0, i ) + Replacement + Temp.Mid( i + j + k + 5 );// 5 for the [[|]]
135  }
136  return Temp;
137 }
138 
139 wxString TitleText( const wxString & Key )
140 {
141  if(Key==wxT("welcome"))
142  {
143  return _("Welcome!");
144  }
145 
146  if(Key ==wxT("play") )
147  {
148  /* i18n-hint: Title for a topic.*/
149  return _("Playing Audio");
150  }
151  if((Key ==wxT("record") ) || (Key ==wxT("norecord") ))
152  {
153  /* i18n-hint: Title for a topic.*/
154  return _("Recording Audio");
155  }
156  if(Key ==wxT("inputdevice") )
157  {
158  /* i18n-hint: Title for a topic.*/
159  return _("Recording - Choosing the Recording Device");
160  }
161  if(Key ==wxT("inputsource") )
162  {
163  /* i18n-hint: Title for a topic.*/
164  return _("Recording - Choosing the Recording Source");
165  }
166  if(Key ==wxT("inputlevel") )
167  {
168  /* i18n-hint: Title for a topic.*/
169  return _("Recording - Setting the Recording Level");
170  }
171  if((Key ==wxT("edit") ) || (Key==wxT("grey")))
172  {
173  /* i18n-hint: Title for a topic.*/
174  return _("Editing and greyed out Menus");
175  }
176  if(Key ==wxT("export") )
177  {
178  /* i18n-hint: Title for a topic.*/
179  return _("Exporting an Audio File");
180  }
181  if(Key ==wxT("save") )
182  {
183  /* i18n-hint: Title for a topic.*/
184  return _("Saving an Audacity Project");
185  }
186  if(Key ==wxT("wma-proprietary") )
187  {
188  /* i18n-hint: Title for a topic.*/
189  return _("Support for Other Formats");
190  }
191  if(Key ==wxT("burncd") )
192  {
193  /* i18n-hint: Title for a topic.*/
194  return _("Burn to CD" );
195  }
196  if(Key == wxT("remotehelp") )
197  {
198  return _("No Local Help");
199  }
200  return Key;
201 }
202 
203 static wxString HelpTextBuiltIn( const wxString & Key )
204 {
205  // PRL: Is it necessary to define these outside of conditional compilation so that both get into the .pot file?
206  auto alphamsg = _("<br><br>The version of Audacity you are using is an <b>Alpha test version</b>.");
207  auto betamsg = _("<br><br>The version of Audacity you are using is a <b>Beta test version</b>.");
208 
209  if (Key == wxT("welcome"))
210  {
213  /* i18n-hint: Preserve [[file:quick_help.html as it's the name of a file.*/
214  wxString result =
215  wxString(wxT("")) +
216 #if defined(IS_ALPHA) || defined(IS_BETA)
217  wxT("<hr><center><h3>") + _("Get the Official Released Version of Audacity") + wxT("</h3></center>") +
218  VerCheckHtml() +
219 #ifdef IS_ALPHA
220  alphamsg
221 #else
222  betamsg
223 #endif
224  + " " +
225  _("We strongly recommend that you use our latest stable released version, which has full documentation and support.<br><br>") +
226  _("You can help us get Audacity ready for release by joining our [[https://www.audacityteam.org/community/|community]].<hr><br><br>") +
227 #endif
228 
229 // DA: Support methods text.
230 #ifdef EXPERIMENTAL_DA
231  // Deliberately not translated.
232  wxT("<center><h3>DarkAudacity ") + AUDACITY_VERSION_STRING + wxT("</h3></center>") +
233  wxT("<br><br>DarkAudacity is based on Audacity:") + wxT("<ul><li>") +
234  wxT(" [[http://www.darkaudacity.com|www.darkaudacity.com]] - for differences between them.") + wxT("</li><li>") +
235  wxT(" email to [[mailto:[email protected]|[email protected]]] - for help using DarkAudacity.") + wxT("</li><li>") +
236  wxT(" [[http://www.darkaudacity.com/video.html|Tutorials]] - for getting started with DarkAudacity.") + wxT("</li></ul>") +
237 
238  wxT("<br><br>Audacity has these support methods:") + wxT("<ul><li>") +
239  wxT(" [[https://manual.audacityteam.org/|Manual]] - for comprehensive Audacity documentation") + wxT("</li><li>") +
240  wxT(" [[https://forum.audacityteam.org/|Forum]] - for large knowledge base on using Audacity.") + wxT("</li></ul>");
241 #else
242  wxT("<center><h3>Audacity ") + AUDACITY_VERSION_STRING + wxT("</h3><h3>") +
243  _("How to get help") + wxT("</h3></center>") +
244  _("These are our support methods:") + wxT("<p><ul><li>") +
245  _(" [[file:quick_help.html|Quick Help]] - if not installed locally, [[https://manual.audacityteam.org/quick_help.html|view online]]") + wxT("</li><li>") +
246  _(" [[file:index.html|Manual]] - if not installed locally, [[https://manual.audacityteam.org/|view online]]") + wxT("</li><li>") +
247  _(" [[https://forum.audacityteam.org/|Forum]] - ask your question directly, online.") + wxT("</li></ul></p><p>") + wxT("<b>") +
248  _("More:</b> Visit our [[https://wiki.audacityteam.org/index.php|Wiki]] for tips, tricks, extra tutorials and effects plug-ins.") + wxT("</p>");
249 #endif
250 
251 #ifdef USE_ALPHA_MANUAL
252  result.Replace( "//manual.audacityteam.org/quick_help.html","//alphamanual.audacityteam.org/man/Quick_Help" );
253  result.Replace( "//manual.audacityteam.org/","//alphamanual.audacityteam.org/man/" );
254 #endif
255 
256  return WrapText( result );
257  }
258  if(Key==wxT("wma-proprietary"))
259  {
260  return WrapText(
261  wxString(wxT("<p>"))+
262  _("Audacity can import unprotected files in many other formats (such as M4A and WMA, \
263 compressed WAV files from portable recorders and audio from video files) if you download and install \
264 the optional [[https://manual.audacityteam.org/man/faq_opening_and_saving_files.html#foreign| \
265 FFmpeg library]] to your computer.") + wxT("</p><p>") +
266  _("You can also read our help on importing \
267 [[https://manual.audacityteam.org/man/playing_and_recording.html#midi|MIDI files]] \
268 and tracks from [[http://manual.audacityteam.org/man/faq_opening_and_saving_files.html#fromcd| \
269 audio CDs]].")
270  + wxT("</p>")
271  );
272  }
273 
274  // Remote help allows us to link to a local copy of the help if it exists,
275  // or provide a message that takes you to the Internet if it does not.
276  // It's used by the menu item Help > Index
277  if(Key == wxT("remotehelp") )
278  {
279 // *URL* will be replaced by whatever URL we are looking for.
280 // DA: View the manual on line is expected.
281 #ifdef EXPERIMENTAL_DA
282  return WrapText(_("The Manual does not appear to be installed. \
283 Please [[*URL*|view the Manual online]].<br><br>\
284 To always view the Manual online, change \"Location of Manual\" in \
285 Interface Preferences to \"From Internet\"."));
286 #else
287  return WrapText( _("The Manual does not appear to be installed. \
288 Please [[*URL*|view the Manual online]] or \
289 [[https://manual.audacityteam.org/man/unzipping_the_manual.html| \
290 download the Manual]].<br><br>\
291 To always view the Manual online, change \"Location of Manual\" in \
292 Interface Preferences to \"From Internet\"."));
293 #endif
294  }
295  return wxT("");
296 }
297 
298 wxString HelpText( const wxString & Key )
299 {
300 
301  // Possible future enhancement...
302  // We could look for the text as a local file and use
303  // that if we find it...
304  // if( wxFileExists( Path+Key ) )
305  // ...
306 
307  wxString Text;
308  Text = HelpTextBuiltIn( Key );
309 
310  if( !Text.IsEmpty())
311  return LinkExpand( Text );
312 
313  // Perhaps useful for debugging - we'll return key that we didn't find.
314  return WrapText( Key );
315 }
316 
317 
318 wxString FormatHtmlText( const wxString & Text ){
319 
320  wxString localeStr = wxLocale::GetSystemEncodingName();
321 
322  return
323  wxT("<html><head><META http-equiv=\"Content-Type\" content=\"text/html; charset=") +
324  localeStr +
325  wxT("\"></head>") +
326  WrapText( LinkExpand( Text ))+
327  wxT("</html>");
328 }
static wxString WikiLink(const wxString &Key, const wxString &Text)
Definition: HelpText.cpp:53
#define AUDACITY_VERSION_STRING
Definition: Audacity.h:81
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
static wxString HelpTextBuiltIn(const wxString &Key)
Definition: HelpText.cpp:203
wxString HtmlColourOfIndex(int i)
Definition: HelpText.cpp:26
const wxString VerCheckHtml()
Definition: AboutDialog.cpp:96
static wxString InnerLink(const wxString &Key, const wxString &Text)
Definition: HelpText.cpp:43
static wxString HtmlHelpDir()
Definition: FileNames.cpp:173
wxString HelpText(const wxString &Key)
Definition: HelpText.cpp:298
static wxString WrapText(const wxString &Text)
Definition: HelpText.cpp:32
wxString FormatHtmlText(const wxString &Text)
Definition: HelpText.cpp:318
static wxString FileLink(const wxString &Key, const wxString &Text)
Definition: HelpText.cpp:63
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1225
static wxString LinkExpand(const wxString &Text)
Definition: HelpText.cpp:85
wxString TitleText(const wxString &Key)
Definition: HelpText.cpp:139
static wxString TypedLink(const wxString &Key, const wxString &Text)
Definition: HelpText.cpp:75