mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-17 14:49:28 +02:00
MG: added multi language syntax hilighting
git-svn-id: trunk@459 -
This commit is contained in:
parent
33efd6b9a0
commit
4262f9a291
@ -137,6 +137,9 @@ type
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
{$IFDEF SYN_LAZARUS}
|
||||
procedure AddSpecialAttribute(const AttribName: string);
|
||||
{$ENDIF}
|
||||
procedure Assign(Source: TPersistent); override;
|
||||
function GetEol: Boolean; virtual; abstract;
|
||||
function GetRange: Pointer; virtual;
|
||||
@ -726,6 +729,13 @@ begin
|
||||
fAttributes.AddObject(AAttrib.Name, AAttrib);
|
||||
end;
|
||||
|
||||
{$IFDEF SYN_LAZARUS}
|
||||
procedure TSynCustomHighlighter.AddSpecialAttribute(const AttribName: string);
|
||||
begin
|
||||
AddAttribute(TSynHighlighterAttributes.Create(AttribName));
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
procedure TSynCustomHighlighter.DefHighlightChange(Sender: TObject);
|
||||
begin
|
||||
fAttrChangeHooks.Fire;
|
||||
|
@ -2035,7 +2035,6 @@ begin
|
||||
fTokenID := tkComment;
|
||||
Inc(Run, 3);
|
||||
end else begin
|
||||
|
||||
if fLine[Run]= '%' then begin
|
||||
fRange := rsASP;
|
||||
fTokenID := tkASP;
|
||||
@ -2044,9 +2043,7 @@ begin
|
||||
fRange := rsKey;
|
||||
fTokenID := tkSymbol;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
procedure TSynHTMLSyn.CRProc;
|
||||
|
@ -1073,6 +1073,8 @@ begin
|
||||
fRange := rsUnknown;
|
||||
fAsmStart := False;
|
||||
fDefaultFilter := SYNS_FilterPascal;
|
||||
|
||||
|
||||
end; { Create }
|
||||
|
||||
procedure TSynPasSyn.SetLine(const NewValue: string; LineNumber:Integer);
|
||||
|
1752
ide/editoroptions.pp
1752
ide/editoroptions.pp
File diff suppressed because it is too large
Load Diff
@ -11,7 +11,7 @@
|
||||
|
||||
{ $DEFINE IDE_MEM_CHECK}
|
||||
|
||||
{ $DEFINE IDE_DEBUG}
|
||||
{$DEFINE IDE_DEBUG}
|
||||
|
||||
// end.
|
||||
|
||||
|
17
ide/main.pp
17
ide/main.pp
@ -672,9 +672,11 @@ CheckHeap(IntToStr(GetMem_Cnt));
|
||||
Project.Free;
|
||||
Project:=nil;
|
||||
end;
|
||||
TheControlSelection.OnChange:=nil;
|
||||
TheControlSelection.Free;
|
||||
TheControlSelection:=nil;
|
||||
if TheControlSelection<>nil then begin
|
||||
TheControlSelection.OnChange:=nil;
|
||||
TheControlSelection.Free;
|
||||
TheControlSelection:=nil;
|
||||
end;
|
||||
FormEditor1.Free;
|
||||
FormEditor1:=nil;
|
||||
PropertyEditorHook1.Free;
|
||||
@ -2631,7 +2633,9 @@ writeln('[TMainIDE.DoOpenEditorFile] B');
|
||||
NewPageName:=copy(NewPageName,1,length(NewPageName)-length(Ext));
|
||||
if NewpageName='' then NewPageName:='file';
|
||||
end;
|
||||
writeln('[TMainIDE.DoOpenEditorFile] B2');
|
||||
SourceNotebook.NewFile(NewPageName,NewUnitInfo.Source);
|
||||
writeln('[TMainIDE.DoOpenEditorFile] B3');
|
||||
NewSrcEdit:=SourceNotebook.GetActiveSE;
|
||||
if not ProjectLoading then
|
||||
Project.InsertEditorIndex(SourceNotebook.NoteBook.PageIndex)
|
||||
@ -2649,9 +2653,13 @@ writeln('[TMainIDE.DoOpenEditorFile] B');
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
writeln('[TMainIDE.DoOpenEditorFile] B4');
|
||||
NewUnitInfo.EditorIndex:=SourceNotebook.NoteBook.PageIndex;
|
||||
writeln('[TMainIDE.DoOpenEditorFile] B5');
|
||||
NewSrcEdit.SyntaxHighlighterType:=NewUnitInfo.SyntaxHighlighter;
|
||||
writeln('[TMainIDE.DoOpenEditorFile] B6');
|
||||
NewSrcEdit.EditorComponent.CaretXY:=NewUnitInfo.CursorPos;
|
||||
writeln('[TMainIDE.DoOpenEditorFile] B7');
|
||||
NewSrcEdit.EditorComponent.TopLine:=NewUnitInfo.TopLine;
|
||||
NewSrcEdit.EditorComponent.LeftChar:=1;
|
||||
|
||||
@ -4759,6 +4767,9 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.159 2001/11/27 15:06:11 lazarus
|
||||
MG: added multi language syntax hilighting
|
||||
|
||||
Revision 1.158 2001/11/22 14:28:30 lazarus
|
||||
MG: cropped all component icons
|
||||
|
||||
|
@ -377,7 +377,7 @@ const
|
||||
);
|
||||
|
||||
var
|
||||
aHighlighter: TSynPasSyn;
|
||||
Highlighters: array[TLazSyntaxHighlighter] of TSynCustomHighlighter;
|
||||
aCompletion : TSynCompletion;
|
||||
scompl : TSynBaseCompletion; //used in ccexecute and cccomplete
|
||||
CurrentCompletionType: TCompletionType;
|
||||
@ -904,12 +904,12 @@ var i:integer;
|
||||
AllMarks: TSynEditMarks;
|
||||
begin
|
||||
if ErrorLine=Line then begin
|
||||
FG:=EditorOpts.ErrorLineElement.Foreground;
|
||||
BG:=EditorOpts.ErrorLineElement.Background;
|
||||
EditorOpts.GetSpecialLineColors(TCustomSynEdit(Sender).Highlighter,
|
||||
ahaErrorLine,FG,BG);
|
||||
Special:=true;
|
||||
end else if ExecutionLine=Line then begin
|
||||
FG:=EditorOpts.ExecutionPointElement.Foreground;
|
||||
BG:=EditorOpts.ExecutionPointElement.Background;
|
||||
EditorOpts.GetSpecialLineColors(TCustomSynEdit(Sender).Highlighter,
|
||||
ahaExecutionPoint,FG,BG);
|
||||
Special:=true;
|
||||
end else begin
|
||||
fEditor.Marks.GetMarksForLine(Line, AllMarks);
|
||||
@ -917,15 +917,15 @@ begin
|
||||
if (AllMarks[i]<>nil) then begin
|
||||
if (AllMarks[i].ImageIndex=TSrcEditMarkerImgIndex[semActiveBreakPoint])
|
||||
then begin
|
||||
FG:=EditorOpts.EnabledBreakPointElement.Foreground;
|
||||
BG:=EditorOpts.EnabledBreakPointElement.Background;
|
||||
EditorOpts.GetSpecialLineColors(TCustomSynEdit(Sender).Highlighter,
|
||||
ahaEnabledBreakpoint,FG,BG);
|
||||
Special:=true;
|
||||
exit;
|
||||
end else if
|
||||
(AllMarks[i].ImageIndex=TSrcEditMarkerImgIndex[semInactiveBreakPoint])
|
||||
then begin
|
||||
FG:=EditorOpts.DisabledBreakPointElement.Foreground;
|
||||
BG:=EditorOpts.DisabledBreakPointElement.Background;
|
||||
EditorOpts.GetSpecialLineColors(TCustomSynEdit(Sender).Highlighter,
|
||||
ahaDisabledBreakpoint,FG,BG);
|
||||
Special:=true;
|
||||
exit;
|
||||
end;
|
||||
@ -937,14 +937,16 @@ end;
|
||||
procedure TSourceEditor.SetSyntaxHighlighterType(
|
||||
ASyntaxHighlighterType: TLazSyntaxHighlighter);
|
||||
begin
|
||||
if (ASyntaxHighlighterType=fSyntaxHighlighterType)
|
||||
and ((FEditor.Highlighter=nil) xor EditorOpts.UseSyntaxHighlight) then exit;
|
||||
if EditorOpts.UseSyntaxHighlight then begin
|
||||
case ASyntaxHighlighterType of
|
||||
lshFreePascal,lshDelphi:
|
||||
FEditor.Highlighter:=aHighlighter;
|
||||
else
|
||||
FEditor.Highlighter:=nil;
|
||||
if Highlighters[ASyntaxHighlighterType]=nil then begin
|
||||
Highlighters[ASyntaxHighlighterType]:=
|
||||
EditorOpts.CreateSyn(ASyntaxHighlighterType);
|
||||
end;
|
||||
end else FEditor.Highlighter:=nil;
|
||||
FEditor.Highlighter:=Highlighters[ASyntaxHighlighterType];
|
||||
end else
|
||||
FEditor.Highlighter:=nil;
|
||||
if ASyntaxHighlighterType<>fSyntaxHighlighterType then begin
|
||||
fSyntaxHighlighterType:=ASyntaxHighlighterType;
|
||||
end;
|
||||
@ -968,12 +970,13 @@ end;
|
||||
|
||||
Function TSourceEditor.RefreshEditorSettings : Boolean;
|
||||
Begin
|
||||
Result := False;
|
||||
|
||||
EditorOpts.GetHighlighterSettings(aHighlighter);
|
||||
SetSyntaxHighlighterType(fSyntaxHighlighterType);
|
||||
|
||||
EditorOpts.GetSynEditSettings(FEditor);
|
||||
Result:=true;
|
||||
try
|
||||
SetSyntaxHighlighterType(fSyntaxHighlighterType);
|
||||
EditorOpts.GetSynEditSettings(FEditor);
|
||||
except
|
||||
Result:=false;
|
||||
end;
|
||||
end;
|
||||
|
||||
Function TSourceEditor.FindFile(const Value : String) : String;
|
||||
@ -1519,11 +1522,6 @@ begin
|
||||
FKeyStrokes:=TSynEditKeyStrokes.Create(Self);
|
||||
EditorOpts.KeyMap.AssignTo(FKeyStrokes);
|
||||
|
||||
aHighlighter:=TSynPasSyn.Create(AOwner);
|
||||
with aHighlighter do begin
|
||||
end;
|
||||
|
||||
|
||||
aCompletion := TSynCompletion.Create(AOwner);
|
||||
with aCompletion do
|
||||
Begin
|
||||
@ -2785,8 +2783,12 @@ end;
|
||||
Procedure TSourceNotebook.ReloadEditorOptions;
|
||||
var
|
||||
I : integer;
|
||||
h: TLazSyntaxHighlighter;
|
||||
Begin
|
||||
//this reloads the colors for the highlighter and other editor settings.
|
||||
for h:=Low(TLazSyntaxHighlighter) to High(TLazSyntaxHighlighter) do
|
||||
if Highlighters[h]<>nil then
|
||||
EditorOpts.GetHighlighterSettings(Highlighters[h]);
|
||||
for I := 0 to FSourceEditorList.Count-1 do
|
||||
TSourceEditor(FSourceEditorList.Items[i]).RefreshEditorSettings;
|
||||
|
||||
@ -2886,21 +2888,39 @@ begin
|
||||
if (Key=VK_ESCAPE) then ModalResult:=mrCancel;
|
||||
end;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
initialization
|
||||
aHighlighter:=nil;
|
||||
procedure InternalInit;
|
||||
var h: TLazSyntaxHighlighter;
|
||||
begin
|
||||
for h:=Low(TLazSyntaxHighlighter) to High(TLazSyntaxHighlighter) do
|
||||
Highlighters[h]:=nil;
|
||||
aCompletion:=nil;
|
||||
scompl:=nil;
|
||||
GotoDialog:=nil;
|
||||
IdentCompletionTimer:=nil;
|
||||
AWordCompletion:=nil;
|
||||
end;
|
||||
|
||||
procedure InternalFinal;
|
||||
var h: TLazSyntaxHighlighter;
|
||||
begin
|
||||
for h:=Low(TLazSyntaxHighlighter) to High(TLazSyntaxHighlighter) do begin
|
||||
Highlighters[h].Free;
|
||||
Highlighters[h]:=nil;
|
||||
end;
|
||||
aWordCompletion.Free;
|
||||
aWordCompletion:=nil;
|
||||
end;
|
||||
|
||||
|
||||
initialization
|
||||
InternalInit;
|
||||
|
||||
{$I images/bookmark.lrs}
|
||||
|
||||
finalization
|
||||
aWordCompletion.Free;
|
||||
aWordCompletion:=nil;
|
||||
|
||||
InternalFinal;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -95,10 +95,13 @@ var Message : TLMSetSel;
|
||||
begin
|
||||
if (Index < 0) or (Index >= Items.Count) then
|
||||
raise Exception.Create('List index out of bounds');
|
||||
//writeln('TCustomListBox.SetSelected A ',Items.Count);
|
||||
HandleNeeded;
|
||||
//writeln('TCustomListBox.SetSelected B ',Items.Count);
|
||||
Message.Index:= Index;
|
||||
Message.Selected:= Val;
|
||||
CNSendMessage(LM_SETSEL, Self, @Message);
|
||||
//writeln('TCustomListBox.SetSelected END ',Items.Count);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -107,7 +110,8 @@ end;
|
||||
function TCustomListBox.GetSelected(Index : integer) : boolean;
|
||||
begin
|
||||
if (Index < 0) or (Index >= Items.Count) then
|
||||
raise Exception.Create('List index out of bound.');
|
||||
raise Exception.Create('TCustomListBox.GetSelected: index '+IntToStr(Index)
|
||||
+' out of bound. Count='+IntToStr(Items.Count));
|
||||
Result:= (CNSendMessage(LM_GETSEL, Self, @Index) >= 0);
|
||||
end;
|
||||
|
||||
@ -162,12 +166,12 @@ end;
|
||||
{------------------------------------------------------------------------------}
|
||||
constructor TCustomListBox.Create(AOwner : TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
fCompStyle := csListBox;
|
||||
inherited Create(AOwner);
|
||||
fCompStyle := csListBox;
|
||||
|
||||
FBorderStyle:= bsSingle;
|
||||
SetBounds(1, 1, 100, 25);
|
||||
FItems := TStringList.Create;
|
||||
FBorderStyle:= bsSingle;
|
||||
FItems := TStringList.Create;
|
||||
SetBounds(1, 1, 100, 25);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
|
@ -37,7 +37,8 @@ end;
|
||||
constructor TGtkListStringList.Create(List : PGtkList);
|
||||
begin
|
||||
inherited Create;
|
||||
if List = nil then raise Exception.Create('Unspecified list widget');
|
||||
if List = nil then raise Exception.Create(
|
||||
'TGtkListStringList.Create Unspecified list widget');
|
||||
FGtkList:= List;
|
||||
end;
|
||||
|
||||
@ -84,13 +85,16 @@ end;
|
||||
procedure TGtkListStringList.Assign(Source : TPersistent);
|
||||
var Counter : integer;
|
||||
begin
|
||||
if (Source=Self) or (Source=nil) then exit;
|
||||
//writeln('[TGtkListStringList.Assign] A ',Source.Classname);
|
||||
if (Source=Self) or (Source=nil)
|
||||
or ((Source is TGtkListStringList)
|
||||
and (TGtkListStringList(Source).FGtkList=FGtkList)) then exit;
|
||||
//writeln('[TGtkListStringList.Assign] A ',Source.Classname,' Self=',HexStr(Cardinal(Self),8),' Source=',HexStr(Cardinal(Source),8));
|
||||
{ Do not call inherited Assign as it does things we do not want to happen }
|
||||
if Source is TStrings then begin
|
||||
Clear;
|
||||
for Counter:= TStrings(Source).Count - 1 downto 0 do
|
||||
for Counter:= TStrings(Source).Count - 1 downto 0 do begin
|
||||
Insert(0, TStrings(Source)[Counter]);
|
||||
end;
|
||||
end else inherited Assign(Source);
|
||||
//writeln('[TGtkListStringList.Assign] END ',Source.Classname);
|
||||
end;
|
||||
@ -133,8 +137,10 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
function TGtkListStringList.GetCount: integer;
|
||||
begin
|
||||
if FGtkList^.children = nil then Result:= 0
|
||||
else Result:= g_list_length(FGtkList^.children);
|
||||
if FGtkList^.children = nil then
|
||||
Result:= 0
|
||||
else
|
||||
Result:= g_list_length(FGtkList^.children);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -188,10 +194,13 @@ begin
|
||||
inc(m);
|
||||
Index:=m;
|
||||
end;
|
||||
if (Index < 0) or (Index > Count) then raise Exception.Create('Out of bounds.');
|
||||
li:= gtk_list_item_new_with_label(PChar(S));
|
||||
if (Index < 0) or (Index > Count) then
|
||||
raise Exception.Create('TGtkListStringList.Insert: Index '+IntToStr(Index)
|
||||
+' out of bounds. Count='+IntToStr(Count));
|
||||
li:=gtk_list_item_new_with_label(PChar(S));
|
||||
gtk_widget_show(li);
|
||||
gtk_list_insert_items(FGtkList, g_list_append(nil, li), Index);
|
||||
//writeln('[TGtkListStringList.Insert] END Index=',Index,' Count=',Count,' ',S,',',Count);
|
||||
end;
|
||||
|
||||
|
||||
@ -376,6 +385,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.4 2001/11/27 15:06:13 lazarus
|
||||
MG: added multi language syntax hilighting
|
||||
|
||||
Revision 1.3 2001/10/31 10:38:26 lazarus
|
||||
MG: fixed sorted customlistbox
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user