From e4f766c12870a58ca33664d58d27248ade04705e Mon Sep 17 00:00:00 2001 From: mattias Date: Sat, 26 Jul 2003 14:16:26 +0000 Subject: [PATCH] added synedit example git-svn-id: trunk@4428 - --- .gitattributes | 1 + examples/Makefile | 37 +++++++++++++++-- examples/Makefile.fpc | 4 +- examples/synedit1.pas | 94 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 131 insertions(+), 5 deletions(-) create mode 100644 examples/synedit1.pas diff --git a/.gitattributes b/.gitattributes index 9391d6f1c0..033619d04f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -287,6 +287,7 @@ examples/scrollbar.pp svneol=native#text/pascal examples/selection.pp svneol=native#text/pascal examples/selectionform.pp svneol=native#text/pascal examples/speedtest.pp svneol=native#text/pascal +examples/synedit1.pas svneol=native#text/pascal examples/testall.pp svneol=native#text/pascal examples/testallform.pp svneol=native#text/pascal examples/testtools.inc svneol=native#text/pascal diff --git a/examples/Makefile b/examples/Makefile index d5d6ea3eb2..aa767685b4 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -1,5 +1,5 @@ # -# Don't edit, this file is generated by FPCMake Version 1.1 [2003/06/20] +# Don't edit, this file is generated by FPCMake Version 1.1 [2003/06/26] # default: all MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx netware openbsd wdosx palmos macos darwin emx @@ -212,8 +212,8 @@ LCL_PLATFORM=gtk endif export LCL_PLATFORM endif -override TARGET_UNITS+=hello notebk comdialogs progressbar trackbar listboxtest bitbutton combobox checkbox scrollbar edittest memotest groupbox speedtest toolbar messagedialogs notebooktest listviewtest testall -override CLEAN_FILES+=$(wildcard *$(OEXT)) $(wildcard *$(PPUEXT)) trackbar toolbar testall speedtest scrollbar progressbar notebooktest notebk messagedialogs memotest listviewtest listboxtest hello groupbox edittest comdialogs combobox checkbox bitbutton +override TARGET_UNITS+=hello notebk comdialogs progressbar trackbar listboxtest bitbutton combobox checkbox scrollbar edittest memotest groupbox speedtest toolbar messagedialogs notebooktest listviewtest synedit1 testall +override CLEAN_FILES+=$(wildcard *$(OEXT)) $(wildcard *$(PPUEXT)) trackbar toolbar testall speedtest scrollbar progressbar notebooktest notebk messagedialogs memotest listviewtest listboxtest hello groupbox edittest comdialogs combobox checkbox bitbutton synedit1 override COMPILER_OPTIONS+=-gl override COMPILER_UNITDIR+=../lcl/units ../lcl/units/$(LCL_PLATFORM) ../components/units .. . ifdef REQUIRE_UNITSDIR @@ -894,6 +894,7 @@ REQUIRE_PACKAGES_RTL=1 REQUIRE_PACKAGES_PASZLIB=1 REQUIRE_PACKAGES_NETDB=1 REQUIRE_PACKAGES_LIBASYNC=1 +REQUIRE_PACKAGES_PTHREADS=1 REQUIRE_PACKAGES_FCL=1 REQUIRE_PACKAGES_REGEXPR=1 REQUIRE_PACKAGES_MYSQL=1 @@ -906,6 +907,7 @@ REQUIRE_PACKAGES_RTL=1 REQUIRE_PACKAGES_PASZLIB=1 REQUIRE_PACKAGES_NETDB=1 REQUIRE_PACKAGES_LIBASYNC=1 +REQUIRE_PACKAGES_PTHREADS=1 REQUIRE_PACKAGES_FCL=1 REQUIRE_PACKAGES_REGEXPR=1 REQUIRE_PACKAGES_MYSQL=1 @@ -918,6 +920,7 @@ REQUIRE_PACKAGES_RTL=1 REQUIRE_PACKAGES_PASZLIB=1 REQUIRE_PACKAGES_NETDB=1 REQUIRE_PACKAGES_LIBASYNC=1 +REQUIRE_PACKAGES_PTHREADS=1 REQUIRE_PACKAGES_FCL=1 REQUIRE_PACKAGES_REGEXPR=1 REQUIRE_PACKAGES_MYSQL=1 @@ -930,6 +933,7 @@ REQUIRE_PACKAGES_RTL=1 REQUIRE_PACKAGES_PASZLIB=1 REQUIRE_PACKAGES_NETDB=1 REQUIRE_PACKAGES_LIBASYNC=1 +REQUIRE_PACKAGES_PTHREADS=1 REQUIRE_PACKAGES_FCL=1 REQUIRE_PACKAGES_REGEXPR=1 REQUIRE_PACKAGES_MYSQL=1 @@ -942,6 +946,7 @@ REQUIRE_PACKAGES_RTL=1 REQUIRE_PACKAGES_PASZLIB=1 REQUIRE_PACKAGES_NETDB=1 REQUIRE_PACKAGES_LIBASYNC=1 +REQUIRE_PACKAGES_PTHREADS=1 REQUIRE_PACKAGES_FCL=1 REQUIRE_PACKAGES_REGEXPR=1 REQUIRE_PACKAGES_MYSQL=1 @@ -1276,6 +1281,32 @@ ifdef UNITDIR_LIBASYNC override COMPILER_UNITDIR+=$(UNITDIR_LIBASYNC) endif endif +ifdef REQUIRE_PACKAGES_PTHREADS +PACKAGEDIR_PTHREADS:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /pthreads/Makefile.fpc,$(PACKAGESDIR)))))) +ifneq ($(PACKAGEDIR_PTHREADS),) +ifneq ($(wildcard $(PACKAGEDIR_PTHREADS)/$(OS_TARGET)),) +UNITDIR_PTHREADS=$(PACKAGEDIR_PTHREADS)/$(OS_TARGET) +else +UNITDIR_PTHREADS=$(PACKAGEDIR_PTHREADS) +endif +ifdef CHECKDEPEND +$(PACKAGEDIR_PTHREADS)/$(FPCMADE): + $(MAKE) -C $(PACKAGEDIR_PTHREADS) $(FPCMADE) +override ALLDEPENDENCIES+=$(PACKAGEDIR_PTHREADS)/$(FPCMADE) +endif +else +PACKAGEDIR_PTHREADS= +UNITDIR_PTHREADS:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /pthreads/Package.fpc,$(UNITSDIR))))) +ifneq ($(UNITDIR_PTHREADS),) +UNITDIR_PTHREADS:=$(firstword $(UNITDIR_PTHREADS)) +else +UNITDIR_PTHREADS= +endif +endif +ifdef UNITDIR_PTHREADS +override COMPILER_UNITDIR+=$(UNITDIR_PTHREADS) +endif +endif ifdef REQUIRE_PACKAGES_FCL PACKAGEDIR_FCL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /fcl/Makefile.fpc,$(PACKAGESDIR)))))) ifneq ($(PACKAGEDIR_FCL),) diff --git a/examples/Makefile.fpc b/examples/Makefile.fpc index 5d7426e63e..6588e72b1b 100644 --- a/examples/Makefile.fpc +++ b/examples/Makefile.fpc @@ -10,7 +10,7 @@ version=0.9b units=hello notebk comdialogs progressbar trackbar listboxtest \ bitbutton combobox checkbox scrollbar edittest memotest \ groupbox speedtest toolbar messagedialogs notebooktest \ - listviewtest testall + listviewtest synedit1 testall [require] packages=fcl regexpr @@ -19,7 +19,7 @@ packages=fcl regexpr files=$(wildcard *$(OEXT)) $(wildcard *$(PPUEXT)) \ trackbar toolbar testall speedtest scrollbar progressbar notebooktest \ notebk messagedialogs memotest listviewtest listboxtest hello groupbox \ - edittest comdialogs combobox checkbox bitbutton + edittest comdialogs combobox checkbox bitbutton synedit1 [default] diff --git a/examples/synedit1.pas b/examples/synedit1.pas new file mode 100644 index 0000000000..b05e6d4b6b --- /dev/null +++ b/examples/synedit1.pas @@ -0,0 +1,94 @@ +{ + *************************************************************************** + * * + * This source is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This code is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * General Public License for more details. * + * * + * A copy of the GNU General Public License is available on the World * + * Wide Web at . You can also * + * obtain it by writing to the Free Software Foundation, * + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * * + *************************************************************************** +} +program synedit1; + +{$mode objfpc}{$H+} + +uses + Interfaces, Classes, SysUtils, Forms, Controls, GraphType, Graphics, SynEdit, + SynHighlighterPas; + +type + TForm1 = class(TForm) + SynEdit1: TSynEdit; + PascalHighligher: TSynPasSyn; + procedure Form1Resize(Sender: TObject); + private + procedure LoadText(const Filename: string); + public + constructor Create(TheOwner: TComponent); override; + destructor Destroy; override; + end; + +{ TForm1 } + +procedure TForm1.Form1Resize(Sender: TObject); +begin + with SynEdit1 do + SetBounds(10,10,Parent.ClientWidth-10,Parent.ClientHeight-20); +end; + +procedure TForm1.LoadText(const Filename: string); +begin + SynEdit1.Lines.LoadFromFile(Filename); +end; + +constructor TForm1.Create(TheOwner: TComponent); +begin + inherited Create(TheOwner); + SetBounds(10,20,620,400); + OnResize:=@Form1Resize; + + SynEdit1:=TSynEdit.Create(Self); + with SynEdit1 do begin + Parent:=Self; + + end; + + PascalHighligher:=TSynPasSyn.Create(Self); + with PascalHighligher do begin + CommentAttri.Foreground:=clBlue; + CommentAttri.Style:=[fsBold]; + KeyAttri.Style:=[fsBold]; + StringAttri.Foreground:=clBlue; + SymbolAttri.Foreground:=clRed; + end; + + SynEdit1.Highlighter:=PascalHighligher; + + LoadText('synedit1.pas'); + OnResize(nil); +end; + +destructor TForm1.Destroy; +begin + inherited Destroy; +end; + +var + Form1: TForm1; + +begin + Application.Initialize; + Application.CreateForm(TForm1, Form1); + Application.Run; +end. +