mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-26 03:01:07 +08:00
Implement customizing of shortcuts for all available TActions and SynEditor commands. Fixes issue #536.
This commit is contained in:
@ -85,7 +85,6 @@ begin
|
||||
|
||||
// Setup SynMemoPreview
|
||||
SynMemoPreview.Highlighter := Mainform.SynSQLSyn1;
|
||||
SynMemoPreview.Font := Mainform.SynMemoQuery.Font;
|
||||
end;
|
||||
|
||||
|
||||
@ -147,6 +146,7 @@ begin
|
||||
|
||||
// Invoke SQL preview
|
||||
Modified(Sender);
|
||||
MainForm.SetupSynEditors;
|
||||
end;
|
||||
|
||||
|
||||
|
@ -173,7 +173,7 @@ begin
|
||||
lblProgress.Caption := '';
|
||||
PageControl1.ActivePageIndex := 0;
|
||||
SynMemoExampleSQL.Highlighter := Mainform.SynSQLSyn1;
|
||||
SynMemoExampleSQL.Font := Mainform.SynMemoQuery.Font;
|
||||
MainForm.SetupSynEditors;
|
||||
|
||||
// read dbs and Tables from treeview
|
||||
comboSelectDatabase.Items.Clear;
|
||||
|
@ -191,7 +191,6 @@ type
|
||||
procedure EnableProgressBar(MaxValue: Integer);
|
||||
function CompareNumbers(List: TStringList; Index1, Index2: Integer): Integer;
|
||||
function ListIndexByRegExpr(List: TWideStrings; Expression: WideString): Integer;
|
||||
procedure RestoreSyneditStyles(Highlighter: TSynCustomHighlighter);
|
||||
procedure SelectNode(VT: TVirtualStringTree; idx: Cardinal; ParentNode: PVirtualNode=nil); overload;
|
||||
procedure SelectNode(VT: TVirtualStringTree; Node: PVirtualNode); overload;
|
||||
function DateBackFriendlyCaption(d: TDateTime): String;
|
||||
@ -2977,22 +2976,6 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure RestoreSyneditStyles(Highlighter: TSynCustomHighlighter);
|
||||
var
|
||||
i: Integer;
|
||||
Attri: TSynHighlighterAttributes;
|
||||
begin
|
||||
// Read font color, bold + italic style of SynEdit attributes from registry
|
||||
// Default colors defined and used from highlighter on main form
|
||||
for i := 0 to Highlighter.AttrCount - 1 do begin
|
||||
Attri := Highlighter.Attribute[i];
|
||||
Attri.Foreground := GetRegValue(REGPREFIX_SQLATTRI+Attri.FriendlyName+REGPOSTFIX_SQL_FG, Mainform.SynSQLSyn1.Attribute[i].Foreground);
|
||||
Attri.Background := GetRegValue(REGPREFIX_SQLATTRI+Attri.FriendlyName+REGPOSTFIX_SQL_BG, Mainform.SynSQLSyn1.Attribute[i].Background);
|
||||
Attri.IntegerStyle := GetRegValue(REGPREFIX_SQLATTRI+Attri.FriendlyName+REGPOSTFIX_SQL_STYLE, Mainform.SynSQLSyn1.Attribute[i].IntegerStyle)
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure SelectNode(VT: TVirtualStringTree; idx: Cardinal; ParentNode: PVirtualNode=nil); overload;
|
||||
var
|
||||
Node: PVirtualNode;
|
||||
|
124
source/main.pas
124
source/main.pas
@ -23,7 +23,7 @@ uses
|
||||
TntStdCtrls, Tabs, SynUnicode, mysqlconn, EditVar, helpers, queryprogress,
|
||||
mysqlquery, createdatabase, table_editor, SynRegExpr,
|
||||
WideStrUtils, ZDbcLogging, ExtActns, CommCtrl, routine_editor, options,
|
||||
Contnrs, PngSpeedButton, connections;
|
||||
Contnrs, PngSpeedButton, connections, SynEditKeyCmds, exportsql;
|
||||
|
||||
|
||||
type
|
||||
@ -834,6 +834,7 @@ type
|
||||
prefNullColorDefault,
|
||||
prefNullBG : TColor;
|
||||
CreateDatabaseForm : TCreateDatabaseForm;
|
||||
ExportSQLForm : TExportSQLForm;
|
||||
TableEditor : TfrmTableEditor;
|
||||
FDataGridSelect : WideStrings.TWideStringList;
|
||||
FDataGridSort : TOrderColArray;
|
||||
@ -916,6 +917,7 @@ type
|
||||
procedure OnMessageHandler(var Msg: TMsg; var Handled: Boolean);
|
||||
function MaskMulti(str: WideString): WideString;
|
||||
procedure SelectDBObject(Text: WideString; NodeType: TListNodeType);
|
||||
procedure SetupSynEditors;
|
||||
end;
|
||||
|
||||
|
||||
@ -951,7 +953,7 @@ const
|
||||
implementation
|
||||
|
||||
uses
|
||||
About, exportsql, loaddata, printlist, copytable, insertfiles, Threading,
|
||||
About, loaddata, printlist, copytable, insertfiles, Threading,
|
||||
mysql_structures, UpdateCheck, uVistaFuncs, runsqlfile, column_selection,
|
||||
data_sorting, grideditlinks, dataviewsave;
|
||||
|
||||
@ -1249,10 +1251,11 @@ procedure TMainForm.FormCreate(Sender: TObject);
|
||||
var
|
||||
i: Integer;
|
||||
menuitem : TMenuItem;
|
||||
fontname, datafontname : String;
|
||||
fontsize, datafontsize : Integer;
|
||||
datafontname : String;
|
||||
datafontsize : Integer;
|
||||
DisableProcessWindowsGhostingProc: procedure;
|
||||
QueryTab: TQueryTab;
|
||||
Action: TAction;
|
||||
begin
|
||||
caption := APPNAME;
|
||||
setLocales;
|
||||
@ -1355,22 +1358,6 @@ begin
|
||||
prefCSVTerminator := GetRegValue(REGNAME_CSV_TERMINATOR, DEFAULT_CSV_TERMINATOR);
|
||||
prefRememberFilters := GetRegValue(REGNAME_REMEMBERFILTERS, DEFAULT_REMEMBERFILTERS);
|
||||
|
||||
// SQL-Font:
|
||||
fontname := GetRegValue(REGNAME_FONTNAME, DEFAULT_FONTNAME);
|
||||
fontsize := GetRegValue(REGNAME_FONTSIZE, DEFAULT_FONTSIZE);
|
||||
SynMemoQuery.Font.Name := fontname;
|
||||
SynMemoQuery.Font.Size := fontsize;
|
||||
SynMemoQuery.Gutter.Font.Name := fontname;
|
||||
SynMemoQuery.Gutter.Font.Size := fontsize;
|
||||
SynMemoFilter.Font.Name := fontname;
|
||||
SynMemoFilter.Font.Size := fontsize;
|
||||
SynMemoSQLLog.Font.Name := fontname;
|
||||
SynMemoSQLLog.Font.Size := fontsize;
|
||||
SynMemoSQLLog.Gutter.Font.Name := fontname;
|
||||
SynMemoSQLLog.Gutter.Font.Size := fontsize;
|
||||
SynMemoProcessView.Font.Name := fontname;
|
||||
SynMemoProcessView.Font.Size := fontsize;
|
||||
|
||||
// Data-Font:
|
||||
datafontname := GetRegValue(REGNAME_DATAFONTNAME, DEFAULT_DATAFONTNAME);
|
||||
datafontsize := GetRegValue(REGNAME_DATAFONTSIZE, DEFAULT_DATAFONTSIZE);
|
||||
@ -1398,10 +1385,6 @@ begin
|
||||
prefEnableSetEditor := GetRegValue(REGNAME_FIELDEDITOR_SET, DEFAULT_FIELDEDITOR_SET);
|
||||
prefEnableNullBG := GetRegValue(REGNAME_BG_NULL_ENABLED, DEFAULT_BG_NULL_ENABLED);
|
||||
|
||||
// Color coding:
|
||||
RestoreSyneditStyles(SynSQLSyn1);
|
||||
SynMemoQuery.ActiveLineColor := StringToColor(GetRegValue(REGNAME_SQLCOLACTIVELINE, ColorToString(DEFAULT_SQLCOLACTIVELINE)));
|
||||
|
||||
// Switch off/on displaying table/db sized in tree
|
||||
menuShowSizeColumn.Checked := GetRegValue(REGNAME_SIZECOL_TREE, DEFAULT_SIZECOL_TREE);
|
||||
if menuShowSizeColumn.Checked then
|
||||
@ -1416,6 +1399,12 @@ begin
|
||||
RestoreListSetup(ListCommandStats);
|
||||
RestoreListSetup(ListTables);
|
||||
|
||||
// Shortcuts
|
||||
for i:=0 to ActionList1.ActionCount-1 do begin
|
||||
Action := TAction(ActionList1.Actions[i]);
|
||||
Action.ShortCut := GetRegValue(REGPREFIX_SHORTCUT1+Action.Name, Action.ShortCut);
|
||||
end;
|
||||
|
||||
// Generate menuitems for popupDbGridHeader (column selection for ListTables)
|
||||
popupDBGridHeader.Items.Clear;
|
||||
for i:=0 to ListTables.Header.Columns.Count-1 do
|
||||
@ -1458,6 +1447,9 @@ begin
|
||||
QueryTabs := TObjectList.Create;
|
||||
QueryTabs.Add(QueryTab);
|
||||
|
||||
// SynMemo font, hightlighting and shortcuts
|
||||
SetupSynEditors;
|
||||
|
||||
DataGridResult := TGridResult.Create;
|
||||
|
||||
btnAddTab := TPngSpeedButton.Create(PageControlMain);
|
||||
@ -2373,12 +2365,11 @@ end;
|
||||
|
||||
procedure TMainForm.actExportTablesExecute(Sender: TObject);
|
||||
var
|
||||
f: TExportSQLForm;
|
||||
ds: TDataset;
|
||||
InDBTree: Boolean;
|
||||
Comp: TComponent;
|
||||
begin
|
||||
f := TExportSQLForm.Create(Self);
|
||||
ExportSQLForm := TExportSQLForm.Create(Self);
|
||||
|
||||
// popupDB is used in DBTree AND ListTables
|
||||
InDBTree := False;
|
||||
@ -2388,19 +2379,18 @@ begin
|
||||
if InDBTree then begin
|
||||
// If a table is selected, use that for preselection. If only a db was selected, use all tables inside it.
|
||||
if SelectedTable.Text <> '' then
|
||||
f.SelectedTables.Add(SelectedTable.Text)
|
||||
ExportSQLForm.SelectedTables.Add(SelectedTable.Text)
|
||||
else if Mainform.ActiveDatabase <> '' then begin
|
||||
ds := Mainform.FetchDbTableList(ActiveDatabase);
|
||||
while not ds.Eof do begin
|
||||
f.SelectedTables.Add(ds.FieldByName(DBO_NAME).AsWideString);
|
||||
ExportSQLForm.SelectedTables.Add(ds.FieldByName(DBO_NAME).AsWideString);
|
||||
ds.Next;
|
||||
end;
|
||||
end;
|
||||
end else
|
||||
f.SelectedTables := GetVTCaptions( Mainform.ListTables, True );
|
||||
ExportSQLForm.SelectedTables := GetVTCaptions( Mainform.ListTables, True );
|
||||
|
||||
f.ShowModal;
|
||||
FreeAndNil(f);
|
||||
ExportSQLForm.ShowModal;
|
||||
end;
|
||||
|
||||
// Drop Table(s)
|
||||
@ -9244,6 +9234,7 @@ begin
|
||||
QueryTab.Grid.OnKeyDown := QueryGrid.OnKeyDown;
|
||||
QueryTab.Grid.OnPaintText := QueryGrid.OnPaintText;
|
||||
FixVT(QueryTab.Grid);
|
||||
SetupSynEditors;
|
||||
|
||||
// Set splitter positions
|
||||
QueryTab.pnlMemo.Height := pnlQueryMemo.Height;
|
||||
@ -9682,5 +9673,76 @@ begin
|
||||
|
||||
end;
|
||||
|
||||
|
||||
procedure TMainform.SetupSynEditors;
|
||||
var
|
||||
i, j: Integer;
|
||||
Editors: TObjectList;
|
||||
BaseEditor, Editor: TSynMemo;
|
||||
FontName: String;
|
||||
FontSize: Integer;
|
||||
KeyStroke: TSynEditKeyStroke;
|
||||
ActiveLineColor: TColor;
|
||||
Attri: TSynHighlighterAttributes;
|
||||
begin
|
||||
// Restore font, highlighter and shortcuts for each instantiated TSynMemo
|
||||
Editors := TObjectList.Create;
|
||||
BaseEditor := SynMemoQuery;
|
||||
for i:=0 to QueryTabs.Count-1 do
|
||||
Editors.Add(TQueryTab(QueryTabs[i]).Memo);
|
||||
Editors.Add(SynMemoFilter);
|
||||
Editors.Add(SynMemoProcessView);
|
||||
Editors.Add(SynMemoSQLLog);
|
||||
if Assigned(TableEditor) then begin
|
||||
Editors.Add(TableEditor.SynMemoCREATEcode);
|
||||
Editors.Add(TableEditor.SynMemoALTERcode);
|
||||
end;
|
||||
if Assigned(ViewEditor) then
|
||||
Editors.Add(ViewEditor.SynMemoSelect);
|
||||
if Assigned(RoutineEditor) then
|
||||
Editors.Add(RoutineEditor.SynMemoBody);
|
||||
if Assigned(CreateDatabaseForm) then
|
||||
Editors.Add(CreateDatabaseForm.SynMemoPreview);
|
||||
if Assigned(OptionsForm) then
|
||||
Editors.Add(OptionsForm.SynMemoSQLSample);
|
||||
if Assigned(SQLHelpForm) then begin
|
||||
Editors.Add(SQLHelpForm.memoDescription);
|
||||
Editors.Add(SQLHelpForm.MemoExample);
|
||||
end;
|
||||
if Assigned(ExportSQLForm) then
|
||||
Editors.Add(ExportSQLForm.SynMemoExampleSQL);
|
||||
|
||||
FontName := GetRegValue(REGNAME_FONTNAME, DEFAULT_FONTNAME);
|
||||
FontSize := GetRegValue(REGNAME_FONTSIZE, DEFAULT_FONTSIZE);
|
||||
ActiveLineColor := StringToColor(GetRegValue(REGNAME_SQLCOLACTIVELINE, ColorToString(DEFAULT_SQLCOLACTIVELINE)));
|
||||
for i:=0 to Editors.Count-1 do begin
|
||||
Editor := Editors[i] as TSynMemo;
|
||||
Editor.Font.Name := FontName;
|
||||
Editor.Font.Size := FontSize;
|
||||
Editor.Gutter.Font.Name := FontName;
|
||||
Editor.Gutter.Font.Size := FontSize;
|
||||
Editor.ActiveLineColor := ActiveLineColor;
|
||||
Editor.Options := BaseEditor.Options;
|
||||
Editor.TabWidth := BaseEditor.TabWidth;
|
||||
// Shortcuts
|
||||
if Editor = BaseEditor then for j:=0 to Editor.Keystrokes.Count-1 do begin
|
||||
KeyStroke := Editor.Keystrokes[i];
|
||||
Keystroke.ShortCut := GetRegValue(REGPREFIX_SHORTCUT1+EditorCommandToCodeString(Keystroke.Command), KeyStroke.ShortCut);
|
||||
Keystroke.ShortCut2 := GetRegValue(REGPREFIX_SHORTCUT2+EditorCommandToCodeString(Keystroke.Command), KeyStroke.ShortCut2);
|
||||
end else
|
||||
Editor.Keystrokes := BaseEditor.KeyStrokes;
|
||||
end;
|
||||
// Highlighting
|
||||
for i:=0 to SynSQLSyn1.AttrCount - 1 do begin
|
||||
Attri := SynSQLSyn1.Attribute[i];
|
||||
Attri.Foreground := GetRegValue(REGPREFIX_SQLATTRI+Attri.FriendlyName+REGPOSTFIX_SQL_FG, Attri.Foreground);
|
||||
Attri.Background := GetRegValue(REGPREFIX_SQLATTRI+Attri.FriendlyName+REGPOSTFIX_SQL_BG, Attri.Background);
|
||||
Attri.IntegerStyle := GetRegValue(REGPREFIX_SQLATTRI+Attri.FriendlyName+REGPOSTFIX_SQL_STYLE, Attri.IntegerStyle);
|
||||
if Assigned(OptionsForm) then
|
||||
OptionsForm.SynSQLSynSQLSample.Attribute[i].AssignColorAndStyle(Attri);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
|
||||
|
@ -760,6 +760,86 @@ object optionsform: Toptionsform
|
||||
OnChanging = anyUpDownLimitChanging
|
||||
end
|
||||
end
|
||||
object tabShortcuts: TTabSheet
|
||||
Caption = 'Shortcuts'
|
||||
ImageIndex = 4
|
||||
DesignSize = (
|
||||
409
|
||||
298)
|
||||
object lblShortcut1: TLabel
|
||||
Left = 199
|
||||
Top = 62
|
||||
Width = 45
|
||||
Height = 13
|
||||
Caption = 'Shortcut:'
|
||||
Enabled = False
|
||||
end
|
||||
object lblShortcutHint: TLabel
|
||||
Left = 199
|
||||
Top = 3
|
||||
Width = 207
|
||||
Height = 46
|
||||
Anchors = [akLeft, akTop, akRight, akBottom]
|
||||
AutoSize = False
|
||||
Caption = 'Please select a shortcut item in the tree.'
|
||||
Enabled = False
|
||||
WordWrap = True
|
||||
end
|
||||
object lblShortcut2: TLabel
|
||||
Left = 199
|
||||
Top = 107
|
||||
Width = 98
|
||||
Height = 13
|
||||
Caption = 'Secondary shortcut:'
|
||||
Enabled = False
|
||||
end
|
||||
object TreeShortcutItems: TVirtualStringTree
|
||||
Left = 3
|
||||
Top = 3
|
||||
Width = 190
|
||||
Height = 292
|
||||
Header.AutoSizeIndex = 0
|
||||
Header.DefaultHeight = 17
|
||||
Header.Font.Charset = DEFAULT_CHARSET
|
||||
Header.Font.Color = clWindowText
|
||||
Header.Font.Height = -11
|
||||
Header.Font.Name = 'Tahoma'
|
||||
Header.Font.Style = []
|
||||
Header.MainColumn = -1
|
||||
Images = MainForm.PngImageListMain
|
||||
TabOrder = 0
|
||||
OnFocusChanged = TreeShortcutItemsFocusChanged
|
||||
OnGetText = TreeShortcutItemsGetText
|
||||
OnGetImageIndex = TreeShortcutItemsGetImageIndex
|
||||
OnGetNodeDataSize = TreeShortcutItemsGetNodeDataSize
|
||||
OnInitChildren = TreeShortcutItemsInitChildren
|
||||
OnInitNode = TreeShortcutItemsInitNode
|
||||
Columns = <>
|
||||
end
|
||||
object Shortcut1: THotKey
|
||||
Left = 199
|
||||
Top = 81
|
||||
Width = 207
|
||||
Height = 19
|
||||
Enabled = False
|
||||
HotKey = 0
|
||||
Modifiers = []
|
||||
TabOrder = 1
|
||||
OnChange = Shortcut1Change
|
||||
end
|
||||
object Shortcut2: THotKey
|
||||
Left = 199
|
||||
Top = 125
|
||||
Width = 207
|
||||
Height = 19
|
||||
Anchors = [akLeft, akTop, akRight]
|
||||
Enabled = False
|
||||
HotKey = 0
|
||||
Modifiers = []
|
||||
TabOrder = 2
|
||||
OnChange = Shortcut2Change
|
||||
end
|
||||
end
|
||||
end
|
||||
object btnCancel: TButton
|
||||
Left = 270
|
||||
|
@ -11,9 +11,16 @@ interface
|
||||
uses
|
||||
Windows, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
||||
StdCtrls, ComCtrls, ExtCtrls, SynEditHighlighter, SynHighlighterSQL,
|
||||
SynEdit, SynMemo, VirtualTrees;
|
||||
SynEdit, SynMemo, VirtualTrees, SynEditKeyCmds, ActnList;
|
||||
|
||||
type
|
||||
TShortcutItemData = record
|
||||
Action: TAction;
|
||||
KeyStroke: TSynEditKeyStroke;
|
||||
Shortcut1, Shortcut2: TShortcut;
|
||||
end;
|
||||
PShortcutItemData = ^TShortcutItemData;
|
||||
|
||||
Toptionsform = class(TForm)
|
||||
pagecontrolMain: TPageControl;
|
||||
tabMisc: TTabSheet;
|
||||
@ -101,6 +108,13 @@ type
|
||||
lblMaxTotalRows: TLabel;
|
||||
editMaxTotalRows: TEdit;
|
||||
chkDoStatistics: TCheckBox;
|
||||
tabShortcuts: TTabSheet;
|
||||
TreeShortcutItems: TVirtualStringTree;
|
||||
Shortcut1: THotKey;
|
||||
lblShortcut1: TLabel;
|
||||
lblShortcutHint: TLabel;
|
||||
Shortcut2: THotKey;
|
||||
lblShortcut2: TLabel;
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure Modified(Sender: TObject);
|
||||
procedure Apply(Sender: TObject);
|
||||
@ -119,9 +133,21 @@ type
|
||||
procedure updownSQLFontSizeClick(Sender: TObject; Button: TUDBtnType);
|
||||
procedure SynMemoSQLSampleClick(Sender: TObject);
|
||||
procedure btnRestoreDefaultsClick(Sender: TObject);
|
||||
procedure TreeShortcutItemsInitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode;
|
||||
var InitialStates: TVirtualNodeInitStates);
|
||||
procedure TreeShortcutItemsGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex;
|
||||
TextType: TVSTTextType; var CellText: WideString);
|
||||
procedure TreeShortcutItemsInitChildren(Sender: TBaseVirtualTree; Node: PVirtualNode; var ChildCount: Cardinal);
|
||||
procedure TreeShortcutItemsGetImageIndex(Sender: TBaseVirtualTree; Node: PVirtualNode; Kind: TVTImageKind;
|
||||
Column: TColumnIndex; var Ghosted: Boolean; var ImageIndex: Integer);
|
||||
procedure TreeShortcutItemsFocusChanged(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex);
|
||||
procedure TreeShortcutItemsGetNodeDataSize(Sender: TBaseVirtualTree; var NodeDataSize: Integer);
|
||||
procedure Shortcut1Change(Sender: TObject);
|
||||
procedure Shortcut2Change(Sender: TObject);
|
||||
private
|
||||
{ Private declarations }
|
||||
FWasModified: Boolean;
|
||||
FShortcutCategories: TStringList;
|
||||
public
|
||||
{ Public declarations }
|
||||
end;
|
||||
@ -162,8 +188,9 @@ procedure Toptionsform.Apply(Sender: TObject);
|
||||
var
|
||||
i, maxrows: Integer;
|
||||
Attri: TSynHighlighterAttributes;
|
||||
Memo: TSynMemo;
|
||||
Grid: TVirtualStringTree;
|
||||
CatNode, ItemNode: PVirtualNode;
|
||||
Data: PShortcutItemData;
|
||||
begin
|
||||
Screen.Cursor := crHourGlass;
|
||||
|
||||
@ -215,20 +242,30 @@ begin
|
||||
MainReg.WriteBool(REGNAME_FIELDEDITOR_SET, chkEditorSet.Checked);
|
||||
MainReg.WriteBool(REGNAME_BG_NULL_ENABLED, chkNullBg.Checked);
|
||||
|
||||
// Shortcuts
|
||||
CatNode := TreeShortcutItems.GetFirst;
|
||||
while Assigned(CatNode) do begin
|
||||
ItemNode := TreeShortcutItems.GetFirstChild(CatNode);
|
||||
while Assigned(ItemNode) do begin
|
||||
Data := TreeShortcutItems.GetNodeData(ItemNode);
|
||||
// Save modified shortcuts
|
||||
if Assigned(Data.KeyStroke) then begin
|
||||
if Data.Shortcut1 <> Data.KeyStroke.ShortCut then
|
||||
MainReg.WriteInteger(REGPREFIX_SHORTCUT1+EditorCommandToCodeString(Data.KeyStroke.Command), Data.Shortcut1);
|
||||
if Data.Shortcut2 <> Data.KeyStroke.ShortCut2 then
|
||||
MainReg.WriteInteger(REGPREFIX_SHORTCUT2+EditorCommandToCodeString(Data.KeyStroke.Command), Data.Shortcut2);
|
||||
end else begin
|
||||
if Data.Shortcut1 <> Data.Action.ShortCut then
|
||||
MainReg.WriteInteger(REGPREFIX_SHORTCUT1+Data.Action.Name, Data.Shortcut1);
|
||||
end;
|
||||
ItemNode := TreeShortcutItems.GetNextSibling(ItemNode);
|
||||
end;
|
||||
CatNode := TreeShortcutItems.GetNextSibling(CatNode);
|
||||
end;
|
||||
// Populate SynMemo settings to all instances
|
||||
Mainform.SetupSynEditors;
|
||||
|
||||
// Set relevant properties in mainform
|
||||
for i:=Mainform.tabQuery.PageIndex to Mainform.PageControlMain.PageCount-1 do begin
|
||||
Memo := TQueryTab(Mainform.QueryTabs[i-Mainform.tabQuery.PageIndex]).Memo;
|
||||
Memo.Font := SynMemoSQLSample.Font;
|
||||
Memo.Gutter.Font := SynMemoSQLSample.Font;
|
||||
end;
|
||||
Mainform.SynMemoSQLLog.Font := SynMemoSQLSample.Font;
|
||||
Mainform.SynMemoSQLLog.Gutter.Font := SynMemoSQLSample.Font;
|
||||
Mainform.SynMemoProcessView.Font := SynMemoSQLSample.Font;
|
||||
Mainform.SynMemoFilter.Font := SynMemoSQLSample.Font;
|
||||
for i := 0 to SynSQLSynSQLSample.AttrCount - 1 do begin
|
||||
Mainform.SynSQLSyn1.Attribute[i].AssignColorAndStyle(SynSQLSynSQLSample.Attribute[i]);
|
||||
end;
|
||||
Mainform.SynMemoQuery.ActiveLineColor := SynMemoSQLSample.ActiveLineColor;
|
||||
Mainform.DataGrid.Font.Name := comboDataFontName.Text;
|
||||
Mainform.DataGrid.Font.Size := updownDataFontSize.Position;
|
||||
FixVT(Mainform.DataGrid);
|
||||
@ -302,20 +339,23 @@ begin
|
||||
comboSQLColElement.Items.Add(SynSQLSynSQLSample.Attribute[i].FriendlyName);
|
||||
comboSQLColElement.Items.Add('Active line background');
|
||||
comboSQLColElement.ItemIndex := 0;
|
||||
FShortcutCategories := TStringList.Create;
|
||||
for i:=0 to Mainform.ActionList1.ActionCount-1 do begin
|
||||
if FShortcutCategories.IndexOf(Mainform.ActionList1.Actions[i].Category) = -1 then
|
||||
FShortcutCategories.Add(Mainform.ActionList1.Actions[i].Category);
|
||||
end;
|
||||
FShortcutCategories.Add('SQL editing');
|
||||
TreeShortcutItems.RootNodeCount := FShortcutCategories.Count;
|
||||
end;
|
||||
|
||||
procedure Toptionsform.FormShow(Sender: TObject);
|
||||
var
|
||||
sqlfontname : String;
|
||||
sqlfontsize : Integer;
|
||||
datafontname : String;
|
||||
datafontsize : Integer;
|
||||
begin
|
||||
screen.Cursor := crHourGlass;
|
||||
|
||||
// Read and display values
|
||||
sqlfontname := GetRegValue(REGNAME_FONTNAME, DEFAULT_FONTNAME);
|
||||
sqlfontsize := GetRegValue(REGNAME_FONTSIZE, DEFAULT_FONTSIZE);
|
||||
datafontname := GetRegValue(REGNAME_DATAFONTNAME, DEFAULT_DATAFONTNAME);
|
||||
datafontsize := GetRegValue(REGNAME_DATAFONTSIZE, DEFAULT_DATAFONTSIZE);
|
||||
chkAutoReconnect.Checked := GetRegValue(REGNAME_AUTORECONNECT, DEFAULT_AUTORECONNECT);
|
||||
@ -343,12 +383,9 @@ begin
|
||||
btnOpenLogFolder.Enabled := DirectoryExists(DirnameSessionLogs);
|
||||
|
||||
// SQL:
|
||||
RestoreSyneditStyles(SynSQLSynSQLSample);
|
||||
SynMemoSQLSample.ActiveLineColor := StringToColor(GetRegValue(REGNAME_SQLCOLACTIVELINE, ColorToString(DEFAULT_SQLCOLACTIVELINE)));
|
||||
comboSQLFontName.ItemIndex := comboSQLFontName.Items.IndexOf(sqlfontname);
|
||||
updownSQLFontSize.Position := sqlfontsize;
|
||||
SynMemoSQLSample.Font.Name := sqlfontname;
|
||||
SynMemoSQLSample.Font.Size := sqlfontsize;
|
||||
Mainform.SetupSynEditors;
|
||||
comboSQLFontName.ItemIndex := comboSQLFontName.Items.IndexOf(SynMemoSQLSample.Font.Name);
|
||||
updownSQLFontSize.Position := SynMemoSQLSample.Font.Size;
|
||||
comboSQLColElementChange(Sender);
|
||||
|
||||
// Data-Appearance:
|
||||
@ -370,6 +407,10 @@ begin
|
||||
chkEditorSet.Checked := GetRegValue(REGNAME_FIELDEDITOR_SET, DEFAULT_FIELDEDITOR_SET);
|
||||
chkNullBG.Checked := GetRegValue(REGNAME_BG_NULL_ENABLED, DEFAULT_BG_NULL_ENABLED);
|
||||
|
||||
// Shortcuts
|
||||
TreeShortcutItems.ReinitChildren(nil, True);
|
||||
TreeShortcutItems.FocusedNode := nil;
|
||||
|
||||
btnApply.Enabled := False;
|
||||
screen.Cursor := crdefault;
|
||||
end;
|
||||
@ -517,4 +558,160 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure Toptionsform.TreeShortcutItemsFocusChanged(Sender: TBaseVirtualTree; Node: PVirtualNode;
|
||||
Column: TColumnIndex);
|
||||
var
|
||||
ShortcutFocused: Boolean;
|
||||
Data: PShortcutItemData;
|
||||
begin
|
||||
// Shortcut item focus change in tree
|
||||
ShortcutFocused := Assigned(Node) and (Sender.GetNodeLevel(Node) = 1);
|
||||
lblShortcutHint.Enabled := ShortcutFocused;
|
||||
lblShortcut1.Enabled := ShortcutFocused;
|
||||
lblShortcut2.Enabled := ShortcutFocused;
|
||||
Shortcut1.Enabled := lblShortcut1.Enabled;
|
||||
if ShortcutFocused then begin
|
||||
Data := Sender.GetNodeData(Node);
|
||||
lblShortcutHint.Caption := TreeShortcutItems.Text[Node, 0];
|
||||
if Assigned(Data.Action) then begin
|
||||
lblShortcut2.Enabled := False;
|
||||
if Data.Action.Hint <> '' then
|
||||
lblShortcutHint.Caption := Data.Action.Hint;
|
||||
end;
|
||||
Shortcut1.HotKey := Data.ShortCut1;
|
||||
Shortcut2.HotKey := Data.ShortCut2;
|
||||
end;
|
||||
Shortcut2.Enabled := lblShortcut2.Enabled;
|
||||
end;
|
||||
|
||||
|
||||
procedure Toptionsform.TreeShortcutItemsGetImageIndex(Sender: TBaseVirtualTree; Node: PVirtualNode;
|
||||
Kind: TVTImageKind; Column: TColumnIndex; var Ghosted: Boolean; var ImageIndex: Integer);
|
||||
var
|
||||
Data: PShortcutItemData;
|
||||
begin
|
||||
// Fetch icon number of shortcut item
|
||||
if Sender.GetNodeLevel(Node) = 1 then begin
|
||||
Data := Sender.GetNodeData(Node);
|
||||
if Assigned(Data.KeyStroke) then
|
||||
ImageIndex := 114
|
||||
else if Assigned(Data.Action) then
|
||||
ImageIndex := Data.Action.ImageIndex;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure Toptionsform.TreeShortcutItemsGetNodeDataSize(Sender: TBaseVirtualTree; var NodeDataSize: Integer);
|
||||
begin
|
||||
NodeDataSize := SizeOf(TShortcutItemData);
|
||||
end;
|
||||
|
||||
|
||||
procedure Toptionsform.TreeShortcutItemsGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex;
|
||||
TextType: TVSTTextType; var CellText: WideString);
|
||||
var
|
||||
Data: PShortcutItemData;
|
||||
i: Integer;
|
||||
t: WideString;
|
||||
begin
|
||||
// Fetch text of shortcut item
|
||||
case Sender.GetNodeLevel(Node) of
|
||||
0: CellText := FShortcutCategories[Node.Index];
|
||||
1: begin
|
||||
Data := Sender.GetNodeData(Node);
|
||||
if Assigned(Data.KeyStroke) then begin
|
||||
t := EditorCommandToCodeString(Data.KeyStroke.Command);
|
||||
t := Copy(t, 3, Length(t)-2);
|
||||
// Insert spaces before uppercase chars
|
||||
CellText := '';
|
||||
for i:=1 to Length(t) do begin
|
||||
if (i > 1) and (UpperCase(t[i]) = t[i]) then
|
||||
CellText := CellText + ' ';
|
||||
CellText := CellText + t[i];
|
||||
end;
|
||||
end else if Assigned(Data.Action) then begin
|
||||
CellText := Data.Action.Caption;
|
||||
CellText := StringReplace(CellText, '&', '', [rfReplaceAll]);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure Toptionsform.TreeShortcutItemsInitChildren(Sender: TBaseVirtualTree; Node: PVirtualNode;
|
||||
var ChildCount: Cardinal);
|
||||
var
|
||||
i: Integer;
|
||||
Category: WideString;
|
||||
begin
|
||||
// First initialization of shortcut items
|
||||
if Sender.GetNodeLevel(Node) = 0 then begin
|
||||
ChildCount := 0;
|
||||
if Integer(Node.Index) = FShortcutCategories.Count-1 then
|
||||
ChildCount := Mainform.SynMemoQuery.Keystrokes.Count
|
||||
else begin
|
||||
Category := (Sender as TVirtualStringTree).Text[Node, 0];
|
||||
for i:=0 to Mainform.ActionList1.ActionCount-1 do begin
|
||||
if Mainform.ActionList1.Actions[i].Category = Category then
|
||||
Inc(ChildCount);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure Toptionsform.TreeShortcutItemsInitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode;
|
||||
var InitialStates: TVirtualNodeInitStates);
|
||||
var
|
||||
Data: PShortcutItemData;
|
||||
ItemIndex, i: Integer;
|
||||
Category: WideString;
|
||||
begin
|
||||
if Sender.GetNodeLevel(Node) = 0 then
|
||||
Include(InitialStates, ivsHasChildren);
|
||||
Data := Sender.GetNodeData(Node);
|
||||
|
||||
if Sender.GetNodeLevel(Node) = 1 then begin
|
||||
if Integer(Node.Parent.Index) = FShortcutCategories.Count-1 then begin
|
||||
Data^.KeyStroke := Mainform.SynMemoQuery.Keystrokes[Node.Index];
|
||||
Data^.Shortcut1 := Data.KeyStroke.ShortCut;
|
||||
Data^.Shortcut2 := Data.KeyStroke.ShortCut2;
|
||||
end else begin
|
||||
ItemIndex := -1;
|
||||
Category := (Sender as TVirtualStringTree).Text[Node.Parent, 0];
|
||||
for i:=0 to Mainform.ActionList1.ActionCount-1 do begin
|
||||
if Mainform.ActionList1.Actions[i].Category = Category then
|
||||
Inc(ItemIndex);
|
||||
if ItemIndex = Integer(Node.Index) then begin
|
||||
Data^.Action := TAction(Mainform.ActionList1.Actions[i]);
|
||||
Data^.Shortcut1 := Data.Action.ShortCut;
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure Toptionsform.Shortcut1Change(Sender: TObject);
|
||||
var
|
||||
Data: PShortcutItemData;
|
||||
begin
|
||||
// Shortcut 1 changed
|
||||
Data := TreeShortcutItems.GetNodeData(TreeShortcutItems.FocusedNode);
|
||||
Data.Shortcut1 := (Sender as THotKey).HotKey;
|
||||
Modified(Sender);
|
||||
end;
|
||||
|
||||
|
||||
procedure Toptionsform.Shortcut2Change(Sender: TObject);
|
||||
var
|
||||
Data: PShortcutItemData;
|
||||
begin
|
||||
// Shortcut 2 changed
|
||||
Data := TreeShortcutItems.GetNodeData(TreeShortcutItems.FocusedNode);
|
||||
Data.Shortcut2 := (Sender as THotKey).HotKey;
|
||||
Modified(Sender);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -110,9 +110,6 @@ begin
|
||||
SetWindowSizeGrip(Handle, True);
|
||||
InheritFont(Font);
|
||||
FixVT(listParameters);
|
||||
SynMemoBody.Font.Name := Mainform.SynMemoQuery.Font.Name;
|
||||
SynMemoBody.Font.Size := Mainform.SynMemoQuery.Font.Size;
|
||||
SynMemoBody.Options := Mainform.SynMemoQuery.Options;
|
||||
Parameters := TWideStringList.Create;
|
||||
end;
|
||||
|
||||
@ -126,6 +123,7 @@ var
|
||||
rx: TRegExpr;
|
||||
i: Integer;
|
||||
begin
|
||||
MainForm.SetupSynEditors;
|
||||
FAlterRoutineName := AlterRoutineName;
|
||||
FAlterRoutineType := AlterRoutineType;
|
||||
editName.Text := FAlterRoutineName;
|
||||
|
@ -88,11 +88,7 @@ begin
|
||||
pnlLeft.Width := GetRegValue( REGNAME_SQLHELPPLWIDTH, pnlLeft.Width );
|
||||
pnlRightTop.Height := GetRegValue( REGNAME_SQLHELPPRHEIGHT, pnlRightTop.Height );
|
||||
Caption := DEFAULT_WINDOW_CAPTION;
|
||||
|
||||
MemoDescription.Font.Name := Mainform.SynMemoQuery.Font.Name;
|
||||
MemoDescription.Font.Size := Mainform.SynMemoQuery.Font.size;
|
||||
MemoExample.Font.Name := Mainform.SynMemoQuery.Font.Name;
|
||||
MemoExample.Font.Size := Mainform.SynMemoQuery.Font.size;
|
||||
MainForm.FixSynEditors;
|
||||
|
||||
// Gather help contents for treeview with SQL: HELP "CONTENTS"
|
||||
fillTreeLevel( nil );
|
||||
|
@ -263,12 +263,6 @@ begin
|
||||
Mainform.RestoreListSetup(listForeignKeys);
|
||||
comboRowFormat.Items.CommaText := 'DEFAULT,DYNAMIC,FIXED,COMPRESSED,REDUNDANT,COMPACT';
|
||||
comboInsertMethod.Items.CommaText := 'NO,FIRST,LAST';
|
||||
SynMemoALTERcode.TabWidth := Mainform.SynMemoQuery.TabWidth;
|
||||
SynMemoALTERcode.Font.Name := Mainform.SynMemoQuery.Font.Name;
|
||||
SynMemoALTERcode.Font.Size := Mainform.SynMemoQuery.Font.Size;
|
||||
SynMemoCREATEcode.TabWidth := Mainform.SynMemoQuery.TabWidth;
|
||||
SynMemoCREATEcode.Font.Name := Mainform.SynMemoQuery.Font.Name;
|
||||
SynMemoCREATEcode.Font.Size := Mainform.SynMemoQuery.Font.Size;
|
||||
FColumns := TObjectList.Create;
|
||||
Indexes := TWideStringList.Create;
|
||||
Indexes.OnChange := IndexesChange;
|
||||
@ -317,6 +311,7 @@ begin
|
||||
btnClearIndexesClick(Self);
|
||||
btnClearForeignKeysClick(Self);
|
||||
tabALTERcode.TabVisible := FAlterTableName <> '';
|
||||
MainForm.SetupSynEditors;
|
||||
|
||||
if FAlterTableName = '' then begin
|
||||
// Creating new table
|
||||
|
@ -46,7 +46,6 @@ begin
|
||||
inherited Create(AOwner);
|
||||
Align := alClient;
|
||||
SynMemoSelect.Highlighter := Mainform.SynSQLSyn1;
|
||||
SynMemoSelect.Font := Mainform.SynMemoQuery.Font;
|
||||
InheritFont(Font);
|
||||
end;
|
||||
|
||||
@ -94,6 +93,7 @@ begin
|
||||
end;
|
||||
// Ensure name is validated
|
||||
editNameChange(Self);
|
||||
MainForm.SetupSynEditors;
|
||||
end;
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user