📄 uoptions.pas
字号:
if FileExists(FilePath+CodeTemplateName) then
CodeTempList.SaveToFile(FilePath+CodeTemplateName);
end;
procedure TOptions.HelpButtonClick(Sender: TObject);
var
KeyWord:string;
begin
KeyWord:= 'Preferences page';
Application.HelpCommand(HELP_KEY,longint(KeyWord));
end;
procedure TOptions.chkCompilerClick(Sender: TObject);
begin
gbAlterCompiler.Visible:= not rbFPC.Checked ;
end;
procedure TOptions.btnBrowseClick(Sender: TObject);
begin
if OpenDialog1.Execute then
edFPC.Text:= OpenDialog1.FileName;
end;
procedure TOptions.GetPaletteOptions;
begin
PageListBox.Items.Text:= GetPalettePage;
PageListBox.Items.Add('[All]');
end;
procedure TOptions.PageListBoxClick(Sender: TObject);
var
Page:string;
begin
Page:= PageListBox.Items[PageListBox.ItemIndex];
if PageListBox.ItemIndex = PageListBox.Items.Count - 1 then
ToolListBox.Items.Text:= GetAllComponentList
else ToolListBox.Items.Text:= GetPalettePageComponent(Page);
end;
procedure TOptions.ToolListBoxDrawItem(Control: TWinControl;
Index: Integer; Rect: TRect; State: TOwnerDrawState);
var
Bitmap:TBitmap;
Offset:Integer;
ResName: array[0..64] of Char;
ComponentName:string;
begin
ComponentName:= ToolListBox.Items[Index];
with (Control as TListBox).Canvas do
begin
FillRect(Rect);
Offset:= 2;
Bitmap := TBitmap.Create;
try
StrPLCopy(ResName, ComponentName, SizeOf(ResName));
AnsiUpper(ResName);
Bitmap.Handle := LoadBitmap(hInstance, ResName);
if Bitmap.Handle = 0 then
Bitmap.Handle := LoadBitmap(hInstance, 'DEFAULT');
BrushCopy(Bounds(Rect.Left + 2, Rect.Top, Bitmap.Width, Bitmap.Height),
Bitmap, Bounds(0, 0, Bitmap.Width, Bitmap.Height), clWhite);
Offset:= Bitmap.Width + 6;
TextOut(Rect.Left + Offset, Rect.Top, ComponentName);
finally
Bitmap.Free;
end;
end;
end;
procedure TOptions.rbFPCClick(Sender: TObject);
begin
if rbFPC.Checked then gbAlterCompiler.Visible:= True;
end;
procedure TOptions.ElementListClick(Sender: TObject);
begin
case ElementList.ItemIndex of
0:
begin
ColorGrid.ForegroundIndex:= ColorGrid.ColorToIndex(PasSyn.AsmAttri.Foreground);
ColorGrid.BackgroundIndex:= ColorGrid.ColorToIndex(PasSyn.AsmAttri.Background);
end;
1:
begin
ColorGrid.ForegroundIndex:= ColorGrid.ColorToIndex(PasSyn.CommentAttri.Foreground);
ColorGrid.BackgroundIndex:= ColorGrid.ColorToIndex(PasSyn.CommentAttri.Background);
end;
2:
begin
ColorGrid.ForegroundIndex:= ColorGrid.ColorToIndex(PasSyn.IdentifierAttri.Foreground);
ColorGrid.BackgroundIndex:= ColorGrid.ColorToIndex(PasSyn.IdentifierAttri.Background);
end;
3:
begin
ColorGrid.ForegroundIndex:= ColorGrid.ColorToIndex(PasSyn.KeyAttri.Foreground) ;
ColorGrid.BackgroundIndex:= ColorGrid.ColorToIndex(PasSyn.KeyAttri.Background) ;
end;
4:
begin
ColorGrid.ForegroundIndex:= ColorGrid.ColorToIndex(PasSyn.NumberAttri.Foreground);
ColorGrid.BackgroundIndex:= ColorGrid.ColorToIndex(PasSyn.NumberAttri.Background);
end;
5:
begin
ColorGrid.ForegroundIndex:= ColorGrid.ColorToIndex(PasSyn.SpaceAttri.Foreground);
ColorGrid.BackgroundIndex:= ColorGrid.ColorToIndex(PasSyn.SpaceAttri.Background);
end;
6:
begin
ColorGrid.ForegroundIndex:= ColorGrid.ColorToIndex(PasSyn.StringAttri.Foreground);
ColorGrid.BackgroundIndex:= ColorGrid.ColorToIndex(PasSyn.StringAttri.Background);
end;
7:
begin
ColorGrid.ForegroundIndex:= ColorGrid.ColorToIndex(PasSyn.SymbolAttri.Foreground);
ColorGrid.BackgroundIndex:= ColorGrid.ColorToIndex(PasSyn.SymbolAttri.Background);
end;
8:
begin
ColorGrid.ForegroundIndex:= ColorGrid.ColorToIndex(PasEdit1.Color);
ColorGrid.BackgroundIndex:= ColorGrid.ColorToIndex(PasEdit1.Color);
end;
end;
end;
procedure TOptions.ColorGridChange(Sender: TObject);
begin
case ElementList.ItemIndex of
0:
begin
PasSyn.AsmAttri.Foreground := ColorGrid.ForegroundColor;
PasSyn.AsmAttri.Background := ColorGrid.BackgroundColor;
end;
1:
begin
PasSyn.CommentAttri.Foreground := ColorGrid.ForegroundColor;
PasSyn.CommentAttri.Background := ColorGrid.BackgroundColor;
end;
2:
begin
PasSyn.IdentifierAttri.Foreground:= ColorGrid.ForegroundColor;
PasSyn.IdentifierAttri.Background:= ColorGrid.BackgroundColor;
end;
3:
begin
PasSyn.KeyAttri.Foreground := ColorGrid.ForegroundColor;
PasSyn.KeyAttri.Background := ColorGrid.BackgroundColor;
end;
4:
begin
PasSyn.NumberAttri.Foreground := ColorGrid.ForegroundColor;
PasSyn.NumberAttri.Background := ColorGrid.BackgroundColor;
end;
5:
begin
PasSyn.SpaceAttri.Foreground := ColorGrid.ForegroundColor;
PasSyn.SpaceAttri.Background := ColorGrid.BackgroundColor;
end;
6:
begin
PasSyn.StringAttri.Foreground := ColorGrid.ForegroundColor;
PasSyn.StringAttri.Background := ColorGrid.BackgroundColor;
end;
7:
begin
PasSyn.SymbolAttri.Foreground := ColorGrid.ForegroundColor;
PasSyn.SymbolAttri.Background := ColorGrid.BackgroundColor;
end;
8:
begin
PasEdit1.Color := ColorGrid.BackgroundColor;
PasEdit1.Font.Color:= ColorGrid.ForegroundColor;
end;
end;
end;
procedure TOptions.BoldClick(Sender: TObject);
var
chkBox: TCheckBox;
begin
chkBox:= TCheckBox(Sender);
case ElementList.ItemIndex of
0:
begin
with PasSyn.AsmAttri do
begin
case chkBox.Tag of
0: if chkBox.Checked then Style:= Style + [fsBold]
else Style:= Style - [fsBold];
1: if chkBox.Checked then Style:= Style + [fsItalic]
else Style:= Style - [fsItalic];
2: if chkBox.Checked then Style:= Style + [fsUnderline]
else Style:= Style - [fsUnderline];
end;
end;
end;
1:
begin
with PasSyn.CommentAttri do
begin
case chkBox.Tag of
0: if chkBox.Checked then Style:= Style + [fsBold]
else Style:= Style - [fsBold];
1: if chkBox.Checked then Style:= Style + [fsItalic]
else Style:= Style - [fsItalic];
2: if chkBox.Checked then Style:= Style + [fsUnderline]
else Style:= Style - [fsUnderline];
end;
end;
end;
2:
begin
with PasSyn.IdentifierAttri do
begin
case chkBox.Tag of
0: if chkBox.Checked then Style:= Style + [fsBold]
else Style:= Style - [fsBold];
1: if chkBox.Checked then Style:= Style + [fsItalic]
else Style:= Style - [fsItalic];
2: if chkBox.Checked then Style:= Style + [fsUnderline]
else Style:= Style - [fsUnderline];
end;
end;
end;
3:
begin
with PasSyn.KeyAttri do
begin
case chkBox.Tag of
0: if chkBox.Checked then Style:= Style + [fsBold]
else Style:= Style - [fsBold];
1: if chkBox.Checked then Style:= Style + [fsItalic]
else Style:= Style - [fsItalic];
2: if chkBox.Checked then Style:= Style + [fsUnderline]
else Style:= Style - [fsUnderline];
end;
end;
end;
4:
begin
with PasSyn.NumberAttri do
begin
case chkBox.Tag of
0: if chkBox.Checked then Style:= Style + [fsBold]
else Style:= Style - [fsBold];
1: if chkBox.Checked then Style:= Style + [fsItalic]
else Style:= Style - [fsItalic];
2: if chkBox.Checked then Style:= Style + [fsUnderline]
else Style:= Style - [fsUnderline];
end;
end;
end;
5:
begin
with PasSyn.SpaceAttri do
begin
case chkBox.Tag of
0: if chkBox.Checked then Style:= Style + [fsBold]
else Style:= Style - [fsBold];
1: if chkBox.Checked then Style:= Style + [fsItalic]
else Style:= Style - [fsItalic];
2: if chkBox.Checked then Style:= Style + [fsUnderline]
else Style:= Style - [fsUnderline];
end;
end;
end;
6:
begin
with PasSyn.StringAttri do
begin
case chkBox.Tag of
0: if chkBox.Checked then Style:= Style + [fsBold]
else Style:= Style - [fsBold];
1: if chkBox.Checked then Style:= Style + [fsItalic]
else Style:= Style - [fsItalic];
2: if chkBox.Checked then Style:= Style + [fsUnderline]
else Style:= Style - [fsUnderline];
end;
end;
end;
7:
begin
with PasSyn.SymbolAttri do
begin
case chkBox.Tag of
0: if chkBox.Checked then Style:= Style + [fsBold]
else Style:= Style - [fsBold];
1: if chkBox.Checked then Style:= Style + [fsItalic]
else Style:= Style - [fsItalic];
2: if chkBox.Checked then Style:= Style + [fsUnderline]
else Style:= Style - [fsUnderline];
end;
end;
end;
end;
end;
procedure TOptions.PageControl1Change(Sender: TObject);
var
Item: TListItem;
List: TStringList;
I: Integer;
begin
if PageControl1.ActivePage = CodeInsight then
begin
CodeList.Items.Clear;
if EditorForm.mwAutoComplete1.AutoCompleteList.Count < 1 then Exit;
List:= TStringList.Create;
List.Text:= EditorForm.mwAutoComplete1.GetTokenList;
for I:= 0 to List.Count - 1 do
begin
Item:= CodeList.Items.Add;
Item.Caption:= List[I];
end;
List.Free;
end;
end;
procedure TOptions.CodeListChange(Sender: TObject; Item: TListItem;
Change: TItemChange);
var
List: TStringList;
begin
if CodeList.Selected = nil then Exit;
CodeEdit.Lines.Clear;
List:= TStringList.Create;
List.Text:= EditorForm.mwAutoComplete1.GetTokenValue(CodeList.Selected.Caption);
CodeEdit.Lines.AddStrings(List);
List.Free;
end;
procedure TOptions.DeleteTemplateBtnClick(Sender: TObject);
var
Idx: Integer;
begin
if CodeList.Selected = nil then Exit;
Idx:= CodeList.Selected.Index;
DeleteCodeTemplate(CodeList.Selected.Caption);
CodeList.Items.Delete(Idx);
if (Idx-1) >= 0 then CodeList.Items[Idx-1].Selected:= True;
end;
procedure TOptions.AddTemplateBtnClick(Sender: TObject);
var
Item: TListItem;
begin
with TADDCODETDIALOG.Create(self) do
begin
if ShowModal <> mrCancel then
begin
Item:= CodeList.Items.Add;
Item.Caption:= ShortName.Text;
Item.Selected:= True;
CodeEdit.Lines.Clear;
CodeEdit.SetFocus;
end;
end;
end;
procedure TOptions.DeleteCodeTemplate(Code:string);
var
I,J,StartPos,EndPos,Pos1:Integer;
Name:string;
begin
if not FileExists(FilePath+CodeTemplateName) then Exit;
CodeTempList:= TStringList.Create;
CodeTempList.LoadFromFile(FilePath+CodeTemplateName);
for I:=0 to CodeTempList.Count-1 do
begin
if IsCodeHeader(CodeTempList[I]) then
begin
Name:= Trim(CodeTempList[I]);
if CompareText(Trim(Code),Trim(Name))=0 then
begin
StartPos:= I;
EndPos:= CodeTempList.Count-1;
for J:= I+1 to CodeTempList.Count-1 do
begin
if IsCodeHeader(CodeTempList[J]) then
begin
EndPos:=J;
Break;
end;
end;
Break;
end;
end;
end;
for I:= EndPos-1 downto StartPos do
CodeTempList.Delete(I);
end;
procedure TOptions.AddCodeTemplate;
begin
{ if GetCodeExists(edName.Text)<>-1 then begin
MsgDlg('This code template exists already!',Application.Title,MB_OK);
Exit;
end;}
with CodeTempList do
begin
Add(CodeList.Selected.Caption);
AddStrings(CodeEdit.Lines);
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -