forked from Sneeds-Feed-and-Seed/sneedacity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHelpText.cpp
414 lines (371 loc) · 12.2 KB
/
HelpText.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
/**********************************************************************
Sneedacity: A Digital Audio Editor
HelpText.cpp
James Crook
********************************************************************//**
\file HelpText.cpp
\brief Given a key, returns some html.
*//********************************************************************/
#include "HelpText.h"
#include <wx/string.h>
#include <wx/intl.h>
#include <wx/sstream.h>
#include <wx/txtstrm.h>
#include "FileNames.h"
#include "Internat.h"
#include "AllThemeResources.h"
#include "Theme.h"
wxString HtmlColourOfIndex( int i ){
wxColour c = theTheme.Colour(i);
return wxString::Format("\"#%02X%02X%02X\"",
c.Red(), c.Green(), c.Blue() );
}
static wxString WrapText( const wxString & Text )
{
return wxString(wxT(""))+
wxT("<html><head></head>") +
wxT("<body bgcolor=") + HtmlColourOfIndex(clrTrackInfo) + wxT(">") +
wxT("<font color=") + HtmlColourOfIndex(clrTrackPanelText) + wxT(">") +
wxT("<p>") + Text +
wxT("</font>")+
wxT("</body></html>");
}
static wxString InnerLink( const wxString &Key, const wxString& Text )
{
return wxString(wxT("")) +
wxT("<a href='innerlink:") +
Key +
wxT("'>") +
Text +
wxT("</a>");
}
static wxString WikiLink( const wxString &Key, const wxString& Text )
{
return wxString(wxT("")) +
wxT("<a href='https://www.sneedacityteam.org/wiki/index.php?title=") +
Key +
wxT("'>") +
Text +
wxT("</a>");
}
static wxString FileLink( const wxString &Key, const wxString& Text )
{
return wxString(wxT("")) +
wxT("<a href='") +
wxT("file:") +
FileNames::HtmlHelpDir() +
Key +
wxT("'>") +
Text +
wxT("</a>");
}
static wxString TypedLink( const wxString &Key, const wxString& Text )
{
return wxString(wxT("")) +
wxT("<a href='") +
Key +
wxT("'>") +
Text +
wxT("</a>");
}
static wxString LinkExpand( const wxString & Text )
{
wxString Temp = Text;
int i,j,k;
while( (i=Temp.First( wxT("[[") ))!= wxNOT_FOUND )
{
wxString Key = Temp.Mid(i+2);
j = Key.First( wxT("|") );
if( j==wxNOT_FOUND )
return Temp;
wxString LinkText = Key.Mid( j+1);
k = LinkText.First( wxT("]]") );
if( k==wxNOT_FOUND )
return Temp;
Key = Key.Mid( 0, j );
LinkText = LinkText.Mid( 0, k );
LinkText=wxString("<font color=") + HtmlColourOfIndex(clrSample) + wxT(">") +LinkText+"</font>";
wxString Replacement;
if( Key.StartsWith( wxT("wiki:") ))
{
Replacement = WikiLink( Key.Mid( 5 ), LinkText );
}
else if( Key.StartsWith( wxT("file:") ))
{
Replacement = FileLink( Key.Mid( 5 ), LinkText );
}
else if( Key.StartsWith( wxT("http:") ))
{
Replacement = TypedLink( Key, LinkText );
}
else if( Key.StartsWith( wxT("https:") ))
{
Replacement = TypedLink( Key, LinkText );
}
else if( Key.StartsWith( wxT("mailto:") ))
{
Replacement = TypedLink( Key, LinkText );
}
else if( Key.StartsWith( wxT("*URL*") ))
{
Replacement = TypedLink( Key, LinkText );
}
else
{
Replacement = InnerLink( Key, LinkText );
}
Temp = Temp.Mid( 0, i ) + Replacement + Temp.Mid( i + j + k + 5 );// 5 for the [[|]]
}
return Temp;
}
TranslatableString TitleText( const wxString & Key )
{
if(Key==wxT("welcome"))
{
return XO("Welcome!");
}
if(Key ==wxT("play") )
{
/* i18n-hint: Title for a topic.*/
return XO("Playing Audio");
}
if((Key ==wxT("record") ) || (Key ==wxT("norecord") ))
{
/* i18n-hint: Title for a topic.*/
return XO("Recording Audio");
}
if(Key ==wxT("inputdevice") )
{
/* i18n-hint: Title for a topic.*/
return XO("Recording - Choosing the Recording Device");
}
if(Key ==wxT("inputsource") )
{
/* i18n-hint: Title for a topic.*/
return XO("Recording - Choosing the Recording Source");
}
if(Key ==wxT("inputlevel") )
{
/* i18n-hint: Title for a topic.*/
return XO("Recording - Setting the Recording Level");
}
if((Key ==wxT("edit") ) || (Key==wxT("grey")))
{
/* i18n-hint: Title for a topic.*/
return XO("Editing and greyed out Menus");
}
if(Key ==wxT("export") )
{
/* i18n-hint: Title for a topic.*/
return XO("Exporting an Audio File");
}
if(Key ==wxT("save") )
{
/* i18n-hint: Title for a topic.*/
return XO("Saving an Sneedacity Project");
}
if(Key ==wxT("wma-proprietary") )
{
/* i18n-hint: Title for a topic.*/
return XO("Support for Other Formats");
}
if(Key ==wxT("burncd") )
{
/* i18n-hint: Title for a topic.*/
return XO("Burn to CD" );
}
if(Key == wxT("remotehelp") )
{
return XO("No Local Help");
}
// Uh oh, no translation...
return Verbatim( Key );
}
static wxString HelpTextBuiltIn( const wxString & Key )
{
// PRL: Is it necessary to define these outside of conditional compilation so that both get into the .pot file?
const auto alphamsg = XO(
"<br><br>The version of Sneedacity you are using is an <b>Alpha test version</b>.");
const auto betamsg = XO(
"<br><br>The version of Sneedacity you are using is a <b>Beta test version</b>.");
if (Key == wxT("welcome"))
{
wxStringOutputStream o;
wxTextOutputStream s(o);
s
#if defined(IS_ALPHA) || defined(IS_BETA)
<< wxT("<hr><center><h3>")
<< XO("Get the Official Released Version of Sneedacity")
<< wxT("</h3></center>")
<< VerCheckHtml()
#ifdef IS_ALPHA
<< alphamsg
#else
<< betamsg
#endif
<< wxT(" ")
<< XO(
"We strongly recommend that you use our latest stable released version, which has full documentation and support.<br><br>")
<< XO(
"You can help us get Sneedacity ready for release by joining our [[https://www.sneedacityteam.org/community/|community]].<hr><br><br>")
#endif
// DA: Support methods text.
#ifdef EXPERIMENTAL_DA
// Deliberately not translated.
<< wxT("<center><h3>DarkSneedacity ")
<< SNEEDACITY_VERSION_STRING
<< wxT("</h3></center>")
<< wxT("<br><br>DarkSneedacity is based on Sneedacity:")
<< wxT("<ul><li>")
<< wxT(" [[http://www.darksneedacity.com|www.darksneedacity.com]] - for differences between them.")
<< wxT("</li><li>")
<< wxT(
" email to [[mailto:james@sneedacityteam.org|james@sneedacityteam.org]] - for help using DarkSneedacity.")
<< wxT("</li><li>")
<< wxT(
" [[http://www.darksneedacity.com/video.html|Tutorials]] - for getting started with DarkSneedacity.")
<< wxT("</li></ul>")
<< wxT("<br><br>Sneedacity has these support methods:")
<< wxT("<ul><li>")
<< wxT(" [[https://manual.sneedacityteam.org/|Manual]] - for comprehensive Sneedacity documentation")
<< wxT("</li><li>")
<< wxT(" [[https://forum.sneedacityteam.org/|Forum]] - for large knowledge base on using Sneedacity.")
<< wxT("</li></ul>")
#else
<< wxT("<center><h3>Sneedacity ")
<< SNEEDACITY_VERSION_STRING
<< wxT("</h3><h3>")
<< XO("How to get help")
<< wxT("</h3></center>")
<< XO("These are our support methods:")
<< wxT("<p><ul><li>")
/* i18n-hint: Preserve '[[help:Quick_Help|' as it's the name of a link.*/
<< XO("[[help:Quick_Help|Quick Help]] - if not installed locally, [[https://manual.sneedacityteam.org/quick_help.html|view online]]")
<< wxT("</li><li>")
<< XO(
/* i18n-hint: Preserve '[[help:Main_Page|' as it's the name of a link.*/
" [[help:Main_Page|Manual]] - if not installed locally, [[https://manual.sneedacityteam.org/|view online]]")
<< wxT("</li><li>")
<< XO(
" [[https://forum.sneedacityteam.org/|Forum]] - ask your question directly, online.")
<< wxT("</li></ul></p><p>")
<< wxT("<b>")
<< XO("More:</b> Visit our [[https://wiki.sneedacityteam.org/index.php|Wiki]] for tips, tricks, extra tutorials and effects plug-ins.")
<< wxT("</p>")
#endif
;
auto result = o.GetString();
#ifdef USE_ALPHA_MANUAL
result.Replace( "//manual.sneedacityteam.org/quick_help.html","//alphamanual.sneedacityteam.org/man/Quick_Help" );
result.Replace( "//manual.sneedacityteam.org/","//alphamanual.sneedacityteam.org/man/" );
#endif
return WrapText( result );
}
if(Key==wxT("wma-proprietary"))
{
wxStringOutputStream o;
wxTextOutputStream s(o);
s
<< wxT("<p>")
<< XO(
"Sneedacity can import unprotected files in many other formats (such as M4A and WMA, \
compressed WAV files from portable recorders and audio from video files) if you download and install \
the optional [[https://manual.sneedacityteam.org/man/faq_opening_and_saving_files.html#foreign| \
FFmpeg library]] to your computer.")
<< wxT("</p><p>")
<< XO(
"You can also read our help on importing \
[[https://manual.sneedacityteam.org/man/playing_and_recording.html#midi|MIDI files]] \
and tracks from [[https://manual.sneedacityteam.org/man/faq_opening_and_saving_files.html#fromcd| \
audio CDs]].")
<< wxT("</p>")
;
return WrapText( o.GetString() );
}
// Remote help allows us to link to a local copy of the help if it exists,
// or provide a message that takes you to the Internet if it does not.
// It's used by the menu item Help > Index
if(Key == wxT("remotehelp") )
{
wxStringOutputStream o;
wxTextOutputStream s(o);
s
// *URL* will be replaced by whatever URL we are looking for.
// DA: View the manual on line is expected.
#ifdef EXPERIMENTAL_DA
<< XO(
"The Manual does not appear to be installed. \
Please [[*URL*|view the Manual online]].<br><br>\
To always view the Manual online, change \"Location of Manual\" in \
Interface Preferences to \"From Internet\".")
#else
<< XO(
"The Manual does not appear to be installed. \
Please [[*URL*|view the Manual online]] or \
[[https://manual.sneedacityteam.org/man/unzipping_the_manual.html| \
download the Manual]].<br><br>\
To always view the Manual online, change \"Location of Manual\" in \
Interface Preferences to \"From Internet\".")
#endif
;
return WrapText( o.GetString() );
}
return {};
}
wxString HelpText( const wxString & Key )
{
// Possible future enhancement...
// We could look for the text as a local file and use
// that if we find it...
// if( wxFileExists( Path+Key ) )
// ...
wxString Text;
Text = HelpTextBuiltIn( Key );
if( !Text.empty())
return LinkExpand( Text );
// Perhaps useful for debugging - we'll return key that we didn't find.
return WrapText( Key );
}
wxString FormatHtmlText( const wxString & Text ){
wxString localeStr = wxLocale::GetSystemEncodingName();
return
wxT("<html><head><META http-equiv=\"Content-Type\" content=\"text/html; charset=") +
localeStr +
wxT("\"></head>") +
WrapText( LinkExpand( Text ))+
wxT("</html>");
}
// Function to give the extra arguments to put on the version check string.
const wxString VerCheckArgs(){
wxString result = wxString("from_ver=") + SNEEDACITY_VERSION_STRING;
#ifdef REV_LONG
result += wxString("&CommitId=")+wxString(REV_LONG).Left(6);
#endif
result += wxString("&Time=") + wxString( __DATE__ ) + wxString( __TIME__ );
result.Replace(" ","");
return result;
}
// Text of hyperlink to check versions.
const wxString VerCheckHtml()
{
wxStringOutputStream o;
wxTextOutputStream s(o);
s
<< "<center>[["
<< VerCheckUrl().GET()
<< "|"
<< XO("Check Online")
<< "]]</center>\n";
return o.GetString();
}
// Url with Version check args attached.
const URLString VerCheckUrl()
{
//The version we intend to use for live Sneedacity.
#define VER_CHECK_URL "https://www.sneedacityteam.org/download/?"
//For testing of our scriptlet.
//#define VER_CHECK_URL "http://www.sneedacityteam.org/slug/?"
//For testing locally
//#define VER_CHECK_URL "http://localhost:63342/WorkingDocs/demos/download.html?"
return wxString( wxT(VER_CHECK_URL)) +VerCheckArgs();
}