Make SQL completion proposal optional. Fixes issue #1782.

This commit is contained in:
Ansgar Becker
2010-04-11 22:23:58 +00:00
parent 2790e5a94b
commit 2cda425c39
4 changed files with 49 additions and 36 deletions

View File

@@ -202,6 +202,8 @@ const
DEFAULT_DISPLAYBARS = true;
REGNAME_BARCOLOR = 'BarColor';
DEFAULT_BARCOLOR = $00BBFFDD;
REGNAME_COMPLETIONPROPOSAL = 'CompletionProposal';
DEFAULT_COMPLETIONPROPOSAL = True;
REGNAME_FILTERACTIVE = 'FilterPanel';
DEFAULT_FILTERACTIVE = False;
REGNAME_MULTI_INSTANCES = 'AllowMultipleInstances';

View File

@@ -869,6 +869,7 @@ type
prefNullBG: TColor;
prefDisplayBars: Boolean;
prefBarColor: TColor;
prefCompletionProposal: Boolean;
// Data grid related stuff
DataGridHiddenColumns: TStringList;
@@ -1257,6 +1258,7 @@ begin
prefLogDebug := GetRegValue(REGNAME_LOG_DEBUG, DEFAULT_LOG_DEBUG);
prefDisplayBars := GetRegValue(REGNAME_DISPLAYBARS, DEFAULT_DISPLAYBARS);
prefBarColor := GetRegValue(REGNAME_BARCOLOR, DEFAULT_BARCOLOR);
prefCompletionProposal := GetRegValue(REGNAME_COMPLETIONPROPOSAL, DEFAULT_COMPLETIONPROPOSAL);
// Data-Font:
datafontname := GetRegValue(REGNAME_DATAFONTNAME, DEFAULT_DATAFONTNAME);
@@ -4178,6 +4180,11 @@ var
end;
begin
if not prefCompletionProposal then begin
CanExecute := False;
Exit;
end;
Proposal := Sender as TSynCompletionProposal;
Editor := Proposal.Form.CurrentEditor;
Editor.GetHighlighterAttriAtRowColEx(Editor.CaretXY, Token, TokenTypeInt, Start, Attri);

View File

@@ -27,7 +27,7 @@ object optionsform: Toptionsform
Height = 352
ActivePage = tabMisc
Anchors = [akLeft, akTop, akRight, akBottom]
TabOrder = 3
TabOrder = 4
OnChange = pagecontrolMainChange
OnChanging = pagecontrolMainChanging
object tabMisc: TTabSheet
@@ -320,9 +320,9 @@ object optionsform: Toptionsform
Caption = 'pt'
end
object comboSQLFontName: TComboBox
Left = 16
Left = 3
Top = 23
Width = 225
Width = 238
Height = 21
Style = csDropDownList
Anchors = [akLeft, akTop, akRight]
@@ -353,21 +353,21 @@ object optionsform: Toptionsform
end
object grpSQLColors: TGroupBox
Left = 1
Top = 61
Top = 86
Width = 438
Height = 68
Height = 225
Anchors = [akLeft, akTop, akRight]
Caption = 'Syntax'
TabOrder = 1
object lblSQLColElement: TLabel
Left = 15
Left = 3
Top = 17
Width = 42
Height = 13
Caption = 'Element:'
end
object lblSQLColForeground: TLabel
Left = 247
Left = 234
Top = 16
Width = 60
Height = 13
@@ -375,7 +375,7 @@ object optionsform: Toptionsform
Caption = 'Foreground:'
end
object lblSQLColBackground: TLabel
Left = 247
Left = 234
Top = 42
Width = 60
Height = 13
@@ -383,7 +383,7 @@ object optionsform: Toptionsform
Caption = 'Background:'
end
object comboSQLColElement: TComboBox
Left = 67
Left = 55
Top = 13
Width = 164
Height = 21
@@ -393,9 +393,9 @@ object optionsform: Toptionsform
OnChange = comboSQLColElementChange
end
object cboxSQLColForeground: TColorBox
Left = 318
Left = 305
Top = 13
Width = 110
Width = 130
Height = 22
Style = [cbStandardColors, cbExtendedColors, cbIncludeNone, cbCustomColor, cbPrettyNames, cbCustomColors]
Anchors = [akTop, akRight]
@@ -403,7 +403,7 @@ object optionsform: Toptionsform
OnChange = SQLFontChange
end
object chkSQLBold: TCheckBox
Left = 67
Left = 55
Top = 41
Width = 57
Height = 17
@@ -412,7 +412,7 @@ object optionsform: Toptionsform
OnClick = SQLFontChange
end
object chkSQLItalic: TCheckBox
Left = 130
Left = 118
Top = 41
Width = 91
Height = 17
@@ -422,39 +422,30 @@ object optionsform: Toptionsform
OnClick = SQLFontChange
end
object cboxSQLColBackground: TColorBox
Left = 318
Left = 305
Top = 39
Width = 110
Width = 130
Height = 22
Style = [cbStandardColors, cbExtendedColors, cbIncludeNone, cbCustomColor, cbPrettyNames, cbCustomColors]
Anchors = [akTop, akRight]
TabOrder = 4
OnChange = SQLFontChange
end
end
object grpSQLSample: TGroupBox
Left = 0
Top = 132
Width = 438
Height = 179
Anchors = [akLeft, akTop, akRight, akBottom]
Caption = 'Sample'
TabOrder = 2
object SynMemoSQLSample: TSynMemo
AlignWithMargins = True
Left = 5
Top = 18
Width = 428
Height = 156
Left = 3
Top = 67
Width = 432
Height = 155
Cursor = crHandPoint
SingleLineMode = False
Align = alClient
Anchors = [akLeft, akTop, akRight, akBottom]
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Courier New'
Font.Style = []
TabOrder = 0
TabOrder = 5
OnClick = SynMemoSQLSampleClick
Gutter.Font.Charset = DEFAULT_CHARSET
Gutter.Font.Color = clWindowText
@@ -481,7 +472,7 @@ object optionsform: Toptionsform
Height = 56
Anchors = [akTop, akRight]
Caption = 'Tab width'
TabOrder = 3
TabOrder = 1
object editSQLTabWidth: TEdit
Left = 14
Top = 23
@@ -501,6 +492,15 @@ object optionsform: Toptionsform
OnClick = updownSQLFontSizeClick
end
end
object chkCompletionProposal: TCheckBox
Left = 3
Top = 63
Width = 434
Height = 17
Anchors = [akLeft, akTop, akRight]
Caption = 'Enable SQL completion proposal'
TabOrder = 2
end
end
object tabData: TTabSheet
BorderWidth = 5
@@ -1032,7 +1032,7 @@ object optionsform: Toptionsform
Cancel = True
Caption = 'Cancel'
ModalResult = 2
TabOrder = 1
TabOrder = 2
end
object btnOK: TButton
Left = 231
@@ -1043,7 +1043,7 @@ object optionsform: Toptionsform
Caption = 'OK'
Default = True
ModalResult = 1
TabOrder = 0
TabOrder = 1
OnClick = Apply
end
object btnApply: TButton
@@ -1054,7 +1054,7 @@ object optionsform: Toptionsform
Anchors = [akRight, akBottom]
Caption = 'Apply'
Enabled = False
TabOrder = 2
TabOrder = 3
OnClick = Apply
end
object btnRestoreDefaults: TButton
@@ -1064,7 +1064,7 @@ object optionsform: Toptionsform
Height = 25
Anchors = [akLeft, akBottom]
Caption = 'Factory defaults'
TabOrder = 4
TabOrder = 0
OnClick = btnRestoreDefaultsClick
end
object SynSQLSynSQLSample: TSynSQLSyn

