mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD: Also save search text options (CaseSens, RegExpr)
This commit is contained in:
parent
34875e54ef
commit
5086aa48b4
6 changed files with 57 additions and 13 deletions
|
|
@ -271,6 +271,7 @@ type
|
|||
procedure ZVTimeFromChange(Sender: TObject);
|
||||
procedure ZVTimeToChange(Sender: TObject);
|
||||
procedure PopupMenuFindPopup(Sender: TObject);
|
||||
function GetTextSearchOptions: UIntPtr;
|
||||
procedure CancelCloseAndFreeMem;
|
||||
procedure LoadHistory;
|
||||
procedure SaveHistory;
|
||||
|
|
@ -832,7 +833,7 @@ begin
|
|||
begin
|
||||
if glsSearchHistory.Count > 0 then
|
||||
cmbFindText.Text := glsSearchHistory[0];
|
||||
end;
|
||||
end;
|
||||
|
||||
cmbSearchDepth.ItemIndex := 0;
|
||||
cmbExcludeFiles.Text := '';
|
||||
|
|
@ -2064,7 +2065,7 @@ begin
|
|||
// 4. Add to search text history
|
||||
if cbFindText.Checked then
|
||||
begin
|
||||
InsertFirstItem(cmbFindText.Text, cmbFindText);
|
||||
InsertFirstItem(cmbFindText.Text, cmbFindText, GetTextSearchOptions);
|
||||
// Update search history, so it can be used in
|
||||
// Viewer/Editor opened from find files dialog
|
||||
gFirstTextSearch := False;
|
||||
|
|
@ -2652,6 +2653,17 @@ begin
|
|||
SelectTemplate(FLastTemplateName);
|
||||
end;
|
||||
|
||||
function TfrmFindDlg.GetTextSearchOptions: UIntPtr;
|
||||
var
|
||||
Options: TTextSearchOptions absolute Result;
|
||||
begin
|
||||
Result:= 0;
|
||||
if cbCaseSens.Checked then
|
||||
Include(Options, tsoMatchCase);
|
||||
if cbTextRegExp.Checked then
|
||||
Include(Options, tsoRegExpr);
|
||||
end;
|
||||
|
||||
procedure TfrmFindDlg.CancelCloseAndFreeMem;
|
||||
begin
|
||||
cm_FreeFromMem([]);
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ type
|
|||
procedure cbDataToFindKeyUp(Sender: TObject; var Key: Word;
|
||||
Shift: TShiftState);
|
||||
private
|
||||
{ Private declarations }
|
||||
function GetTextSearchOptions: UIntPtr;
|
||||
public
|
||||
{ Public declarations }
|
||||
end;
|
||||
|
|
@ -48,7 +48,7 @@ implementation
|
|||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
LCLProc, LCLType, uDCUtils;
|
||||
LCLProc, LCLType, uFindFiles, uDCUtils;
|
||||
|
||||
procedure TfrmFindView.FormShow(Sender: TObject);
|
||||
begin
|
||||
|
|
@ -74,7 +74,7 @@ end;
|
|||
|
||||
procedure TfrmFindView.btnFindClick(Sender: TObject);
|
||||
begin
|
||||
InsertFirstItem(cbDataToFind.Text, cbDataToFind);
|
||||
InsertFirstItem(cbDataToFind.Text, cbDataToFind, GetTextSearchOptions);
|
||||
ModalResult:= mrOk;
|
||||
end;
|
||||
|
||||
|
|
@ -96,4 +96,15 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
function TfrmFindView.GetTextSearchOptions: UIntPtr;
|
||||
var
|
||||
Options: TTextSearchOptions absolute Result;
|
||||
begin
|
||||
Result:= 0;
|
||||
if cbCaseSens.Checked then
|
||||
Include(Options, tsoMatchCase);
|
||||
if cbRegExp.Checked then
|
||||
Include(Options, tsoRegExpr);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
|
|
|||
|
|
@ -450,7 +450,7 @@ uses
|
|||
FileUtil, IntfGraphics, Math, uLng, uShowMsg, uGlobs, LCLType, LConvEncoding,
|
||||
DCClassesUtf8, uFindMmap, DCStrUtils, uDCUtils, LCLIntf, uDebug, uHotkeyManager,
|
||||
uConvEncoding, DCBasicTypes, DCOSUtils, uOSUtils, uFindByrMr, uFileViewWithGrid,
|
||||
fPrintSetup;
|
||||
fPrintSetup, uFindFiles;
|
||||
|
||||
const
|
||||
HotkeysCategory = 'Viewer';
|
||||
|
|
@ -2272,6 +2272,7 @@ var
|
|||
sSearchTextA: AnsiString;
|
||||
iSearchParameter: Integer;
|
||||
RecodeTable: TRecodeTable;
|
||||
Options: TTextSearchOptions;
|
||||
begin
|
||||
// in first use create dialog
|
||||
if not Assigned(FFindDialog) then
|
||||
|
|
@ -2286,6 +2287,16 @@ begin
|
|||
if FWlxModule.CallListSearchDialog(0) = LISTPLUGIN_OK then
|
||||
Exit;
|
||||
end;
|
||||
|
||||
if glsSearchHistory.Count > 0 then
|
||||
begin
|
||||
Options:= TTextSearchOptions(UInt32(UIntPtr(glsSearchHistory.Objects[0])));
|
||||
if (tsoMatchCase in Options) then
|
||||
FFindDialog.cbCaseSens.Checked:= True;
|
||||
if (tsoRegExpr in Options) then
|
||||
FFindDialog.cbRegExp.Checked:= True;
|
||||
end;
|
||||
|
||||
FFindDialog.chkHex.Visible:= not bPlugin;
|
||||
FFindDialog.cbRegExp.Visible:= (not bPlugin) and
|
||||
(ViewerControl.FileSize < High(IntPtr)) and
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ procedure SplitCmdLine(sCmdLine : String; var sCmd, sParams : String);
|
|||
{$ENDIF}
|
||||
function CompareStrings(const s1, s2: String; Natural: Boolean; Special: Boolean; CaseSensitivity: TCaseSensitivity): PtrInt;
|
||||
|
||||
procedure InsertFirstItem(sLine: String; comboBox: TCustomComboBox);
|
||||
procedure InsertFirstItem(sLine: String; comboBox: TCustomComboBox; AValue: UIntPtr = 0);
|
||||
{en
|
||||
Compares two strings taking into account the numbers or special chararcters
|
||||
}
|
||||
|
|
@ -856,7 +856,7 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
procedure InsertFirstItem(sLine: String; comboBox: TCustomComboBox);
|
||||
procedure InsertFirstItem(sLine: String; comboBox: TCustomComboBox; AValue: UIntPtr);
|
||||
var
|
||||
I: Integer = 0;
|
||||
begin
|
||||
|
|
@ -877,6 +877,7 @@ begin
|
|||
// Reset selected item (and combobox text), because Move has destroyed it.
|
||||
comboBox.ItemIndex := 0;
|
||||
end;
|
||||
Objects[0]:= TObject(AValue);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ uses
|
|||
Classes, SysUtils, DCBasicTypes, uFile;
|
||||
|
||||
type
|
||||
TTextSearchOption = (tsoMatchCase, tsoRegExpr);
|
||||
TTextSearchOptions = set of TTextSearchOption;
|
||||
TTextSearch = (tsAnsi, tsUtf8, tsUtf16le, tsUtf16be, tsOther);
|
||||
TTimeUnit = (tuSecond, tuMinute, tuHour, tuDay, tuWeek, tuMonth, tuYear);
|
||||
TFileSizeUnit = (suBytes, suKilo, suMega, suGiga, suTera);
|
||||
|
|
|
|||
|
|
@ -825,8 +825,9 @@ var
|
|||
Root: TXmlNode;
|
||||
History: TXmlConfig;
|
||||
|
||||
procedure LoadHistory(const NodeName: String; HistoryList: TStrings);
|
||||
procedure LoadHistory(const NodeName: String; HistoryList: TStrings; LoadObj: Boolean = False);
|
||||
var
|
||||
Idx: Integer;
|
||||
Node: TXmlNode;
|
||||
begin
|
||||
Node := History.FindNode(Root, NodeName);
|
||||
|
|
@ -838,7 +839,10 @@ var
|
|||
begin
|
||||
if Node.CompareName('Item') = 0 then
|
||||
begin
|
||||
HistoryList.Add(History.GetContent(Node));
|
||||
Idx:= HistoryList.Add(History.GetContent(Node));
|
||||
if LoadObj then begin
|
||||
HistoryList.Objects[Idx]:= TObject(UIntPtr(History.GetAttr(Node, 'Tag', 0)));
|
||||
end;
|
||||
if HistoryList.Count >= cMaxStringItems then Break;
|
||||
end;
|
||||
Node := Node.NextSibling;
|
||||
|
|
@ -856,7 +860,7 @@ begin
|
|||
LoadHistory('Navigation', glsDirHistory);
|
||||
LoadHistory('CommandLine', glsCmdLineHistory);
|
||||
LoadHistory('FileMask', glsMaskHistory);
|
||||
LoadHistory('SearchText', glsSearchHistory);
|
||||
LoadHistory('SearchText', glsSearchHistory, True);
|
||||
LoadHistory('SearchTextPath', glsSearchPathHistory);
|
||||
LoadHistory('ReplaceText', glsReplaceHistory);
|
||||
LoadHistory('ReplaceTextPath', glsReplacePathHistory);
|
||||
|
|
@ -875,7 +879,7 @@ var
|
|||
Root: TXmlNode;
|
||||
History: TXmlConfig;
|
||||
|
||||
procedure SaveHistory(const NodeName: String; HistoryList: TStrings);
|
||||
procedure SaveHistory(const NodeName: String; HistoryList: TStrings; SaveObj: Boolean = False);
|
||||
var
|
||||
I: Integer;
|
||||
Node, SubNode: TXmlNode;
|
||||
|
|
@ -886,6 +890,9 @@ var
|
|||
begin
|
||||
SubNode := History.AddNode(Node, 'Item');
|
||||
History.SetContent(SubNode, HistoryList[I]);
|
||||
if SaveObj then begin
|
||||
History.SetAttr(SubNode, 'Tag', UInt32(UIntPtr(HistoryList.Objects[I])));
|
||||
end;
|
||||
if I >= cMaxStringItems then Break;
|
||||
end;
|
||||
end;
|
||||
|
|
@ -899,7 +906,7 @@ begin
|
|||
if gSaveFileMaskHistory then SaveHistory('FileMask', glsMaskHistory);
|
||||
if gSaveSearchReplaceHistory then
|
||||
begin
|
||||
SaveHistory('SearchText', glsSearchHistory);
|
||||
SaveHistory('SearchText', glsSearchHistory, True);
|
||||
SaveHistory('SearchTextPath', glsSearchPathHistory);
|
||||
SaveHistory('ReplaceText', glsReplaceHistory);
|
||||
SaveHistory('ReplaceTextPath', glsReplacePathHistory);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue