mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2026-03-13 09:24:25 +08:00
* Fix hint for SQL functions menuitems which have pipes in declarations (fx TRIM).
* Fix splitting of function descriptions by implementing + using LastPos()
This commit is contained in:
@@ -10,7 +10,7 @@ interface
|
||||
|
||||
uses Classes, SysUtils, Graphics, db, clipbrd, dialogs,
|
||||
forms, controls, ShellApi, checklst, windows, ZDataset, ZAbstractDataset,
|
||||
shlobj, ActiveX;
|
||||
shlobj, ActiveX, StrUtils;
|
||||
|
||||
{$I const.inc}
|
||||
|
||||
@@ -66,6 +66,7 @@ uses Classes, SysUtils, Graphics, db, clipbrd, dialogs,
|
||||
function ConvertWindowsCodepageToMysqlCharacterSet(codepage: Cardinal): string;
|
||||
procedure AddUniqueItemsToList( ToAdd: TStrings; BaseList: TStrings );
|
||||
function GetFieldValue( Field: TField ): String;
|
||||
function LastPos( substr: WideString; str: WideString): Integer;
|
||||
|
||||
var
|
||||
MYSQL_KEYWORDS : TStringList;
|
||||
@@ -1868,6 +1869,22 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
|
||||
{**
|
||||
Get last position of substr in str
|
||||
@param string Substring
|
||||
@param string Text
|
||||
@return Integer Last position
|
||||
}
|
||||
function LastPos( substr: WideString; str: WideString): Integer;
|
||||
begin
|
||||
Result := 0;
|
||||
str := ReverseString( str );
|
||||
if Pos( substr, str ) > 0 then
|
||||
Result := Length(str) - Pos( substr, str ) + 1;
|
||||
end;
|
||||
|
||||
|
||||
initialization
|
||||
|
||||
|
||||
|
||||
@@ -525,17 +525,21 @@ begin
|
||||
FunctionDeclaration := Copy(FunctionLine, 0, Pos( ')', FunctionLine ) );
|
||||
FunctionDeclaration := Copy(FunctionDeclaration, Pos( '(', FunctionDeclaration ), Length(FunctionDeclaration) );
|
||||
|
||||
pipeposition := pos('|', FunctionLine);
|
||||
pipeposition := LastPos('|', FunctionLine);
|
||||
if pipeposition > 0 then // read hint
|
||||
begin
|
||||
FunctionDescription := copy(FunctionLine, 0, pipeposition-1) + ' - ' + copy(FunctionLine, pipeposition+1, length(FunctionLine)-1);
|
||||
FunctionDescription := copy(FunctionLine, pipeposition+1, length(FunctionLine)-1);
|
||||
FunctionDescription := trim(FunctionDescription);
|
||||
end;
|
||||
|
||||
mi := TMenuItem.Create(self);
|
||||
mi.Caption := FunctionName;
|
||||
mi.Hint := FunctionDescription;
|
||||
mi.OnClick := insertFunction;
|
||||
mi.Hint := FunctionName + FunctionDeclaration;
|
||||
if FunctionDescription <> '' then
|
||||
mi.Hint := mi.Hint + ' - ' + FunctionDescription;
|
||||
mi.Hint := Trim(mi.Hint);
|
||||
// Replace pipes as they're used to seperate ShortHint and LongHint
|
||||
mi.Hint := StringReplace( mi.Hint, '|', '<27>', [rfReplaceAll] );
|
||||
|
||||
if FunctionLine[1] <> ' ' then // build submenu
|
||||
begin
|
||||
@@ -543,7 +547,7 @@ begin
|
||||
inc(i);
|
||||
end else
|
||||
begin
|
||||
SQLfunctions.Items[i+11].OnClick := nil; // deactivate parent Menuitem
|
||||
mi.OnClick := insertFunction;
|
||||
SQLfunctions.Items[i+11].Add(mi);
|
||||
SQLFunctionNames.Add(FunctionName);
|
||||
SQLFunctionDeclarations.Add(FunctionDeclaration);
|
||||
@@ -584,6 +588,8 @@ begin
|
||||
sm := ChildWin.SynMemoQuery;
|
||||
f := TMenuItem(Sender).Hint;
|
||||
f := stringreplace(f, '&', '', [rfReplaceAll]);
|
||||
// Restore pipes as they're used to seperate ShortHint and LongHint
|
||||
f := StringReplace( f, '<27>', '|', [rfReplaceAll] );
|
||||
f := copy(f, 0, pos(')', f));
|
||||
sm.UndoList.AddGroupBreak;
|
||||
sm.SelText := f;
|
||||
|
||||
Reference in New Issue
Block a user