mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-23 01:19:37 +02:00
implemented selecting highlighter in source editor
git-svn-id: trunk@8846 -
This commit is contained in:
parent
8e1ecbd222
commit
b8881b0c6c
@ -170,6 +170,9 @@ type
|
||||
end;
|
||||
|
||||
{ list of TEditOptLanguageInfo }
|
||||
|
||||
{ TEditOptLangList }
|
||||
|
||||
TEditOptLangList = class(TList)
|
||||
private
|
||||
function GetInfos(Index: Integer): TEditOptLanguageInfo;
|
||||
@ -182,6 +185,7 @@ type
|
||||
function FindByHighlighter(Hilighter: TSynCustomHighlighter): Integer;
|
||||
function FindByType(AType: TLazSyntaxHighlighter): Integer;
|
||||
function GetDefaultFilextension(AType: TLazSyntaxHighlighter): String;
|
||||
function GetInfoByType(AType: TLazSyntaxHighlighter): TEditOptLanguageInfo;
|
||||
property Items[Index: Integer]: TEditOptLanguageInfo read GetInfos;
|
||||
default;
|
||||
end;
|
||||
@ -1144,6 +1148,18 @@ begin
|
||||
Result := '';
|
||||
end;
|
||||
|
||||
function TEditOptLangList.GetInfoByType(AType: TLazSyntaxHighlighter
|
||||
): TEditOptLanguageInfo;
|
||||
var
|
||||
i: LongInt;
|
||||
begin
|
||||
i:=FindByType(AType);
|
||||
if i>=0 then
|
||||
Result:=Items[i]
|
||||
else
|
||||
Result:=nil;
|
||||
end;
|
||||
|
||||
{ TEditorOptions }
|
||||
|
||||
constructor TEditorOptions.Create;
|
||||
|
@ -81,10 +81,7 @@ begin
|
||||
// Show splashform
|
||||
if ShowSplashScreen then begin
|
||||
SplashForm := TSplashForm.Create(nil);
|
||||
with SplashForm do begin
|
||||
Show;
|
||||
Paint;
|
||||
end;
|
||||
SplashForm.Show;
|
||||
Application.ProcessMessages; // process splash paint message
|
||||
end;
|
||||
|
||||
|
@ -4127,7 +4127,6 @@ var
|
||||
SrcEdit: TSourceEditor;
|
||||
OldFilename: String;
|
||||
NewResFilename: String;
|
||||
NewHighlighter: TLazSyntaxHighlighter;
|
||||
AmbiguousFiles: TStringList;
|
||||
AmbiguousText: string;
|
||||
i: Integer;
|
||||
|
@ -402,6 +402,7 @@ type
|
||||
procedure BookmarkSetFreeClicked(Sender: TObject);
|
||||
procedure BookMarkToggle(Value: Integer);
|
||||
procedure EditorPropertiesClicked(Sender: TObject);
|
||||
procedure HighlighterClicked(Sender: TObject);
|
||||
procedure FindDeclarationClicked(Sender: TObject);
|
||||
procedure MoveEditorLeftClicked(Sender: TObject);
|
||||
procedure MoveEditorRightClicked(Sender: TObject);
|
||||
@ -3411,6 +3412,25 @@ begin
|
||||
FOnEditorPropertiesClicked(Sender);
|
||||
end;
|
||||
|
||||
procedure TSourceNotebook.HighlighterClicked(Sender: TObject);
|
||||
var
|
||||
IDEMenuItem: TIDEMenuItem;
|
||||
i: LongInt;
|
||||
SrcEdit: TSourceEditor;
|
||||
h: TLazSyntaxHighlighter;
|
||||
begin
|
||||
if Sender is TIDEMenuItem then begin
|
||||
IDEMenuItem:=TIDEMenuItem(Sender);
|
||||
i:=IDEMenuItem.SectionIndex;
|
||||
if (i>=ord(Low(TLazSyntaxHighlighter)))
|
||||
and (i<=ord(High(TLazSyntaxHighlighter))) then begin
|
||||
h:=TLazSyntaxHighlighter(i);
|
||||
SrcEdit:=GetActiveSE;
|
||||
SrcEdit.SyntaxHighlighterType:=h;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSourceNotebook.SrcPopUpMenuPopup(Sender: TObject);
|
||||
var
|
||||
ASrcEdit: TSourceEditor;
|
||||
@ -3621,10 +3641,29 @@ procedure TSourceNotebook.UpdateHighlightMenuItems;
|
||||
var
|
||||
h: TLazSyntaxHighlighter;
|
||||
i: Integer;
|
||||
CurName: String;
|
||||
CurCaption: String;
|
||||
IDEMenuItem: TIDEMenuItem;
|
||||
SrcEdit: TSourceEditor;
|
||||
begin
|
||||
SrcEditMenuSectionHighlighter.ChildsAsSubMenu:=true;
|
||||
SrcEdit:=GetActiveSE;
|
||||
i:=0;
|
||||
for h:=Low(TLazSyntaxHighlighter) to High(TLazSyntaxHighlighter) do begin
|
||||
|
||||
CurName:='Highlighter'+IntToStr(i);
|
||||
CurCaption:=LazSyntaxHighlighterNames[h];
|
||||
if SrcEditMenuSectionHighlighter.Count=i then begin
|
||||
// add new item
|
||||
IDEMenuItem:=RegisterIDEMenuCommand(SrcEditMenuSectionHighlighter,
|
||||
CurName,CurCaption,@HighlighterClicked);
|
||||
end else begin
|
||||
IDEMenuItem:=SrcEditMenuSectionHighlighter[i];
|
||||
IDEMenuItem.Caption:=CurCaption;
|
||||
IDEMenuItem.OnClick:=@HighlighterClicked;
|
||||
end;
|
||||
if IDEMenuItem is TIDEMenuCommand then
|
||||
TIDEMenuCommand(IDEMenuItem).Checked:=(SrcEdit<>nil)
|
||||
and (SrcEdit.SyntaxHighlighterType=h);
|
||||
inc(i);
|
||||
end;
|
||||
end;
|
||||
|
@ -249,7 +249,7 @@ function ClassCase(const AClass: TClass; const ACase: array of TClass; const ADe
|
||||
// MG: Should be moved to the RTL
|
||||
function UTF8CharacterLength(p: PChar): integer;
|
||||
function UTF8Length(const s: string): integer;
|
||||
function UTF8Length(p: PChar; Count: integer): integer;
|
||||
function UTF8Length(p: PChar; ByteCount: integer): integer;
|
||||
function UTF8CharacterToUnicode(p: PChar; out CharLen: integer): Cardinal;
|
||||
function UnicodeToUTF8(u: cardinal): string;
|
||||
function UTF8ToDoubleByteString(const s: string): string;
|
||||
@ -1886,16 +1886,16 @@ begin
|
||||
Result:=UTF8Length(PChar(s),length(s));
|
||||
end;
|
||||
|
||||
function UTF8Length(p: PChar; Count: integer): integer;
|
||||
function UTF8Length(p: PChar; ByteCount: integer): integer;
|
||||
var
|
||||
CharLen: LongInt;
|
||||
begin
|
||||
Result:=0;
|
||||
while (Count>0) do begin
|
||||
while (ByteCount>0) do begin
|
||||
inc(Result);
|
||||
CharLen:=UTF8CharacterLength(p);
|
||||
inc(p,CharLen);
|
||||
dec(Count,CharLen);
|
||||
dec(ByteCount,CharLen);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user