1 {
2  /***************************************************************************
3                             makeresstrdlg.pas
4                             -----------------
5 
6 
7  ***************************************************************************/
8 
9  ***************************************************************************
10  *                                                                         *
11  *   This source is free software; you can redistribute it and/or modify   *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  *   This code is distributed in the hope that it will be useful, but      *
17  *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
18  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
19  *   General Public License for more details.                              *
20  *                                                                         *
21  *   A copy of the GNU General Public License is available on the World    *
22  *   Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also      *
23  *   obtain it by writing to the Free Software Foundation,                 *
24  *   Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1335, USA.   *
25  *                                                                         *
26  ***************************************************************************
27 
28  Author: Mattias Gaertner
29 
30  Abstract:
31    TMakeResStrDialog is the dialog to setup how to convert a string constant
32    into a pascal resourcestring.
33 
34 }
35 unit MakeResStrDlg;
36 
37 {$mode objfpc}{$H+}
38 
39 interface
40 
41 uses
42   Classes, SysUtils,
43   // LCL
44   LCLProc, Forms, Controls, StdCtrls, Dialogs, ExtCtrls, ButtonPanel,
45   // SynEdit
46   SynHighlighterPas, SynEdit,
47   // CodeTools
48   CodeToolManager, CodeToolsStructs, CodeCache,
49   // IdeIntf
50   IDEWindowIntf, IDEHelpIntf, IDEDialogs,
51   // IDE
52   LazarusIDEStrConsts, EditorOptions, InputHistory, MiscOptions, IDEProcs;
53 
54 type
55 
56   { TMakeResStrDialog }
57 
58   TMakeResStrDialog = class(TForm)
59     ButtonPanel1: TButtonPanel;
60     CustomIdentifierCheckBox: TCheckBox;
61     IdentifierGroupBox: TGroupBox;
62     IdentifierEdit: TEdit;
63     IdentLengthComboBox: TComboBox;
64     IdentLengthLabel: TLabel;
65     IdentPrefixComboBox: TComboBox;
66     IdentPrefixLabel: TLabel;
67 
68     // options
69     ConversionGroupBox: TGroupBox;
70     CodePanel: TPanel;
71     // resourcestring section
72     ResStrSectionLabel: TLabel;
73     ResStrSectionComboBox: TComboBox;
74     // resourcestrings with same value
75     ResStrWithSameValueLabel: TLabel;
76     ResStrWithSameValuesCombobox: TComboBox;
77     // insert position type
78     AppendResStrRadioButton: TRadioButton;
79     InsertAlphabeticallyResStrRadioButton: TRadioButton;
80     InsertContextSensitiveRadioButton: TRadioButton;
81 
82     Splitter1: TSplitter;
83     SrcPreviewGroupBox: TGroupBox;
84     SrcPreviewSynEdit: TSynEdit;
85     StringConstGroupBox: TGroupBox;
86     StringConstSynEdit: TSynEdit;
87 
88     // highlighter
89     SynPasSyn: TSynPasSyn;
90 
91 
92     procedure CustomIdentifierCheckBoxClick(Sender: TObject);
93     procedure HelpButtonClick(Sender: TObject);
94     procedure IdentLengthComboBoxChange(Sender: TObject);
95     procedure IdentPrefixComboBoxChange(Sender: TObject);
96     procedure IdentifierEditChange(Sender: TObject);
97     procedure OkButtonClick(Sender: TObject);
98     procedure ResStrSectionComboBoxChange(Sender: TObject);
99     procedure ResStrWithSameValuesComboboxChange(Sender: TObject);
100   private
101     procedure SetupComponents;
102   public
103     DefaultIdentifier: string;
104     Code: TCodeBuffer;
105     StartPos, EndPos: TPoint;
106     Positions: TCodeXYPositions;
107     constructor Create(TheOwner: TComponent); override;
108     destructor Destroy; override;
109     procedure FillResourceStringSections(NewPositions: TCodeXYPositions);
110     procedure FillIdentPrefixes;
111     procedure FillIdentLengths;
112     procedure FillStringsWithSameValue;
113     procedure UpdateIdentifier;
114     procedure UpdateSourcePreview;
GetIdentifiernull115     function GetIdentifier: string;
GetDefaultIdentifiernull116     function GetDefaultIdentifier: string;
117     procedure SetSource(NewCode: TCodeBuffer;
118       const NewStartPos, NewEndPos: TPoint);
ResStrExistsInCurrentSectionnull119     function ResStrExistsInCurrentSection(const Identifier: string): boolean;
ResStrExistsInAnySectionnull120     function ResStrExistsInAnySection(const Identifier: string): boolean;
ResStrExistsWithSameValuenull121     function ResStrExistsWithSameValue(const Identifier: string): boolean;
122     procedure GetNewSource(out NewSource, ResourceStringValue: string);
123     procedure Init;
124     procedure SaveHistories;
125     procedure SaveIdentPrefixes;
126     procedure SaveIdentLengths;
127     procedure Save;
128   end;
129 
ShowMakeResStrDialognull130 function ShowMakeResStrDialog(
131   const StartPos, EndPos: TPoint; Code: TCodeBuffer;
132   out NewIdentifier, NewIdentifierValue: string;
133   out NewSourceLines: string;
134   out ResStrSectionCode: TCodeBuffer;
135   out ResStrSectionXY: TPoint;
136   out InsertPolicy: TResourcestringInsertPolicy): TModalResult;
137 
138 implementation
139 
140 {$R *.lfm}
141 
142 
ShowMakeResStrDialognull143 function ShowMakeResStrDialog(const StartPos, EndPos: TPoint;
144   Code: TCodeBuffer; out NewIdentifier, NewIdentifierValue: string; out
145   NewSourceLines: string; out ResStrSectionCode: TCodeBuffer; out
146   ResStrSectionXY: TPoint; out InsertPolicy: TResourcestringInsertPolicy
147   ): TModalResult;
148 var
149   MakeResStrDialog: TMakeResStrDialog;
150   Section: PCodeXYPosition;
151   ResourcestringSectionID: Integer;
152 begin
153   //debugln('ShowMakeResStrDialog StartPos=',dbgs(StartPos),' EndPos=',dbgs(EndPos),' ');
154   NewIdentifier:='';
155   NewIdentifierValue:='';
156   NewSourceLines:='';
157   ResStrSectionCode:=nil;
158   ResStrSectionXY:=Point(0,0);
159   InsertPolicy:=rsipNone;
160 
161   MakeResStrDialog:=TMakeResStrDialog.Create(nil);
162   MakeResStrDialog.Positions:=CodeToolBoss.Positions.CreateCopy;
163   MakeResStrDialog.SetSource(Code,StartPos,EndPos);
164   MakeResStrDialog.Init;
165 
166   // show dialog
167   Result:=MakeResStrDialog.ShowModal;
168   if Result=mrOk then begin
169     // return results
170     NewIdentifier:=MakeResStrDialog.GetIdentifier;
171     MakeResStrDialog.GetNewSource(NewSourceLines,NewIdentifierValue);
172     if MakeResStrDialog.ResStrExistsWithSameValue(NewIdentifier) then
173       InsertPolicy:=rsipNone
174     else begin
175       if MakeResStrDialog.InsertAlphabeticallyResStrRadioButton.Checked then
176         InsertPolicy:=rsipAlphabetically
177       else if MakeResStrDialog.InsertContextSensitiveRadioButton.Checked then
178         InsertPolicy:=rsipContext
179       else
180         InsertPolicy:=rsipAppend;
181     end;
182     ResourcestringSectionID:=MakeResStrDialog.ResStrSectionComboBox.ItemIndex;
183     Section:=CodeToolBoss.Positions[ResourcestringSectionID];
184     ResStrSectionCode:=Section^.Code;
185     ResStrSectionXY:=Point(Section^.X,Section^.Y);
186   end;
187 
188   // save settings and clean up
189   IDEDialogLayoutList.SaveLayout(MakeResStrDialog);
190 
191   MakeResStrDialog.Positions.Free;
192   MakeResStrDialog.Free;
193 end;
194 
195 { TMakeResStrDialog }
196 
197 procedure TMakeResStrDialog.CustomIdentifierCheckBoxClick(Sender: TObject);
198 begin
199   UpdateIdentifier;
200 end;
201 
202 procedure TMakeResStrDialog.HelpButtonClick(Sender: TObject);
203 begin
204   LazarusHelp.ShowHelpForIDEControl(Self);
205 end;
206 
207 procedure TMakeResStrDialog.IdentLengthComboBoxChange(Sender: TObject);
208 begin
209   UpdateIdentifier;
210   UpdateSourcePreview;
211 end;
212 
213 procedure TMakeResStrDialog.IdentPrefixComboBoxChange(Sender: TObject);
214 begin
215   UpdateIdentifier;
216   UpdateSourcePreview;
217 end;
218 
219 procedure TMakeResStrDialog.IdentifierEditChange(Sender: TObject);
220 begin
221   UpdateIdentifier;
222   UpdateSourcePreview;
223 end;
224 
225 procedure TMakeResStrDialog.OkButtonClick(Sender: TObject);
226 var
227   Index: Integer;
228 begin
229   Index:=ResStrSectionComboBox.ItemIndex;
230   if (Index<0) or (Index>=Positions.Count) then begin
231     IDEMessageDialog(lisMakeResStrInvalidResourcestringSect,
232       lisMakeResStrPleaseChooseAResourcestring,
233       mtError,[mbCancel]);
234     exit;
235   end;
236   if ResStrExistsInAnySection(IdentifierEdit.Text)
237   and (not ResStrExistsWithSameValue(IdentifierEdit.Text)) then begin
238     if IDEMessageDialog(lisMakeResStrResourcestringAlreadyExis,
239       Format(lisMakeResStrChooseAnotherName,[IdentifierEdit.Text,LineEnding,LineEnding]),
240       mtWarning,[mbOk,mbIgnore]) = mrOk
241     then
242       exit;
243   end;
244   Save;
245   ModalResult:=mrOk;
246 end;
247 
248 procedure TMakeResStrDialog.ResStrSectionComboBoxChange(Sender: TObject);
249 begin
250   UpdateIdentifier;
251   UpdateSourcePreview;
252 end;
253 
254 procedure TMakeResStrDialog.ResStrWithSameValuesComboboxChange(Sender: TObject);
255 var
256   NewIdentifier: String;
257   i: Integer;
258 begin
259   NewIdentifier:=ResStrWithSameValuesCombobox.Text;
260   i:=ResStrWithSameValuesCombobox.Items.IndexOf(NewIdentifier);
261   if i<0 then exit;
262   IdentifierEdit.Text:=NewIdentifier;
263 end;
264 
265 procedure TMakeResStrDialog.SetupComponents;
266 begin
267   // source
268   AppendResStrRadioButton.Caption:=lisMakeResStrAppendToSection;
269   ConversionGroupBox.Caption:=lisMakeResStrConversionOptions;
270   CustomIdentifierCheckBox.Caption:=lisMakeResStrCustomIdentifier;
271   IdentifierGroupBox.Caption := lisMakeResStrDialogIdentifier;
272   IdentLengthLabel.Caption:=lisMakeResStrIdentifierLength;
273   IdentPrefixLabel.Caption:=lisMakeResStrIdentifierPrefix;
274   InsertAlphabeticallyResStrRadioButton.Caption:=lisMakeResStrInsertAlphabetically;
275   InsertContextSensitiveRadioButton.Caption:=lisMakeResStrInsertContexttSensitive;
276   ResStrSectionLabel.Caption:=lisMakeResStrResourcestringSection;
277   ResStrWithSameValueLabel.Caption:=lisMakeResStrStringsWithSameValue;
278   SrcPreviewGroupBox.Caption:=lisMakeResStrSourcePreview;
279   StringConstGroupBox.Caption:=lisMakeResStrStringConstantInSource;
280 
281   // OK, Cancel, Help buttons
282   ButtonPanel1.OkButton.Caption:=lisMenuOk;
283   ButtonPanel1.CancelButton.Caption:=lisCancel;
284   ButtonPanel1.HelpButton.Caption:=lisMenuHelp;
285 end;
286 
287 constructor TMakeResStrDialog.Create(TheOwner: TComponent);
288 begin
289   inherited Create(TheOwner);
290 
291   Caption := lisMakeResourceString;
292   SetupComponents;
293 
294   IDEDialogLayoutList.ApplyLayout(Self,550,400);
295 
296   EditorOpts.GetHighlighterSettings(SynPasSyn);
297   EditorOpts.GetSynEditSettings(StringConstSynEdit);
298   StringConstSynEdit.ReadOnly:=true;
299   StringConstSynEdit.Gutter.Visible:=false;
300   EditorOpts.GetSynEditSettings(SrcPreviewSynEdit);
301   SrcPreviewSynEdit.ReadOnly:=true;
302   SrcPreviewSynEdit.Gutter.Visible:=false;
303 end;
304 
305 destructor TMakeResStrDialog.Destroy;
306 begin
307   inherited Destroy;
308 end;
309 
310 procedure TMakeResStrDialog.FillResourceStringSections(
311   NewPositions: TCodeXYPositions);
312 var
313   i: Integer;
314   p: PCodeXYPosition;
315   s: String;
316 begin
317   Positions:=NewPositions;
318   // the history list contains the filenames plus the
319   with ResStrSectionComboBox do begin
320     Text:='';
321     Items.BeginUpdate;
322     for i:=0 to Positions.Count-1 do begin
323       p:=Positions[i];
324       s:=p^.Code.Filename+' ('+IntToStr(p^.Y)+','+IntToStr(p^.X)+')';
325       if i<Items.Count then
326         Items[i]:=s
327       else
328         Items.Add(s);
329     end;
330     while Items.Count>Positions.Count do
331       Items.Delete(Items.Count-1);
332     Items.EndUpdate;
333     ItemIndex:=0;
334   end;
335 end;
336 
337 procedure TMakeResStrDialog.FillIdentPrefixes;
338 var
339   HistoryList: THistoryList;
340 begin
341   // get the Prefixes history list
342   HistoryList:=
343          InputHistories.HistoryLists.GetList(hlMakeResourceStringPrefixes,true,
344                                              rltCaseSensitive);
345   IdentPrefixComboBox.Items.Assign(HistoryList);
346   if IdentPrefixComboBox.Items.Count>0 then
347     IdentPrefixComboBox.Text:=IdentPrefixComboBox.Items[0]
348   else
349     IdentPrefixComboBox.Text:='rs';
350 end;
351 
352 procedure TMakeResStrDialog.FillIdentLengths;
353 var
354   HistoryList: THistoryList;
355 begin
356   // get the Length history list
357   HistoryList:=
358     InputHistories.HistoryLists.GetList(hlMakeResourceStringLengths,true,
359                                         rltCaseSensitive);
360   IdentLengthComboBox.Items.Assign(HistoryList);
361   if IdentLengthComboBox.Items.Count>0 then
362     IdentLengthComboBox.Text:=IdentLengthComboBox.Items[0]
363   else begin
364     with IdentLengthComboBox.Items do begin
365       Add('8');
366       Add('12');
367       Add('20');
368       Add('50');
369     end;
370     IdentLengthComboBox.Text:='12';
371   end;
372 end;
373 
374 procedure TMakeResStrDialog.FillStringsWithSameValue;
375 var
376   i: Integer;
377   CurSection: TCodeXYPosition;
378   NewSource, ResourceStringValue: string;
379   StringConstPositions: TCodeXYPositions;
380   ExistingIdentifier: string;
381 begin
382   // get value of the new resourcestring
383   GetNewSource(NewSource, ResourceStringValue);
384   // get all existing resourcestrings with same value
385   StringConstPositions:=TCodeXYPositions.Create;
386   for i:=0 to Positions.Count-1 do begin
387     CurSection:=Positions[i]^;
388     CodeToolBoss.GatherResourceStringsWithValue(
389       CurSection.Code,CurSection.X,CurSection.Y,
390       ResourceStringValue,StringConstPositions);
391   end;
392   // fill combobox
393   ResStrWithSameValuesCombobox.Items.Clear;
394   for i:=0 to StringConstPositions.Count-1 do begin
395     CurSection:=StringConstPositions[i]^;
396     CodeToolBoss.GetIdentifierAt(CurSection.Code,CurSection.X,CurSection.Y,
397                                  ExistingIdentifier);
398     if ExistingIdentifier<>'' then
399       ResStrWithSameValuesCombobox.Items.Add(ExistingIdentifier);
400   end;
401   // enable components for selection
402   if ResStrWithSameValuesCombobox.Items.Count>0 then begin
403     ResStrWithSameValuesCombobox.Text:=ResStrWithSameValuesCombobox.Items[0];
404     ResStrWithSameValuesCombobox.Enabled:=true;
405   end else begin
406     ResStrWithSameValuesCombobox.Text:='';
407     ResStrWithSameValuesCombobox.Enabled:=false;
408   end;
409   ResStrWithSameValueLabel.Enabled:=ResStrWithSameValuesCombobox.Enabled;
410   // clean up
411   StringConstPositions.Free;
412 end;
413 
414 procedure TMakeResStrDialog.UpdateIdentifier;
415 var
416   CustomIdent: Boolean;
417 begin
418   CustomIdent:=CustomIdentifierCheckBox.Checked;
419   IdentifierEdit.Enabled:=CustomIdent;
420   IdentPrefixLabel.Enabled:=not CustomIdent;
421   IdentPrefixComboBox.Enabled:=not CustomIdent;
422   IdentLengthLabel.Enabled:=not CustomIdent;
423   IdentLengthComboBox.Enabled:=not CustomIdent;
424   if not CustomIdent then
425     IdentifierEdit.Text:=GetDefaultIdentifier;
426 end;
427 
428 procedure TMakeResStrDialog.UpdateSourcePreview;
429 var
430   NewSource, NewValue: string;
431 begin
432   GetNewSource(NewSource,NewValue);
433   SrcPreviewSynEdit.Text:=NewSource+LineEnding
434      +StringOfChar('-',
435                   CodeToolBoss.SourceChangeCache.BeautifyCodeOptions.LineLength)
436      +LineEnding
437      +CodeToolBoss.SourceChangeCache.BeautifyCodeOptions.BeautifyStatement(
438         GetIdentifier+' = '''+NewValue+'''',0);
439 end;
440 
GetIdentifiernull441 function TMakeResStrDialog.GetIdentifier: string;
442 begin
443   Result:=IdentifierEdit.Text;
444   if Result='' then Result:=GetDefaultIdentifier;
445 end;
446 
TMakeResStrDialog.GetDefaultIdentifiernull447 function TMakeResStrDialog.GetDefaultIdentifier: string;
448 var
449   DefIdenLength: Integer;
450   i: Integer;
451 begin
452   if ResStrWithSameValuesCombobox.Items.Count>0 then begin
453     Result:=ResStrWithSameValuesCombobox.Items[0];
454     exit;
455   end;
456   DefIdenLength:=StrToIntDef(IdentLengthComboBox.Text,8);
457   if DefIdenLength<1 then DefIdenLength:=1;
458   if DefIdenLength>80 then DefIdenLength:=80;
459   Result:=IdentPrefixComboBox.Text+copy(DefaultIdentifier,1,DefIdenLength);
460   if ResStrExistsInCurrentSection(Result) then begin
461     i:=2;
462     while ResStrExistsInCurrentSection(Result+IntToStr(i)) do inc(i);
463     Result:=Result+IntToStr(i);
464   end;
465 end;
466 
467 procedure TMakeResStrDialog.SetSource(NewCode: TCodeBuffer; const NewStartPos,
468   NewEndPos: TPoint);
469 begin
470   Code:=NewCode;
471   StartPos:=NewStartPos;
472   EndPos:=NewEndPos;
473 end;
474 
ResStrExistsInCurrentSectionnull475 function TMakeResStrDialog.ResStrExistsInCurrentSection(const Identifier: string
476   ): boolean;
477 var
478   CodeXY: PCodeXYPosition;
479   Index: Integer;
480 begin
481   Result:=false;
482   Index:=ResStrSectionComboBox.ItemIndex;
483   if (Index<0) or (Index>=Positions.Count) then exit;
484   CodeXY:=Positions.Items[Index];
485   Result:=CodeToolBoss.IdentifierExistsInResourceStringSection(
486                                 CodeXY^.Code,CodeXY^.X,CodeXY^.Y,Identifier);
487 end;
488 
TMakeResStrDialog.ResStrExistsInAnySectionnull489 function TMakeResStrDialog.ResStrExistsInAnySection(const Identifier: string
490   ): boolean;
491 var
492   CodeXY: PCodeXYPosition;
493   Index: Integer;
494 begin
495   Result:=false;
496   for Index:=0 to Positions.Count-1 do begin
497     CodeXY:=Positions.Items[Index];
498     Result:=CodeToolBoss.IdentifierExistsInResourceStringSection(
499                                    CodeXY^.Code,CodeXY^.X,CodeXY^.Y,Identifier);
500     if Result then exit;
501   end;
502 end;
503 
ResStrExistsWithSameValuenull504 function TMakeResStrDialog.ResStrExistsWithSameValue(const Identifier: string
505   ): boolean;
506 var
507   i: Integer;
508 begin
509   if Identifier<>'' then begin
510     for i:=0 to ResStrWithSameValuesCombobox.Items.Count-1 do begin
511       if CompareText(Identifier,ResStrWithSameValuesCombobox.Items[i])=0
512       then begin
513         Result:=true;
514         exit;
515       end;
516     end;
517   end;
518   Result:=false;
519 end;
520 
521 procedure TMakeResStrDialog.GetNewSource(out NewSource,
522   ResourceStringValue: string);
523 var
524   FormatStringConstant: string;
525   FormatParameters: string;
526   LeftSide: String;
527   LastLine: string;
528   NewString: String;
529   RightSide: String;
530   StartInStringConst, EndInStringConst: boolean;
531 begin
532   NewSource:='';
533   ResourceStringValue:='';
534   if not CodeToolBoss.StringConstToFormatString(Code,StartPos.X,StartPos.Y,
535      Code,EndPos.X,EndPos.Y,FormatStringConstant,FormatParameters,
536      StartInStringConst,EndInStringConst)
537   then begin
538     SrcPreviewSynEdit.Text:=lisCCOErrorCaption+':'#13+CodeToolBoss.ErrorMessage;
539     exit;
540   end;
541   if FormatParameters='' then
542     NewString:=GetIdentifier
543   else
544     NewString:='Format('+GetIdentifier+',['+FormatParameters+'])';
545   if StartInStringConst then
546     NewString:='''+'+NewString;
547   if EndInStringConst then
548     NewString:=NewString+'+''';
549   LeftSide:=copy(StringConstSynEdit.Lines[0],1,StartPos.X-1);
550   LastLine:=StringConstSynEdit.Lines[EndPos.Y-StartPos.Y];
551   RightSide:=copy(LastLine,EndPos.X,length(LastLine)-EndPos.X+1);
552 
553   NewSource:=LeftSide+NewString+RightSide;
554   with CodeToolBoss.SourceChangeCache.BeautifyCodeOptions do
555     NewSource:=BeautifyStatement(NewSource,0);
556 
557   ResourceStringValue:=FormatStringConstant;
558 end;
559 
560 procedure TMakeResStrDialog.Init;
561 var
562   InsertPolicy: TResourcestringInsertPolicy;
563 begin
564   // string constant
565   StringConstSynEdit.Text:=Code.GetLines(StartPos.Y,EndPos.Y);
566   // reachable resourcestring sections
567   FillResourceStringSections(Positions);
568   // identifier prefixes
569   FillIdentPrefixes;
570   // identifier lengths
571   FillIdentLengths;
572   // existing resource strings with same value
573   FillStringsWithSameValue;
574   // identifier
575   CustomIdentifierCheckBox.Checked:=false;
576   CodeToolBoss.CreateIdentifierFromStringConst(Code,StartPos.X,StartPos.Y,
577      Code,EndPos.X,EndPos.Y,DefaultIdentifier,50);
578   UpdateIdentifier;
579   // insert policy
580   InsertPolicy:=MiscellaneousOptions.MakeResourceStringInsertPolicy;
581   case InsertPolicy of
582   rsipAlphabetically: InsertAlphabeticallyResStrRadioButton.Checked:=true;
583   rsipContext:        InsertContextSensitiveRadioButton.Checked:=true;
584   else                AppendResStrRadioButton.Checked:=true;
585   end;
586   // show new source
587   UpdateSourcePreview;
588 end;
589 
590 procedure TMakeResStrDialog.SaveHistories;
591 begin
592   SaveIdentPrefixes;
593   SaveIdentLengths;
594 end;
595 
596 procedure TMakeResStrDialog.SaveIdentPrefixes;
597 var
598   HistoryList: THistoryList;
599 begin
600   if CustomIdentifierCheckBox.Checked
601   or (IdentPrefixComboBox.Text='') then
602     exit;
603   HistoryList:=
604     InputHistories.HistoryLists.GetList(hlMakeResourceStringPrefixes,true,rltCaseSensitive);
605   if HistoryList.Count=0 then
606     HistoryList.Assign(IdentPrefixComboBox.Items);
607   HistoryList.Push(IdentPrefixComboBox.Text);
608 end;
609 
610 procedure TMakeResStrDialog.SaveIdentLengths;
611 var
612   HistoryList: THistoryList;
613 begin
614   if CustomIdentifierCheckBox.Checked
615   or (IdentLengthComboBox.Text='') then
616     exit;
617   HistoryList:=
618     InputHistories.HistoryLists.GetList(hlMakeResourceStringLengths,true,rltCaseSensitive);
619   if HistoryList.Count=0 then
620     HistoryList.Assign(IdentLengthComboBox.Items);
621   HistoryList.Push(IdentLengthComboBox.Text);
622 end;
623 
624 procedure TMakeResStrDialog.Save;
625 var
626   InsertPolicy: TResourcestringInsertPolicy;
627 begin
628   SaveHistories;
629   if InsertContextSensitiveRadioButton.Checked then
630     InsertPolicy:=rsipContext
631   else if InsertAlphabeticallyResStrRadioButton.Checked then
632     InsertPolicy:=rsipAlphabetically
633   else
634     InsertPolicy:=rsipAppend;
635   MiscellaneousOptions.MakeResourceStringInsertPolicy:=InsertPolicy;
636   MiscellaneousOptions.Save;
637 end;
638 
639 end.
640 
641