mirror of https://gitlab.com/basile.b/dexed.git
disable empty searches
This commit is contained in:
parent
0682122b3f
commit
9a9f2d817d
|
|
@ -6,7 +6,7 @@ interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
|
|
||||||
Classes, SysUtils,
|
Classes, SysUtils, strutils,
|
||||||
{$IFDEF WINDOWS}
|
{$IFDEF WINDOWS}
|
||||||
Windows, JwaTlHelp32,
|
Windows, JwaTlHelp32,
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
|
|
@ -15,7 +15,7 @@ uses
|
||||||
{$IFNDEF CEBUILD}
|
{$IFNDEF CEBUILD}
|
||||||
forms,
|
forms,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
process, asyncprocess;
|
process, asyncprocess, fgl;
|
||||||
|
|
||||||
const
|
const
|
||||||
exeExt = {$IFDEF WINDOWS} '.exe' {$ELSE} '' {$ENDIF};
|
exeExt = {$IFDEF WINDOWS} '.exe' {$ELSE} '' {$ENDIF};
|
||||||
|
|
@ -25,6 +25,8 @@ const
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
|
TIntByString = class(specialize TFPGMap<string, integer>);
|
||||||
|
|
||||||
TCECompiler = (dmd, gdc, ldc);
|
TCECompiler = (dmd, gdc, ldc);
|
||||||
|
|
||||||
// aliased to get a custom prop inspector
|
// aliased to get a custom prop inspector
|
||||||
|
|
@ -48,6 +50,7 @@ type
|
||||||
TStringHelper = type helper for string
|
TStringHelper = type helper for string
|
||||||
function isEmpty: boolean;
|
function isEmpty: boolean;
|
||||||
function isNotEmpty: boolean;
|
function isNotEmpty: boolean;
|
||||||
|
function isBlank: boolean;
|
||||||
function extractFileName: string;
|
function extractFileName: string;
|
||||||
function extractFileExt: string;
|
function extractFileExt: string;
|
||||||
function extractFilePath: string;
|
function extractFilePath: string;
|
||||||
|
|
@ -260,6 +263,11 @@ type
|
||||||
*)
|
*)
|
||||||
procedure deleteDups(str: TStrings);
|
procedure deleteDups(str: TStrings);
|
||||||
|
|
||||||
|
(**
|
||||||
|
* Indicates wether str is only made of blank characters
|
||||||
|
*)
|
||||||
|
function isBlank(const str: string): boolean;
|
||||||
|
|
||||||
var
|
var
|
||||||
// supplementatl directories to find background tools
|
// supplementatl directories to find background tools
|
||||||
additionalPath: string;
|
additionalPath: string;
|
||||||
|
|
@ -313,6 +321,11 @@ begin
|
||||||
exit(self <> '');
|
exit(self <> '');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TStringHelper.isBlank: boolean;
|
||||||
|
begin
|
||||||
|
exit(ce_common.isBlank(self));
|
||||||
|
end;
|
||||||
|
|
||||||
function TStringHelper.extractFileName: string;
|
function TStringHelper.extractFileName: string;
|
||||||
begin
|
begin
|
||||||
exit(sysutils.extractFileName(self));
|
exit(sysutils.extractFileName(self));
|
||||||
|
|
@ -1137,6 +1150,16 @@ begin
|
||||||
{$POP}
|
{$POP}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function isBlank(const str: string): boolean;
|
||||||
|
var
|
||||||
|
c: char;
|
||||||
|
begin
|
||||||
|
result := true;
|
||||||
|
for c in str do
|
||||||
|
if not (c in [#9, ' ']) then
|
||||||
|
exit(false);
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
registerClasses([TCEPersistentShortcut]);
|
registerClasses([TCEPersistentShortcut]);
|
||||||
end.
|
end.
|
||||||
|
|
|
||||||
|
|
@ -335,9 +335,6 @@ begin
|
||||||
search.Whole := ssoWholeWord in options;
|
search.Whole := ssoWholeWord in options;
|
||||||
search.RegularExpressions:= ssoRegExpr in options;
|
search.RegularExpressions:= ssoRegExpr in options;
|
||||||
search.Pattern:=fToFind;
|
search.Pattern:=fToFind;
|
||||||
|
|
||||||
// search.IdentChars:= [];
|
|
||||||
|
|
||||||
start := Point(1,1);
|
start := Point(1,1);
|
||||||
stop := Point(high(integer), lines.Count);
|
stop := Point(high(integer), lines.Count);
|
||||||
while search.FindNextOne(lines, start, stop, startf, stopf) do
|
while search.FindNextOne(lines, start, stop, startf, stopf) do
|
||||||
|
|
@ -348,7 +345,8 @@ begin
|
||||||
start := stopf;
|
start := stopf;
|
||||||
end;
|
end;
|
||||||
msgs := getMessageDisplay;
|
msgs := getMessageDisplay;
|
||||||
msg := format('%d result(s) for the pattern <%s>', [length(res), fToFind]);
|
msg := format('%d result(s) for the pattern <%s> in %s',
|
||||||
|
[length(res), fToFind, filename]);
|
||||||
msgs.message(msg, nil, amcMisc, amkInf);
|
msgs.message(msg, nil, amcMisc, amkInf);
|
||||||
fmt := fileName + '(%d,%d): "%s"';
|
fmt := fileName + '(%d,%d): "%s"';
|
||||||
for i := 0 to high(res) do
|
for i := 0 to high(res) do
|
||||||
|
|
@ -556,14 +554,16 @@ end;
|
||||||
procedure TCESearchWidget.updateImperative;
|
procedure TCESearchWidget.updateImperative;
|
||||||
var
|
var
|
||||||
canAll: boolean;
|
canAll: boolean;
|
||||||
|
hasTxt: boolean;
|
||||||
begin
|
begin
|
||||||
canAll := (fDoc.isNotNil and not fAllInProj) or (fAllInProj and (fProj <> nil));
|
canAll := ((fDoc.isNotNil and not fAllInProj) or (fAllInProj and (fProj <> nil)));
|
||||||
btnFind.Enabled := fDoc.isNotNil and fToFind.isNotEmpty;
|
hasTxt := fToFind.isNotEmpty and not fToFind.isBlank;
|
||||||
btnFindAll.Enabled := canAll;
|
btnFind.Enabled := fDoc.isNotNil and hasTxt;
|
||||||
|
btnFindAll.Enabled := canAll and hasTxt;
|
||||||
btnReplace.Enabled := fDoc.isNotNil and chkEnableRep.Checked and fToFind.isNotEmpty;
|
btnReplace.Enabled := fDoc.isNotNil and chkEnableRep.Checked and fToFind.isNotEmpty;
|
||||||
btnReplaceAll.Enabled := btnReplace.Enabled;
|
btnReplaceAll.Enabled := btnReplace.Enabled;
|
||||||
cbReplaceWth.Enabled := fDoc.isNotNil and chkEnableRep.Checked;
|
cbReplaceWth.Enabled := fDoc.isNotNil and chkEnableRep.Checked;
|
||||||
cbToFind.Enabled := canAll;
|
cbToFind.Enabled := canAll or fDoc.isNotNil;
|
||||||
end;
|
end;
|
||||||
{$ENDREGION}
|
{$ENDREGION}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue