From da09c34c3269ff5c8d86b23fd1322b480b291c22 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 9 Mar 2016 21:50:51 +0100 Subject: [PATCH] init commit --- Script/rylon.ysc | 1 + Script/ycfg.ysc | 17 ++++ TextPad.cfg | 35 +++++++ TextPad.dof | 83 +++++++++++++++ TextPad.dpr | 14 +++ TextPad.res | Bin 0 -> 876 bytes main.dfm | 103 +++++++++++++++++++ main.pas | 255 +++++++++++++++++++++++++++++++++++++++++++++++ textpad.ycfg | 12 +++ tpscript.pas | 164 ++++++++++++++++++++++++++++++ 10 files changed, 684 insertions(+) create mode 100644 Script/rylon.ysc create mode 100644 Script/ycfg.ysc create mode 100644 TextPad.cfg create mode 100644 TextPad.dof create mode 100644 TextPad.dpr create mode 100644 TextPad.res create mode 100644 main.dfm create mode 100644 main.pas create mode 100644 textpad.ycfg create mode 100644 tpscript.pas diff --git a/Script/rylon.ysc b/Script/rylon.ysc new file mode 100644 index 0000000..ec58298 --- /dev/null +++ b/Script/rylon.ysc @@ -0,0 +1 @@ +ladida;;;255;;;;;; \ No newline at end of file diff --git a/Script/ycfg.ysc b/Script/ycfg.ysc new file mode 100644 index 0000000..25a7de4 --- /dev/null +++ b/Script/ycfg.ysc @@ -0,0 +1,17 @@ +//text;FontName;FontSize;FontColor;Bold;Italic;Underline;StrikeOut;Großkleinschreibung beachten? +=;;;255;;;;;; +0;;;8421376;;;;;; +1;;;8421376;;;;;; +2;;;8421376;;;;;; +3;;;8421376;;;;;; +4;;;8421376;;;;;; +5;;;8421376;;;;;; +6;;;8421376;;;;;; +7;;;8421376;;;;;; +8;;;8421376;;;;;; +9;;;8421376;;;;;; +//;;;16711935;;1;;;; +ö;;;255;;;1;;; +ä;;;255;;;1;;; +ü;;;255;;;1;;; +ß;;;255;;;1;;; \ No newline at end of file diff --git a/TextPad.cfg b/TextPad.cfg new file mode 100644 index 0000000..1884010 --- /dev/null +++ b/TextPad.cfg @@ -0,0 +1,35 @@ +-$A8 +-$B- +-$C+ +-$D+ +-$E- +-$F- +-$G+ +-$H+ +-$I+ +-$J- +-$K- +-$L+ +-$M- +-$N+ +-$O+ +-$P+ +-$Q- +-$R- +-$S- +-$T- +-$U- +-$V+ +-$W- +-$X+ +-$YD +-$Z1 +-cg +-AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; +-H+ +-W+ +-M +-$M16384,1048576 +-K$00400000 +-LE"c:\programme\delphi\delphi 6\Projects\Bpl" +-LN"c:\programme\delphi\delphi 6\Projects\Bpl" diff --git a/TextPad.dof b/TextPad.dof new file mode 100644 index 0000000..e93a303 --- /dev/null +++ b/TextPad.dof @@ -0,0 +1,83 @@ +[FileVersion] +Version=6.0 +[Compiler] +A=8 +B=0 +C=1 +D=1 +E=0 +F=0 +G=1 +H=1 +I=1 +J=0 +K=0 +L=1 +M=0 +N=1 +O=1 +P=1 +Q=0 +R=0 +S=0 +T=0 +U=0 +V=1 +W=0 +X=1 +Y=1 +Z=1 +ShowHints=1 +ShowWarnings=1 +UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; +[Linker] +MapFile=0 +OutputObjs=0 +ConsoleApp=1 +DebugInfo=0 +RemoteSymbols=0 +MinStackSize=16384 +MaxStackSize=1048576 +ImageBase=4194304 +ExeDescription= +[Directories] +OutputDir= +UnitOutputDir= +PackageDLLOutputDir= +PackageDCPOutputDir= +SearchPath= +Packages=vcl;rtl;vclx;VclSmp;vclshlctrls;fileinfo;gif;rotlab;Zip;Indy60;semipanel;trayico;MivSkinComponents +Conditionals= +DebugSourceDirs= +UsePackages=0 +[Parameters] +RunParams= +HostApplication= +Launcher= +UseLauncher=0 +DebugCWD= +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1031 +CodePage=1252 +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= diff --git a/TextPad.dpr b/TextPad.dpr new file mode 100644 index 0000000..49a900f --- /dev/null +++ b/TextPad.dpr @@ -0,0 +1,14 @@ +program TextPad; + +uses + Forms, + main in 'main.pas' {fTextPad}, + tpscript in 'tpscript.pas'; + +{$R *.res} + +begin + Application.Initialize; + Application.CreateForm(TfTextPad, fTextPad); + Application.Run; +end. diff --git a/TextPad.res b/TextPad.res new file mode 100644 index 0000000000000000000000000000000000000000..466ff97afdde6a4d8fd145dc81a01ecec516c763 GIT binary patch literal 876 zcmd5*Ar8Vo5ZnR@sUa13Dv|sE2nqo_i8>_M{-z0ncQiFfa1{;1EX&a=A%tLHa&x

gJG-MK!6EYCHPUv}!M1)I{!~%Dwl4TjA7PJWs zu)y8=(#xM9Oq-wmw{x2A{076c+2He;YTpp*+51B^`wysAHFsEA8%$aoO!+XlLTzvl zeG%~vmoe}Os{v4MjpqZ9?}4HK4mq$n0oxK7l0 then setycfgbool(temps,'Bold',true) else setycfgbool(temps,'Bold',false); + if Integer(fsItalic in Text.Font.Style)>0 then setycfgbool(temps,'Italic',true) else setycfgbool(temps,'Italic',false); + if Integer(fsUnderline in Text.Font.Style)>0 then setycfgbool(temps,'Underline',true) else setycfgbool(temps,'Underline',false); + if Integer(fsStrikeOut in Text.Font.Style)>0 then setycfgbool(temps,'StrikeOut',true) else setycfgbool(temps,'StrikeOut',false); + + temps.SaveToFile(extractfilepath(Application.exename)+'textpad.ycfg'); + + temps.Free; + end; + +end; + +procedure TfTextPad.Exit1Click(Sender: TObject); +begin + + Application.Terminate; + +end; + +procedure TfTextPad.Schrift1Click(Sender: TObject); +begin + + dSchrift.Font:=text.Font; + if dSchrift.Execute then text.Font:=dSchrift.Font; + +end; + +procedure TfTextPad.About1Click(Sender: TObject); +begin + + showabout(Application); + +end; + +procedure TfTextPad.FormCreate(Sender: TObject); +begin + + loadconfig; + + Script:=TScript.Create; + + Script.loadscript(scriptname); + + textname:=''; + + open.InitialDir:=extractfilepath(Application.exename); + save.InitialDir:=extractfilepath(Application.exename); + + text.SelLength:=2; + +end; + +procedure TfTextPad.FormClose(Sender: TObject; var Action: TCloseAction); +begin + + saveconfig; + +end; + +function TfTextPad.askReally:word; +begin + + result:=messagedlg('Du hast nocht gespeichert - Daten Speichern?',mtwarning,[mbyes,mbno,mbAbort],0); + +end; + +procedure TfTextPad.Save1Click(Sender: TObject); +var temps:TStringlist; +begin + + temps:=TStringlist.Create; + + temps.Text:=text.Lines.Text; + + if textname='' then + begin + if save.Execute then + begin + textname:=save.FileName; + temps.SaveToFile(textname); + + end; + end else temps.SaveToFile(textname); + + text.Modified:=false; + + fTextPad.caption:='TextPad - '+extractfilename(textname); + + temps.Free; + +end; + +procedure TfTextPad.Saveas1Click(Sender: TObject); +var temps:TStringlist; +begin + + temps:=TStringlist.Create; + + temps.Text:=text.Lines.Text; + + if save.Execute then + begin + textname:=save.FileName; + temps.SaveToFile(textname); + end; + + text.Modified:=false; + + fTextPad.caption:='TextPad - '+extractfilename(textname); + + temps.Free; + +end; + +procedure TfTextPad.Open1Click(Sender: TObject); +var tempw:word; +begin + + if text.Modified then + begin + tempw:=askReally; + + if tempw=mryes then Save1Click(self); + if tempw=mrabort then exit; + end; + + if open.Execute then + begin + textname:=open.FileName; + text.Lines.LoadFromFile(textname); + end; + + text.Modified:=false; + + fTextPad.caption:='TextPad - '+extractfilename(textname); + +end; + +procedure TfTextPad.FormCloseQuery(Sender: TObject; var CanClose: Boolean); +var tempw:word; +begin + + if text.Modified then + begin + tempw:=askReally; + + if tempw=mryes then Save1Click(self); + if tempw=mrabort then canclose:=false; + end; + +end; + +procedure TfTextPad.textChange(Sender: TObject); +var temp:TPoint; +begin + + text.SelLength:=2; + + if script.changedebug then script.setRich(text); + +end; + +end. diff --git a/textpad.ycfg b/textpad.ycfg new file mode 100644 index 0000000..fa21ddb --- /dev/null +++ b/textpad.ycfg @@ -0,0 +1,12 @@ +//textpad config + +//Font +Font=Fixedsys +Fontsize=10 +Bold=1 +Italic=0 +Color=0 +Underline=0 +StrikeOut=0 + +Script=Script\ycfg.ysc diff --git a/tpscript.pas b/tpscript.pas new file mode 100644 index 0000000..ec9e1e2 --- /dev/null +++ b/tpscript.pas @@ -0,0 +1,164 @@ +unit tpscript; + +interface + +uses sysutils,classes,ycfg,ComCtrls,Graphics,dialogs,windows; + +type TScriptPart = class + public + Text:string; + FontName:string; + FontSize:integer; + FontColor:integer; + Bold:integer; + Italic:integer; + Underline:integer; + StrikeOut:integer; + Grosskleinschreibung:boolean; + BisZeilenEnde:boolean; + NurSeperiert:boolean; + VorrigesWort:boolean; + NaechstesWort:boolean; + +end; + +type TScript = class + public + ScriptParts:array of TScriptPart; + changedebug:boolean; + Font:TFont; + + procedure loadscript(Filepath:string); + procedure setRich(Rich:TRichedit); + + destructor destroy; + constructor create; +end; + +implementation + +constructor Tscript.create; +begin + + changedebug:=true; + +end; + +procedure TScript.setRich(Rich:TRichedit); +var i,j:integer; + tempp:TPoint; + font:TFont; +begin + + for i:=0 to length(ScriptParts)-1 do + begin + if ScriptParts[i].Grosskleinschreibung then + begin + if lowercase(copy(rich.lines.text,length(rich.lines.Text)-length(ScriptParts[i].text)-1,length(ScriptParts[i].text)))=lowercase(ScriptParts[i].text) then + begin + tempp:=rich.CaretPos; + font:=rich.Font; + changedebug:=false; + rich.Lines.BeginUpdate; + + rich.SelStart:=length(rich.lines.Text)-length(ScriptParts[i].text)-2; + rich.SelLength:=length(ScriptParts[i].text); + + changedebug:=false; + + if ScriptParts[i].FontName<>'' then rich.SelAttributes.Name:=ScriptParts[i].FontName; + if ScriptParts[i].FontSize>0 then rich.SelAttributes.Size:=ScriptParts[i].FontSize; + if ScriptParts[i].FontColor>0 then rich.SelAttributes.Color:=ScriptParts[i].FontColor; + if ScriptParts[i].Bold=0 then rich.SelAttributes.Style:=rich.SelAttributes.Style-[fsbold]; + if ScriptParts[i].Bold=1 then rich.SelAttributes.Style:=rich.SelAttributes.Style+[fsbold]; + if ScriptParts[i].italic=0 then rich.SelAttributes.Style:=rich.SelAttributes.Style-[fsitalic]; + if ScriptParts[i].italic=1 then rich.SelAttributes.Style:=rich.SelAttributes.Style+[fsitalic]; + if ScriptParts[i].underline=0 then rich.SelAttributes.Style:=rich.SelAttributes.Style-[fsunderline]; + if ScriptParts[i].underline=1 then rich.SelAttributes.Style:=rich.SelAttributes.Style+[fsunderline]; + if ScriptParts[i].strikeout=0 then rich.SelAttributes.Style:=rich.SelAttributes.Style-[fsstrikeout]; + if ScriptParts[i].strikeout=1 then rich.SelAttributes.Style:=rich.SelAttributes.Style+[fsstrikeout]; + + rich.CaretPos:=tempp; + rich.SelLength:=2; + rich.Font:=font; + rich.Lines.EndUpdate; + changedebug:=true; + end; + end else + begin + if lowercase(copy(rich.lines.text,length(rich.lines.Text)-length(ScriptParts[i].text)-1,length(ScriptParts[i].text)))=lowercase(ScriptParts[i].text) then + begin + tempp:=rich.CaretPos; + font:=rich.Font; + changedebug:=false; + rich.Lines.BeginUpdate; + + rich.SelStart:=length(rich.lines.Text)-length(ScriptParts[i].text)-2; + rich.SelLength:=length(ScriptParts[i].text); + + changedebug:=false; + + if ScriptParts[i].FontName<>'' then rich.SelAttributes.Name:=ScriptParts[i].FontName; + if ScriptParts[i].FontSize>0 then rich.SelAttributes.Size:=ScriptParts[i].FontSize; + if ScriptParts[i].FontColor>0 then rich.SelAttributes.Color:=ScriptParts[i].FontColor; + if ScriptParts[i].Bold=0 then rich.SelAttributes.Style:=rich.SelAttributes.Style-[fsbold]; + if ScriptParts[i].Bold=1 then rich.SelAttributes.Style:=rich.SelAttributes.Style+[fsbold]; + if ScriptParts[i].italic=0 then rich.SelAttributes.Style:=rich.SelAttributes.Style-[fsitalic]; + if ScriptParts[i].italic=1 then rich.SelAttributes.Style:=rich.SelAttributes.Style+[fsitalic]; + if ScriptParts[i].underline=0 then rich.SelAttributes.Style:=rich.SelAttributes.Style-[fsunderline]; + if ScriptParts[i].underline=1 then rich.SelAttributes.Style:=rich.SelAttributes.Style+[fsunderline]; + if ScriptParts[i].strikeout=0 then rich.SelAttributes.Style:=rich.SelAttributes.Style-[fsstrikeout]; + if ScriptParts[i].strikeout=1 then rich.SelAttributes.Style:=rich.SelAttributes.Style+[fsstrikeout]; + + rich.CaretPos:=tempp; + rich.SelLength:=2; + rich.Font:=font; + rich.Lines.EndUpdate; + changedebug:=true; + end; + end; + end; + +end; + +procedure TScript.loadscript(Filepath:string); +var temps:TStringlist; + i:integer; +begin + + if fileexists(filepath) then + begin + temps:=TStringlist.create; + temps.LoadFromFile(filepath); + for i:=0 to temps.Count-1 do + begin + if getnumberofdivides(temps.Strings[i],';')>=9 then + begin + setlength(Scriptparts,length(scriptparts)+1); + Scriptparts[length(scriptparts)-1]:=TScriptpart.Create; + Scriptparts[length(scriptparts)-1].Text:=dividestring(temps.Strings[i],';',1); + Scriptparts[length(scriptparts)-1].FontName:=dividestring(temps.Strings[i],';',2); + Scriptparts[length(scriptparts)-1].FontSize:=strtointdef(dividestring(temps.Strings[i],';',3),-1); + Scriptparts[length(scriptparts)-1].FontColor:=strtointdef(dividestring(temps.Strings[i],';',4),-1); + Scriptparts[length(scriptparts)-1].Bold:=strtointdef(dividestring(temps.Strings[i],';',5),-1); + Scriptparts[length(scriptparts)-1].Italic:=strtointdef(dividestring(temps.Strings[i],';',6),-1); + Scriptparts[length(scriptparts)-1].Underline:=strtointdef(dividestring(temps.Strings[i],';',7),-1); + Scriptparts[length(scriptparts)-1].StrikeOut:=strtointdef(dividestring(temps.Strings[i],';',8),-1); + if dividestring(temps.Strings[i],';',9)='1' then Scriptparts[length(scriptparts)-1].Grosskleinschreibung:=true else Scriptparts[length(scriptparts)-1].Grosskleinschreibung:=false; + end; + end; + temps.Free; + end; + +end; + +destructor TScript.destroy; +var i:integer; +begin + + for i:=0 to length(ScriptParts)-1 do Scriptparts[i].Free; + +end; + +end. +