tab completion is now case sensitive

git-svn-id: trunk@5039 -
This commit is contained in:
mattias 2004-01-10 01:31:13 +00:00
parent e6a056de16
commit 2926828c97
2 changed files with 6 additions and 12 deletions

View File

@ -2340,7 +2340,7 @@ begin
ctWordCompletion: ctWordCompletion:
begin begin
aWordCompletion.CompletePrefix(OldPrefix,NewPrefix,false); aWordCompletion.CompletePrefix(OldPrefix,NewPrefix);
end; end;
end; end;

View File

@ -47,8 +47,7 @@ type
read GetWordBufferCapacity write SetWordBufferCapacity; read GetWordBufferCapacity write SetWordBufferCapacity;
procedure GetWordList(AWordList:TStrings; const Prefix:String; procedure GetWordList(AWordList:TStrings; const Prefix:String;
CaseSensitive:boolean; MaxResults:integer); CaseSensitive:boolean; MaxResults:integer);
procedure CompletePrefix(const Prefix: string; var CompletedPrefix: string; procedure CompletePrefix(const Prefix: string; var CompletedPrefix: string);
CaseSensitive:boolean);
public public
property OnGetSource:TWordCompletionGetSource property OnGetSource:TWordCompletionGetSource
read FOnGetSource write FOnGetSource; read FOnGetSource write FOnGetSource;
@ -198,7 +197,7 @@ begin
end; end;
procedure TWordCompletion.CompletePrefix(const Prefix: string; procedure TWordCompletion.CompletePrefix(const Prefix: string;
var CompletedPrefix: string; CaseSensitive: boolean); var CompletedPrefix: string);
var var
WordList: TStringList; WordList: TStringList;
s: string; s: string;
@ -210,7 +209,7 @@ begin
WordList:=TStringList.Create; WordList:=TStringList.Create;
try try
// fetch all words with Prefix // fetch all words with Prefix
GetWordList(WordList,Prefix,CaseSensitive,10000); GetWordList(WordList,Prefix,true,10000);
if WordList.Count=0 then exit; if WordList.Count=0 then exit;
// find the biggest prefix of all available words // find the biggest prefix of all available words
CompletedPrefix:=WordList[0]; CompletedPrefix:=WordList[0];
@ -224,13 +223,8 @@ begin
MaxPos:=length(s); MaxPos:=length(s);
if MaxPos>length(CompletedPrefix) then MaxPos:=length(CompletedPrefix); if MaxPos>length(CompletedPrefix) then MaxPos:=length(CompletedPrefix);
while (SamePos<MaxPos) do begin while (SamePos<MaxPos) do begin
if CaseSensitive then begin
if s[SamePos+1]<>CompletedPrefix[SamePos+1] then if s[SamePos+1]<>CompletedPrefix[SamePos+1] then
break; break;
end else begin
if upcase(s[SamePos+1])<>upcase(CompletedPrefix[SamePos+1]) then
break;
end;
inc(SamePos); inc(SamePos);
end; end;
if SamePos<length(Prefix) then continue; if SamePos<length(Prefix) then continue;