Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b9d2cf4

Browse files
Merge branch 'feature/166-improve-TSaveSourceDlg-usage+appearance' into develop
Fixes #166
2 parents 122df99 + 1eb2d60 commit b9d2cf4

File tree

9 files changed

+160
-119
lines changed

9 files changed

+160
-119
lines changed

‎Docs/Design/FileFormats/saved.html

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ <h2>
5151

5252
<ol>
5353
<li>
54-
By saving snippet information to file from the <em>File | Save Snippet Information</em> menu option.
54+
By saving snippet information using the <em>File | Save Snippet Information</em> menu option.
5555
</li>
5656
<li>
57-
By saving snippets to file from the <em>File | Save Snippet</em> menu option.
57+
By saving snippets using the <em>File | Save Snippet</em> menu option.
5858
</li>
5959
<li>
60-
By saving units to file from the <em>File | Save Unit</em> menu option.
60+
By saving units using the <em>File | Save Unit</em> menu option.
6161
</li>
6262
</ol>
6363

@@ -115,7 +115,7 @@ <h2>
115115
</h2>
116116

117117
<p>
118-
The available encodings used depend on the file type and user choice. Different file
118+
The available encodings depend on the file type and user choice. Different file
119119
types have different encoding choices, as follows:
120120
</p>
121121

@@ -132,10 +132,10 @@ <h2>
132132
UTF-8
133133
</li>
134134
<li>
135-
Unicode little endian (UTF16-LE)
135+
UTF-16LE
136136
</li>
137137
<li>
138-
Unicode big endian (UTF16-BE)
138+
UTF-16BE
139139
</li>
140140
</ul>
141141
</dd>
@@ -178,7 +178,26 @@ <h2>
178178
<dd>
179179
<ul class="squashed">
180180
<li>
181-
ASCII [for Snippet Information] or ANSI [otherwise]. Regardless of naming, ASCII format is always used.
181+
ASCII
182+
</li>
183+
</ul>
184+
</dd>
185+
<dt>
186+
Markdown
187+
</dt>
188+
<dd>
189+
<ul class="squashed">
190+
<li>
191+
ANSI (system default code page)
192+
</li>
193+
<li>
194+
UTF-8
195+
</li>
196+
<li>
197+
UTF-16LE
198+
</li>
199+
<li>
200+
UTF-16BE
182201
</li>
183202
</ul>
184203
</dd>

‎Src/Help/HTML/dlg_saveinfo.htm

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ <h1>
6868
</p>
6969
<ul>
7070
<li>
71-
<em>ANSI (Default)</em> &ndash; the system default ANSI encoding.
71+
<em>ANSI Code Page <code>nnn</code></em> &ndash; ANSI encoding for the system default code page,
72+
where <code>nnn</code> is the code page for the user's locale.
7273
Available as an option for plain text and Markdown file formats.
7374
</li>
7475
<li>
@@ -77,14 +78,12 @@ <h1>
7778
as the only encoding available for HTML 5 and XHTML file formats.
7879
</li>
7980
<li>
80-
<em>Unicode (Little Endian)</em> &ndash; UTF-16 LE encoding, with
81-
BOM<sup>&dagger;</sup>. Available as an option for plain text files and Markdown
82-
file formats.
81+
<em>UTF-16 Little Endian</em> &ndash; UTF-16 LE encoding, with
82+
BOM<sup>&dagger;</sup>. Available as an option for plain text and Markdown file formats.
8383
</li>
8484
<li>
85-
<em>Unicode (Big Endian)</em> &ndash; UTF-16 BE encoding, with
86-
BOM<sup>&dagger;</sup>. Available as an option for plain text files and Markdown
87-
file formats.
85+
<em>UTF-18 Big Endian</em> &ndash; UTF-16 BE encoding, with
86+
BOM<sup>&dagger;</sup>. Available as an option for plain text and Markdown file formats.
8887
</li>
8988
<li>
9089
<em>ASCII</em> &ndash; The only encoding available for the rich text file.

‎Src/Help/HTML/dlg_savesnippet.htm

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,29 +104,34 @@ <h1>
104104
<p>
105105
The output file encoding can be be specified in the <em>File Encoding</em>
106106
drop down list. Options vary depending on the file type. Some file types
107-
support only a single encoding. The encodings are:
107+
support only a single encoding, in which case the drop down list will be
108+
disabled. The encodings are:
108109
</p>
109110
<ul>
110111
<li>
111-
<em>ANSI (Default)</em> &ndash; the system default ANSI encoding.
112-
Available for both plain text and Pascal include files and as the only
113-
option for rich text files.
112+
<em>ANSI Code Page <code>nnn</code></em> &ndash; ANSI encoding for the system default code page,
113+
where <code>nnn</code> is the code page for the user's locale.
114+
Available for both plain text and Pascal include files.
114115
</li>
115116
<li>
116117
<em>UTF-8</em> &ndash; UTF-8 encoding, with BOM<sup>&dagger;</sup>.
117118
Available for both plain text and Pascal include files and as the only
118-
option for XHTML files. If used for Pascal include files be warned that
119+
option for HTML5 and XHTML files. If used for Pascal include files be warned that
119120
the files will only compile with compilers that support Unicode source
120121
files.
121122
</li>
122123
<li>
123-
<em>Unicode (Little Endian)</em> &ndash; UTF-16 LE encoding, with
124+
<em>UTF-16 Little Endian</em> &ndash; UTF-16 LE encoding, with
124125
BOM<sup>&dagger;</sup>. Available for plain text files only.
125126
</li>
126127
<li>
127-
<em>Unicode (Big Endian)</em> &ndash; UTF-16 BE encoding, with
128+
<em>UTF-18 Big Endian</em> &ndash; UTF-16 BE encoding, with
128129
BOM<sup>&dagger;</sup>. Available for plain text files only.
129130
</li>
131+
<li>
132+
<em>ASCII</em> &ndash; ASCII encoding. Available as the only option for
133+
rich text files.
134+
</li>
130135
</ul>
131136
<p>
132137
The output can be previewed by clicking the <em>Preview</em> button. This

‎Src/Help/HTML/dlg_saveunit.htm

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,29 +89,34 @@ <h1>
8989
<p>
9090
The output file encoding can be be specified in the <em>File Encoding</em>
9191
drop down list. Options vary depending on the file type. Some file types
92-
support only a single encoding. The encodings are:
92+
support only a single encoding, in which case the drop down list will be
93+
disabled. The encodings are:
9394
</p>
9495
<ul>
9596
<li>
96-
<em>ANSI (Default)</em> &ndash; the system default ANSI encoding.
97-
Available for both plain text and Pascal unit files and as the only
98-
option for rich text files.
97+
<em>ANSI Code Page <code>nnn</code></em> &ndash; ANSI encoding for the system default code page,
98+
where <code>nnn</code> is the code page for the user's locale.
99+
Available for both plain text and Pascal unit files.
99100
</li>
100101
<li>
101102
<em>UTF-8</em> &ndash; UTF-8 encoding, with BOM<sup>&dagger;</sup>.
102103
Available for both plain text and Pascal unit files and as the only
103-
option for XHTML files. If used for Pascal units be warned that the
104+
option for HTML 5 and XHTML files. If used for Pascal units be warned that the
104105
unit will only compile with compilers that support Unicode source
105106
files.
106107
</li>
107108
<li>
108-
<em>Unicode (Little Endian)</em> &ndash; UTF-16 LE encoding, with
109+
<em>UTF-16 Little Endian</em> &ndash; UTF-16 LE encoding, with
109110
BOM<sup>&dagger;</sup>. Available for plain text files only.
110111
</li>
111112
<li>
112-
<em>Unicode (Big Endian)</em> &ndash; UTF-16 BE encoding, with
113+
<em>UTF-18 Big Endian</em> &ndash; UTF-16 BE encoding, with
113114
BOM<sup>&dagger;</sup>. Available for plain text files only.
114115
</li>
116+
<li>
117+
<em>ASCII</em> &ndash; ASCII encoding. Available as the only option for
118+
rich text files.
119+
</li>
115120
</ul>
116121
<p>
117122
The output can be previewed by clicking the <em>Preview</em> button. This

‎Src/USaveInfoMgr.pas

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ destructor TSaveInfoMgr.Destroy;
151151
end;
152152

153153
procedure TSaveInfoMgr.DoExecute;
154+
resourcestring
155+
sDlgCaption = 'Save Snippet Information for %s';
154156
var
155157
Encoding: TEncoding; // encoding to use for output file
156158
FileContent: string; // output file content before encoding
@@ -164,6 +166,9 @@ procedure TSaveInfoMgr.DoExecute;
164166
1
165167
);
166168
fSaveDlg.FileName := fSourceFileInfo.DefaultFileName;
169+
fSaveDlg.Title := Format(sDlgCaption, [
170+
(fView as ISnippetView).Snippet.DisplayName]
171+
);
167172
// Display dialog box and save file if user OKs
168173
if fSaveDlg.Execute then
169174
begin
@@ -268,20 +273,13 @@ constructor TSaveInfoMgr.InternalCreate(AView: IView);
268273
const
269274
DlgHelpKeyword = 'SnippetInfoFileDlg';
270275
resourcestring
271-
sDefFileName = 'SnippetInfo';
272-
sDlgCaption = 'Save Snippet Information';
273-
// descriptions of supported encodings
274-
sASCIIEncoding = 'ASCII';
275-
sANSIDefaultEncoding = 'ANSI (Default)';
276-
sUTF8Encoding = 'UTF-8';
277-
sUTF16LEEncoding = 'Unicode (Little Endian)';
278-
sUTF16BEEncoding = 'Unicode (Big Endian)';
279276
// descriptions of supported file filter strings
280277
sRTFDesc = 'Rich text file';
281278
sTextDesc = 'Plain text file';
282279
sHTML5Desc = 'HTML 5 file';
283280
sXHTMLDesc = 'XHTML file';
284281
sMarkdownDesc = 'Markdown file';
282+
285283
begin
286284
inherited InternalCreate;
287285
fView := AView;
@@ -290,50 +288,34 @@ constructor TSaveInfoMgr.InternalCreate(AView: IView);
290288
fSourceFileInfo.FileTypeInfo[sfRTF] := TSourceFileTypeInfo.Create(
291289
'.rtf',
292290
sRTFDesc,
293-
[
294-
TSourceFileEncoding.Create(etASCII, sASCIIEncoding)
295-
]
291+
[etASCII]
296292
);
297293
fSourceFileInfo.FileTypeInfo[sfText] := TSourceFileTypeInfo.Create(
298294
'.txt',
299295
sTextDesc,
300-
[
301-
TSourceFileEncoding.Create(etUTF8, sUTF8Encoding),
302-
TSourceFileEncoding.Create(etUTF16LE, sUTF16LEEncoding),
303-
TSourceFileEncoding.Create(etUTF16BE, sUTF16BEEncoding),
304-
TSourceFileEncoding.Create(etSysDefault, sANSIDefaultEncoding)
305-
]
296+
[etUTF8, etUTF16LE, etUTF16BE, etSysDefault]
306297
);
307298
fSourceFileInfo.FileTypeInfo[sfHTML5] := TSourceFileTypeInfo.Create(
308299
'.html',
309300
sHTML5Desc,
310-
[
311-
TSourceFileEncoding.Create(etUTF8, sUTF8Encoding)
312-
]
301+
[etUTF8]
313302
);
314-
fSourceFileInfo.DefaultFileName := sDefFileName;
315303
fSourceFileInfo.FileTypeInfo[sfXHTML] := TSourceFileTypeInfo.Create(
316304
'.html',
317305
sXHTMLDesc,
318-
[
319-
TSourceFileEncoding.Create(etUTF8, sUTF8Encoding)
320-
]
306+
[etUTF8]
321307
);
322-
fSourceFileInfo.DefaultFileName := sDefFileName;
323308
fSourceFileInfo.FileTypeInfo[sfMarkdown] := TSourceFileTypeInfo.Create(
324309
'.md',
325310
sMarkdownDesc,
326-
[
327-
TSourceFileEncoding.Create(etUTF8, sUTF8Encoding),
328-
TSourceFileEncoding.Create(etUTF16LE, sUTF16LEEncoding),
329-
TSourceFileEncoding.Create(etUTF16BE, sUTF16BEEncoding),
330-
TSourceFileEncoding.Create(etSysDefault, sANSIDefaultEncoding)
331-
]
311+
[etUTF8, etUTF16LE, etUTF16BE, etSysDefault]
332312
);
333-
fSourceFileInfo.DefaultFileName := sDefFileName;
313+
314+
// set default file name without converting to valid Pascal identifier
315+
fSourceFileInfo.RequirePascalDefFileName := False;
316+
fSourceFileInfo.DefaultFileName := fView.Description;
334317

335318
fSaveDlg := TSaveSourceDlg.Create(nil);
336-
fSaveDlg.Title := sDlgCaption;
337319
fSaveDlg.HelpKeyword := DlgHelpKeyword;
338320
fSaveDlg.CommentStyle := TCommentStyle.csNone;
339321
fSaveDlg.EnableCommentStyles := False;

‎Src/USaveSnippetMgr.pas

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ implementation
9292

9393
resourcestring
9494
// Dialog box title
95-
sSaveSnippetDlgTitle = 'Save %0:s Snippet';
96-
sSaveCategoryDlgTitle = 'Save %0:s Category';
95+
sSaveSnippetDlgTitle = 'Save Annotated Source of %0:s';
96+
sSaveCategoryDlgTitle = 'Save Annotated Source of %0:s Category';
9797
// Output document title for snippets and categories
9898
sDocTitle = '"%0:s" %1:s';
9999
sCategory = 'category';

‎Src/USaveSourceDlg.pas

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,6 @@ implementation
228228
sChkTruncateComment = 'Truncate comments to 1st paragraph';
229229
sBtnPreview = '&Preview...';
230230
sBtnHelp = '&Help';
231-
// Default encoding name
232-
sANSIEncoding = 'ANSI (Default)';
233231

234232

235233
const
@@ -483,7 +481,7 @@ procedure TSaveSourceDlg.DoTypeChange;
483481
fOnEncodingQuery(Self, Encodings);
484482
if Length(Encodings) = 0 then
485483
Encodings := TSourceFileEncodings.Create(
486-
TSourceFileEncoding.Create(etSysDefault, sANSIEncoding)
484+
TSourceFileEncoding.Create(etSysDefault)
487485
);
488486
fCmbEncoding.Clear;
489487
for Encoding in Encodings do
@@ -495,6 +493,8 @@ procedure TSaveSourceDlg.DoTypeChange;
495493
fCmbEncoding.ItemIndex := IndexOfEncodingType(fSelectedEncoding);
496494
if fCmbEncoding.ItemIndex = -1 then
497495
fCmbEncoding.ItemIndex := 0;
496+
fCmbEncoding.Enabled := fCmbEncoding.Items.Count > 1;
497+
fLblEncoding.Enabled := fCmbEncoding.Enabled;
498498
DoEncodingChange;
499499

500500
inherited;

‎Src/USaveSourceMgr.pas

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ implementation
134134
// Delphi
135135
SysUtils,
136136
// Project
137-
FmPreviewDlg, Hiliter.UFileHiliter, UIOUtils, UMessageBox, UOpenDialogHelper,
138-
UPreferences;
137+
FmPreviewDlg, Hiliter.UFileHiliter, UIOUtils, UMessageBox,
138+
UOpenDialogHelper, UPreferences;
139139

140140

141141
{ TSaveSourceMgr }
@@ -244,53 +244,33 @@ procedure TSaveSourceMgr.HiliteQueryHandler(Sender: TObject;
244244
end;
245245

246246
constructor TSaveSourceMgr.InternalCreate;
247-
resourcestring
248-
// descriptions of supported encodings
249-
sANSIDefaultEncoding = 'ANSI (Default)';
250-
sUTF8Encoding = 'UTF-8';
251-
sUTF16LEEncoding = 'Unicode (Little Endian)';
252-
sUTF16BEEncoding = 'Unicode (Big Endian)';
253247
begin
254248
inherited InternalCreate;
255249
fSourceFileInfo := TSourceFileInfo.Create;
256250
fSourceFileInfo.FileTypeInfo[sfText] := TSourceFileTypeInfo.Create(
257251
'.txt',
258252
GetFileTypeDesc(sfText),
259-
[
260-
TSourceFileEncoding.Create(etSysDefault, sANSIDefaultEncoding),
261-
TSourceFileEncoding.Create(etUTF8, sUTF8Encoding),
262-
TSourceFileEncoding.Create(etUTF16LE, sUTF16LEEncoding),
263-
TSourceFileEncoding.Create(etUTF16BE, sUTF16BEEncoding)
264-
]
253+
[etSysDefault, etUTF8, etUTF16LE, etUTF16BE]
265254
);
266255
fSourceFileInfo.FileTypeInfo[sfPascal] := TSourceFileTypeInfo.Create(
267256
'.pas',
268257
GetFileTypeDesc(sfPascal),
269-
[
270-
TSourceFileEncoding.Create(etSysDefault, sANSIDefaultEncoding),
271-
TSourceFileEncoding.Create(etUTF8, sUTF8Encoding)
272-
]
258+
[etSysDefault, etUTF8]
273259
);
274260
fSourceFileInfo.FileTypeInfo[sfHTML5] := TSourceFileTypeInfo.Create(
275261
'.html',
276262
GetFileTypeDesc(sfHTML5),
277-
[
278-
TSourceFileEncoding.Create(etUTF8, sUTF8Encoding)
279-
]
263+
[etUTF8]
280264
);
281265
fSourceFileInfo.FileTypeInfo[sfXHTML] := TSourceFileTypeInfo.Create(
282266
'.html',
283267
GetFileTypeDesc(sfXHTML),
284-
[
285-
TSourceFileEncoding.Create(etUTF8, sUTF8Encoding)
286-
]
268+
[etUTF8]
287269
);
288270
fSourceFileInfo.FileTypeInfo[sfRTF] := TSourceFileTypeInfo.Create(
289271
'.rtf',
290272
GetFileTypeDesc(sfRTF),
291-
[
292-
TSourceFileEncoding.Create(etSysDefault, sANSIDefaultEncoding)
293-
]
273+
[etASCII]
294274
);
295275
fSourceFileInfo.DefaultFileName := GetDefaultFileName;
296276

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /