mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Rename 'memoeditor' to 'texteditor', in preparation for inclusion of a binary editor.
This commit is contained in:
@ -103,10 +103,10 @@ const
|
|||||||
REGNAME_DBTREEWIDTH = 'dbtreewidth';
|
REGNAME_DBTREEWIDTH = 'dbtreewidth';
|
||||||
REGNAME_SQLOUTHEIGHT = 'sqloutheight';
|
REGNAME_SQLOUTHEIGHT = 'sqloutheight';
|
||||||
REGNAME_QUERYHELPERSWIDTH = 'queryhelperswidth';
|
REGNAME_QUERYHELPERSWIDTH = 'queryhelperswidth';
|
||||||
REGNAME_MEMOEDITOR_WIDTH = 'MemoEditorWidth';
|
REGNAME_EDITOR_WIDTH = 'MemoEditorWidth';
|
||||||
DEFAULT_MEMOEDITOR_WIDTH = 100;
|
DEFAULT_EDITOR_WIDTH = 100;
|
||||||
REGNAME_MEMOEDITOR_HEIGHT = 'MemoEditorHeight';
|
REGNAME_EDITOR_HEIGHT = 'MemoEditorHeight';
|
||||||
DEFAULT_MEMOEDITOR_HEIGHT = 100;
|
DEFAULT_EDITOR_HEIGHT = 100;
|
||||||
REGNAME_SQLWHEREFILE = 'SQLWhereFile';
|
REGNAME_SQLWHEREFILE = 'SQLWhereFile';
|
||||||
REGNAME_DELIMITER = 'Delimiter';
|
REGNAME_DELIMITER = 'Delimiter';
|
||||||
DEFAULT_DELIMITER = ';';
|
DEFAULT_DELIMITER = ';';
|
||||||
|
@ -38,7 +38,7 @@ uses
|
|||||||
editvar in '..\..\source\editvar.pas' {frmEditVariable},
|
editvar in '..\..\source\editvar.pas' {frmEditVariable},
|
||||||
view in '..\..\source\view.pas' {frmView},
|
view in '..\..\source\view.pas' {frmView},
|
||||||
selectdbobject in '..\..\source\selectdbobject.pas' {frmSelectDBObject},
|
selectdbobject in '..\..\source\selectdbobject.pas' {frmSelectDBObject},
|
||||||
memoeditor in '..\..\source\memoeditor.pas' {frmMemoEditor},
|
texteditor in '..\..\source\texteditor.pas' {frmTextEditor},
|
||||||
grideditlinks in '..\..\source\grideditlinks.pas',
|
grideditlinks in '..\..\source\grideditlinks.pas',
|
||||||
uVistaFuncs in '..\..\source\uVistaFuncs.pas';
|
uVistaFuncs in '..\..\source\uVistaFuncs.pas';
|
||||||
|
|
||||||
|
@ -4,13 +4,13 @@ unit grideditlinks;
|
|||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses Windows, Graphics, messages, VirtualTrees, memoeditor, ComCtrls, SysUtils, Classes,
|
uses Windows, Forms, Graphics, messages, VirtualTrees, texteditor, ComCtrls, SysUtils, Classes,
|
||||||
mysql_structures, Main, TntStdCtrls, WideStrings, StdCtrls;
|
mysql_structures, Main, helpers, TntStdCtrls, WideStrings, StdCtrls;
|
||||||
|
|
||||||
type
|
type
|
||||||
TMemoEditorLink = class(TInterfacedObject, IVTEditLink)
|
TMemoEditorLink = class(TInterfacedObject, IVTEditLink)
|
||||||
private
|
private
|
||||||
FForm: TfrmMemoEditor;
|
FForm: TMemoEditor;
|
||||||
FTree: TCustomVirtualStringTree; // A back reference to the tree calling.
|
FTree: TCustomVirtualStringTree; // A back reference to the tree calling.
|
||||||
FNode: PVirtualNode; // The node to be edited.
|
FNode: PVirtualNode; // The node to be edited.
|
||||||
FColumn: TColumnIndex; // The column of the node.
|
FColumn: TColumnIndex; // The column of the node.
|
||||||
@ -82,12 +82,13 @@ implementation
|
|||||||
constructor TMemoEditorLink.Create;
|
constructor TMemoEditorLink.Create;
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
|
FForm := nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TMemoEditorLink.Destroy;
|
destructor TMemoEditorLink.Destroy;
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
FForm.Free;
|
FreeAndNil(FForm);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -113,11 +114,10 @@ begin
|
|||||||
Text := FTree.Text[FNode, FColumn];
|
Text := FTree.Text[FNode, FColumn];
|
||||||
|
|
||||||
// Create the editor form
|
// Create the editor form
|
||||||
FForm := TfrmMemoEditor.Create(Ftree);
|
FForm := TfrmTextEditor.Create(Ftree);
|
||||||
FForm.memoText.Font := F;
|
FForm.SetFont(F);
|
||||||
// TODO: The Text property is ANSI.
|
FForm.SetText(Text);
|
||||||
FForm.memoText.Text := Text;
|
FForm.SetMaxLength(MaxLength);
|
||||||
FForm.memoText.MaxLength := MaxLength;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -146,8 +146,8 @@ begin
|
|||||||
Result := not FStopping;
|
Result := not FStopping;
|
||||||
if Result then try
|
if Result then try
|
||||||
FStopping := True;
|
FStopping := True;
|
||||||
if FForm.memoText.Text <> FTree.Text[FNode, FColumn] then
|
if FForm.GetText <> FTree.Text[FNode, FColumn] then
|
||||||
FTree.Text[FNode, FColumn] := FForm.memoText.Text;
|
FTree.Text[FNode, FColumn] := FForm.GetText;
|
||||||
FForm.Hide;
|
FForm.Hide;
|
||||||
FTree.SetFocus;
|
FTree.SetFocus;
|
||||||
except
|
except
|
||||||
|
@ -72,6 +72,14 @@ type
|
|||||||
Columns: TGridColumns;
|
Columns: TGridColumns;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
TMemoEditor = class(TForm)
|
||||||
|
public
|
||||||
|
function GetText: WideString; virtual; abstract;
|
||||||
|
procedure SetText(text: WideString); virtual; abstract;
|
||||||
|
procedure SetMaxLength(len: integer); virtual; abstract;
|
||||||
|
procedure SetFont(font: TFont); virtual; abstract;
|
||||||
|
end;
|
||||||
|
|
||||||
{$I const.inc}
|
{$I const.inc}
|
||||||
|
|
||||||
function implodestr(seperator: WideString; a: TWideStringList) :WideString;
|
function implodestr(seperator: WideString; a: TWideStringList) :WideString;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
object frmMemoEditor: TfrmMemoEditor
|
object frmTextEditor: TfrmTextEditor
|
||||||
Left = 0
|
Left = 0
|
||||||
Top = 0
|
Top = 0
|
||||||
BorderStyle = bsSizeToolWin
|
BorderStyle = bsSizeToolWin
|
@ -1,15 +1,15 @@
|
|||||||
unit memoeditor;
|
unit texteditor;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Windows, Classes, Graphics, Controls, Forms, StdCtrls, TntStdCtrls, Registry, VirtualTrees,
|
Windows, Classes, Graphics, Forms, Controls, helpers, StdCtrls, TntStdCtrls, Registry, VirtualTrees,
|
||||||
ComCtrls, ToolWin, Dialogs;
|
ComCtrls, ToolWin, Dialogs;
|
||||||
|
|
||||||
{$I const.inc}
|
{$I const.inc}
|
||||||
|
|
||||||
type
|
type
|
||||||
TfrmMemoEditor = class(TForm)
|
TfrmTextEditor = class(TMemoEditor)
|
||||||
memoText: TTntMemo;
|
memoText: TTntMemo;
|
||||||
tlbStandard: TToolBar;
|
tlbStandard: TToolBar;
|
||||||
btnWrap: TToolButton;
|
btnWrap: TToolButton;
|
||||||
@ -33,42 +33,66 @@ type
|
|||||||
procedure SetModified(NewVal: Boolean);
|
procedure SetModified(NewVal: Boolean);
|
||||||
property Modified: Boolean read FModified write SetModified;
|
property Modified: Boolean read FModified write SetModified;
|
||||||
public
|
public
|
||||||
{ Public declarations }
|
function GetText: WideString; override;
|
||||||
|
procedure SetText(text: WideString); override;
|
||||||
|
procedure SetMaxLength(len: integer); override;
|
||||||
|
procedure SetFont(font: TFont); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses main, helpers;
|
uses main;
|
||||||
|
|
||||||
{$R *.dfm}
|
{$R *.dfm}
|
||||||
|
|
||||||
|
|
||||||
procedure TfrmMemoEditor.FormCreate(Sender: TObject);
|
function TfrmTextEditor.GetText: WideString;
|
||||||
|
begin
|
||||||
|
Result := memoText.Text;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmTextEditor.SetText(text: WideString);
|
||||||
|
begin
|
||||||
|
// TODO: Text property is ANSI !!!
|
||||||
|
memoText.Text := text;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmTextEditor.SetMaxLength(len: integer);
|
||||||
|
begin
|
||||||
|
memoText.MaxLength := len;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmTextEditor.SetFont(font: TFont);
|
||||||
|
begin
|
||||||
|
memoText.Font := font;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmTextEditor.FormCreate(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
InheritFont(Font);
|
InheritFont(Font);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TfrmMemoEditor.FormDestroy(Sender: TObject);
|
procedure TfrmTextEditor.FormDestroy(Sender: TObject);
|
||||||
var
|
var
|
||||||
reg: TRegistry;
|
reg: TRegistry;
|
||||||
begin
|
begin
|
||||||
reg := TRegistry.Create;
|
reg := TRegistry.Create;
|
||||||
if reg.OpenKey(REGPATH, False) then begin
|
if reg.OpenKey(REGPATH, False) then begin
|
||||||
reg.WriteInteger( REGNAME_MEMOEDITOR_WIDTH, Width );
|
reg.WriteInteger( REGNAME_EDITOR_WIDTH, Width );
|
||||||
reg.WriteInteger( REGNAME_MEMOEDITOR_HEIGHT, Height );
|
reg.WriteInteger( REGNAME_EDITOR_HEIGHT, Height );
|
||||||
reg.CloseKey;
|
reg.CloseKey;
|
||||||
end;
|
end;
|
||||||
reg.Free;
|
reg.Free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TfrmMemoEditor.FormShow(Sender: TObject);
|
procedure TfrmTextEditor.FormShow(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
// Restore form dimensions
|
// Restore form dimensions
|
||||||
Width := Mainform.GetRegValue(REGNAME_MEMOEDITOR_WIDTH, DEFAULT_MEMOEDITOR_WIDTH);
|
Width := Mainform.GetRegValue(REGNAME_EDITOR_WIDTH, DEFAULT_EDITOR_WIDTH);
|
||||||
Height := Mainform.GetRegValue(REGNAME_MEMOEDITOR_HEIGHT, DEFAULT_MEMOEDITOR_HEIGHT);
|
Height := Mainform.GetRegValue(REGNAME_EDITOR_HEIGHT, DEFAULT_EDITOR_HEIGHT);
|
||||||
// Fix label position:
|
// Fix label position:
|
||||||
lblTextLength.Top := tlbStandard.Top + (tlbStandard.Height-lblTextLength.Height) div 2;
|
lblTextLength.Top := tlbStandard.Top + (tlbStandard.Height-lblTextLength.Height) div 2;
|
||||||
SetWindowSizeGrip(Handle, True);
|
SetWindowSizeGrip(Handle, True);
|
||||||
@ -79,7 +103,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TfrmMemoEditor.memoTextKeyDown(Sender: TObject; var Key: Word; Shift:
|
procedure TfrmTextEditor.memoTextKeyDown(Sender: TObject; var Key: Word; Shift:
|
||||||
TShiftState);
|
TShiftState);
|
||||||
begin
|
begin
|
||||||
case Key of
|
case Key of
|
||||||
@ -90,7 +114,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmMemoEditor.btnWrapClick(Sender: TObject);
|
procedure TfrmTextEditor.btnWrapClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
WasModified: Boolean;
|
WasModified: Boolean;
|
||||||
begin
|
begin
|
||||||
@ -107,7 +131,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TfrmMemoEditor.btnLoadTextClick(Sender: TObject);
|
procedure TfrmTextEditor.btnLoadTextClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
d: TOpenDialog;
|
d: TOpenDialog;
|
||||||
begin
|
begin
|
||||||
@ -126,7 +150,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TfrmMemoEditor.btnCancelClick(Sender: TObject);
|
procedure TfrmTextEditor.btnCancelClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
DoPost: Boolean;
|
DoPost: Boolean;
|
||||||
begin
|
begin
|
||||||
@ -141,20 +165,20 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TfrmMemoEditor.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
procedure TfrmTextEditor.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
||||||
begin
|
begin
|
||||||
btnCancelClick(Sender);
|
btnCancelClick(Sender);
|
||||||
CanClose := False; // Done by editor link
|
CanClose := False; // Done by editor link
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TfrmMemoEditor.btnApplyClick(Sender: TObject);
|
procedure TfrmTextEditor.btnApplyClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
TCustomVirtualStringTree(Owner).EndEditNode;
|
TCustomVirtualStringTree(Owner).EndEditNode;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TfrmMemoEditor.memoTextChange(Sender: TObject);
|
procedure TfrmTextEditor.memoTextChange(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
lblTextLength.Caption := FormatNumber(Length(memoText.Text)) + ' characters.';
|
lblTextLength.Caption := FormatNumber(Length(memoText.Text)) + ' characters.';
|
||||||
if memoText.MaxLength > 0 then
|
if memoText.MaxLength > 0 then
|
||||||
@ -163,7 +187,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TfrmMemoEditor.SetModified(NewVal: Boolean);
|
procedure TfrmTextEditor.SetModified(NewVal: Boolean);
|
||||||
begin
|
begin
|
||||||
if FModified <> NewVal then begin
|
if FModified <> NewVal then begin
|
||||||
FModified := NewVal;
|
FModified := NewVal;
|
Reference in New Issue
Block a user