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