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