View File

@@ -85,7 +85,6 @@ type
lblSQLColElement: TLabel;
lblSQLColForeground: TLabel;
cboxSQLColForeground: TColorBox;
grpSQLSample: TGroupBox;
SynMemoSQLSample: TSynMemo;
SynSQLSynSQLSample: TSynSQLSyn;
lblCopyDataMaxSize: TLabel;
@@ -134,6 +133,7 @@ type
updownGridRowsLineCount: TUpDown;
chkColorBars: TCheckBox;
cboxColorBars: TColorBox;
chkCompletionProposal: TCheckBox;
procedure FormShow(Sender: TObject);
procedure Modified(Sender: TObject);
procedure Apply(Sender: TObject);
@@ -279,6 +279,8 @@ begin
MainReg.WriteBool(REGNAME_FIELDEDITOR_SET, chkEditorSet.Checked);
MainReg.WriteBool(REGNAME_BG_NULL_ENABLED, chkNullBg.Checked);
MainReg.WriteBool(REGNAME_COMPLETIONPROPOSAL, chkCompletionProposal.Checked);
// Shortcuts
CatNode := TreeShortcutItems.GetFirst;
while Assigned(CatNode) do begin
@@ -353,6 +355,7 @@ begin
Mainform.prefEnableNullBG := chkNullBg.Checked;
Mainform.prefDisplayBars := chkColorBars.Checked;
Mainform.prefBarColor := cboxColorBars.Selected;
Mainform.prefCompletionProposal := chkCompletionProposal.Checked;
Mainform.ListTables.Invalidate;
Mainform.ListProcesses.Invalidate;
Mainform.ListCommandStats.Invalidate;
@@ -448,6 +451,7 @@ begin
comboSQLFontName.ItemIndex := comboSQLFontName.Items.IndexOf(SynMemoSQLSample.Font.Name);
updownSQLFontSize.Position := SynMemoSQLSample.Font.Size;
updownSQLTabWidth.Position := SynMemoSQLSample.TabWidth;
chkCompletionProposal.Checked := GetRegValue(REGNAME_COMPLETIONPROPOSAL, DEFAULT_COMPLETIONPROPOSAL);
comboSQLColElementChange(Sender);
// Data-Appearance: