IDE: identifier completion window: optional icons. issue #32983, patch from regs

git-svn-id: trunk@57110 -
This commit is contained in:
ondrej 2018-01-18 07:28:56 +00:00
parent 761123c874
commit 203b6860ad
9 changed files with 293 additions and 103 deletions

View File

@ -1390,6 +1390,7 @@ type
fAutoDisplayFuncPrototypes: Boolean;
fUseContainsFilter: Boolean;
fHighlightCodeCompletionPrefix: Boolean;
fUseImagesInCompletionBox: Boolean;
// Code Folding
FUseCodeFolding: Boolean;
@ -1585,6 +1586,8 @@ type
read fUseContainsFilter write fUseContainsFilter default True;
property HighlightCodeCompletionPrefix: Boolean
read fHighlightCodeCompletionPrefix write fHighlightCodeCompletionPrefix default True;
property UseImagesInCompletionBox: Boolean
read fUseImagesInCompletionBox write fUseImagesInCompletionBox default True;
published
property DbgHintAutoTypeCastClass: Boolean
@ -4778,6 +4781,8 @@ begin
XMLConfig.GetValue('EditorOptions/CodeTools/ContainsCompletionFilter', True);
fHighlightCodeCompletionPrefix :=
XMLConfig.GetValue('EditorOptions/CodeTools/HighlightCodeCompletionPrefix', True);
fUseImagesInCompletionBox :=
XMLConfig.GetValue('EditorOptions/CodeTools/UseImagesInCompletionBox', True);
// Code Folding
FUseCodeFolding :=
@ -4975,6 +4980,8 @@ begin
, fUseContainsFilter, True);
XMLConfig.SetDeleteValue('EditorOptions/CodeTools/HighlightCodeCompletionPrefix'
, fHighlightCodeCompletionPrefix, True);
XMLConfig.SetDeleteValue('EditorOptions/CodeTools/UseImagesInCompletionBox'
, fUseImagesInCompletionBox, True);
// Code Folding
XMLConfig.SetDeleteValue('EditorOptions/CodeFolding/UseCodeFolding',

View File

@ -16,10 +16,10 @@ object EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
AnchorSideLeft.Control = AutoHintAndCompletionDelayLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = AutoHintAndCompletionDelayLabel
Left = 253
Height = 19
Top = 180
Width = 101
Left = 217
Height = 15
Top = 156
Width = 83
BorderSpacing.Left = 20
Caption = 'AutoDelayLabel'
ParentColor = False
@ -32,7 +32,7 @@ object EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
AnchorSideRight.Side = asrBottom
Left = 0
Height = 3
Top = 64
Top = 56
Width = 634
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
@ -42,9 +42,9 @@ object EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 6
Height = 23
Height = 19
Top = 6
Width = 255
Width = 210
BorderSpacing.Left = 6
BorderSpacing.Top = 6
Caption = 'AutoRemoveEmptyMethodsOnSave'
@ -55,9 +55,9 @@ object EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
AnchorSideTop.Control = AutoDisplayFuncProtoCheckBox
AnchorSideTop.Side = asrBottom
Left = 6
Height = 23
Top = 99
Width = 236
Height = 19
Top = 87
Width = 198
BorderSpacing.Left = 6
BorderSpacing.Top = 6
Caption = 'AutoToolTipSymbToolsCheckBox'
@ -68,9 +68,9 @@ object EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
AnchorSideTop.Control = AutoRemoveEmptyMethodsOnSave
AnchorSideTop.Side = asrBottom
Left = 6
Height = 23
Top = 35
Width = 218
Height = 19
Top = 31
Width = 179
BorderSpacing.Left = 6
BorderSpacing.Top = 6
Caption = 'AutoCompleteBlockCheckBox'
@ -81,9 +81,9 @@ object EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
AnchorSideTop.Control = AutoToolTipSymbToolsCheckBox
AnchorSideTop.Side = asrBottom
Left = 6
Height = 23
Top = 128
Width = 222
Height = 19
Top = 112
Width = 182
BorderSpacing.Left = 6
BorderSpacing.Top = 6
Caption = 'AutoToolTipExprEvalCheckBox'
@ -97,7 +97,7 @@ object EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
AnchorSideRight.Side = asrBottom
Left = 6
Height = 30
Top = 200
Top = 172
Width = 622
Frequency = 250
Max = 4000
@ -116,9 +116,9 @@ object EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
AnchorSideTop.Control = DbgToolTipAutoCastClass
AnchorSideTop.Side = asrBottom
Left = 6
Height = 19
Top = 180
Width = 227
Height = 15
Top = 156
Width = 191
BorderSpacing.Left = 6
BorderSpacing.Top = 6
Caption = 'AutoHintAndCompletionDelayLabel'
@ -132,7 +132,7 @@ object EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
AnchorSideRight.Side = asrBottom
Left = 6
Height = 30
Top = 256
Top = 224
Width = 622
Frequency = 250
Max = 4000
@ -150,9 +150,9 @@ object EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
AnchorSideTop.Control = AutoDelayTrackBar
AnchorSideTop.Side = asrBottom
Left = 6
Height = 19
Top = 236
Width = 177
Height = 15
Top = 208
Width = 148
BorderSpacing.Left = 6
BorderSpacing.Top = 6
Caption = 'CompletionDropDownLabel'
@ -162,10 +162,10 @@ object EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
AnchorSideLeft.Control = CompletionDropDownLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = CompletionDropDownLabel
Left = 203
Height = 19
Top = 236
Width = 213
Left = 174
Height = 15
Top = 208
Width = 177
BorderSpacing.Left = 20
Caption = 'CompletionDropDownDelayLabel'
ParentColor = False
@ -177,12 +177,12 @@ object EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 33
Top = 288
Height = 23
Top = 256
Width = 220
BorderSpacing.Left = 6
BorderSpacing.Top = 2
ItemHeight = 19
ItemHeight = 15
Style = csDropDownList
TabOrder = 6
end
@ -192,9 +192,9 @@ object EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
AnchorSideTop.Control = CompletionDropDownHint
AnchorSideTop.Side = asrCenter
Left = 232
Height = 19
Top = 295
Width = 205
Height = 15
Top = 260
Width = 171
BorderSpacing.Around = 6
Caption = 'CompletionDropDownHintLabel'
ParentColor = False
@ -204,9 +204,9 @@ object EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
AnchorSideTop.Control = AutoToolTipExprEvalCheckBox
AnchorSideTop.Side = asrBottom
Left = 26
Height = 23
Top = 151
Width = 191
Height = 19
Top = 131
Width = 159
BorderSpacing.Left = 20
Caption = 'DbgToolTipAutoCastClass'
TabOrder = 7
@ -215,9 +215,9 @@ object EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = ToolTipBevel
Left = 6
Height = 23
Top = 70
Width = 234
Height = 19
Top = 62
Width = 191
BorderSpacing.Left = 6
BorderSpacing.Top = 6
Caption = 'AutoDisplayFuncProtoCheckBox'
@ -227,12 +227,12 @@ object EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = CompletionDropDownHint
AnchorSideTop.Side = asrBottom
Left = 9
Height = 23
Top = 330
Width = 181
BorderSpacing.Left = 9
BorderSpacing.Top = 9
Left = 6
Height = 19
Top = 285
Width = 145
BorderSpacing.Left = 6
BorderSpacing.Top = 6
Caption = 'ContainsFilterCheckBox'
TabOrder = 9
end
@ -240,13 +240,26 @@ object EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = ContainsFilterCheckBox
AnchorSideTop.Side = asrBottom
Left = 9
Height = 23
Top = 362
Width = 188
BorderSpacing.Left = 9
BorderSpacing.Top = 9
Left = 6
Height = 19
Top = 310
Width = 151
BorderSpacing.Left = 6
BorderSpacing.Top = 6
Caption = 'HighlightPrefixCheckBox'
TabOrder = 10
end
object UseImagesInCompletionBoxCheckBox: TCheckBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = HighlightPrefixCheckBox
AnchorSideTop.Side = asrBottom
Left = 6
Height = 19
Top = 335
Width = 221
BorderSpacing.Left = 6
BorderSpacing.Top = 6
Caption = 'UseImagesInCompletionBoxCheckBox'
TabOrder = 11
end
end

View File

@ -41,6 +41,7 @@ type
CompletionDropDownHintLabel: TLabel;
CompletionDropDownHint: TComboBox;
CompletionDropDownDelayLabel: TLabel;
UseImagesInCompletionBoxCheckBox: TCheckBox;
AutoDelayTrackBar: TTrackBar;
CompletionDropDownLabel: TLabel;
CompletionDropDownHintTrackBar: TTrackBar;
@ -89,6 +90,7 @@ begin
AutoDisplayFuncProtoCheckBox.Caption := dlgAutoDisplayFuncProto;
ContainsFilterCheckBox.Caption := dlgIncludeIdentifiersContainingPrefix;
HighlightPrefixCheckBox.Caption := dlgHighlightPrefix;
UseImagesInCompletionBoxCheckBox.Caption := dlgUseImagesInCompletionBox;
AutoHintAndCompletionDelayLabel.Caption:=lisDelayForHintsAndCompletionBox;
CompletionDropDownLabel.Caption := lisDelayForCompletionLongLineHint;
@ -113,6 +115,7 @@ begin
AutoDisplayFuncProtoCheckBox.Checked := AutoDisplayFunctionPrototypes;
ContainsFilterCheckBox.Checked := ContainsCompletionFilter;
HighlightPrefixCheckBox.Checked := HighlightCodeCompletionPrefix;
UseImagesInCompletionBoxCheckBox.Checked := UseImagesInCompletionBox;
CompletionDropDownHintTrackBar.Position := CompletionLongLineHintInMSec;
CompletionDropDownHint.ItemIndex := ord(CompletionLongLineHintType);
@ -134,6 +137,7 @@ begin
AutoDisplayFunctionPrototypes := AutoDisplayFuncProtoCheckBox.Checked;
ContainsCompletionFilter := ContainsFilterCheckBox.Checked;
HighlightCodeCompletionPrefix := HighlightPrefixCheckBox.Checked;
UseImagesInCompletionBox := UseImagesInCompletionBoxCheckBox.Checked;
CompletionLongLineHintInMSec := CompletionDropDownHintTrackBar.Position;
CompletionLongLineHintType := TSynCompletionLongHintType(CompletionDropDownHint.ItemIndex);

View File

@ -157,6 +157,7 @@
<Filename Value="frames/editor_codetools_options.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="EditorCodetoolsOptionsFrame"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Frame"/>
</Unit13>
<Unit14>

View File

@ -1971,6 +1971,7 @@ resourcestring
dlgHighlightPrefix = 'Highlight prefix';
lisAutomaticFeatures = 'Completion and Hints';
lisAutoMarkup = 'Markup and Matches';
dlgUseImagesInCompletionBox = 'Icons in code completion box';
dlgMarkupUserDefined = 'User defined markup';
dlgMarkupUserDefinedNoLists = 'No lists';

View File

@ -261,7 +261,8 @@ var
ItemNode: TCodeTreeNode;
SubNode: TCodeTreeNode;
IsReadOnly: boolean;
ImageIndex: longint;
UseImages: boolean;
ImageIndex, ImageIndexCC: longint;
Prefix: String;
PrefixPosition: Integer;
HintModifiers: TPascalHintModifiers;
@ -301,11 +302,14 @@ begin
exit;
end;
IdentItem.BeautifyIdentifier(CodeToolBoss.IdentifierList);
ItemNode:=IdentItem.Node;
BackgroundColor:=ColorToRGB(ACanvas.Brush.Color);
BGRed:=(BackgroundColor shr 16) and $ff;
BGGreen:=(BackgroundColor shr 8) and $ff;
BGBlue:=BackgroundColor and $ff;
ImageIndex:=-1;
ImageIndexCC := -1;
UseImages := EditorOpts.UseImagesInCompletionBox;
// first write the type
// var, procedure, property, function, type, const
@ -313,86 +317,160 @@ begin
ctnVarDefinition, ctnRecordCase:
begin
AColor:=clMaroon;
s:='var';
if UseImages then
ImageIndexCC := IDEImages.LoadImage('cc_variable', 16)
else begin
AColor:=clMaroon;
s:='var';
end;
end;
ctnTypeDefinition, ctnEnumerationType:
begin
AColor:=clLime;
s:='type';
if UseImages then
begin
if ItemNode <> nil then
begin
ANode := IdentItem.Tool.FindTypeNodeOfDefinition(ItemNode);
case ANode.Desc of
ctnClass:
ImageIndexCC := IDEImages.LoadImage('cc_class', 16);
ctnRecordType:
ImageIndexCC := IDEImages.LoadImage('cc_record', 16);
ctnEnumerationType:
ImageIndexCC := IDEImages.LoadImage('cc_enum', 16);
else
ImageIndexCC := IDEImages.LoadImage('cc_type', 16);
end;
end
else
ImageIndexCC := IDEImages.LoadImage('cc_type', 16);
end
else
begin
AColor:=clLime;
s:='type';
end;
end;
ctnConstDefinition,ctnConstant:
begin
AColor:=clOlive;
s:='const';
if UseImages then
ImageIndexCC := IDEImages.LoadImage('cc_constant', 16);
end;
ctnProcedure:
begin
if IdentItem.IsFunction then
if UseImages then
begin
AColor:=clTeal;
s:='function';
if IdentItem.IsFunction then
ImageIndexCC := IDEImages.LoadImage('cc_function', 16)
else if IdentItem.IsConstructor then
ImageIndexCC := IDEImages.LoadImage('cc_constructor', 16)
else if IdentItem.IsDestructor then
ImageIndexCC := IDEImages.LoadImage('cc_destructor', 16)
else
ImageIndexCC := IDEImages.LoadImage('cc_procedure', 16);
end
else
begin
AColor:=clNavy;
if IdentItem.IsConstructor then
s := 'constructor'
if IdentItem.IsFunction then
begin
AColor:=clTeal;
s:='function';
end
else
if IdentItem.IsDestructor then
s := 'destructor'
else
s:='procedure';
begin
AColor:=clNavy;
if IdentItem.IsConstructor then
s := 'constructor'
else if IdentItem.IsDestructor then
s := 'destructor'
else
s:='procedure';
end;
if IdentItem.TryIsAbstractMethod then
AColor:=clRed;
if iliHasLowerVisibility in IdentItem.Flags then
AColor:=clGray;
end;
if IdentItem.TryIsAbstractMethod then
AColor:=clRed;
if iliHasLowerVisibility in IdentItem.Flags then
AColor:=clGray;
end;
ctnProperty,ctnGlobalProperty:
begin
AColor:=clPurple;
s:='property';
IsReadOnly:=IdentItem.IsPropertyReadOnly;
if IsReadOnly then
ImageIndex:=IDEImages.LoadImage('ce_property_readonly');
if UseImages then
begin
if IsReadOnly then
ImageIndexCC := IDEImages.LoadImage('cc_property_ro', 16)
else
ImageIndexCC := IDEImages.LoadImage('cc_property', 16);
end
else
begin
AColor:=clPurple;
s:='property';
if IsReadOnly then
ImageIndex:=IDEImages.LoadImage('ce_property_readonly');
end;
end;
ctnEnumIdentifier:
begin
AColor:=clOlive;
s:='enum';
if UseImages then
ImageIndexCC := IDEImages.LoadImage('cc_enum', 16)
else
begin
AColor:=clOlive;
s:='enum';
end;
end;
ctnLabel:
begin
AColor:=clOlive;
s:='label';
if UseImages then
ImageIndexCC := IDEImages.LoadImage('cc_label', 16)
else
begin
AColor:=clOlive;
s:='label';
end;
end;
ctnUnit, ctnUseUnitClearName:
begin
AColor:=clBlack;
s:='unit';
if UseImages then
ImageIndexCC := IDEImages.LoadImage('cc_unit', 16)
else
begin
AColor:=clBlack;
s:='unit';
end;
end;
ctnUseUnitNamespace:
begin
AColor:=clBlack;
s:='namespace';
if UseImages then
ImageIndexCC := IDEImages.LoadImage('cc_namespace', 16)
else
begin
AColor:=clBlack;
s:='namespace';
end;
end;
ctnNone:
if iliKeyword in IdentItem.Flags then begin
AColor:=clBlack;
s:='keyword';
end else begin
AColor:=clGray;
s:='';
if not UseImages then
begin
if iliKeyword in IdentItem.Flags then begin
AColor:=clBlack;
s:='keyword';
end else begin
AColor:=clGray;
s:='';
end;
end;
else
@ -400,12 +478,28 @@ begin
s:='';
end;
SetFontColor(AColor);
if MeasureOnly then
Inc(Result.X, ACanvas.TextWidth('constructor '))
if UseImages then
begin
// drawing type image
if MeasureOnly then
Inc(Result.X, IDEImages.Images_16.Width + round(IDEImages.Images_16.Width / 4))
else
begin
if ImageIndexCC >= 0 then
IDEImages.Images_16.Draw(ACanvas, x+1, y+(Result.Y-IDEImages.Images_16.Height) div 2, ImageIndexCC);
end;
Inc(x,IDEImages.Images_16.Width + round(IDEImages.Images_16.Width / 4));
end
else
ACanvas.TextOut(x+1,y,s);
inc(x,ACanvas.TextWidth('constructor '));
begin
SetFontColor(AColor);
if MeasureOnly then
Inc(Result.X, ACanvas.TextWidth('constructor '))
else
ACanvas.TextOut(x+1,y,s);
inc(x,ACanvas.TextWidth('constructor '));
end;
if x>MaxX then exit;
// paint the identifier
@ -445,19 +539,21 @@ begin
end;
// paint icon
if ImageIndex>=0 then begin
if MeasureOnly then
Inc(Result.X, 18)
else begin
IDEImages.Images_16.Draw(ACanvas,x+1,y+(Result.Y-16) div 2,ImageIndex);
inc(x,18);
if x>MaxX then exit;
if not UseImages then
begin
if ImageIndex>=0 then begin
if MeasureOnly then
Inc(Result.X, 18)
else begin
IDEImages.Images_16.Draw(ACanvas,x+1,y+(Result.Y-16) div 2,ImageIndex);
inc(x,18);
if x>MaxX then exit;
end;
end;
end;
// finally paint the type/value/parameters
s:='';
ItemNode:=IdentItem.Node;
if ItemNode<>nil then begin
case ItemNode.Desc of

View File

@ -565,3 +565,26 @@ menu_quick_compile.png, menu_quick_compile_150.png, menu_quick_compile_200.png
menu_reset_debugger.png, menu_reset_debugger_150.png, menu_reset_debugger_200.png
menu_run_file.png, menu_run_file_150.png, menu_run_file_200.png
menu_uncomment.png, menu_uncomment_150.png, menu_uncomment_200.png
---
Following images were created by regs:
codecompletion folder:
cc_class.png, cc_class_150.png, cc_class_200.png
cc_constant.png, cc_constant_150.png, cc_constant_200.png
cc_constructor.png, cc_constructor_150.png, cc_constructor_200.png
cc_destructor.png, cc_destructor_150.png, cc_destructor_200.png
cc_enum.png, cc_enum_150.png, cc_enum_200.png
cc_function.png, cc_function_150.png, cc_function_200.png
cc_label.png, cc_label_150.png, cc_label_200.png
cc_namespace.png, cc_namespace_150.png, cc_namespace_200.png
cc_procedure.png, cc_procedure_150.png, cc_procedure_200.png
cc_property.png, cc_property_150.png, cc_property_200.png
cc_property_ro.png, cc_property_ro_150.png, cc_property_ro_200.png
cc_record.png, cc_record_150.png, cc_record_200.png
cc_type.png, cc_type_150.png, cc_type_200.png
cc_unit.png, cc_unit_150.png, cc_unit_200.png
cc_variable.png, cc_variable_150.png, cc_variable_200.png

Binary file not shown.

View File

@ -71,6 +71,51 @@ actions/laz_set_color_default.png
actions/laz_tick.png
actions/laz_wand.png
actions/preferences.xpm
codecompletion/cc_class.png
codecompletion/cc_class_150.png
codecompletion/cc_class_200.png
codecompletion/cc_constant.png
codecompletion/cc_constant_150.png
codecompletion/cc_constant_200.png
codecompletion/cc_constructor.png
codecompletion/cc_constructor_150.png
codecompletion/cc_constructor_200.png
codecompletion/cc_destructor.png
codecompletion/cc_destructor_150.png
codecompletion/cc_destructor_200.png
codecompletion/cc_enum.png
codecompletion/cc_enum_150.png
codecompletion/cc_enum_200.png
codecompletion/cc_function.png
codecompletion/cc_function_150.png
codecompletion/cc_function_200.png
codecompletion/cc_label.png
codecompletion/cc_label_150.png
codecompletion/cc_label_200.png
codecompletion/cc_namespace.png
codecompletion/cc_namespace_150.png
codecompletion/cc_namespace_200.png
codecompletion/cc_procedure.png
codecompletion/cc_procedure_150.png
codecompletion/cc_procedure_200.png
codecompletion/cc_property.png
codecompletion/cc_property_150.png
codecompletion/cc_property_200.png
codecompletion/cc_property_ro.png
codecompletion/cc_property_ro_150.png
codecompletion/cc_property_ro_200.png
codecompletion/cc_record.png
codecompletion/cc_record_150.png
codecompletion/cc_record_200.png
codecompletion/cc_type.png
codecompletion/cc_type_150.png
codecompletion/cc_type_200.png
codecompletion/cc_unit.png
codecompletion/cc_unit_150.png
codecompletion/cc_unit_200.png
codecompletion/cc_variable.png
codecompletion/cc_variable_150.png
codecompletion/cc_variable_200.png
codeexplorer/ce_class.png
codeexplorer/ce_classinterface.png
codeexplorer/ce_const.png