├── src ├── version.inc ├── ovotextfont.rc ├── ovotext.ico ├── ovotext.res ├── ovotextfont.res ├── ovotextfont.ttf ├── udglgoto.lrt ├── udmmain.lfm ├── ukeys.lrj ├── uabout.lrt ├── udglgoto.lrj ├── umacroplayback.lrj ├── ukeys.pas ├── umacroeditor.lrj ├── ukeys.lfm ├── codegen.inc ├── supportclasses.pas ├── platform │ ├── unix │ │ ├── platformpath.pas │ │ └── monitoringthread.pas │ └── win │ │ ├── platformpath.pas │ │ └── monitoringthread.pas ├── udglgoto.lfm ├── udlgsort.lrj ├── uabout.lrj ├── udglgoto.pas ├── udmmain.pas ├── ovotext.lpr ├── umacroplayback.pas ├── mycustomdialogs.pas ├── replacedialog.lrj ├── highlighters │ ├── SynDefines.inc │ ├── mysehighlighterrust.pas │ ├── mysehighlightergo.pas │ └── SynExportRTF.pas ├── uabout.pas ├── stringcostants.pas ├── umacroplayback.lfm ├── comparer.pas ├── udlgsort.pas ├── ureplacemacro.pas ├── iconloader.pas ├── printing │ ├── syneditprintmarginsdialog.pas │ ├── SynEditPrintTypes.pas │ └── syneditprinterinfo.pas ├── simplesingleinstance.pas ├── umacroeditor.pas ├── udlgsort.lfm ├── replacedialog.lfm ├── cmdlineparser.pas └── replacedialog.pas ├── testfile ├── TestFile-ansi.txt ├── TestFile-utf8.txt ├── TestFile-utf8-bom.txt ├── TestFile-utf16BE.txt └── TestFile-utf16LE.txt ├── images ├── ovotext.png ├── ovotext.xcf ├── icon-mapping.pdf └── ovotext.xpm ├── highgen ├── highgen.ico ├── highgen.res ├── highgen.lpr ├── unit1.lfm └── highgen.lpi ├── doc ├── Mapping-state.ods └── AliasMapping.txt ├── packages ├── lintian-overrides ├── changelog ├── ovotext.desktop ├── debian │ ├── DEBIAN │ │ └── control │ └── usr │ │ └── share │ │ └── pixmaps │ │ └── ovotext.xpm ├── control └── copyright ├── get_architecture.sh ├── DOC └── manpages │ └── ovotext.1 ├── .github ├── stale.yml └── workflows │ └── CI.yml ├── .gitignore ├── README.md ├── create_deb.sh └── color-schemas ├── schema-paste-dark.json ├── schema-default.json └── schema-son-of-obsidian.json /src/version.inc: -------------------------------------------------------------------------------- 1 | '0.1.0' -------------------------------------------------------------------------------- /src/ovotextfont.rc: -------------------------------------------------------------------------------- 1 | OVOFONT RCDATA "ovotextfont.ttf" 2 | -------------------------------------------------------------------------------- /testfile/TestFile-ansi.txt: -------------------------------------------------------------------------------- 1 | Test file 2 | 3 | 测试文件 4 | 5 | Тестовый файл -------------------------------------------------------------------------------- /testfile/TestFile-utf8.txt: -------------------------------------------------------------------------------- 1 | Test file 2 | 3 | 测试文件 4 | 5 | Тестовый файл -------------------------------------------------------------------------------- /src/ovotext.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varianus/ovotext/HEAD/src/ovotext.ico -------------------------------------------------------------------------------- /src/ovotext.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varianus/ovotext/HEAD/src/ovotext.res -------------------------------------------------------------------------------- /testfile/TestFile-utf8-bom.txt: -------------------------------------------------------------------------------- 1 | Test file 2 | 3 | 测试文件 4 | 5 | Тестовый файл -------------------------------------------------------------------------------- /images/ovotext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varianus/ovotext/HEAD/images/ovotext.png -------------------------------------------------------------------------------- /images/ovotext.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varianus/ovotext/HEAD/images/ovotext.xcf -------------------------------------------------------------------------------- /highgen/highgen.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varianus/ovotext/HEAD/highgen/highgen.ico -------------------------------------------------------------------------------- /highgen/highgen.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varianus/ovotext/HEAD/highgen/highgen.res -------------------------------------------------------------------------------- /src/ovotextfont.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varianus/ovotext/HEAD/src/ovotextfont.res -------------------------------------------------------------------------------- /src/ovotextfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varianus/ovotext/HEAD/src/ovotextfont.ttf -------------------------------------------------------------------------------- /doc/Mapping-state.ods: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varianus/ovotext/HEAD/doc/Mapping-state.ods -------------------------------------------------------------------------------- /images/icon-mapping.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varianus/ovotext/HEAD/images/icon-mapping.pdf -------------------------------------------------------------------------------- /testfile/TestFile-utf16BE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varianus/ovotext/HEAD/testfile/TestFile-utf16BE.txt -------------------------------------------------------------------------------- /testfile/TestFile-utf16LE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varianus/ovotext/HEAD/testfile/TestFile-utf16LE.txt -------------------------------------------------------------------------------- /packages/lintian-overrides: -------------------------------------------------------------------------------- 1 | ovotext: hardening-no-relro usr/bin/ovotext 2 | ovotext: extended-description-contains-empty-paragraph 3 | -------------------------------------------------------------------------------- /packages/changelog: -------------------------------------------------------------------------------- 1 | ovotext (0.1.0) UNSTABLE; urgency=low 2 | 3 | * First Release 4 | 5 | -- Marco Caselli Sun, 28 Oct 2018 00:01:00 +0100 6 | -------------------------------------------------------------------------------- /src/udglgoto.lrt: -------------------------------------------------------------------------------- 1 | TDLGGOTO.CAPTION=Go to 2 | TDLGGOTO.LABEL1.CAPTION=Line number 3 | TDLGGOTO.BUTTONPANEL1.OKBUTTON.CAPTION=Go to 4 | TDLGGOTO.LABEL2.CAPTION=Column number 5 | -------------------------------------------------------------------------------- /src/udmmain.lfm: -------------------------------------------------------------------------------- 1 | object dmMain: TdmMain 2 | OldCreateOrder = False 3 | Height = 313 4 | HorizontalOffset = 695 5 | VerticalOffset = 311 6 | Width = 725 7 | object imgBookMark: TImageList 8 | Left = 56 9 | Top = 24 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /get_architecture.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ARCH=$(uname -m) 4 | 5 | case "$ARCH" in 6 | 7 | "i686") ARCH="i386";; 8 | 9 | "i586") ARCH="i386";; 10 | 11 | "i486") ARCH="i386";; 12 | 13 | "x86_64") ARCH="amd64";; 14 | 15 | "armv7l") ARCH="armhf";; 16 | esac 17 | 18 | echo "$ARCH" 19 | 20 | -------------------------------------------------------------------------------- /packages/ovotext.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Version=1.0 3 | Encoding=UTF-8 4 | Name=OvoText 5 | GenericName=Text editor 6 | Comment=Text editor 7 | Categories=TextEditor 8 | Exec=/usr/bin/ovotext %F 9 | Hidden=false 10 | Icon=/usr/share/pixmaps/ovotext.xpm 11 | Terminal=false 12 | Type=Application 13 | MimeType=text/plain; 14 | -------------------------------------------------------------------------------- /DOC/manpages/ovotext.1: -------------------------------------------------------------------------------- 1 | .TH "OVOTEXT" "1" "0.1.0" "Marco Caselli" "User Commands" 2 | .SH "NAME" 3 | ovotext \- simple text editor 4 | .SH "SYNTAX" 5 | .LP 6 | \fBovotext\fR\ [files] 7 | .SH "DESCRIPTION" 8 | .LP 9 | ovotext is a simple text editor written in Lazarus/FreePascal. 10 | .SH "OPTIONS" 11 | .LP 12 | .TP 13 | None 14 | .SH "AUTHORS" 15 | .LP 16 | Marco Caselli 17 | -------------------------------------------------------------------------------- /src/ukeys.lrj: -------------------------------------------------------------------------------- 1 | {"version":1,"strings":[ 2 | {"hash":264512997,"name":"tfkeys.caption","sourcebytes":[75,101,121,115,116,114,111,107,101,115,32,116,97,98,108,101],"value":"Keystrokes table"}, 3 | {"hash":174340100,"name":"tfkeys.grdcommands.columns[0].title.caption","sourcebytes":[67,111,109,109,97,110,100],"value":"Command"}, 4 | {"hash":258584404,"name":"tfkeys.grdcommands.columns[1].title.caption","sourcebytes":[83,104,111,114,116,99,117,116],"value":"Shortcut"} 5 | ]} 6 | -------------------------------------------------------------------------------- /highgen/highgen.lpr: -------------------------------------------------------------------------------- 1 | program highgen; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | uses 6 | {$IFDEF UNIX}{$IFDEF UseCThreads} 7 | cthreads, 8 | {$ENDIF}{$ENDIF} 9 | Interfaces, // this includes the LCL widgetset 10 | Forms, Unit1, SupportFuncs 11 | { you can add units after this }; 12 | 13 | {$R *.res} 14 | 15 | begin 16 | RequireDerivedFormResource := True; 17 | Application.Initialize; 18 | Application.CreateForm(TForm1, Form1); 19 | Application.Run; 20 | end. 21 | 22 | -------------------------------------------------------------------------------- /src/uabout.lrt: -------------------------------------------------------------------------------- 1 | TFABOUT.CAPTION=About 2 | TFABOUT.LABEL1.CAPTION=OvoText 3 | TFABOUT.LABEL2.CAPTION=Version 4 | TFABOUT.LVERSION.CAPTION=Version 5 | TFABOUT.LABEL3.CAPTION=Author : Marco Caselli 6 | TFABOUT.LABEL4.CAPTION=Another text editor 7 | TFABOUT.LABEL6.CAPTION=Home Page 8 | TFABOUT.LHOMEPAGE.CAPTION=https://github.com/varianus/ovotext 9 | TFABOUT.BLICENSE.CAPTION=&License 10 | TFABOUT.LABEL7.CAPTION=FPC 11 | TFABOUT.LABEL5.CAPTION=Lazarus 12 | TFABOUT.LABEL8.CAPTION=Build Date 13 | TFABOUT.LABEL9.CAPTION=SVN rev: 14 | -------------------------------------------------------------------------------- /src/udglgoto.lrj: -------------------------------------------------------------------------------- 1 | {"version":1,"strings":[ 2 | {"hash":5117871,"name":"tdlggoto.caption","sourcebytes":[71,111,32,116,111],"value":"Go to"}, 3 | {"hash":118045874,"name":"tdlggoto.label1.caption","sourcebytes":[76,105,110,101,32,110,117,109,98,101,114],"value":"Line number"}, 4 | {"hash":5117871,"name":"tdlggoto.buttonpanel1.okbutton.caption","sourcebytes":[71,111,32,116,111],"value":"Go to"}, 5 | {"hash":221904002,"name":"tdlggoto.label2.caption","sourcebytes":[67,111,108,117,109,110,32,110,117,109,98,101,114],"value":"Column number"} 6 | ]} 7 | -------------------------------------------------------------------------------- /packages/debian/DEBIAN/control: -------------------------------------------------------------------------------- 1 | Package: ovotext 2 | Version: 0.1.0 3 | Section: editors 4 | Priority: optional 5 | Architecture: amd64 6 | Depends: libatk1.0-0, libc6, libcairo2, libgdk-pixbuf2.0-0, libglib2.0-0, libgtk2.0-0, libpango-1.0-0, libpangocairo-1.0-0, libx11-6 7 | Installed-Size: 7392 8 | Maintainer: marco caselli 9 | Description: ovotext is a simple text editor written in Lazarus/FreePascal. 10 | . 11 | Some features: 12 | . 13 | * Tabbed editor. 14 | * Syntax highligthing for a lot of programming languages and file formats. 15 | * Undo/Redo support. 16 | * Print with syntax highligthing. 17 | -------------------------------------------------------------------------------- /packages/control: -------------------------------------------------------------------------------- 1 | Package: ovotext 2 | Version: :VERSION 3 | Section: editors 4 | Priority: optional 5 | Architecture: :ARCHITECTURE 6 | Depends: libatk1.0-0, libc6, libcairo2, libgdk-pixbuf2.0-0, libglib2.0-0, libgtk2.0-0, libpango-1.0-0, libpangocairo-1.0-0, libx11-6 7 | Installed-Size: :INSTALLEDSIZE 8 | Maintainer: marco caselli 9 | Description: ovotext is a simple text editor written in Lazarus/FreePascal. 10 | . 11 | Some features: 12 | . 13 | * Tabbed editor. 14 | * Syntax highligthing for a lot of programming languages and file formats. 15 | * Undo/Redo support. 16 | * Print with syntax highligthing. 17 | -------------------------------------------------------------------------------- /src/umacroplayback.lrj: -------------------------------------------------------------------------------- 1 | {"version":1,"strings":[ 2 | {"hash":86415355,"name":"tfmacroplayback.caption","sourcebytes":[77,97,99,114,111,32,80,108,97,121,98,97,99,107],"value":"Macro Playback"}, 3 | {"hash":8061891,"name":"tfmacroplayback.label2.caption","sourcebytes":[116,105,109,101,115],"value":"times"}, 4 | {"hash":5470863,"name":"tfmacroplayback.label1.caption","sourcebytes":[77,97,99,114,111],"value":"Macro"}, 5 | {"hash":93088644,"name":"tfmacroplayback.chkrepeat.caption","sourcebytes":[82,101,112,101,97,116],"value":"Repeat"}, 6 | {"hash":197055621,"name":"tfmacroplayback.cbrepeatuntileof.caption","sourcebytes":[85,110,116,105,108,32,101,110,100,32,111,102,32,102,105,108,101],"value":"Until end of file"} 7 | ]} 8 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Number of days of inactivity before an issue becomes stale 2 | daysUntilStale: 60 3 | # Number of days of inactivity before a stale issue is closed 4 | daysUntilClose: 7 5 | # Issues with these labels will never be considered stale 6 | exemptLabels: 7 | - pinned 8 | - security 9 | # Label to use when marking an issue as stale 10 | staleLabel: wontfix 11 | # Comment to post when marking an issue as stale. Set to `false` to disable 12 | markComment: > 13 | This issue has been automatically marked as stale because it has not had 14 | recent activity. It will be closed if no further activity occurs. Thank you 15 | for your contributions. 16 | # Comment to post when closing a stale issue. Set to `false` to disable 17 | closeComment: false 18 | -------------------------------------------------------------------------------- /doc/AliasMapping.txt: -------------------------------------------------------------------------------- 1 | Comment#Comment|Documentation|Rpl comment|SASM Comment| 2 | String#String| 3 | Symbol#Brackets|Round Bracket|Square Bracket|Symbol| 4 | Number#Number| 5 | Key#Key|Rpl key|SASM Key|SQL keyword|SQL*Plus command|TeX Command| 6 | Float#Float| 7 | Hexadecimal#Hexadecimal| 8 | Reserved word#Reserved word|Reserved word (PL/SQL)|Second reserved word| 9 | Directive#IDE Directive|Include|Preprocessor|Processing Instruction| 10 | Character#Character| 11 | Variable#Special variable| 12 | Null#Null| 13 | Operator#Operator| 14 | Attribute Name#Element Name|Namespace Attribute Name| 15 | Attribute Value#CDATA|DOCTYPE|Namespace Attribute Value|Val| 16 | Macro#Pragma| 17 | Text#Embedded text|Text| 18 | Section#Asp|CDATA Section|DOCTYPE Section|Section| 19 | Data type#Data type| -------------------------------------------------------------------------------- /src/ukeys.pas: -------------------------------------------------------------------------------- 1 | unit uKeys; 2 | 3 | {$mode ObjFPC}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ButtonPanel, Grids, SynEditKeyCmds; 9 | 10 | type 11 | 12 | { TfKeys } 13 | 14 | TfKeys = class(TForm) 15 | ButtonPanel1: TButtonPanel; 16 | grdCommands: TStringGrid; 17 | private 18 | 19 | public 20 | procedure Initialize(Keys: TSynEditKeyStrokes); 21 | end; 22 | 23 | var 24 | fKeys: TfKeys; 25 | 26 | implementation 27 | 28 | {$R *.lfm} 29 | 30 | { TfKeys } 31 | uses LCLProc; 32 | 33 | procedure TfKeys.Initialize(Keys: TSynEditKeyStrokes); 34 | var 35 | Key: TSynEditKeyStroke; 36 | i: integer; 37 | begin 38 | grdCommands.Clear; 39 | IF Not assigned(Keys) then 40 | exit; 41 | 42 | grdCommands.RowCount := Keys.Count + 1; 43 | 44 | for i := 0 to Keys.Count - 1 do 45 | begin 46 | key := Keys[i]; 47 | grdCommands.Cells[0, i + 1] := EditorCommandToCodeString(Key.Command); 48 | grdCommands.Cells[1, i + 1] := ShortCutToText(Key.ShortCut); 49 | end; 50 | end; 51 | 52 | end. 53 | -------------------------------------------------------------------------------- /src/umacroeditor.lrj: -------------------------------------------------------------------------------- 1 | {"version":1,"strings":[ 2 | {"hash":59679858,"name":"tfmacroeditor.caption","sourcebytes":[77,97,99,114,111,32,101,100,105,116,111,114],"value":"Macro editor"}, 3 | {"hash":93079605,"name":"tfmacroeditor.btnrename.caption","sourcebytes":[82,101,110,97,109,101],"value":"Rename"}, 4 | {"hash":268236911,"name":"tfmacroeditor.btnplay.caption","sourcebytes":[80,108,97,121,98,97,99,107,32,109,97,99,114,111],"value":"Playback macro"}, 5 | {"hash":66640911,"name":"tfmacroeditor.btnrecord.caption","sourcebytes":[82,101,99,111,114,100,32,109,97,99,114,111],"value":"Record macro"}, 6 | {"hash":51041111,"name":"tfmacroeditor.btnrecordstop.caption","sourcebytes":[83,116,111,112,32,114,101,99,111,114,100,105,110,103],"value":"Stop recording"}, 7 | {"hash":78392485,"name":"tfmacroeditor.btndelete.caption","sourcebytes":[68,101,108,101,116,101],"value":"Delete"}, 8 | {"hash":93088644,"name":"tfmacroeditor.chkrepeat.caption","sourcebytes":[82,101,112,101,97,116],"value":"Repeat"}, 9 | {"hash":194958469,"name":"tfmacroeditor.cbrepeatuntileof.caption","sourcebytes":[117,110,116,105,108,32,101,110,100,32,111,102,32,102,105,108,101],"value":"until end of file"} 10 | ]} 11 | -------------------------------------------------------------------------------- /src/ukeys.lfm: -------------------------------------------------------------------------------- 1 | object fKeys: TfKeys 2 | Left = 300 3 | Height = 493 4 | Top = 250 5 | Width = 500 6 | Caption = 'Keystrokes table' 7 | ClientHeight = 493 8 | ClientWidth = 500 9 | LCLVersion = '4.99.0.0' 10 | object ButtonPanel1: TButtonPanel 11 | Left = 6 12 | Height = 34 13 | Top = 453 14 | Width = 488 15 | OKButton.Name = 'OKButton' 16 | OKButton.DefaultCaption = True 17 | HelpButton.Name = 'HelpButton' 18 | HelpButton.DefaultCaption = True 19 | CloseButton.Name = 'CloseButton' 20 | CloseButton.DefaultCaption = True 21 | CancelButton.Name = 'CancelButton' 22 | CancelButton.DefaultCaption = True 23 | TabOrder = 1 24 | ShowButtons = [pbClose] 25 | end 26 | object grdCommands: TStringGrid 27 | Left = 0 28 | Height = 447 29 | Top = 0 30 | Width = 500 31 | Align = alClient 32 | ColCount = 2 33 | Columns = < 34 | item 35 | Title.Caption = 'Command' 36 | Width = 300 37 | end 38 | item 39 | Title.Caption = 'Shortcut' 40 | Width = 150 41 | end> 42 | FixedCols = 0 43 | ScrollBars = ssBoth 44 | TabOrder = 0 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /packages/copyright: -------------------------------------------------------------------------------- 1 | Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=135 2 | Name: ovotext 3 | Maintainer: Marco Caselli 4 | Source: https://github.com/varianus/ovotext/ 5 | 6 | Files: * 7 | Copyright: 2011, Marco Caselli 8 | License: GPL-2+ 9 | This program is free software; you can redistribute it 10 | and/or modify it under the terms of the GNU General Public 11 | License as published by the Free Software Foundation; either 12 | version 2 of the License, or (at your option) any later 13 | version. 14 | . 15 | This program is distributed in the hope that it will be 16 | useful, but WITHOUT ANY WARRANTY; without even the implied 17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 18 | PURPOSE. See the GNU General Public License for more 19 | details. 20 | . 21 | You should have received a copy of the GNU General Public 22 | License along with this package; if not, write to the Free 23 | Software Foundation, Inc., 51 Franklin St, Fifth Floor, 24 | Boston, MA 02110-1301 USA 25 | . 26 | On Debian systems, the full text of the GNU General Public 27 | License version 2 can be found in the file 28 | `/usr/share/common-licenses/GPL-2'. 29 | -------------------------------------------------------------------------------- /src/codegen.inc: -------------------------------------------------------------------------------- 1 | { 2 | This file is part of OvoText 3 | Copyright (C) 2019 Marco Caselli 4 | 5 | OvoText is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | 19 | } 20 | // General options for code generation 21 | 22 | // compiler and interface mode 23 | {$mode objfpc}{$H+} 24 | {$interfaces corba} 25 | {$modeswitch ADVANCEDRECORDS} 26 | 27 | {$IFDEF WINDOWS} 28 | {$DEFINE DARKSTYLE} 29 | {$ENDIF} 30 | 31 | //if release is defined, try to be quiet and efficient... 32 | {$IF defined(Release)} 33 | {$HINTS OFF} 34 | {$INLINE ON} 35 | {$warn 6058 off} 36 | {$warn 5024 off} 37 | {$ENDIF} 38 | -------------------------------------------------------------------------------- /src/supportclasses.pas: -------------------------------------------------------------------------------- 1 | {$I codegen.inc} 2 | unit SupportClasses; 3 | 4 | interface 5 | 6 | uses 7 | Classes, SysUtils; 8 | 9 | type 10 | 11 | { THistory } 12 | 13 | THistory = class 14 | private 15 | FItems: TStrings; 16 | FMaxItems: integer; 17 | procedure SetMaxItems(AValue: integer); 18 | public 19 | constructor Create; 20 | destructor Destroy; override; 21 | procedure Add(AString: string); 22 | property Items: TStrings read FItems; 23 | property MaxItems: integer read FMaxItems write SetMaxItems; 24 | end; 25 | 26 | implementation 27 | 28 | { THistory } 29 | 30 | procedure THistory.SetMaxItems(AValue: integer); 31 | begin 32 | if FMaxItems = AValue then 33 | Exit; 34 | if AValue < FMaxItems then 35 | FItems.Capacity := AValue; 36 | FMaxItems := AValue; 37 | end; 38 | 39 | constructor THistory.Create; 40 | begin 41 | FItems := TStringList.Create; 42 | FMaxItems := 10; 43 | end; 44 | 45 | destructor THistory.Destroy; 46 | begin 47 | FItems.Free; 48 | inherited Destroy; 49 | end; 50 | 51 | procedure THistory.Add(AString: string); 52 | begin 53 | i := FItems.IndexOf(AString); 54 | if i = 0 then 55 | exit; 56 | else if i > 0 then 57 | FItems.Delete(i); 58 | FItems.Insert(0, AString); 59 | if FItems.Count > FMaxItems; 60 | fFileList.Delete(FMaxItems); 61 | end; 62 | 63 | end. 64 | -------------------------------------------------------------------------------- /src/platform/unix/platformpath.pas: -------------------------------------------------------------------------------- 1 | { Ovotext - simple text editor 2 | 3 | Copyright (C) 2015 Marco Caselli 4 | 5 | This source is free software; you can redistribute it and/or modify it under 6 | the terms of the GNU General Public License as published by the Free 7 | Software Foundation; either version 2 of the License, or (at your option) 8 | any later version. 9 | 10 | This code is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 13 | details. 14 | 15 | A copy of the GNU General Public License is available on the World Wide Web 16 | at . You can also obtain it by writing 17 | to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 18 | MA 02111-1307, USA. 19 | } 20 | {$I codegen.inc} 21 | unit platformpath; 22 | interface 23 | 24 | uses 25 | Classes, SysUtils; 26 | 27 | type 28 | 29 | { TPlatformPath } 30 | 31 | TPlatformPath = class 32 | RefCount: integer; 33 | Handle: Thandle; 34 | Path: string; 35 | constructor Create; 36 | end; 37 | 38 | implementation 39 | 40 | { TPlatformPath } 41 | 42 | constructor TPlatformPath.Create; 43 | begin 44 | RefCount := 0; 45 | Handle := feInvalidHandle; 46 | end; 47 | 48 | end. 49 | -------------------------------------------------------------------------------- /highgen/unit1.lfm: -------------------------------------------------------------------------------- 1 | object Form1: TForm1 2 | Left = 721 3 | Height = 347 4 | Top = 234 5 | Width = 503 6 | Caption = 'Color schema tools' 7 | ClientHeight = 347 8 | ClientWidth = 503 9 | object bConvert: TButton 10 | Left = 24 11 | Height = 57 12 | Top = 24 13 | Width = 168 14 | Caption = 'Convert Lazarus scheme' 15 | OnClick = bConvertClick 16 | TabOrder = 0 17 | end 18 | object bTemplate: TButton 19 | Left = 24 20 | Height = 57 21 | Top = 96 22 | Width = 168 23 | Caption = 'Create full template' 24 | OnClick = bTemplateClick 25 | TabOrder = 1 26 | end 27 | object bCreateSamples: TButton 28 | Left = 24 29 | Height = 57 30 | Top = 168 31 | Width = 168 32 | Caption = 'Create All sample files' 33 | OnClick = bCreateSamplesClick 34 | TabOrder = 2 35 | end 36 | object bConvert1: TButton 37 | Left = 216 38 | Height = 57 39 | Top = 24 40 | Width = 192 41 | Caption = 'Batch convert Lazarus scheme' 42 | OnClick = bConvert1Click 43 | TabOrder = 3 44 | end 45 | object OpenDialog1: TOpenDialog 46 | Filter = 'Color*.xml|Color*.xml' 47 | Left = 24 48 | Top = 200 49 | end 50 | object SaveDialog1: TSaveDialog 51 | Left = 120 52 | Top = 208 53 | end 54 | object SelectDirectoryDialogOut: TSelectDirectoryDialog 55 | Title = 'Select input folder' 56 | Left = 240 57 | Top = 208 58 | end 59 | object SelectDirectoryDialogIn: TSelectDirectoryDialog 60 | Title = 'Select output folder' 61 | Left = 240 62 | Top = 275 63 | end 64 | end 65 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Uncomment these types if you want even more clean repository. But be careful. 2 | # It can make harm to an existing project source. Read explanations below. 3 | # 4 | # Resource files are binaries containing manifest, project icon and version info. 5 | # They can not be viewed as text or compared by diff-tools. Consider replacing them with .rc files. 6 | #*.res 7 | # 8 | # Type library file (binary). In old Delphi versions it should be stored. 9 | # Since Delphi 2009 it is produced from .ridl file and can safely be ignored. 10 | #*.tlb 11 | # 12 | # Diagram Portfolio file. Used by the diagram editor up to Delphi 7. 13 | # Uncomment this if you are not using diagrams or use newer Delphi version. 14 | #*.ddp 15 | # 16 | # Visual LiveBindings file. Added in Delphi XE2. 17 | # Uncomment this if you are not using LiveBindings Designer. 18 | #*.vlb 19 | # 20 | # Deployment Manager configuration file for your project. Added in Delphi XE2. 21 | # Uncomment this if it is not mobile development and you do not use remote debug feature. 22 | #*.deployproj 23 | # 24 | ovotext 25 | # Delphi compiler-generated binaries (safe to delete) 26 | *.exe 27 | *.dbg 28 | *.dll 29 | *.bpl 30 | *.bpi 31 | *.dcp 32 | *.so 33 | *.apk 34 | *.drc 35 | *.map 36 | *.dres 37 | *.rsm 38 | *.tds 39 | *.ppu 40 | *.lib 41 | *.lps 42 | *.o 43 | *.a 44 | 45 | # Delphi autogenerated files (duplicated info) 46 | *.cfg 47 | *Resource.rc 48 | 49 | # Delphi local files (user-specific info) 50 | *.local 51 | *.identcache 52 | *.projdata 53 | *.tvsconfig 54 | *.dsk 55 | /bin 56 | # Delphi history and backups 57 | lib/ 58 | backup/ 59 | *.~* 60 | *.bak 61 | /.project 62 | 63 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## ovotext 2 | **Current state: alpha** 3 | 4 | ovotext is a simple text editor written in Lazarus/FreePascal. 5 | 6 | 7 | 8 | Some features: 9 | 10 | * Tabbed editor 11 | * Syntax highligthing for a lot of programming languages and file formats 12 | * Export formatted text to RTF or HTML file/clipboard 13 | * Undo/Redo support 14 | * Tools for text editing (change line endings, native XML/JSON/SQL beautifier, sort, change case and so on) 15 | * Support for various encoding (UTF-8, UCS2, ISO-8859-1, ecc.) 16 | * Print with syntax highligthing 17 | 18 | ### Development 19 | This application is built using Lazarus (version 2.1) and FreePascal compiler (version 3.2.0). 20 | For syntax highlighting it uses: 21 | 22 | * Synedit components, included in Lazarus, 23 | * Some additional highlighters, ported by John Kozikopoulos. [Download available here](http://mantis.freepascal.org/view.php?id=18248). 24 | * Synedit components for printing, ported to Lazarus by myself. 25 | 26 | 27 | ###License: GPLV2 28 | 29 | >Copyright (C) 2015 Marco Caselli 30 | 31 | >OvoText 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. 32 | 33 | >This program 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. 34 | 35 | >You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 36 | -------------------------------------------------------------------------------- /src/platform/win/platformpath.pas: -------------------------------------------------------------------------------- 1 | { Ovotext - simple text editor 2 | 3 | Copyright (C) 2015 Marco Caselli 4 | 5 | This source is free software; you can redistribute it and/or modify it under 6 | the terms of the GNU General Public License as published by the Free 7 | Software Foundation; either version 2 of the License, or (at your option) 8 | any later version. 9 | 10 | This code is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 13 | details. 14 | 15 | A copy of the GNU General Public License is available on the World Wide Web 16 | at . You can also obtain it by writing 17 | to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 18 | MA 02111-1307, USA. 19 | } 20 | {$I codegen.inc} 21 | unit platformpath; 22 | interface 23 | 24 | uses 25 | Classes, SysUtils, Windows, jwawinbase; 26 | 27 | type 28 | 29 | { TPlatformPath } 30 | 31 | TPlatformPath = class 32 | RefCount: integer; 33 | Path: string; 34 | fOverlapped: TOverlapped; 35 | Buffer: pbyte; 36 | Handle: THandle; 37 | constructor Create; 38 | destructor Destroy; override; 39 | end; 40 | 41 | implementation 42 | 43 | const 44 | READDIRECTORYCHANGESW_BUFFERSIZE = 4096; { TPlatformPath } 45 | 46 | constructor TPlatformPath.Create; 47 | begin 48 | RefCount := 0; 49 | Handle := feInvalidHandle; 50 | Buffer := GetMem(READDIRECTORYCHANGESW_BUFFERSIZE); 51 | end; 52 | 53 | destructor TPlatformPath.Destroy; 54 | begin 55 | Freemem(Buffer); 56 | inherited Destroy; 57 | end; 58 | 59 | end. 60 | -------------------------------------------------------------------------------- /src/udglgoto.lfm: -------------------------------------------------------------------------------- 1 | object dlgGoTo: TdlgGoTo 2 | Left = 885 3 | Height = 149 4 | Top = 384 5 | Width = 250 6 | BorderStyle = bsDialog 7 | Caption = 'Go to' 8 | ClientHeight = 149 9 | ClientWidth = 250 10 | Font.Height = -12 11 | LCLVersion = '4.99.0.0' 12 | OnShow = FormShow 13 | object seLine: TSpinEdit 14 | Left = 139 15 | Height = 23 16 | Top = 16 17 | Width = 98 18 | Alignment = taRightJustify 19 | MaxValue = 1 20 | TabOrder = 0 21 | Value = 1 22 | OnChange = seLineChange 23 | end 24 | object Label1: TLabel 25 | Left = 16 26 | Height = 17 27 | Top = 21 28 | Width = 116 29 | Alignment = taRightJustify 30 | AutoSize = False 31 | Caption = 'Line number' 32 | FocusControl = seLine 33 | ParentColor = False 34 | end 35 | object ButtonPanel1: TButtonPanel 36 | Left = 6 37 | Height = 34 38 | Top = 109 39 | Width = 238 40 | OKButton.Name = 'OKButton' 41 | OKButton.Caption = 'Go to' 42 | OKButton.OnClick = OKButtonClick 43 | HelpButton.Name = 'HelpButton' 44 | HelpButton.DefaultCaption = True 45 | CloseButton.Name = 'CloseButton' 46 | CloseButton.DefaultCaption = True 47 | CancelButton.Name = 'CancelButton' 48 | CancelButton.DefaultCaption = True 49 | TabOrder = 2 50 | ShowButtons = [pbOK, pbCancel] 51 | end 52 | object Label2: TLabel 53 | Left = 16 54 | Height = 17 55 | Top = 61 56 | Width = 116 57 | Alignment = taRightJustify 58 | AutoSize = False 59 | Caption = 'Column number' 60 | FocusControl = seColumn 61 | ParentColor = False 62 | end 63 | object seColumn: TSpinEdit 64 | Left = 139 65 | Height = 23 66 | Top = 56 67 | Width = 98 68 | Alignment = taRightJustify 69 | TabOrder = 1 70 | Value = 1 71 | end 72 | end 73 | -------------------------------------------------------------------------------- /src/udlgsort.lrj: -------------------------------------------------------------------------------- 1 | {"version":1,"strings":[ 2 | {"hash":187475700,"name":"tdlgsort.caption","sourcebytes":[100,108,103,83,111,114,116],"value":"dlgSort"}, 3 | {"hash":370324,"name":"tdlgsort.buttonpanel1.okbutton.caption","sourcebytes":[83,111,114,116],"value":"Sort"}, 4 | {"hash":4861987,"name":"tdlgsort.rbcolumnmode.caption","sourcebytes":[83,111,114,116,32,111,110,32,102,105,120,101,100,32,99,111,108,117,109,110,115],"value":"Sort on fixed columns"}, 5 | {"hash":252461609,"name":"tdlgsort.rbdelimitedmode.caption","sourcebytes":[83,111,114,116,32,100,101,108,105,109,105,116,101,100,32,116,101,120,116,32,40,67,83,86,41],"value":"Sort delimited text (CSV)"}, 6 | {"hash":4767230,"name":"tdlgsort.label1.caption","sourcebytes":[66,101,103,105,110],"value":"Begin"}, 7 | {"hash":19524,"name":"tdlgsort.label2.caption","sourcebytes":[69,110,100],"value":"End"}, 8 | {"hash":78003262,"name":"tdlgsort.label3.caption","sourcebytes":[67,111,108,117,109,110],"value":"Column"}, 9 | {"hash":4456611,"name":"tdlgsort.cgdelimiters.caption","sourcebytes":[68,101,108,105,109,105,116,101,114,115],"value":"Delimiters"}, 10 | {"hash":34,"name":"tdlgsort.cbquotechar.text","sourcebytes":[34],"value":"\""}, 11 | {"hash":18544002,"name":"tdlgsort.label4.caption","sourcebytes":[81,117,111,116,105,110,103,32,99,104,97,114],"value":"Quoting char"}, 12 | {"hash":32,"name":"tdlgsort.edchar.text","sourcebytes":[32],"value":" "}, 13 | {"hash":5671618,"name":"tdlgsort.rgorder.caption","sourcebytes":[79,114,100,101,114],"value":"Order"}, 14 | {"hash":150262642,"name":"tdlgsort.cbnumeric.caption","sourcebytes":[83,111,114,116,32,97,110,121,32,118,97,108,117,101,32,116,104,97,116,32,108,111,111,107,115,32,108,105,107,101,32,97,32,110,117,109,98,101,114,32,97,115,32,105,102,32,105,116,32,119,101,114,101,32,97,32,110,117,109,98,101,114],"value":"Sort any value that looks like a number as if it were a number"} 15 | ]} 16 | -------------------------------------------------------------------------------- /src/uabout.lrj: -------------------------------------------------------------------------------- 1 | {"version":1,"strings":[ 2 | {"hash":4691652,"name":"tfabout.caption","sourcebytes":[65,98,111,117,116],"value":"About"}, 3 | {"hash":114601124,"name":"tfabout.label1.caption","sourcebytes":[79,118,111,84,101,120,116],"value":"OvoText"}, 4 | {"hash":214540302,"name":"tfabout.label2.caption","sourcebytes":[86,101,114,115,105,111,110],"value":"Version"}, 5 | {"hash":214540302,"name":"tfabout.lversion.caption","sourcebytes":[86,101,114,115,105,111,110],"value":"Version"}, 6 | {"hash":90281113,"name":"tfabout.label3.caption","sourcebytes":[65,117,116,104,111,114,32,58,32,77,97,114,99,111,32,67,97,115,101,108,108,105],"value":"Author : Marco Caselli"}, 7 | {"hash":177695874,"name":"tfabout.label4.caption","sourcebytes":[65,110,111,116,104,101,114,32,116,101,120,116,32,101,100,105,116,111,114],"value":"Another text editor"}, 8 | {"hash":58009781,"name":"tfabout.label6.caption","sourcebytes":[72,111,109,101,32,80,97,103,101],"value":"Home Page"}, 9 | {"hash":1119172,"name":"tfabout.lhomepage.caption","sourcebytes":[104,116,116,112,115,58,47,47,103,105,116,104,117,98,46,99,111,109,47,118,97,114,105,97,110,117,115,47,111,118,111,116,101,120,116],"value":"https://github.com/varianus/ovotext"}, 10 | {"hash":49923877,"name":"tfabout.blicense.caption","sourcebytes":[38,76,105,99,101,110,115,101],"value":"&License"}, 11 | {"hash":19267,"name":"tfabout.label7.caption","sourcebytes":[70,80,67],"value":"FPC"}, 12 | {"hash":43026835,"name":"tfabout.label5.caption","sourcebytes":[76,97,122,97,114,117,115],"value":"Lazarus"}, 13 | {"hash":39859365,"name":"tfabout.label8.caption","sourcebytes":[66,117,105,108,100,32,68,97,116,101],"value":"Build Date"}, 14 | {"hash":20493008,"name":"tfabout.label11.caption","sourcebytes":[73,99,111,110,115,32,97,114,101,32,102,114,111,109,32],"value":"Icons are from "}, 15 | {"hash":207650499,"name":"tfabout.lhomepage2.caption","sourcebytes":[104,116,116,112,115,58,47,47,103,105,116,104,117,98,46,99,111,109,47,75,68,69,47,98,114,101,101,122,101,45,105,99,111,110,115],"value":"https://github.com/KDE/breeze-icons"} 16 | ]} 17 | -------------------------------------------------------------------------------- /src/udglgoto.pas: -------------------------------------------------------------------------------- 1 | { Ovotext - simple text editor 2 | 3 | Copyright (C) 2015 Marco Caselli 4 | 5 | This source is free software; you can redistribute it and/or modify it under 6 | the terms of the GNU General Public License as published by the Free 7 | Software Foundation; either version 2 of the License, or (at your option) 8 | any later version. 9 | 10 | This code is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 13 | details. 14 | 15 | A copy of the GNU General Public License is available on the World Wide Web 16 | at . You can also obtain it by writing 17 | to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 18 | MA 02111-1307, USA. 19 | } 20 | {$I codegen.inc} 21 | unit uDglGoTo; 22 | 23 | interface 24 | 25 | uses 26 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Spin, 27 | StdCtrls, ButtonPanel, ueditor; 28 | 29 | type 30 | 31 | { TdlgGoTo } 32 | 33 | TdlgGoTo = class(TForm) 34 | ButtonPanel1: TButtonPanel; 35 | Label1: TLabel; 36 | Label2: TLabel; 37 | seLine: TSpinEdit; 38 | seColumn: TSpinEdit; 39 | procedure FormShow(Sender: TObject); 40 | procedure OKButtonClick(Sender: TObject); 41 | procedure seLineChange(Sender: TObject); 42 | private 43 | { private declarations } 44 | public 45 | Editor : TEditor; 46 | end; 47 | 48 | var 49 | dlgGoTo: TdlgGoTo; 50 | 51 | implementation 52 | 53 | {$R *.lfm} 54 | 55 | { TdlgGoTo } 56 | 57 | procedure TdlgGoTo.FormShow(Sender: TObject); 58 | begin 59 | seLine.MaxValue:= Editor.Lines.Count; 60 | end; 61 | 62 | procedure TdlgGoTo.OKButtonClick(Sender: TObject); 63 | begin 64 | Editor.CaretXY := Point(seColumn.Value, seLine.Value); 65 | end; 66 | 67 | procedure TdlgGoTo.seLineChange(Sender: TObject); 68 | begin 69 | seColumn.MaxValue:= Length(Editor.Lines[seLine.Value]); 70 | end; 71 | 72 | end. 73 | 74 | -------------------------------------------------------------------------------- /src/udmmain.pas: -------------------------------------------------------------------------------- 1 | { Ovotext - simple text editor 2 | 3 | Copyright (C) 2015 Marco Caselli 4 | 5 | This source is free software; you can redistribute it and/or modify it under 6 | the terms of the GNU General Public License as published by the Free 7 | Software Foundation; either version 2 of the License, or (at your option) 8 | any later version. 9 | 10 | This code is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 13 | details. 14 | 15 | A copy of the GNU General Public License is available on the World Wide Web 16 | at . You can also obtain it by writing 17 | to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 18 | MA 02111-1307, USA. 19 | } 20 | {$I codegen.inc} 21 | unit udmmain; 22 | 23 | interface 24 | 25 | uses 26 | Classes, SysUtils, Forms, Dialogs, Controls, 27 | SupportFuncs, SynEditHighlighter, SynExportHTML, Graphics, config, 28 | SynExportRTF; 29 | 30 | 31 | type 32 | 33 | { TdmMain } 34 | 35 | TdmMain = class(TDataModule) 36 | imgBookMark: TImageList; 37 | private 38 | fRTFExporter : TSynExporterRTF; 39 | fHTMLExporter : TSynExporterHTML; 40 | function GetSynExporterHTML: TSynExporterHTML; 41 | function GetSynExporterRTF: TSynExporterRTF; 42 | 43 | public 44 | Property RFTExporter: TSynExporterRTF read GetSynExporterRTF; 45 | Property HTMLExporter: TSynExporterHTML read GetSynExporterHTML; 46 | end; 47 | 48 | var 49 | dmMain: TdmMain; 50 | 51 | 52 | implementation 53 | 54 | uses lclproc; 55 | 56 | {$R *.lfm} 57 | 58 | { TdmMain } 59 | 60 | function TdmMain.GetSynExporterHTML: TSynExporterHTML; 61 | begin 62 | if not Assigned(fHTMLExporter) then 63 | fHTMLExporter:= TSynExporterHTML.Create(Self); 64 | result := fHTMLExporter; 65 | end; 66 | 67 | function TdmMain.GetSynExporterRTF: TSynExporterRTF; 68 | begin 69 | if not Assigned(fRTFExporter) then 70 | fRTFExporter:= TSynExporterRTF.Create(Self); 71 | result := fRTFExporter; 72 | end; 73 | 74 | 75 | end. 76 | -------------------------------------------------------------------------------- /src/ovotext.lpr: -------------------------------------------------------------------------------- 1 | { Ovotext - simple text editor 2 | 3 | Copyright (C) 2015 Marco Caselli 4 | 5 | This source is free software; you can redistribute it and/or modify it under 6 | the terms of the GNU General Public License as published by the Free 7 | Software Foundation; either version 2 of the License, or (at your option) 8 | any later version. 9 | 10 | This code is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 13 | details. 14 | 15 | A copy of the GNU General Public License is available on the World Wide Web 16 | at . You can also obtain it by writing 17 | to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 18 | MA 02111-1307, USA. 19 | } 20 | {$I codegen.inc} 21 | program ovotext; 22 | 23 | uses 24 | {$IFDEF UNIX} 25 | cthreads, 26 | {$ENDIF} 27 | Interfaces, // this includes the LCL widgetset 28 | Forms, DefaultTranslator, singleinstance, 29 | printer4lazarus, SynEditPrintExtProcs, 30 | // Dark style 31 | {$IFDEF DARKSTYLE} 32 | uDarkStyleParams, 33 | uDarkStyleSchemes, 34 | uMetaDarkStyle, 35 | {$ENDIF} 36 | //projects unit 37 | umain, uabout, udmmain, Stringcostants, SupportFuncs, config, 38 | uCheckFileChange, udglgoto, simplemrumanager, uMacroEditor, uActionMacro, 39 | uReplaceMacro, uMacroRecorder, ReplaceDialog, LazLogger, SimpleSingleInstance, 40 | JsonTools, umacroplayback, iconloader, udlgsort, Comparer, CmdLineParser; 41 | 42 | {$R *.res} 43 | begin 44 | Application.SingleInstanceClass:= DefaultSingleInstanceClass; 45 | Application.SingleInstanceEnabled:= True; 46 | TSimpleSingleInstance(Application.SingleInstance).DefaultMessage := '--show'; 47 | Application.Initialize; 48 | Application.Scaled := True; 49 | {$IFDEF DARKSTYLE} 50 | PreferredAppMode := pamDefault; 51 | uMetaDarkStyle.ApplyMetaDarkStyle(DefaultDark); 52 | {$ENDIF} 53 | 54 | if Application.SingleInstance.StartResult <> siClient then 55 | begin 56 | Application.CreateForm(TdmMain, dmMain); 57 | Application.CreateForm(TfMain, fMain); 58 | Application.Run; 59 | end 60 | else 61 | begin 62 | Application.Free; 63 | end; 64 | 65 | end. 66 | 67 | -------------------------------------------------------------------------------- /src/umacroplayback.pas: -------------------------------------------------------------------------------- 1 | unit umacroplayback; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, ExtCtrls, Spin, StdCtrls, ButtonPanel, 9 | uMacroRecorder, ueditor; 10 | 11 | type 12 | 13 | { TfMacroPlayBack } 14 | 15 | TfMacroPlayBack = class(TForm) 16 | ButtonPanel1: TButtonPanel; 17 | cbMacro: TComboBox; 18 | cbRepeatUntilEof: TRadioButton; 19 | chkRepeat: TRadioButton; 20 | edRepeat: TSpinEdit; 21 | Label1: TLabel; 22 | Label2: TLabel; 23 | PanelRepeat: TPanel; 24 | procedure CloseButtonClick(Sender: TObject); 25 | procedure OKButtonClick(Sender: TObject); 26 | private 27 | SynMacroRec: TMacroRecorder; 28 | procedure ReloadMacros; 29 | public 30 | 31 | end; 32 | 33 | procedure ShowMacroPlayBack(Recorder: TMacroRecorder); 34 | 35 | implementation 36 | uses 37 | Config; 38 | var 39 | fMacroPlayBack: TfMacroPlayBack; 40 | 41 | {$R *.lfm} 42 | 43 | procedure ShowMacroPlayBack(Recorder: TMacroRecorder); 44 | begin 45 | if not Assigned(fMacroPlayBack) then 46 | fMacroPlayBack := TfMacroPlayBack.Create(Nil); 47 | fMacroPlayBack.SynMacroRec:= Recorder; 48 | fMacroPlayBack.ReloadMacros; 49 | fMacroPlayBack.Show; 50 | 51 | end; 52 | 53 | { TfMacroPlayBack } 54 | 55 | procedure TfMacroPlayBack.OKButtonClick(Sender: TObject); 56 | var 57 | ed : TEditor; 58 | begin 59 | ed := SynMacroRec.Factory.CurrentEditor; 60 | if not Assigned(ed) then 61 | exit; 62 | 63 | if not Assigned(cbMacro.Items.Objects[cbMacro.ItemIndex]) then 64 | exit; 65 | 66 | ed.SetFocus; 67 | if chkRepeat.Checked then 68 | SynMacroRec.Playback(TMacro(cbMacro.Items.Objects[cbMacro.ItemIndex]), True, edRepeat.Value) 69 | else 70 | if cbRepeatUntilEof.Checked then 71 | SynMacroRec.Playback(TMacro(cbMacro.Items.Objects[cbMacro.ItemIndex]), True, -1) 72 | else 73 | SynMacroRec.Playback(TMacro(cbMacro.Items.Objects[cbMacro.ItemIndex])); 74 | end; 75 | 76 | procedure TfMacroPlayBack.CloseButtonClick(Sender: TObject); 77 | begin 78 | Self.Close; 79 | end; 80 | 81 | procedure TfMacroPlayBack.ReloadMacros; 82 | var 83 | Macro: TMacro; 84 | i: Integer; 85 | begin 86 | cbMacro.Clear; 87 | for i := 0 to SynMacroRec.Macros.Count - 1 do 88 | begin 89 | Macro := SynMacroRec.Macros[i]; 90 | cbMacro.Items.AddObject(Macro.Name, Macro); 91 | end; 92 | end; 93 | 94 | end. 95 | 96 | -------------------------------------------------------------------------------- /src/mycustomdialogs.pas: -------------------------------------------------------------------------------- 1 | unit mycustomdialogs; 2 | 3 | {$mode objfpc}{$H+} 4 | 5 | interface 6 | 7 | uses 8 | Classes, SysUtils, controls, ExtCtrls, forms, Dialogs, LazLogger; 9 | 10 | type 11 | 12 | { TMyReplaceDialog } 13 | TSearchMode = (smNormal, smExtended, smRegexp); 14 | 15 | TMyReplaceDialog = class(TReplaceDialog) 16 | private 17 | rgSearchMode: TRadioGroup; 18 | FSearchMode: TSearchMode; 19 | procedure SetSearchMode(AValue: TSearchMode); 20 | protected 21 | function CreateForm: TForm; override; 22 | procedure SetFormValues; override; 23 | procedure GetFormValues; override; 24 | public 25 | property SearchMode: TSearchMode read FSearchMode write SetSearchMode; 26 | end; 27 | 28 | implementation 29 | 30 | procedure TMyReplaceDialog.SetSearchMode(AValue: TSearchMode); 31 | begin 32 | if FSearchMode = AValue then Exit; 33 | FSearchMode := AValue; 34 | 35 | end; 36 | 37 | { TMyReplaceDialog } 38 | function TMyReplaceDialog.CreateForm: TForm; 39 | var 40 | i: Integer; 41 | begin 42 | Result := inherited CreateForm; 43 | rgSearchMode := TRadioGroup.Create(Result); 44 | with rgSearchMode do 45 | begin 46 | AnchorSideLeft.Side := asrBottom; 47 | Parent := result; 48 | AnchorSideTop.Side := asrBottom; 49 | AnchorSideBottom.Side := asrCenter; 50 | Left := 8; 51 | Height := 107; 52 | Top := 197; 53 | Width := 168; 54 | AutoFill := True; 55 | BorderSpacing.Left := 12; 56 | Caption := 'Search Mode'; 57 | ChildSizing.LeftRightSpacing := 6; 58 | ChildSizing.TopBottomSpacing := 6; 59 | ChildSizing.EnlargeHorizontal := crsHomogenousChildResize; 60 | ChildSizing.EnlargeVertical := crsHomogenousChildResize; 61 | ChildSizing.ShrinkHorizontal := crsScaleChilds; 62 | ChildSizing.ShrinkVertical := crsScaleChilds; 63 | ChildSizing.Layout := cclLeftToRightThenTopToBottom; 64 | ChildSizing.ControlsPerLine := 1; 65 | ClientHeight := 87; 66 | ClientWidth := 164; 67 | Items.AddStrings(['Normal','Extended','Grep search']); 68 | TabOrder := 5; 69 | end; 70 | 71 | end; 72 | 73 | procedure TMyReplaceDialog.SetFormValues; 74 | begin 75 | inherited SetFormValues; 76 | rgSearchMode.ItemIndex:= Integer(FSearchMode); 77 | 78 | end; 79 | 80 | procedure TMyReplaceDialog.GetFormValues; 81 | begin 82 | inherited GetFormValues; 83 | FSearchMode := TSearchMode(rgSearchMode.ItemIndex); 84 | end; 85 | 86 | end. 87 | 88 | -------------------------------------------------------------------------------- /create_deb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # set -x 3 | if [ "$BASE" = "" ]; then 4 | BASE=$(pwd) 5 | fi 6 | 7 | ARCH=$(./get_architecture.sh ) 8 | 9 | bash $BASE/buildlinux.sh 10 | 11 | PROG_VER=$(sed -e "s/[^0-9.a-zA-Z]//g" $BASE/src/version.inc) 12 | BIN_DIR=$BASE/bin/linux 13 | DEBSRCDIR=$BASE/packages/debian/ 14 | PACKAGES_DIR=$BASE/packages 15 | 16 | MKDIR="install -m 755 -d " 17 | INSTALLFILE="install -c -m 644" 18 | INSTALLEXE="install -c -m 755" 19 | 20 | 21 | ## 22 | copylanguage() 23 | { 24 | $MKDIR $DEBSRCDIR/usr/share/locale/$1 25 | $MKDIR $DEBSRCDIR/usr/share/locale/$1/LC_MESSAGES 26 | $INSTALLFILE $BASE/src/locale/ovotext.$1.po $DEBSRCDIR/usr/share/locale/$1/LC_MESSAGES/ovotext.po 27 | } 28 | 29 | 30 | rm -Rf $DEBSRCDIR 31 | $MKDIR $DEBSRCDIR 32 | $MKDIR $DEBSRCDIR/usr 33 | $MKDIR $DEBSRCDIR/usr/bin 34 | $MKDIR $DEBSRCDIR/usr/share 35 | $MKDIR $DEBSRCDIR/usr/share/doc 36 | $MKDIR $DEBSRCDIR/usr/share/doc/ovotext 37 | $MKDIR $DEBSRCDIR/usr/share/ovotext 38 | $MKDIR $DEBSRCDIR/usr/share/applications 39 | $MKDIR $DEBSRCDIR/usr/share/pixmaps 40 | $MKDIR $DEBSRCDIR/usr/share/man 41 | $MKDIR $DEBSRCDIR/usr/share/man/man1 42 | $MKDIR $DEBSRCDIR/usr/share/locale 43 | $MKDIR $DEBSRCDIR/usr/share/lintian 44 | $MKDIR $DEBSRCDIR/usr/share/lintian/overrides 45 | 46 | $MKDIR $DEBSRCDIR/DEBIAN 47 | 48 | $INSTALLEXE -s $BIN_DIR/ovotext $DEBSRCDIR/usr/bin 49 | $INSTALLFILE $BASE/images/ovotext.xpm $DEBSRCDIR/usr/share/pixmaps/ovotext.xpm 50 | $INSTALLFILE $BASE/color-schemas/schema-*.json $DEBSRCDIR/usr/share/ovotext 51 | $INSTALLFILE $PACKAGES_DIR/ovotext.desktop $DEBSRCDIR/usr/share/applications 52 | 53 | ## Add language files 54 | #copylanguage it 55 | ## 56 | 57 | $INSTALLFILE $PACKAGES_DIR/copyright $DEBSRCDIR/usr/share/doc/ovotext 58 | $INSTALLFILE $PACKAGES_DIR/lintian-overrides $DEBSRCDIR/usr/share/lintian/overrides/ovotext 59 | 60 | gzip -c --best $PACKAGES_DIR/changelog > $DEBSRCDIR/usr/share/doc/ovotext/changelog.gz 61 | chmod 0644 $DEBSRCDIR/usr/share/doc/ovotext/changelog.gz 62 | 63 | INSTALLEDSIZE=$(du -0 -xs --apparent-size --block-size=1024 $DEBSRCDIR/usr | cut -f 1) 64 | sed -e 's/:INSTALLEDSIZE/'$INSTALLEDSIZE'/;s/:VERSION/'$PROG_VER'/;s/:ARCHITECTURE/'$ARCH'/' $BASE/packages/control > $DEBSRCDIR/DEBIAN/control 65 | chmod 0644 $DEBSRCDIR/DEBIAN/control 66 | 67 | cd $DEBSRCDIR 68 | find usr -type f | xargs md5sum >> $DEBSRCDIR/DEBIAN/md5sums 69 | chmod 0644 $DEBSRCDIR/DEBIAN/md5sums 70 | 71 | fakeroot dpkg --build $DEBSRCDIR $PACKAGES_DIR/ovotext-$PROG_VER-gtk2-$ARCH.deb 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /highgen/highgen.lpi: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | <ResourceType Value="res"/> 11 | <UseXPManifest Value="True"/> 12 | </General> 13 | <i18n> 14 | <EnableI18N LFM="False"/> 15 | </i18n> 16 | <BuildModes Count="1"> 17 | <Item1 Name="Default" Default="True"/> 18 | </BuildModes> 19 | <PublishOptions> 20 | <Version Value="2"/> 21 | </PublishOptions> 22 | <RunParams> 23 | <FormatVersion Value="2"/> 24 | <Modes Count="1"> 25 | <Mode0 Name="default"/> 26 | </Modes> 27 | </RunParams> 28 | <RequiredPackages Count="2"> 29 | <Item1> 30 | <PackageName Value="SynEdit"/> 31 | </Item1> 32 | <Item2> 33 | <PackageName Value="LCL"/> 34 | </Item2> 35 | </RequiredPackages> 36 | <Units Count="3"> 37 | <Unit0> 38 | <Filename Value="highgen.lpr"/> 39 | <IsPartOfProject Value="True"/> 40 | </Unit0> 41 | <Unit1> 42 | <Filename Value="unit1.pas"/> 43 | <IsPartOfProject Value="True"/> 44 | <ComponentName Value="Form1"/> 45 | <HasResources Value="True"/> 46 | <ResourceBaseClass Value="Form"/> 47 | <UnitName Value="Unit1"/> 48 | </Unit1> 49 | <Unit2> 50 | <Filename Value="..\supportfuncs.pas"/> 51 | <IsPartOfProject Value="True"/> 52 | <UnitName Value="SupportFuncs"/> 53 | </Unit2> 54 | </Units> 55 | </ProjectOptions> 56 | <CompilerOptions> 57 | <Version Value="11"/> 58 | <PathDelim Value="\"/> 59 | <Target> 60 | <Filename Value="highgen"/> 61 | </Target> 62 | <SearchPaths> 63 | <IncludeFiles Value="$(ProjOutDir)"/> 64 | <OtherUnitFiles Value="..\highlighters;.."/> 65 | <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 66 | </SearchPaths> 67 | <Linking> 68 | <Options> 69 | <Win32> 70 | <GraphicApplication Value="True"/> 71 | </Win32> 72 | </Options> 73 | </Linking> 74 | </CompilerOptions> 75 | <Debugging> 76 | <Exceptions Count="3"> 77 | <Item1> 78 | <Name Value="EAbort"/> 79 | </Item1> 80 | <Item2> 81 | <Name Value="ECodetoolError"/> 82 | </Item2> 83 | <Item3> 84 | <Name Value="EFOpenError"/> 85 | </Item3> 86 | </Exceptions> 87 | </Debugging> 88 | </CONFIG> 89 | -------------------------------------------------------------------------------- /src/replacedialog.lrj: -------------------------------------------------------------------------------- 1 | {"version":1,"strings":[ 2 | {"hash":217702020,"name":"tcustomreplacedialog.caption","sourcebytes":[82,101,112,108,97,99,101,32,84,101,120,116],"value":"Replace Text"}, 3 | {"hash":12204740,"name":"tcustomreplacedialog.textlabel.caption","sourcebytes":[84,101,120,116,32,116,111,32,102,105,110,100],"value":"Text to find"}, 4 | {"hash":167681317,"name":"tcustomreplacedialog.rgsearchmode.caption","sourcebytes":[83,101,97,114,99,104,32,77,111,100,101],"value":"Search Mode"}, 5 | {"hash":5875301,"name":"tcustomreplacedialog.scopegroupbox.caption","sourcebytes":[83,99,111,112,101],"value":"Scope"}, 6 | {"hash":44373508,"name":"tcustomreplacedialog.selectedradiobutton.caption","sourcebytes":[83,101,108,101,99,116,101,100,32,116,101,120,116],"value":"Selected text"}, 7 | {"hash":82008188,"name":"tcustomreplacedialog.globalradiobutton.caption","sourcebytes":[71,108,111,98,97,108],"value":"Global"}, 8 | {"hash":147269573,"name":"tcustomreplacedialog.btnpanel.okbutton.caption","sourcebytes":[82,101,112,108,97,99,101],"value":"Replace"}, 9 | {"hash":131039500,"name":"tcustomreplacedialog.btnpanel.closebutton.caption","sourcebytes":[82,101,112,108,97,99,101,32,65,108,108],"value":"Replace All"}, 10 | {"hash":108725763,"name":"tcustomreplacedialog.gboptions.caption","sourcebytes":[79,112,116,105,111,110,115],"value":"Options"}, 11 | {"hash":153444057,"name":"tcustomreplacedialog.wholewordsonlycheckbox.caption","sourcebytes":[87,104,111,108,101,32,119,111,114,100,115,32,111,110,108,121],"value":"Whole words only"}, 12 | {"hash":219672053,"name":"tcustomreplacedialog.casesensitivecheckbox.caption","sourcebytes":[67,97,115,101,32,115,101,110,115,105,116,105,118,101],"value":"Case sensitive"}, 13 | {"hash":126295477,"name":"tcustomreplacedialog.entirescopecheckbox.caption","sourcebytes":[83,101,97,114,99,104,32,101,110,116,105,114,101,32,102,105,108,101],"value":"Search entire file"}, 14 | {"hash":267776421,"name":"tcustomreplacedialog.promptonreplacecheckbox.caption","sourcebytes":[80,114,111,109,112,116,32,111,110,32,114,101,112,108,97,99,101],"value":"Prompt on replace"}, 15 | {"hash":217690840,"name":"tcustomreplacedialog.cbreplace.caption","sourcebytes":[82,101,112,108,97,99,101,32,87,105,116,104],"value":"Replace With"}, 16 | {"hash":146466142,"name":"tcustomreplacedialog.directiongroupbox.caption","sourcebytes":[68,105,114,101,99,116,105,111,110],"value":"Direction"}, 17 | {"hash":128113668,"name":"tcustomreplacedialog.backwardradiobutton.caption","sourcebytes":[66,97,99,107,119,97,114,100],"value":"Backward"}, 18 | {"hash":225040580,"name":"tcustomreplacedialog.forwardradiobutton.caption","sourcebytes":[70,111,114,119,97,114,100],"value":"Forward"} 19 | ]} 20 | -------------------------------------------------------------------------------- /src/highlighters/SynDefines.inc: -------------------------------------------------------------------------------- 1 | (******************************************************************************) 2 | (* SynEdit Include File. This file was adapted from Brad Stowers' DFS.INC *) 3 | (* file and used with permission. This will help reduce headaches when new *) 4 | (* versions of Delphi and C++Builder are released, among other things. *) 5 | (******************************************************************************) 6 | (* Brad Stowers: bstowers@pobox.com *) 7 | (* Delphi Free Stuff: http://delphifreestuff.com/ *) 8 | (* February 24, 1999 *) 9 | (******************************************************************************) 10 | (* *) 11 | (* Complete Boolean Evaluation compiler directive is turned off by including *) 12 | (* this file. *) 13 | (* *) 14 | (* Here is a brief explanation of what each of the defines mean: *) 15 | (* SYN_WIN32 : Compilation target is 32-bit Windows *) 16 | (* SYN_LAZARUS : Used to append the GetTokenEx on the extra *) 17 | (* Highlighters. Redefine it if the file is copied *) 18 | (* again *) 19 | (******************************************************************************) 20 | 21 | {$IFDEF FPC} 22 | {$MODE OBJFPC} 23 | {$ENDIF} 24 | {$IFDEF LCL} 25 | {$DEFINE SYN_LAZARUS} 26 | {$ENDIF} 27 | {$DEFINE SYNEDIT_INCLUDE} 28 | 29 | {$IFdef MSWindows} 30 | {$DEFINE SYN_WIN32} 31 | {$ENDIF} 32 | 33 | {------------------------------------------------------------------------------} 34 | { Common compiler defines } 35 | {------------------------------------------------------------------------------} 36 | 37 | // defaults are short evaluation of boolean values and long strings 38 | 39 | // lazarus change no $B- 40 | {$H+} 41 | 42 | {------------------------------------------------------------------------------} 43 | { Please change this to suit your needs } 44 | {------------------------------------------------------------------------------} 45 | 46 | // support for multibyte character sets 47 | {.$DEFINE SYN_MBCSSUPPORT} 48 | 49 | // additional tests for debugging 50 | 51 | {.$DEFINE SYN_DEVELOPMENT_CHECKS} 52 | 53 | {$IFDEF SYN_DEVELOPMENT_CHECKS} 54 | 55 | {$R+,Q+,S+,T+} 56 | 57 | {$ENDIF} 58 | 59 | // $Id: synedit.inc 42184 2013-07-23 18:44:37Z martin $ 60 | 61 | -------------------------------------------------------------------------------- /src/uabout.pas: -------------------------------------------------------------------------------- 1 | { Ovotext - simple text editor 2 | 3 | Copyright (C) 2015 Marco Caselli <marcocas@gmail.com> 4 | 5 | This source is free software; you can redistribute it and/or modify it under 6 | the terms of the GNU General Public License as published by the Free 7 | Software Foundation; either version 2 of the License, or (at your option) 8 | any later version. 9 | 10 | This code is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 13 | details. 14 | 15 | A copy of the GNU General Public License is available on the World Wide Web 16 | at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing 17 | to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 18 | MA 02111-1307, USA. 19 | } 20 | {$I codegen.inc} 21 | unit uabout; 22 | 23 | interface 24 | 25 | uses 26 | Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, 27 | StdCtrls, Buttons, ExtCtrls, LCLIntf; 28 | 29 | type 30 | 31 | { TfAbout } 32 | 33 | TfAbout = class(TForm) 34 | bClose: TBitBtn; 35 | bLicense: TBitBtn; 36 | Image1: TImage; 37 | Label1: TLabel; 38 | Label11: TLabel; 39 | Label2: TLabel; 40 | Label3: TLabel; 41 | Label4: TLabel; 42 | Label5: TLabel; 43 | Label6: TLabel; 44 | Label7: TLabel; 45 | Label8: TLabel; 46 | lbBuildDate: TLabel; 47 | lbEngine: TLabel; 48 | lbFPCVersion: TLabel; 49 | lbLazVersion: TLabel; 50 | lHomePage: TLabel; 51 | lHomePage2: TLabel; 52 | lVersion: TLabel; 53 | procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 54 | procedure FormShow(Sender: TObject); 55 | procedure lHomePageMouseDown(Sender: TObject; Button: TMouseButton; 56 | Shift: TShiftState; X, Y: Integer); 57 | procedure lHomePageMouseEnter(Sender: TObject); 58 | procedure lHomePageMouseLeave(Sender: TObject); 59 | private 60 | { private declarations } 61 | public 62 | { public declarations } 63 | end; 64 | 65 | var 66 | fAbout: TfAbout; 67 | 68 | implementation 69 | uses Stringcostants; 70 | {$R *.lfm} 71 | 72 | { TfAbout } 73 | 74 | procedure TfAbout.lHomePageMouseDown(Sender: TObject; Button: TMouseButton; 75 | Shift: TShiftState; X, Y: Integer); 76 | begin 77 | OpenURL(TLabel(Sender).Caption); 78 | end; 79 | 80 | procedure TfAbout.FormShow(Sender: TObject); 81 | var 82 | i:Integer; 83 | begin 84 | lVersion.caption := AppVersion; 85 | lbFPCVersion.Caption := fpcVersion; 86 | lbLazVersion.Caption := lazVersion; 87 | lbBuildDate.Caption := BuildDate; 88 | // lbSVNRev.Caption := ovoRevision; 89 | 90 | for i := 0 to ComponentCount -1 do 91 | if Components[i] is TLabel then 92 | if Tlabel (Components[i]).OptimalFill then 93 | Tlabel (Components[i]).AdjustFontForOptimalFill; 94 | end; 95 | 96 | procedure TfAbout.FormClose(Sender: TObject; var CloseAction: TCloseAction); 97 | begin 98 | CloseAction:=cafree; 99 | end; 100 | 101 | procedure TfAbout.lHomePageMouseEnter(Sender: TObject); 102 | begin 103 | TLabel(Sender).Font.Style := [fsUnderLine]; 104 | TLabel(Sender).Font.Color := clRed; 105 | TLabel(Sender).Cursor := crHandPoint; 106 | end; 107 | 108 | procedure TfAbout.lHomePageMouseLeave(Sender: TObject); 109 | begin 110 | TLabel(Sender).Font.Style := []; 111 | TLabel(Sender).Font.Color := clBlue; 112 | TLabel(Sender).Cursor := crDefault; 113 | end; 114 | 115 | end. 116 | 117 | -------------------------------------------------------------------------------- /color-schemas/schema-paste-dark.json: -------------------------------------------------------------------------------- 1 | { 2 | "Schema": { 3 | "Name": "Pastel Dark", 4 | "Default": { 5 | "Text": { 6 | "Background": "$003F3F3F", 7 | "Foreground": "clWhite" 8 | }, 9 | "Gutter": { 10 | "Background": "$00232323" 11 | }, 12 | "LineNumber": { 13 | "Foreground": "$00555555" 14 | } 15 | }, 16 | "DefaultLang": { 17 | "Assembler": { 18 | "Foreground": "clLime" 19 | }, 20 | "Comment": { 21 | "Style": "fsItalic", 22 | "Foreground": "$007F9F7F" 23 | }, 24 | "Directive": { 25 | "Foreground": "$00B7B7FF" 26 | }, 27 | "Number": { 28 | "Foreground": "$00D3D08C" 29 | }, 30 | "Reserved_word": { 31 | "Style": "fsBold", 32 | "Foreground": "$007DC4DF" 33 | }, 34 | "String": { 35 | "Foreground": "$009393CC" 36 | }, 37 | "Symbol": { 38 | "Foreground": "$00858585" 39 | }, 40 | "Text": { 41 | "Background": "$003F3F3F", 42 | "Foreground": "clWhite" 43 | }, 44 | "Special": { 45 | "Style": "fsBold", 46 | "Foreground": "clLime" 47 | }, 48 | "Error": { 49 | "Style": "fsBold", 50 | "Foreground": "clRed" 51 | }, 52 | "Space": { 53 | "Foreground": "clWindow" 54 | }, 55 | "Identifier": { 56 | "Background": "$003F3F3F", 57 | "Foreground": "clWhite" 58 | } 59 | }, 60 | "HTML_document": { 61 | "Asp": { 62 | "Background": "clYellow", 63 | "Foreground": "clBlack" 64 | } 65 | }, 66 | "SQL": { 67 | "Data_type": { 68 | "Style": "fsBold" 69 | }, 70 | "Default_packages": { 71 | "Style": "fsBold" 72 | }, 73 | "Exception": { 74 | "Style": "fsItalic" 75 | }, 76 | "Function": { 77 | "Style": "fsBold" 78 | }, 79 | "Reserved_word__PL_SQL_": { 80 | "Style": "fsBold" 81 | }, 82 | "SQL_Plus_command": { 83 | "Style": "fsBold" 84 | } 85 | }, 86 | "Python": { 87 | "Float": { 88 | "Foreground": "clBlue" 89 | }, 90 | "Hexadecimal": { 91 | "Foreground": "clBlue" 92 | }, 93 | "Non_reserved_keyword": { 94 | "Style": "fsBold", 95 | "Foreground": "clNavy" 96 | }, 97 | "Octal": { 98 | "Foreground": "clBlue" 99 | }, 100 | "SyntaxError": { 101 | "Foreground": "clRed" 102 | }, 103 | "System_functions_and_variables": { 104 | "Style": "fsBold" 105 | } 106 | }, 107 | "INI_file": { 108 | "Section": { 109 | "Style": "fsBold" 110 | } 111 | }, 112 | "Diff_File": { 113 | "Diff_Added_line": { 114 | "Foreground": "clGreen" 115 | }, 116 | "Diff_Changed_Line": { 117 | "Foreground": "clPurple" 118 | }, 119 | "Diff_Chunk_Line_Counts": { 120 | "Style": "fsBold", 121 | "Foreground": "clPurple" 122 | }, 123 | "Diff_Chunk_Marker": { 124 | "Style": "fsBold" 125 | }, 126 | "Diff_Chunk_New_Line_Count": { 127 | "Style": "fsBold", 128 | "Foreground": "clGreen" 129 | }, 130 | "Diff_Chunk_Original_Line_Count": { 131 | "Style": "fsBold", 132 | "Foreground": "clRed" 133 | }, 134 | "Diff_New_File": { 135 | "Style": "fsBold", 136 | "Background": "clGreen" 137 | }, 138 | "Diff_Original_File": { 139 | "Style": "fsBold", 140 | "Background": "clRed" 141 | }, 142 | "Diff_Removed_Line": { 143 | "Foreground": "clRed" 144 | } 145 | } 146 | } 147 | } 148 | 149 | -------------------------------------------------------------------------------- /src/stringcostants.pas: -------------------------------------------------------------------------------- 1 | { Ovotext - simple text editor 2 | 3 | Copyright (C) 2015 Marco Caselli <marcocas@gmail.com> 4 | 5 | This source is free software; you can redistribute it and/or modify it under 6 | the terms of the GNU General Public License as published by the Free 7 | Software Foundation; either version 2 of the License, or (at your option) 8 | any later version. 9 | 10 | This code is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 13 | details. 14 | 15 | A copy of the GNU General Public License is available on the World Wide Web 16 | at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing 17 | to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 18 | MA 02111-1307, USA. 19 | } 20 | {$I codegen.inc} 21 | unit Stringcostants; 22 | 23 | interface 24 | 25 | uses 26 | LCLVersion; 27 | 28 | const 29 | DisplayAppName = 'OvoText'; 30 | AppVersion = {$i version.inc}; 31 | BuildDate = {$I %DATE%}; 32 | lazVersion = lcl_version; // Lazarus version (major.minor.micro) 33 | fpcVersion = {$I %FPCVERSION%}; // FPC version (major.minor.micro) 34 | TargetCPU = {$I %FPCTARGETCPU%}; // Target CPU of FPC 35 | TargetOS = {$I %FPCTARGETOS%}; // Target Operating System of FPC 36 | AppName = 'ovotext'; 37 | 38 | resourcestring 39 | RSNormalText = 'Normal text file'; 40 | RSAllFile = 'All files'; 41 | RSError = 'Error'; 42 | RSMonitoring = 'Monitoring'; 43 | RSAskSave = 'File %s have been modified. Do you want to save changes before monitoring?'; 44 | RSReload = 'Reload'; 45 | RSNewFile = '<new %d>'; 46 | RSStatusBarPos = 'Line: %d Col:%d'; 47 | RSStatusBarSel = 'Sel: %d'; 48 | RSStatusBarInsMode = 'INS'; 49 | RSStatusBarOvrMode = 'OVR'; 50 | RSAdministrativeRights = 'Warning, you are using the root account, you may harm your system!'; 51 | //-- Files 52 | RSSaveChanges = 'Save changes to'+LineEnding+ 53 | ' "%s"?'; 54 | RSCannotSave = 'Can not save changes to'+LineEnding+ 55 | ' "%s" '+LineEnding+ 56 | ' Error: %d - %s'; 57 | 58 | RSCannotOpen = 'Cannot open file '+LineEnding+ 59 | ' "%s" '+LineEnding+ 60 | ' Error: %d - %s'; 61 | 62 | RSAskFileCreation = '"%s"'+LineEnding+ 63 | 'does not exists. Do you want to create it?'; 64 | RSCannotCreate = 'Can not create'+LineEnding+ 65 | ' "%s"'; 66 | RSReloadSimple = '%s' +LineEnding+LineEnding+ 67 | 'This file has been modified by another application.'+LineEnding+ 68 | 'Do you want to reload it?'; 69 | 70 | RSReloadModified = '%s' +LineEnding+LineEnding+ 71 | 'This file has been modified by another application.'+LineEnding+ 72 | 'Do you want to reload it and lose changes?'; 73 | 74 | RSReloadFile = '%s' +LineEnding+LineEnding+ 75 | 'This file has been modified.'+LineEnding+ 76 | 'Do you want to reload it and lose changes?'; 77 | 78 | RSKeepDeleted = '%s' +LineEnding+LineEnding+ 79 | 'This file has been deleted by another application.'+LineEnding+ 80 | 'Do you want to keep it in the editor?'; 81 | 82 | //-- 83 | RSTextNotFound = 'Text not found:'+LineEnding+'"%s"'; 84 | 85 | RSMacro = 'Macro'; 86 | RSMacroDefaultName = 'Current recorded macro'; 87 | RSMacroSaving = 'Select a name for macro'; 88 | RSMacroNewName = 'Select a new name for macro'; 89 | 90 | RSMacroDelete = 'Delete macro "%s" ?'; 91 | 92 | 93 | 94 | implementation 95 | 96 | end. 97 | -------------------------------------------------------------------------------- /color-schemas/schema-default.json: -------------------------------------------------------------------------------- 1 | { 2 | "Schema": { 3 | "Name": "Default", 4 | "Default": { 5 | "Text": { 6 | "Background": "clWhite", 7 | "Foreground": "clBlack" 8 | }, 9 | "Gutter": { 10 | "Background": "clBtnFace" 11 | } 12 | }, 13 | "DefaultLang": { 14 | "Assembler": { 15 | "Foreground": "clGreen" 16 | }, 17 | "Comment": { 18 | "Style": "fsBold", 19 | "Foreground": "clBlue" 20 | }, 21 | "Directive": { 22 | "Style": "fsBold", 23 | "Foreground": "clRed" 24 | }, 25 | "Number": { 26 | "Foreground": "clNavy" 27 | }, 28 | "Reserved_word": { 29 | "Style": "fsBold" 30 | }, 31 | "String": { 32 | "Foreground": "clBlue" 33 | }, 34 | "Symbol": { 35 | "Foreground": "clRed" 36 | }, 37 | "Text": { 38 | "Background": "clWhite", 39 | "Foreground": "clBlack" 40 | }, 41 | "Special": { 42 | "Style": "fsBold", 43 | "Foreground": "clLime" 44 | }, 45 | "Error": { 46 | "Style": "fsBold", 47 | "Foreground": "clRed" 48 | }, 49 | "Space": { 50 | "Foreground": "clWindow" 51 | }, 52 | "Identifier": { 53 | "Background": "clWhite", 54 | "Foreground": "clBlack" 55 | } 56 | }, 57 | "HTML_document": { 58 | "Asp": { 59 | "Background": "clYellow", 60 | "Foreground": "clBlack" 61 | } 62 | }, 63 | "SQL": { 64 | "Data_type": { 65 | "Style": "fsBold" 66 | }, 67 | "Default_packages": { 68 | "Style": "fsBold" 69 | }, 70 | "Exception": { 71 | "Style": "fsItalic" 72 | }, 73 | "Function": { 74 | "Style": "fsBold" 75 | }, 76 | "Reserved_word__PL_SQL_": { 77 | "Style": "fsBold" 78 | }, 79 | "SQL_Plus_command": { 80 | "Style": "fsBold" 81 | } 82 | }, 83 | "Python": { 84 | "Float": { 85 | "Foreground": "clBlue" 86 | }, 87 | "Hexadecimal": { 88 | "Foreground": "clBlue" 89 | }, 90 | "Non_reserved_keyword": { 91 | "Style": "fsBold", 92 | "Foreground": "clNavy" 93 | }, 94 | "Octal": { 95 | "Foreground": "clBlue" 96 | }, 97 | "SyntaxError": { 98 | "Foreground": "clRed" 99 | }, 100 | "System_functions_and_variables": { 101 | "Style": "fsBold" 102 | } 103 | }, 104 | "INI_file": { 105 | "Section": { 106 | "Style": "fsBold" 107 | } 108 | }, 109 | "po_language_files": { 110 | "Flags": { 111 | "Foreground": "clTeal" 112 | }, 113 | "Previous_value": { 114 | "Style": "fsItalic", 115 | "Foreground": "clOlive" 116 | } 117 | }, 118 | "Diff_File": { 119 | "Diff_Added_line": { 120 | "Foreground": "clGreen" 121 | }, 122 | "Diff_Changed_Line": { 123 | "Foreground": "clPurple" 124 | }, 125 | "Diff_Chunk_Line_Counts": { 126 | "Style": "fsBold", 127 | "Foreground": "clPurple" 128 | }, 129 | "Diff_Chunk_Marker": { 130 | "Style": "fsBold" 131 | }, 132 | "Diff_Chunk_New_Line_Count": { 133 | "Style": "fsBold", 134 | "Foreground": "clGreen" 135 | }, 136 | "Diff_Chunk_Original_Line_Count": { 137 | "Style": "fsBold", 138 | "Foreground": "clRed" 139 | }, 140 | "Diff_New_File": { 141 | "Style": "fsBold", 142 | "Background": "clGreen" 143 | }, 144 | "Diff_Original_File": { 145 | "Style": "fsBold", 146 | "Background": "clRed" 147 | }, 148 | "Diff_Removed_Line": { 149 | "Foreground": "clRed" 150 | } 151 | } 152 | } 153 | } 154 | 155 | -------------------------------------------------------------------------------- /src/umacroplayback.lfm: -------------------------------------------------------------------------------- 1 | object fMacroPlayBack: TfMacroPlayBack 2 | Left = 350 3 | Height = 144 4 | Top = 31 5 | Width = 326 6 | Caption = 'Macro Playback' 7 | ClientHeight = 144 8 | ClientWidth = 326 9 | Font.Height = -12 10 | KeyPreview = True 11 | LCLVersion = '4.99.0.0' 12 | object Label2: TLabel 13 | AnchorSideLeft.Control = edRepeat 14 | AnchorSideLeft.Side = asrBottom 15 | AnchorSideTop.Control = edRepeat 16 | AnchorSideTop.Side = asrCenter 17 | Left = 153 18 | Height = 15 19 | Top = 47 20 | Width = 29 21 | BorderSpacing.Left = 7 22 | Caption = 'times' 23 | ParentColor = False 24 | end 25 | object edRepeat: TSpinEdit 26 | AnchorSideLeft.Side = asrBottom 27 | AnchorSideTop.Control = cbMacro 28 | AnchorSideTop.Side = asrBottom 29 | Left = 72 30 | Height = 23 31 | Top = 43 32 | Width = 74 33 | Anchors = [akTop] 34 | AutoSize = False 35 | BorderSpacing.Left = 9 36 | BorderSpacing.Top = 12 37 | BorderSpacing.Right = 7 38 | BorderSpacing.Bottom = 3 39 | MaxValue = 999 40 | MinValue = 1 41 | TabOrder = 0 42 | Value = 1 43 | end 44 | object Label1: TLabel 45 | AnchorSideLeft.Control = cbMacro 46 | AnchorSideLeft.Side = asrBottom 47 | AnchorSideTop.Control = cbMacro 48 | AnchorSideTop.Side = asrCenter 49 | AnchorSideRight.Control = cbMacro 50 | Left = 8 51 | Height = 15 52 | Top = 12 53 | Width = 34 54 | Anchors = [akTop, akRight] 55 | BorderSpacing.Around = 6 56 | Caption = 'Macro' 57 | ParentColor = False 58 | end 59 | object cbMacro: TComboBox 60 | Left = 48 61 | Height = 23 62 | Top = 8 63 | Width = 258 64 | Anchors = [akTop, akLeft, akRight] 65 | AutoComplete = True 66 | AutoCompleteText = [cbactEnabled, cbactEndOfLineComplete, cbactSearchAscending] 67 | AutoDropDown = True 68 | ItemHeight = 15 69 | Style = csDropDownList 70 | TabOrder = 1 71 | end 72 | object PanelRepeat: TPanel 73 | AnchorSideTop.Side = asrBottom 74 | AnchorSideRight.Side = asrBottom 75 | Left = 136 76 | Height = 0 77 | Top = 91 78 | Width = 127 79 | Anchors = [akLeft, akRight, akBottom] 80 | AutoSize = True 81 | BorderSpacing.Left = 6 82 | BorderSpacing.Top = 6 83 | BorderSpacing.Right = 6 84 | BevelOuter = bvNone 85 | BorderStyle = bsSingle 86 | TabOrder = 2 87 | end 88 | object ButtonPanel1: TButtonPanel 89 | Left = 6 90 | Height = 34 91 | Top = 104 92 | Width = 314 93 | OKButton.Name = 'OKButton' 94 | OKButton.DefaultCaption = True 95 | OKButton.OnClick = OKButtonClick 96 | HelpButton.Name = 'HelpButton' 97 | HelpButton.DefaultCaption = True 98 | CloseButton.Name = 'CloseButton' 99 | CloseButton.DefaultCaption = True 100 | CloseButton.OnClick = CloseButtonClick 101 | CancelButton.Name = 'CancelButton' 102 | CancelButton.DefaultCaption = True 103 | TabOrder = 3 104 | ShowButtons = [pbOK, pbClose] 105 | end 106 | object chkRepeat: TRadioButton 107 | AnchorSideTop.Control = edRepeat 108 | AnchorSideTop.Side = asrCenter 109 | AnchorSideRight.Control = edRepeat 110 | AnchorSideBottom.Control = edRepeat 111 | Left = 7 112 | Height = 19 113 | Top = 45 114 | Width = 56 115 | Anchors = [akTop, akRight] 116 | BorderSpacing.Left = 3 117 | BorderSpacing.Top = 3 118 | BorderSpacing.Right = 3 119 | BorderSpacing.Bottom = 3 120 | Caption = 'Repeat' 121 | TabOrder = 4 122 | end 123 | object cbRepeatUntilEof: TRadioButton 124 | AnchorSideLeft.Control = chkRepeat 125 | AnchorSideTop.Control = chkRepeat 126 | AnchorSideTop.Side = asrBottom 127 | Left = 7 128 | Height = 19 129 | Top = 72 130 | Width = 101 131 | BorderSpacing.Top = 8 132 | Caption = 'Until end of file' 133 | TabOrder = 5 134 | end 135 | end 136 | -------------------------------------------------------------------------------- /images/ovotext.xpm: -------------------------------------------------------------------------------- 1 | /* XPM */ 2 | static char * ovotext_xpm[] = { 3 | "48 48 65 1", 4 | " c None", 5 | ". c #2A2B29", 6 | "+ c #30312F", 7 | "@ c #323431", 8 | "# c #3A3635", 9 | "$ c #373836", 10 | "% c #3C3D3A", 11 | "& c #41413F", 12 | "* c #484845", 13 | "= c #4E504D", 14 | "- c #544F4E", 15 | "; c #565855", 16 | "> c #5C5856", 17 | ", c #625D5C", 18 | "' c #5F615E", 19 | ") c #6C6766", 20 | "! c #676966", 21 | "~ c #6D6F6C", 22 | "{ c #746F6E", 23 | "] c #757774", 24 | "^ c #7D7877", 25 | "/ c #7E807D", 26 | "( c #847F7D", 27 | "_ c #878785", 28 | ": c #8C8E8B", 29 | "< c #928D8C", 30 | "[ c #949693", 31 | "} c #9A9594", 32 | "| c #A29D9C", 33 | "1 c #9EA09D", 34 | "2 c #A7A2A0", 35 | "3 c #ABA6A5", 36 | "4 c #AEA9A8", 37 | "5 c #A9ABA8", 38 | "6 c #B2ADAB", 39 | "7 c #AEB0AD", 40 | "8 c #B4AFAD", 41 | "9 c #B8B2B1", 42 | "0 c #B2B4B1", 43 | "a c #BCB7B5", 44 | "b c #B9BBB8", 45 | "c c #C0BAB9", 46 | "d c #C3BEBD", 47 | "e c #BEC0BD", 48 | "f c #C9C3C2", 49 | "g c #C3C5C2", 50 | "h c #CCC7C5", 51 | "i c #C7C9C5", 52 | "j c #D0CBC9", 53 | "k c #CFD1CE", 54 | "l c #D6D0CF", 55 | "m c #D4D6D3", 56 | "n c #DBD5D4", 57 | "o c #DFD9D8", 58 | "p c #DBDDDA", 59 | "q c #E3DDDC", 60 | "r c #E7E1E0", 61 | "s c #E3E5E1", 62 | "t c #ECE6E5", 63 | "u c #F0EBE9", 64 | "v c #EDEFEC", 65 | "w c #F7F2F0", 66 | "x c #F4F6F3", 67 | "y c #FCF6F5", 68 | "z c #F9FBF8", 69 | " @$%$+ ", 70 | " @,3lpn4,@ ", 71 | " +*6rrstuuu8& ", 72 | " +,jrrttuuuvun=+ ", 73 | " +'nrrrttuuuwwwo* ", 74 | " =lqrrstuuuwwwwwl% ", 75 | " &fqqrrttuuuwwwyyy7@ ", 76 | " @2oqqrrsuuuwwxxyzzy]+ ", 77 | " +)ooqrrttuuvwwxzzzzzs& ", 78 | " &hooqrrstuuvwwyyzzzzy[@ ", 79 | " @<nooqrrstuuuwwxzzzzzzv* ", 80 | " *jnooqrrrtuuuwwxxyzzzyx1@ ", 81 | " @<lnooqqrrttuuuwwwyyyxxws& ", 82 | " &jlnnooqrrttuuvwwwwwwxxww_+ .&. ", 83 | " @(lln869daci6hdjecrjfgffovk@ .~:!+ ", 84 | " $clll96cf8oejghjjjhjnjhlovu' .~51_'. ", 85 | " 'jlll999cdhcdhfhhlgirikgnuu[.!555[/& ", 86 | " +}jjll9a8ahfccmhcfhddrnqnqto)!555em1;. ", 87 | " $cjjll8daafbbdhcjhfhluutttq~!555epp1$ ", 88 | " >hhjjl48868acd8jfcbdtrtttp]'555bpp1% ", 89 | " +(hhjjl643a3488aj9hf60cbpo^'155bpp5& ", 90 | " @3fhhjj2c6684c8865al8crro^;[55bpp5& ", 91 | " %dffhhj32a3c34483ccd846d(;:15bpp5* ", 92 | " >ddfhhj3|86a|8d44cac81l_=_[1bps7= ", 93 | " {cddfhha3a669h8c99dcan<=/:[7ms0=. ", 94 | " +(cddffha3489a948aajlj<=~/:5ms0;,+ ", 95 | " +}ccddff8323ca38acahl[=!]_1ksb'_2@ ", 96 | " @}cccddf4|26a69ac34a2=!~/[isb'(j8@ ", 97 | " +3acccdd42362238a39l^'~]:gpe'(jjc@ ", 98 | " @4aacccd}|43|6|33cjc)5~/bpe!(hjjc@ ", 99 | " @3aaacccdddfffhhhhh<:p[7pb!^hjhhc@ ", 100 | " +|9aaaccccdddfffhhd)iss05!^fhhhha+ ", 101 | " @<89aaaccccddddfff2&1vm[;^dhhfff|@ ", 102 | " +(889aaaaccccddddd{+&/,^3dffffdd<+ ", 103 | " +)68899aaaccccccd8;={}addddddddd^@ ", 104 | " *666889aaaaccccc4<6cdddddddcccc> ", 105 | " @|4668889aaaaacccccccccccccccca# ", 106 | " +{446668899aaaaaacccccccccccca<@ ", 107 | " %244466888899aaaaaaaaaaaaaaaa> ", 108 | " @{334466668888999aaaaaaaaaa9}@ ", 109 | " #}3334446668888889999999886- ", 110 | " *|33344446666688888888888{@ ", 111 | " +-|333334444466666666666^@ ", 112 | " +*<2333333444444444444^@ ", 113 | " +%{|233333333344444|,@ ", 114 | " @&{}22333333333})%+ ", 115 | " +$-{(}}}}}({-#+ ", 116 | " +@@@#@@@+ "}; 117 | -------------------------------------------------------------------------------- /packages/debian/usr/share/pixmaps/ovotext.xpm: -------------------------------------------------------------------------------- 1 | /* XPM */ 2 | static char * ovotext_xpm[] = { 3 | "48 48 65 1", 4 | " c None", 5 | ". c #2A2B29", 6 | "+ c #30312F", 7 | "@ c #323431", 8 | "# c #3A3635", 9 | "$ c #373836", 10 | "% c #3C3D3A", 11 | "& c #41413F", 12 | "* c #484845", 13 | "= c #4E504D", 14 | "- c #544F4E", 15 | "; c #565855", 16 | "> c #5C5856", 17 | ", c #625D5C", 18 | "' c #5F615E", 19 | ") c #6C6766", 20 | "! c #676966", 21 | "~ c #6D6F6C", 22 | "{ c #746F6E", 23 | "] c #757774", 24 | "^ c #7D7877", 25 | "/ c #7E807D", 26 | "( c #847F7D", 27 | "_ c #878785", 28 | ": c #8C8E8B", 29 | "< c #928D8C", 30 | "[ c #949693", 31 | "} c #9A9594", 32 | "| c #A29D9C", 33 | "1 c #9EA09D", 34 | "2 c #A7A2A0", 35 | "3 c #ABA6A5", 36 | "4 c #AEA9A8", 37 | "5 c #A9ABA8", 38 | "6 c #B2ADAB", 39 | "7 c #AEB0AD", 40 | "8 c #B4AFAD", 41 | "9 c #B8B2B1", 42 | "0 c #B2B4B1", 43 | "a c #BCB7B5", 44 | "b c #B9BBB8", 45 | "c c #C0BAB9", 46 | "d c #C3BEBD", 47 | "e c #BEC0BD", 48 | "f c #C9C3C2", 49 | "g c #C3C5C2", 50 | "h c #CCC7C5", 51 | "i c #C7C9C5", 52 | "j c #D0CBC9", 53 | "k c #CFD1CE", 54 | "l c #D6D0CF", 55 | "m c #D4D6D3", 56 | "n c #DBD5D4", 57 | "o c #DFD9D8", 58 | "p c #DBDDDA", 59 | "q c #E3DDDC", 60 | "r c #E7E1E0", 61 | "s c #E3E5E1", 62 | "t c #ECE6E5", 63 | "u c #F0EBE9", 64 | "v c #EDEFEC", 65 | "w c #F7F2F0", 66 | "x c #F4F6F3", 67 | "y c #FCF6F5", 68 | "z c #F9FBF8", 69 | " @$%$+ ", 70 | " @,3lpn4,@ ", 71 | " +*6rrstuuu8& ", 72 | " +,jrrttuuuvun=+ ", 73 | " +'nrrrttuuuwwwo* ", 74 | " =lqrrstuuuwwwwwl% ", 75 | " &fqqrrttuuuwwwyyy7@ ", 76 | " @2oqqrrsuuuwwxxyzzy]+ ", 77 | " +)ooqrrttuuvwwxzzzzzs& ", 78 | " &hooqrrstuuvwwyyzzzzy[@ ", 79 | " @<nooqrrstuuuwwxzzzzzzv* ", 80 | " *jnooqrrrtuuuwwxxyzzzyx1@ ", 81 | " @<lnooqqrrttuuuwwwyyyxxws& ", 82 | " &jlnnooqrrttuuvwwwwwwxxww_+ .&. ", 83 | " @(lln869daci6hdjecrjfgffovk@ .~:!+ ", 84 | " $clll96cf8oejghjjjhjnjhlovu' .~51_'. ", 85 | " 'jlll999cdhcdhfhhlgirikgnuu[.!555[/& ", 86 | " +}jjll9a8ahfccmhcfhddrnqnqto)!555em1;. ", 87 | " $cjjll8daafbbdhcjhfhluutttq~!555epp1$ ", 88 | " >hhjjl48868acd8jfcbdtrtttp]'555bpp1% ", 89 | " +(hhjjl643a3488aj9hf60cbpo^'155bpp5& ", 90 | " @3fhhjj2c6684c8865al8crro^;[55bpp5& ", 91 | " %dffhhj32a3c34483ccd846d(;:15bpp5* ", 92 | " >ddfhhj3|86a|8d44cac81l_=_[1bps7= ", 93 | " {cddfhha3a669h8c99dcan<=/:[7ms0=. ", 94 | " +(cddffha3489a948aajlj<=~/:5ms0;,+ ", 95 | " +}ccddff8323ca38acahl[=!]_1ksb'_2@ ", 96 | " @}cccddf4|26a69ac34a2=!~/[isb'(j8@ ", 97 | " +3acccdd42362238a39l^'~]:gpe'(jjc@ ", 98 | " @4aacccd}|43|6|33cjc)5~/bpe!(hjjc@ ", 99 | " @3aaacccdddfffhhhhh<:p[7pb!^hjhhc@ ", 100 | " +|9aaaccccdddfffhhd)iss05!^fhhhha+ ", 101 | " @<89aaaccccddddfff2&1vm[;^dhhfff|@ ", 102 | " +(889aaaaccccddddd{+&/,^3dffffdd<+ ", 103 | " +)68899aaaccccccd8;={}addddddddd^@ ", 104 | " *666889aaaaccccc4<6cdddddddcccc> ", 105 | " @|4668889aaaaacccccccccccccccca# ", 106 | " +{446668899aaaaaacccccccccccca<@ ", 107 | " %244466888899aaaaaaaaaaaaaaaa> ", 108 | " @{334466668888999aaaaaaaaaa9}@ ", 109 | " #}3334446668888889999999886- ", 110 | " *|33344446666688888888888{@ ", 111 | " +-|333334444466666666666^@ ", 112 | " +*<2333333444444444444^@ ", 113 | " +%{|233333333344444|,@ ", 114 | " @&{}22333333333})%+ ", 115 | " +$-{(}}}}}({-#+ ", 116 | " +@@@#@@@+ "}; 117 | -------------------------------------------------------------------------------- /src/highlighters/mysehighlighterrust.pas: -------------------------------------------------------------------------------- 1 | { <PiNote - free source code editor> 2 | 3 | Copyright (C) <2020> <Enzo Antonio Calogiuri> <ecalogiuri(at)gmail.com> 4 | 5 | This source is free software; you can redistribute it and/or modify it under 6 | the terms of the GNU General Public License as published by the Free 7 | Software Foundation; either version 2 of the License, or (at your option) 8 | any later version. 9 | 10 | This code is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 13 | details. 14 | 15 | A copy of the GNU General Public License is available on the World Wide Web 16 | at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing 17 | to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, 18 | Boston, MA 02110-1335, USA. 19 | } 20 | unit MySEHighlighterRust; 21 | 22 | {$mode objfpc}{$H+} 23 | 24 | interface 25 | 26 | uses 27 | Classes, SysUtils, SynFacilHighlighter, SynEditHighlighter; 28 | 29 | Type 30 | 31 | { TMySEHighlighterRust } 32 | 33 | TMySEHighlighterRust = Class(TSynFacilSyn) 34 | Private 35 | fKeyWordList : TStringList; 36 | 37 | Protected 38 | function IsFilterStored: Boolean; override; 39 | function GetSampleSource: string; override; 40 | Public 41 | Constructor Create(AOwner: TComponent); Override; 42 | Destructor Destroy; Override; 43 | 44 | class function GetLanguageName: string; override; 45 | End; 46 | 47 | const 48 | SYNS_FilterRust = 'Rust source files (*.rs;*.rslib)|*.rs;*.rslib'; 49 | 50 | implementation 51 | 52 | Uses SynFacilBasic; 53 | 54 | Const 55 | 56 | SYNS_LangTust = 'Rust'; 57 | 58 | RustKeyWords = 'as,break,const,continue,crate,else,enum,extern,' + 59 | 'false,fn,for,if,impl,in,let,loop,match,mod,move,' + 60 | 'mut,pub,ref,return,self,static,struct,super,' + 61 | 'trait,true,type,unsafe,use,where,while,dyn,' + 62 | 'abstract,become,box,do,final,macro,override,priv,' + 63 | 'typeof,unsized,virtual,yield,async,await,try,' + 64 | 'union,bool,u8,u16,u32,u64,u128,i8,i16,' + 65 | 'i32,i64,i128,char,str'; 66 | 67 | { TMySEHighlighterRust } 68 | 69 | function TMySEHighlighterRust.IsFilterStored: Boolean; 70 | begin 71 | Result := fDefaultFilter <> SYNS_FilterRust; 72 | end; 73 | 74 | function TMySEHighlighterRust.GetSampleSource: string; 75 | begin 76 | Result:=inherited GetSampleSource; 77 | end; 78 | 79 | constructor TMySEHighlighterRust.Create(AOwner: TComponent); 80 | Var I : Integer; 81 | begin 82 | LangName := SYNS_LangTust; 83 | fKeyWordList := TStringList.Create; 84 | fKeyWordList.Delimiter := ','; 85 | fKeyWordList.StrictDelimiter := True; 86 | 87 | fKeyWordList.DelimitedText := RustKeyWords; 88 | 89 | Inherited Create(AOwner); 90 | 91 | ClearMethodTables; 92 | ClearSpecials; 93 | 94 | DefTokIdentif('[A-Za-z_]', '[A-Za-z0-9_]*'); 95 | 96 | For I := 0 To fKeyWordList.Count - 1 Do 97 | AddKeyword(fKeyWordList[I]); 98 | 99 | fKeyWordList.Free; 100 | 101 | DefTokDelim('"','"', tnString); 102 | DefTokDelim('//','', tnComment); 103 | 104 | DefTokContent('#', '[A-Za-z]*', tnDirective); 105 | DefTokContent('[0123456789]','[0-9]', tnNumber); 106 | //DefTokContent('''','[0-9A-FHOa-fho]*', tnNumber); 107 | 108 | fDefaultFilter := SYNS_FilterRust; 109 | 110 | Rebuild; 111 | 112 | SetAttributesOnChange(@DefHighlightChange); 113 | end; 114 | 115 | destructor TMySEHighlighterRust.Destroy; 116 | begin 117 | inherited Destroy; 118 | end; 119 | 120 | class function TMySEHighlighterRust.GetLanguageName: string; 121 | begin 122 | Result:=SYNS_LangTust; 123 | end; 124 | 125 | Initialization 126 | {$IFNDEF SYN_CPPB_1} 127 | RegisterPlaceableHighlighter(TMySEHighlighterRust); 128 | {$ENDIF} 129 | end. 130 | 131 | -------------------------------------------------------------------------------- /src/comparer.pas: -------------------------------------------------------------------------------- 1 | { Ovotext - simple text editor 2 | 3 | Copyright (C) 2015 Marco Caselli <marcocas@gmail.com> 4 | 5 | This source is free software; you can redistribute it and/or modify it under 6 | the terms of the GNU General Public License as published by the Free 7 | Software Foundation; either version 2 of the License, or (at your option) 8 | any later version. 9 | 10 | This code is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 13 | details. 14 | 15 | A copy of the GNU General Public License is available on the World Wide Web 16 | at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing 17 | to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 18 | MA 02111-1307, USA. 19 | } 20 | {$I codegen.inc} 21 | unit Comparer; 22 | 23 | interface 24 | 25 | type 26 | TCompareString = function(const Item1, Item2: string): integer of object; 27 | 28 | TBaseComparer = class 29 | public 30 | Ascending: boolean; 31 | AsNumeric: boolean; 32 | function Compare(const Item1, Item2: string): integer; virtual abstract; 33 | end; 34 | 35 | TSimpleComparer = class(TBaseComparer) 36 | function Compare(const Item1, Item2: string): integer; override; 37 | end; 38 | 39 | 40 | { RColumnComparer } 41 | 42 | TColumnComparer = class(TBaseComparer) 43 | ColStart, ColEnd: integer; 44 | function Compare(const Item1, Item2: string): integer; override; 45 | end; 46 | 47 | { RDelimitedComparer } 48 | 49 | TDelimitedComparer = class(TBaseComparer) 50 | Column: integer; 51 | Delimiters: string; 52 | QuoteChar: char; 53 | function Compare(const Item1, Item2: string): integer; override; 54 | end; 55 | 56 | 57 | implementation 58 | 59 | uses 60 | Classes, SysUtils, strutils; 61 | 62 | function TSimpleComparer.Compare(const Item1, Item2: string): integer; 63 | begin 64 | Result := CompareStr(Item1, Item2); 65 | if not Ascending then 66 | Result := Result * -1; 67 | end; 68 | 69 | { RColumnComparer } 70 | 71 | function TColumnComparer.Compare(const Item1, Item2: string): integer; 72 | var 73 | Value1, Value2: string; 74 | Num1, Num2: double; 75 | begin 76 | Value1 := Copy(Item1, ColStart, ColEnd - ColStart); 77 | Value2 := Copy(Item2, ColStart, ColEnd - ColStart); 78 | 79 | if AsNumeric then 80 | if TryStrToFloat(Value1, Num1) and TryStrToFloat(Value2, Num2) then 81 | begin 82 | // Ordinamento numerico 83 | if Num1 < Num2 then 84 | Result := -1 85 | else if Num1 > Num2 then 86 | Result := 1 87 | else 88 | Result := 0; 89 | if not Ascending then 90 | Result := Result * -1; 91 | exit; 92 | end; 93 | Result := CompareStr(Value1, Value2); 94 | if not Ascending then 95 | Result := Result * -1; 96 | 97 | end; 98 | 99 | { RDelimitedComparer } 100 | 101 | function TDelimitedComparer.Compare(const Item1, Item2: string): integer; 102 | 103 | function GetColumn(const Line: string; ColumnIndex: integer): string; 104 | var 105 | Columns: specialize TArray<string>; 106 | begin 107 | Result := ''; 108 | if QuoteChar <> #00 then 109 | Columns := Line.Split(Delimiters) 110 | else 111 | Columns := Line.Split(Delimiters, QuoteChar); 112 | 113 | if (ColumnIndex >= 0) and (ColumnIndex < Length(Columns)) then 114 | Result := Columns[ColumnIndex].DeQuotedString(QuoteChar); 115 | 116 | if AsNumeric and (QuoteChar <> #00) then 117 | Result:=Result.DeQuotedString(QuoteChar); 118 | end; 119 | 120 | var 121 | Value1, Value2: string; 122 | Num1, Num2: double; 123 | begin 124 | Value1 := GetColumn(Item1, Column); 125 | Value2 := GetColumn(item2, Column); 126 | 127 | if AsNumeric then 128 | if TryStrToFloat(Value1, Num1) and TryStrToFloat(Value2, Num2) then 129 | begin 130 | // Ordinamento numerico 131 | if Num1 < Num2 then 132 | Result := -1 133 | else if Num1 > Num2 then 134 | Result := 1 135 | else 136 | Result := 0; 137 | if not Ascending then 138 | Result := Result * -1; 139 | exit; 140 | end; 141 | Result := CompareStr(Value1, Value2); 142 | if not Ascending then 143 | Result := Result * -1; 144 | 145 | end; 146 | 147 | end. 148 | 149 | -------------------------------------------------------------------------------- /src/udlgsort.pas: -------------------------------------------------------------------------------- 1 | { Ovotext - simple text editor 2 | 3 | Copyright (C) 2015 Marco Caselli <marcocas@gmail.com> 4 | 5 | This source is free software; you can redistribute it and/or modify it under 6 | the terms of the GNU General Public License as published by the Free 7 | Software Foundation; either version 2 of the License, or (at your option) 8 | any later version. 9 | 10 | This code is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 13 | details. 14 | 15 | A copy of the GNU General Public License is available on the World Wide Web 16 | at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing 17 | to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 18 | MA 02111-1307, USA. 19 | } 20 | {$I codegen.inc} 21 | unit udlgsort; 22 | 23 | interface 24 | 25 | uses 26 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ButtonPanel, StdCtrls, Spin, ExtCtrls, MaskEdit, StrUtils, 27 | ueditor, Comparer; 28 | 29 | type 30 | 31 | { TdlgSort } 32 | 33 | TdlgSort = class(TForm) 34 | ButtonPanel1: TButtonPanel; 35 | cgDelimiters: TCheckGroup; 36 | cbQuoteChar: TComboBox; 37 | cbNumeric: TCheckBox; 38 | edChar: TMaskEdit; 39 | pnlGeneral: TPanel; 40 | Label1: TLabel; 41 | Label2: TLabel; 42 | Label3: TLabel; 43 | Label4: TLabel; 44 | pnlDelimited: TPanel; 45 | pnlColumns: TPanel; 46 | rgOrder: TRadioGroup; 47 | rbColumnMode: TRadioButton; 48 | rbDelimitedMode: TRadioButton; 49 | dlgSort: TSpinEdit; 50 | speEnd: TSpinEdit; 51 | speStart: TSpinEdit; 52 | speColumn: TSpinEdit; 53 | procedure OKButtonClick(Sender: TObject); 54 | procedure ChangeSortMode(Sender: TObject); 55 | private 56 | procedure SortByColumns; 57 | procedure SortByDelimiters; 58 | 59 | public 60 | Editor: TEditor; 61 | end; 62 | 63 | var 64 | dlgSort: TdlgSort; 65 | 66 | implementation 67 | 68 | {$R *.lfm} 69 | 70 | { TdlgSort } 71 | 72 | procedure TdlgSort.SortByColumns; 73 | var 74 | CompareRec: TColumnComparer; 75 | begin 76 | CompareRec := TColumnComparer.Create; 77 | try 78 | CompareRec.Ascending := rgOrder.ItemIndex = 0; 79 | CompareRec.AsNumeric := cbNumeric.Checked; 80 | CompareRec.ColStart := speStart.Value; 81 | CompareRec.ColEnd := speEnd.Value; 82 | Editor.BeginUpdate(True); 83 | try 84 | Editor.CustomSort(@(CompareRec.Compare)); 85 | finally 86 | Editor.EndUpdate; 87 | end; 88 | 89 | finally 90 | CompareRec.Free; 91 | end; 92 | end; 93 | 94 | procedure TdlgSort.SortByDelimiters; 95 | var 96 | CompareRec: TDelimitedComparer; 97 | begin 98 | CompareRec := TDelimitedComparer.Create; 99 | try 100 | CompareRec.Ascending := rgOrder.ItemIndex = 0; 101 | CompareRec.AsNumeric := cbNumeric.Checked; 102 | CompareRec.Column := speColumn.Value -1; 103 | case cbQuoteChar.ItemIndex of 104 | 0: CompareRec.QuoteChar := '"'; 105 | 1: CompareRec.QuoteChar := ''''; 106 | else 107 | CompareRec.QuoteChar := #00; 108 | end; 109 | CompareRec.Delimiters := ''; 110 | if cgDelimiters.Checked[0] then 111 | CompareRec.Delimiters := CompareRec.Delimiters +','; 112 | if cgDelimiters.Checked[1] then 113 | CompareRec.Delimiters := CompareRec.Delimiters +';'; 114 | if cgDelimiters.Checked[2] then 115 | CompareRec.Delimiters := CompareRec.Delimiters +#09; 116 | if cgDelimiters.Checked[3] then 117 | CompareRec.Delimiters := CompareRec.Delimiters + ' '; 118 | if cgDelimiters.Checked[4] then 119 | CompareRec.Delimiters := CompareRec.Delimiters + edChar.Text; 120 | 121 | Editor.BeginUpdate(True); 122 | try 123 | Editor.CustomSort(@(CompareRec.Compare)); 124 | finally 125 | Editor.EndUpdate; 126 | end; 127 | 128 | finally 129 | CompareRec.Free; 130 | end; 131 | 132 | end; 133 | 134 | procedure TdlgSort.OKButtonClick(Sender: TObject); 135 | begin 136 | if rbColumnMode.Checked then 137 | SortByColumns; 138 | if rbDelimitedMode.Checked then 139 | SortByDelimiters; 140 | 141 | end; 142 | 143 | procedure TdlgSort.ChangeSortMode(Sender: TObject); 144 | begin 145 | pnlColumns.Enabled := rbColumnMode.Checked; 146 | pnlDelimited.Enabled := rbDelimitedMode.Checked; 147 | end; 148 | 149 | end. 150 | -------------------------------------------------------------------------------- /.github/workflows/CI.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | test: 7 | name: ${{ matrix.config.name }} 8 | runs-on: ${{ matrix.config.os }} 9 | env: 10 | OS: ${{ matrix.config.os }} 11 | LAZ_VER: ${{ matrix.config.LAZ_VER }} 12 | LAZ_OPT: ${{ matrix.config.LAZ_OPT }} 13 | ARTIFACT: ${{ matrix.config.ARTIFACT }} 14 | strategy: 15 | fail-fast: false 16 | matrix: 17 | config: 18 | - os: windows-latest 19 | name: Windows 32 20 | LAZ_VER: 4.0 21 | LAZ_OPT: "--os=win32 --cpu=i386" 22 | ARTIFACT: "ovotext.exe" 23 | lazbuild: "c:/lazarus/lazbuild.exe" 24 | 25 | - os: windows-latest 26 | name: Windows 64 27 | LAZ_VER: 4.0 28 | LAZ_OPT: "--os=win64 --cpu=x86_64" 29 | ARTIFACT: "ovotext.exe" 30 | lazbuild: "c:/lazarus/lazbuild.exe" 31 | 32 | - os: ubuntu-latest 33 | name: Linux 64 34 | LAZ_VER: 4.0 35 | LAZ_OPT: "--os=linux --cpu=x86_64" 36 | ARTIFACT: "ovotext" 37 | lazbuild: "lazbuild" 38 | 39 | steps: 40 | - uses: actions/checkout@v1 41 | 42 | - name: Install Modules 43 | run: | 44 | git submodule init 45 | git submodule update 46 | - name: Install Dependencies 47 | if: env.OS == 'ubuntu-latest' 48 | run: sudo apt-get update && sudo apt-get install libxml2 libxml2-utils 49 | 50 | - name: Install Lazarus 51 | shell: python 52 | run: | 53 | import sys 54 | import os 55 | import subprocess 56 | import re 57 | 58 | try: 59 | from urllib import quote 60 | except ImportError: 61 | from urllib.parse import quote 62 | OS_NAME = os.environ.get('RUNNER_OS') 63 | OS_PMAN = {'Linux': 'sudo apt-get', 'Windows': 'choco', 'macOS': 'brew'}[OS_NAME] 64 | LAZ_DOWNLOAD_DIR = '.laz' 65 | LAZ_BIN_ROOT = 'https://sourceforge.net/projects/lazarus/files/' 66 | LAZ_BIN_TARGET = { 67 | 'Linux': 'Lazarus Linux amd64 DEB/Lazarus %(version)s', 68 | 'Windows': 'Lazarus Windows 64 bits/Lazarus %(version)s', 69 | 'macOS': 'Lazarus macOS x86-64/' 70 | }[OS_NAME]; 71 | def install_lazarus_version(ver): 72 | url = LAZ_BIN_TARGET % {'version': ver} 73 | url = LAZ_BIN_ROOT + quote(url) 74 | # Collect all download links on target version 75 | assets = re.findall("https://(.*?)/download", subprocess.check_output('wget -O- %s' % (url), shell=True).decode('utf-8')) 76 | for asset in list(set(assets)): 77 | os.system('wget --progress=dot:mega -P "%s" %s' % (LAZ_DOWNLOAD_DIR, asset)) 78 | if OS_NAME == 'Windows': 79 | # Add Lazarus directory to PATH 80 | os.environ['PATH'] += os.pathsep + 'C:/lazarus/;' 81 | # Install all .exe files 82 | process_file = lambda f: (not f.endswith('.exe')) or os.system('%s /VERYSILENT /DIR="C:\Lazarus"' % (f)) == 0 83 | elif OS_NAME == 'Linux': 84 | # Install dependencies 85 | if os.system('%s install libgtk2.0-dev' % (OS_PMAN)) != 0: 86 | return False 87 | # Install all .deb files 88 | process_file = lambda f: (not f.endswith('.deb')) or os.system('sudo dpkg --force-overwrite -i %s' % (f)) == 0 89 | elif OS_NAME == 'macOS': 90 | # Install all .pkg files 91 | process_file = lambda f: (not f.endswith('.pkg')) or os.system('sudo installer -pkg %s -target /' % (f)) == 0 92 | else: 93 | return False 94 | # Process all downloaded files 95 | if not all(map(lambda f: os.system('echo Installing %s' % (f)) == 0 and process_file(os.path.join(LAZ_DOWNLOAD_DIR, f)), sorted(os.listdir(LAZ_DOWNLOAD_DIR)))): 96 | return False 97 | return True 98 | def main(): 99 | if os.system('%s install wget' % (OS_PMAN)) != 0: 100 | return False 101 | return install_lazarus_version(os.environ.get('LAZ_VER')) 102 | sys.exit(int(not main())) 103 | - name: Build OvoText 104 | run: | 105 | ${{ matrix.config.lazbuild }} ${{ env.LAZ_OPT }} --build-mode=Release "src/ovotext.lpi" 106 | 107 | -------------------------------------------------------------------------------- /src/highlighters/mysehighlightergo.pas: -------------------------------------------------------------------------------- 1 | { <PiNote - free source code editor> 2 | 3 | Copyright (C) <2020> <Enzo Antonio Calogiuri> <ecalogiuri(at)gmail.com> 4 | 5 | This source is free software; you can redistribute it and/or modify it under 6 | the terms of the GNU General Public License as published by the Free 7 | Software Foundation; either version 2 of the License, or (at your option) 8 | any later version. 9 | 10 | This code is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 13 | details. 14 | 15 | A copy of the GNU General Public License is available on the World Wide Web 16 | at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing 17 | to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, 18 | Boston, MA 02110-1335, USA. 19 | } 20 | unit MySEHighlighterGO; 21 | 22 | {$mode objfpc}{$H+} 23 | 24 | interface 25 | 26 | uses 27 | Classes, SysUtils, SynFacilHighlighter, SynEditHighlighter; 28 | 29 | Type 30 | 31 | { TMySEHighlighterGO } 32 | 33 | TMySEHighlighterGO = Class(TSynFacilSyn) 34 | Private 35 | fKeyWordList : TStringList; 36 | 37 | Protected 38 | function IsFilterStored: Boolean; override; 39 | function GetSampleSource: string; override; 40 | 41 | Public 42 | Constructor Create(AOwner: TComponent); Override; 43 | Destructor Destroy; Override; 44 | 45 | class function GetLanguageName: string; override; 46 | end; 47 | Const 48 | SYNS_FilterGO = 'Go source files (*.go)|*.go'; 49 | 50 | implementation 51 | 52 | Uses SynFacilBasic; 53 | 54 | Const 55 | SYNS_LangGO = 'Go'; 56 | 57 | GOKeyWords = 'break,case,chan,const,continue,default,defer,else,' + 58 | 'fallthrough,for,func,go,goto,if,import,interface,' + 59 | 'map,package,range,return,select,struct,switch,type,' + 60 | 'var,bool,byte,complex64,complex128,error,float32,' + 61 | 'float64,int,int8,int16,int32,int64,rune,string,uint,' + 62 | 'uint8,uint16,uint32,uint64,uintptr,true,false,iota,' + 63 | 'nil,append,cap,close,complex,copy,delete,imag,' + 64 | 'len,make,new,panic,print,println,real,recover'; 65 | 66 | { TMySEHighlighterGO } 67 | 68 | function TMySEHighlighterGO.IsFilterStored: Boolean; 69 | begin 70 | Result := fDefaultFilter <> SYNS_FilterGO; 71 | end; 72 | 73 | function TMySEHighlighterGO.GetSampleSource: string; 74 | begin 75 | Result := '//Simple GO source code' + #13#10 + 76 | '' + #13#10 + 77 | 'package main' + #13#10 + 78 | '' + #13#10 + 79 | 'import (' + #13#10 + 80 | ' "fmt"' + #13#10 + 81 | ' "math/cmplx"' + #13#10 + 82 | ')' + #13#10 + 83 | '' + #13#10 + 84 | 'var (' + #13#10 + 85 | ' ToBe bool = false' + #13#10 + 86 | ' MaxInt uint64 = 1<<64 - 1' + #13#10 + 87 | ' z complex128 = cmplx.Sqrt(-5 + 12i)' + #13#10 + 88 | ')' + #13#10 + 89 | '' + #13#10 + 90 | 'func main() {' + #13#10 + 91 | ' fmt.Printf("Type: %T Value: %v\n", ToBe, ToBe)' + #13#10 + 92 | ' fmt.Printf("Type: %T Value: %v\n", MaxInt, MaxInt)' + #13#10 + 93 | ' fmt.Printf("Type: %T Value: %v\n", z, z)' + #13#10 + 94 | '}'; 95 | end; 96 | 97 | constructor TMySEHighlighterGO.Create(AOwner: TComponent); 98 | Var I : Integer; 99 | begin 100 | LangName := SYNS_LangGO; 101 | fKeyWordList := TStringList.Create; 102 | fKeyWordList.Delimiter := ','; 103 | fKeyWordList.StrictDelimiter := True; 104 | 105 | fKeyWordList.DelimitedText := GOKeyWords; 106 | 107 | Inherited Create(AOwner); 108 | 109 | ClearMethodTables; 110 | ClearSpecials; 111 | 112 | DefTokIdentif('[A-Za-z_]', '[A-Za-z0-9_]*'); 113 | 114 | For I := 0 To fKeyWordList.Count - 1 Do 115 | AddKeyword(fKeyWordList[I]); 116 | 117 | fKeyWordList.Free; 118 | 119 | DefTokDelim('"','"', tnString); 120 | DefTokDelim('''','''', tnString); 121 | DefTokDelim('//','', tnComment); 122 | 123 | //DefTokContent('$', '[A-Za-z]*', tnDirective); 124 | DefTokContent('[0123456789]','[0-9]', tnNumber); 125 | DefTokContent('0x','[0-9A-Fa-f]*', tnNumber); 126 | 127 | fDefaultFilter := SYNS_FilterGO; 128 | 129 | Rebuild; 130 | 131 | SetAttributesOnChange(@DefHighlightChange); 132 | end; 133 | 134 | destructor TMySEHighlighterGO.Destroy; 135 | begin 136 | inherited Destroy; 137 | end; 138 | 139 | class function TMySEHighlighterGO.GetLanguageName: string; 140 | begin 141 | Result := SYNS_LangGO; 142 | end; 143 | Initialization 144 | {$IFNDEF SYN_CPPB_1} 145 | RegisterPlaceableHighlighter(TMySEHighlighterGO); 146 | {$ENDIF} 147 | end. 148 | 149 | -------------------------------------------------------------------------------- /color-schemas/schema-son-of-obsidian.json: -------------------------------------------------------------------------------- 1 | { 2 | "Schema": { 3 | "Name": "Son of obsidian", 4 | "Default": { 5 | "Text": { 6 | "Background": "$002A2822", 7 | "Foreground": "$00F3F2F1" 8 | }, 9 | "Gutter": { 10 | "Background": "$002A2822", 11 | "Foreground": "$0063C793" 12 | }, 13 | "LineNumber": { 14 | "Background": "$002A2822", 15 | "Foreground": "$0063C793" 16 | } 17 | }, 18 | "DefaultLang": { 19 | "Assembler": { 20 | "Background": "$002A2822", 21 | "Foreground": "$0063C793" 22 | }, 23 | "Comment": { 24 | "Style": "fsBold", 25 | "Background": "$002A2822", 26 | "Foreground": "$007B7466" 27 | }, 28 | "Directive": { 29 | "Style": "fsBold", 30 | "Background": "$002A2822", 31 | "Foreground": "$00BD82A0" 32 | }, 33 | "Number": { 34 | "Background": "$002A2822", 35 | "Foreground": "$0022CDFF" 36 | }, 37 | "Reserved_word": { 38 | "Style": "fsBold", 39 | "Background": "$002A2822", 40 | "Foreground": "$0063C793" 41 | }, 42 | "String": { 43 | "Background": "$002A2822", 44 | "Foreground": "$000076EC" 45 | }, 46 | "Symbol": { 47 | "Background": "$002A2822", 48 | "Foreground": "$00F3F2F1" 49 | }, 50 | "Text": { 51 | "Background": "$002A2822", 52 | "Foreground": "$00F3F2F1" 53 | }, 54 | "Special": { 55 | "Style": "fsBold", 56 | "Foreground": "clLime" 57 | }, 58 | "Error": { 59 | "Style": "fsBold", 60 | "Foreground": "clRed" 61 | }, 62 | "Space": { 63 | "Background": "$002A2822", 64 | "Foreground": "$00F3F2F1" 65 | }, 66 | "Identifier": { 67 | "Background": "$002A2822", 68 | "Foreground": "$00F3F2F1" 69 | } 70 | }, 71 | "HTML_document": { 72 | "Asp": { 73 | "Background": "clYellow", 74 | "Foreground": "clBlack" 75 | } 76 | }, 77 | "SQL": { 78 | "Data_type": { 79 | "Style": "fsBold", 80 | "Background": "$002A2822", 81 | "Foreground": "$00F3F2F1" 82 | }, 83 | "Default_packages": { 84 | "Style": "fsBold", 85 | "Background": "$002A2822", 86 | "Foreground": "$000076EC" 87 | }, 88 | "Exception": { 89 | "Style": "fsItalic", 90 | "Background": "$002A2822", 91 | "Foreground": "$000076EC" 92 | }, 93 | "Function": { 94 | "Style": "fsBold", 95 | "Background": "$002A2822", 96 | "Foreground": "$0063C793" 97 | }, 98 | "Reserved_word__PL_SQL_": { 99 | "Style": "fsBold", 100 | "Background": "$002A2822", 101 | "Foreground": "$0063C793" 102 | }, 103 | "SQL_Plus_command": { 104 | "Style": "fsBold", 105 | "Background": "clWhite", 106 | "Foreground": "clPurple" 107 | } 108 | }, 109 | "Python": { 110 | "Float": { 111 | "Background": "$002A2822", 112 | "Foreground": "$0022CDFF" 113 | }, 114 | "Hexadecimal": { 115 | "Background": "$002A2822", 116 | "Foreground": "$0022CDFF" 117 | }, 118 | "Non_reserved_keyword": { 119 | "Style": "fsBold", 120 | "Background": "$002A2822", 121 | "Foreground": "$00F3F2F1" 122 | }, 123 | "Octal": { 124 | "Background": "$002A2822", 125 | "Foreground": "$0022CDFF" 126 | }, 127 | "SyntaxError": { 128 | "Background": "$002A2822", 129 | "Foreground": "$000076EC" 130 | }, 131 | "System_functions_and_variables": { 132 | "Style": "fsBold", 133 | "Background": "$002A2822", 134 | "Foreground": "$00F3F2F1" 135 | } 136 | }, 137 | "INI_file": { 138 | "Section": { 139 | "Style": "fsBold", 140 | "Background": "$002A2822", 141 | "Foreground": "$0063C793" 142 | } 143 | }, 144 | "Diff_File": { 145 | "Diff_Added_line": { 146 | "Background": "$00CCFFCC", 147 | "Foreground": "clBlack" 148 | }, 149 | "Diff_Changed_Line": { 150 | "Background": "$00AAFFFF", 151 | "Foreground": "clBlack" 152 | }, 153 | "Diff_Chunk_Line_Counts": { 154 | "Style": "fsBold", 155 | "Background": "$002A2822", 156 | "Foreground": "$0022CDFF" 157 | }, 158 | "Diff_Chunk_Marker": { 159 | "Style": "fsBold", 160 | "Background": "$002A2822", 161 | "Foreground": "$00F3F2F1" 162 | }, 163 | "Diff_Chunk_New_Line_Count": { 164 | "Style": "fsBold", 165 | "Background": "$002A2822", 166 | "Foreground": "$00BD82A0" 167 | }, 168 | "Diff_Chunk_Original_Line_Count": { 169 | "Style": "fsBold", 170 | "Background": "$002A2822", 171 | "Foreground": "$000076EC" 172 | }, 173 | "Diff_New_File": { 174 | "Style": "fsBold", 175 | "Background": "$002A2822", 176 | "Foreground": "$00F3F2F1" 177 | }, 178 | "Diff_Original_File": { 179 | "Style": "fsBold", 180 | "Background": "$002A2822", 181 | "Foreground": "$00B18C67" 182 | }, 183 | "Diff_Removed_Line": { 184 | "Background": "$00FFC7C7", 185 | "Foreground": "clBlack" 186 | } 187 | } 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /src/ureplacemacro.pas: -------------------------------------------------------------------------------- 1 | { Ovotext - simple text editor 2 | 3 | Copyright (C) 2015 Marco Caselli <marcocas@gmail.com> 4 | 5 | This source is free software; you can redistribute it and/or modify it under 6 | the terms of the GNU General Public License as published by the Free 7 | Software Foundation; either version 2 of the License, or (at your option) 8 | any later version. 9 | 10 | This code is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 13 | details. 14 | 15 | A copy of the GNU General Public License is available on the World Wide Web 16 | at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing 17 | to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 18 | MA 02111-1307, USA. 19 | } 20 | {$I codegen.inc} 21 | unit uReplaceMacro; 22 | 23 | interface 24 | 25 | uses 26 | SysUtils, Classes, TypInfo, Graphics, Controls, Forms, Dialogs, 27 | SynEdit, Menus, ActnList, StdCtrls, ExtCtrls, LCLType, 28 | ReplaceDialog, SupportFuncs, 29 | SynEditKeyCmds, SynMacroRecorder, SynEditTypes; 30 | 31 | const 32 | ecReplace: TsynEditorCommand = ecUserFirst +15001; 33 | 34 | type 35 | 36 | { TReplaceMacroEvent } 37 | 38 | TReplaceMacroEvent = class(TSynMacroEvent) 39 | 40 | private 41 | fSearch, fReplace: string; 42 | fReplaceOptions: TMySynSearchOptions; 43 | protected 44 | function GetAsString : String; override; 45 | procedure InitEventParameters(sStr : String); override; 46 | public 47 | constructor Create(); override; 48 | destructor Destroy; override; 49 | procedure Initialize(aCmd: TSynEditorCommand; const aChar: TUTF8Char; aData: Pointer); override; 50 | procedure LoadFromStream(aStream: TStream); override; 51 | procedure SaveToStream(aStream: TStream); override; 52 | procedure Playback(aEditor: TCustomSynEdit); override; 53 | public 54 | property Replace: string read fReplace write fReplace; 55 | property Search: string read fSearch write fSearch; 56 | property ReplaceOptions: TMySynSearchOptions read fReplaceOptions write fReplaceOptions; 57 | 58 | end; 59 | 60 | implementation 61 | 62 | { TReplaceMacroEvent } 63 | 64 | constructor TReplaceMacroEvent.Create(); 65 | begin 66 | inherited Create; 67 | end; 68 | 69 | destructor TReplaceMacroEvent.Destroy; 70 | begin 71 | end; 72 | 73 | function TReplaceMacroEvent.GetAsString: String; 74 | begin 75 | 76 | Result := 'ecReplace ' + fSearch + #09 + 77 | fReplace + #09 + 78 | SetToString(PTypeInfo(TypeInfo(TmySynSearchOptions)), LongInt(fReplaceOptions), true); 79 | end; 80 | 81 | procedure TReplaceMacroEvent.InitEventParameters(sStr: String); 82 | var 83 | cHead: PChar; 84 | st: TStringList; 85 | begin 86 | cHead:= PChar(sStr); 87 | while cHead^ in [#6, ' '] do Inc(cHead); 88 | st := TStringList.Create; 89 | try 90 | st.Delimiter := #09; 91 | st.StrictDelimiter := true; 92 | st.DelimitedText := Copy(cHead, 1, Length(sStr)); 93 | fSearch := st[0]; 94 | fReplace := st[1]; 95 | fReplaceOptions:=TMySynSearchOptions(StringToSet(PTypeInfo(TypeInfo(TMySynSearchOptions)), st[2])); 96 | finally 97 | st.free 98 | end; 99 | 100 | 101 | end; 102 | 103 | procedure TReplaceMacroEvent.Initialize(aCmd: TSynEditorCommand; const aChar: TUTF8Char; aData: Pointer); 104 | begin 105 | fSearch := String(aData); 106 | end; 107 | 108 | procedure TReplaceMacroEvent.LoadFromStream(aStream: TStream); 109 | var 110 | l : Integer; 111 | cBuff : PChar; 112 | 113 | begin 114 | aStream.Read(l, SizeOf(l)); 115 | GetMem(cBuff, l); 116 | try 117 | FillByte(cBuff, l, 0); 118 | aStream.Read(cBuff^, l); 119 | InitEventParameters(cBuff); 120 | finally 121 | FreeMem(cBuff); 122 | end; 123 | end; 124 | 125 | procedure TReplaceMacroEvent.Playback(aEditor: TCustomSynEdit); 126 | var 127 | ReplaceText, FindText: String; 128 | begin 129 | if ssoExtended in TMySynSearchOptions(fReplaceOptions) then 130 | begin 131 | FindText := decodeExtendedSearch(fSearch); 132 | ReplaceText := decodeExtendedSearch(fReplace); 133 | end 134 | else 135 | begin 136 | FindText := fSearch; 137 | ReplaceText := fReplace; 138 | end; 139 | aEditor.SearchReplace(FindText, ReplaceText, TSynSearchOptions(fReplaceOptions)); 140 | end; 141 | 142 | procedure TReplaceMacroEvent.SaveToStream(aStream: TStream); 143 | var 144 | l : Integer; 145 | cBuff : PChar; 146 | 147 | begin 148 | aStream.Write(ecReplace, SizeOf(ecReplace)); 149 | l := Length(AsString) + 1; 150 | aStream.Write(l, sizeof(l)); 151 | GetMem(cBuff, l); 152 | try 153 | FillByte(cBuff, l, 0); 154 | StrPCopy(cBuff, AsString); 155 | aStream.Write(cBuff^, l); 156 | finally 157 | FreeMem(cBuff); 158 | end; 159 | 160 | end; 161 | 162 | 163 | const 164 | SynReplaceCommandStrs: array[0..0] of TIdentMapEntry = ( 165 | (Value: ecUserFirst +15001; Name: 'ecReplace') 166 | ); 167 | 168 | function IdentToReplaceCommand(const Ident: string; var Cmd: longint): boolean; 169 | begin 170 | Result := IdentToInt(Ident, Cmd, SynReplaceCommandStrs); 171 | end; 172 | 173 | function ReplaceCommandToIdent(Cmd: longint; var Ident: string): boolean; 174 | begin 175 | Result := Cmd = ecReplace; 176 | if not Result then exit; 177 | Result := IntToIdent(Cmd, Ident, SynReplaceCommandStrs); 178 | end; 179 | 180 | initialization 181 | RegisterKeyCmdIdentProcs(@IdentToReplaceCommand, @ReplaceCommandToIdent); 182 | 183 | end. 184 | -------------------------------------------------------------------------------- /src/iconloader.pas: -------------------------------------------------------------------------------- 1 | { 2 | This file is part of OvoText 3 | Copyright (C) 2011 Marco Caselli 4 | 5 | OvoPlayer is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | 19 | } 20 | {$I codegen.inc} 21 | unit iconloader; 22 | 23 | interface 24 | 25 | uses 26 | Classes, SysUtils,Graphics, fpimage, LCLType, IntfGraphics, GraphType, EasyLazFreeType, LazFreeTypeIntfDrawer, // LazFreeTypeFPImageDrawer, 27 | imglist, Forms; 28 | 29 | Type 30 | 31 | { TIconRenderer } 32 | 33 | TIconRenderer = class 34 | private 35 | FColor: TColor; 36 | FFontData:TFreeTypeFont; 37 | FSize: Integer; 38 | fImageSize: integer; 39 | procedure SetColor(AValue: TColor); 40 | procedure SetDefaults; 41 | public 42 | Constructor Create(AStream: TStream); 43 | destructor Destroy; override; 44 | function AddToImageList(imageList: TCustomImageList; Code:Cardinal): integer; overload; 45 | function AddToImageList(imageList: TCustomImageList; CodeList:array of Cardinal): integer; overload; 46 | Procedure SetSize(const AImageSize: integer; const FontSize:Integer; AutoScale: boolean=true); 47 | property FontSize:Integer read FSize; 48 | property ImageSize:Integer read FimageSize; 49 | property Color:TColor read FColor write SetColor; 50 | function getIcon(iconCode: Cardinal): TBitmap; 51 | end; 52 | 53 | 54 | implementation 55 | uses lazutf8, LCLIntf; 56 | 57 | { TIconRenderer } 58 | function TIconRenderer.getIcon(iconCode: Cardinal): TBitmap; 59 | var 60 | image: TLazIntfImage; 61 | freeTypePainter: TIntfFreeTypeDrawer; //TFPImageFreeTypeDrawer; 62 | fontColor: TFPColor; 63 | utf8Value: string; 64 | begin 65 | try 66 | Result := TBitmap.Create; 67 | image := TLazIntfImage.Create(0, 0, [riqfRGB, riqfAlpha]); 68 | freeTypePainter := TIntfFreeTypeDrawer.Create(image); 69 | utf8Value := UnicodetoUTF8(iconCode); 70 | fontColor := TColorToFPColor(FColor); 71 | try 72 | image.SetSize(FImageSize, FImageSize); 73 | freeTypePainter.FillPixels(colTransparent); 74 | freeTypePainter.DrawText(utf8Value, FFontData, FImageSize div 2, FImageSize div 2, fontColor, [ftaCenter, ftaVerticalCenter]); 75 | Result.LoadFromIntfImage(image); 76 | finally 77 | freeTypePainter.Free; 78 | image.Free; 79 | end; 80 | except 81 | Result := nil; 82 | end; 83 | end; 84 | 85 | 86 | procedure TIconRenderer.SetSize(const AImageSize: integer; const FontSize:Integer; AutoScale: boolean=true); 87 | 88 | begin 89 | FFontData.DPI := Screen.PixelsPerInch; 90 | if AutoScale then 91 | begin 92 | FImageSize := MulDiv(AImageSize, Screen.PixelsPerInch, 96); 93 | FSize := MulDiv(FontSize, Screen.PixelsPerInch, 96); 94 | end 95 | else 96 | begin 97 | FImageSize := AImageSize; 98 | FSize := FontSize; 99 | end; 100 | 101 | FFontData.SizeInPixels := FSize; 102 | 103 | SetDefaults; 104 | end; 105 | 106 | procedure TIconRenderer.SetDefaults; 107 | begin 108 | FFontData.Hinted := true;// False; // setting to true create strange artifact... 109 | FFontData.ClearType := True; 110 | FFontData.Quality := grqHighQuality; 111 | FFontData.SmallLinePadding := true; 112 | end; 113 | 114 | procedure TIconRenderer.SetColor(AValue: TColor); 115 | begin 116 | if FColor = AValue then Exit; 117 | FColor := AValue; 118 | 119 | end; 120 | 121 | constructor TIconRenderer.Create(AStream: TStream); 122 | begin 123 | FFontData := TFreeTypeFont.Create; 124 | FFontData.AccessFromStream(AStream, True); 125 | end; 126 | 127 | destructor TIconRenderer.Destroy; 128 | begin 129 | FFontData.Free; 130 | inherited Destroy; 131 | end; 132 | 133 | function TIconRenderer.AddToImageList(imageList: TCustomImageList; Code: Cardinal): integer; 134 | var 135 | abmp:TBitmap; 136 | begin 137 | abmp := getIcon(Code); 138 | abmp.SaveToFile('c:\xxx.bmp'); 139 | try 140 | Result := imageList.Add(abmp, nil); 141 | finally 142 | abmp.Free; 143 | end; 144 | end; 145 | 146 | function TIconRenderer.AddToImageList(imageList: TCustomImageList; CodeList: array of Cardinal): integer; 147 | var 148 | bmp: TBitmap; 149 | image: TLazIntfImage; 150 | freeTypePainter: TIntfFreeTypeDrawer; 151 | fontColor: TFPColor; 152 | utf8Value: string; 153 | i: Integer; 154 | begin 155 | Result := 0; 156 | try 157 | bmp := TBitmap.Create; 158 | image := TLazIntfImage.Create(0, 0, [riqfRGB, riqfAlpha]); 159 | freeTypePainter := TIntfFreeTypeDrawer.Create(image); 160 | fontColor := TColorToFPColor(FColor); 161 | try 162 | image.SetSize(FImageSize, FImageSize); 163 | for i:= low(CodeList) to high(codeList) do 164 | begin 165 | utf8Value := UnicodetoUTF8(codelist[i]); 166 | freeTypePainter.FillPixels(colTransparent); 167 | freeTypePainter.DrawText(utf8Value, FFontData, FImageSize div 2, FImageSize div 2, fontColor, [ftaCenter, ftaVerticalCenter]); 168 | bmp.LoadFromIntfImage(image); 169 | imageList.Add(bmp, nil); 170 | inc(result); 171 | end; 172 | finally 173 | freeTypePainter.Free; 174 | image.Free; 175 | bmp.Free; 176 | end; 177 | except 178 | Result := -1; 179 | end; 180 | end; 181 | 182 | 183 | end. 184 | 185 | -------------------------------------------------------------------------------- /src/printing/syneditprintmarginsdialog.pas: -------------------------------------------------------------------------------- 1 | {------------------------------------------------------------------------------- 2 | The contents of this file are subject to the Mozilla Public License 3 | Version 1.1 (the "License"); you may not use this file except in compliance 4 | with the License. You may obtain a copy of the License at 5 | http://www.mozilla.org/MPL/ 6 | 7 | Software distributed under the License is distributed on an "AS IS" basis, 8 | WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for 9 | the specific language governing rights and limitations under the License. 10 | 11 | The Original Code is: SynEditPrintMarginsDialog.pas, released 2000-06-01. 12 | 13 | The Initial Author of the Original Code is Morten J. Skovrup. 14 | Portions written by Morten J. Skovrup are copyright 2000 Morten J. Skovrup. 15 | All Rights Reserved. 16 | 17 | Contributors to the SynEdit project are listed in the Contributors.txt file. 18 | 19 | Alternatively, the contents of this file may be used under the terms of the 20 | GNU General Public License Version 2 or later (the "GPL"), in which case 21 | the provisions of the GPL are applicable instead of those above. 22 | If you wish to allow use of your version of this file only under the terms 23 | of the GPL and not to allow others to use your version of this file 24 | under the MPL, indicate your decision by deleting the provisions above and 25 | replace them with the notice and other provisions required by the GPL. 26 | If you do not delete the provisions above, a recipient may use your version 27 | of this file under either the MPL or the GPL. 28 | 29 | $Id: SynEditPrintMarginsDialog.pas,v 1.1.1.1 2000/07/08 15:54:06 mghie Exp $ 30 | 31 | You may retrieve the latest version of this file at the SynEdit home page, 32 | located at http://SynEdit.SourceForge.net 33 | 34 | Known Issues: 35 | -------------------------------------------------------------------------------} 36 | 37 | 38 | {------------------------------------------------------------------------------- 39 | CONTENTS: 40 | Property editor for TSynEditPrintMargins - nothing fancy, it only displays 41 | a picture that can help with understanding the different values. 42 | -------------------------------------------------------------------------------} 43 | 44 | unit SynEditPrintMarginsDialog; 45 | 46 | interface 47 | 48 | uses 49 | SysUtils, Classes, Graphics, Forms, Controls, StdCtrls, 50 | Buttons, ExtCtrls, Dialogs, DsgnIntf, SynEditPrint, SynEditPrintTypes, 51 | SynEditPrintMargins; 52 | 53 | type 54 | TSynEditPrintMarginsDlg = class(TForm) 55 | OKBtn: TButton; 56 | CancelBtn: TButton; 57 | Image1: TImage; 58 | Label1: TLabel; 59 | Label2: TLabel; 60 | Label3: TLabel; 61 | Label4: TLabel; 62 | Label5: TLabel; 63 | Label6: TLabel; 64 | Label7: TLabel; 65 | Label8: TLabel; 66 | Label9: TLabel; 67 | CBMirrorMargins: TCheckBox; 68 | Label10: TLabel; 69 | Label11: TLabel; 70 | EditLeft: TEdit; 71 | EditRight: TEdit; 72 | EditTop: TEdit; 73 | EditBottom: TEdit; 74 | EditGutter: TEdit; 75 | EditHeader: TEdit; 76 | EditFooter: TEdit; 77 | EditHFInternalMargin: TEdit; 78 | EditLeftHFTextIndent: TEdit; 79 | EditRightHFTextIndent: TEdit; 80 | CBUnits: TComboBox; 81 | procedure FormCreate(Sender: TObject); 82 | procedure FormDestroy(Sender: TObject); 83 | procedure CBUnitsChange(Sender: TObject); 84 | private 85 | { Private declarations } 86 | FMargins: TSynEditPrintMargins; 87 | FInternalCall: Boolean; 88 | public 89 | { Public declarations } 90 | procedure SetMargins(SynEditMargins: TSynEditPrintMargins); 91 | procedure GetMargins(SynEditMargins: TSynEditPrintMargins); 92 | end; 93 | 94 | implementation 95 | 96 | {$R *.DFM} 97 | 98 | { TSynEditPrintMarginsDlg } 99 | 100 | procedure TSynEditPrintMarginsDlg.FormCreate(Sender: TObject); 101 | begin 102 | FMargins := TSynEditPrintMargins.Create; 103 | FInternalCall := False; 104 | end; 105 | 106 | procedure TSynEditPrintMarginsDlg.FormDestroy(Sender: TObject); 107 | begin 108 | FMargins.Free; 109 | end; 110 | 111 | procedure TSynEditPrintMarginsDlg.GetMargins( 112 | SynEditMargins: TSynEditPrintMargins); 113 | var 114 | CurEdit: TEdit; 115 | function StringToFloat(Edit: TEdit): Double; 116 | begin 117 | CurEdit := Edit; 118 | Result := StrToFloat(Edit.Text); 119 | end; 120 | begin 121 | with SynEditMargins do begin 122 | if not FInternalCall then 123 | UnitSystem := TUnitSystem(CBUnits.ItemIndex); 124 | try 125 | Left := StringToFloat(EditLeft); 126 | Right := StringToFloat(EditRight); 127 | Top := StringToFloat(EditTop); 128 | Bottom := StringToFloat(EditBottom); 129 | Gutter := StringToFloat(EditGutter); 130 | Header := StringToFloat(EditHeader); 131 | Footer := StringToFloat(EditFooter); 132 | LeftHFTextIndent := StringToFloat(EditLeftHFTextIndent); 133 | RightHFTextIndent := StringToFloat(EditRightHFTextIndent); 134 | HFInternalMargin := StringToFloat(EditHFInternalMargin); 135 | except 136 | MessageDlg('Invalid number!', mtError, [mbOk], 0); 137 | CurEdit.SetFocus; 138 | end; 139 | MirrorMargins := CBMirrorMargins.Checked; 140 | end; 141 | end; 142 | 143 | procedure TSynEditPrintMarginsDlg.SetMargins( 144 | SynEditMargins: TSynEditPrintMargins); 145 | begin 146 | with SynEditMargins do begin 147 | CBUnits.ItemIndex := Ord(UnitSystem); 148 | EditLeft.Text := FloatToStr(Left); 149 | EditRight.Text := FloatToStr(Right); 150 | EditTop.Text := FloatToStr(Top); 151 | EditBottom.Text := FloatToStr(Bottom); 152 | EditGutter.Text := FloatToStr(Gutter); 153 | EditHeader.Text := FloatToStr(Header); 154 | EditFooter.Text := FloatToStr(Footer); 155 | EditLeftHFTextIndent.Text := FloatToStr(LeftHFTextIndent); 156 | EditRightHFTextIndent.Text := FloatToStr(RightHFTextIndent); 157 | EditHFInternalMargin.Text := FloatToStr(HFInternalMargin); 158 | CBMirrorMargins.Checked := MirrorMargins; 159 | end; 160 | end; 161 | 162 | procedure TSynEditPrintMarginsDlg.CBUnitsChange(Sender: TObject); 163 | begin 164 | FInternalCall := True; 165 | GetMargins(FMargins); 166 | FInternalCall := False; 167 | FMargins.UnitSystem := TUnitSystem(CBUnits.ItemIndex); 168 | SetMargins(FMargins); 169 | end; 170 | 171 | end. 172 | 173 | -------------------------------------------------------------------------------- /src/platform/win/monitoringthread.pas: -------------------------------------------------------------------------------- 1 | { Ovotext - simple text editor 2 | 3 | Copyright (C) 2015 Marco Caselli <marcocas@gmail.com> 4 | 5 | This source is free software; you can redistribute it and/or modify it under 6 | the terms of the GNU General Public License as published by the Free 7 | Software Foundation; either version 2 of the License, or (at your option) 8 | any later version. 9 | 10 | This code is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 13 | details. 14 | 15 | A copy of the GNU General Public License is available on the World Wide Web 16 | at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing 17 | to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 18 | MA 02111-1307, USA. 19 | } 20 | {$I codegen.inc} 21 | unit monitoringthread; 22 | 23 | interface 24 | 25 | uses 26 | Classes, SysUtils, uCheckFileChange, Windows, JwaWinNT, JwaWinBase, platformpath; 27 | 28 | type 29 | 30 | { TPlatformMonitoring } 31 | 32 | TPlatformMonitoring = class(TWatcherThread) 33 | private 34 | FCompletionPort: HANDLE; 35 | procedure ReadChanges(const DirectoryHandle: THandle; var Overlapped: TOverlapped; Buffer: pbyte); 36 | protected 37 | function Init: boolean; override; 38 | procedure Cleanup; override; 39 | procedure TriggerTerminateEvent; override; 40 | procedure DoMonitor; override; 41 | procedure StartMonitoringPath(aPath: string; Data: TPlatformPath); override; 42 | procedure StopMonitoringPath(aPath: string; Data: TPlatformPath); override; 43 | 44 | end; 45 | 46 | implementation 47 | 48 | 49 | { TPlatformMonitoring } 50 | 51 | function TPlatformMonitoring.Init: boolean; 52 | begin 53 | FCompletionPort := CreateIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 0); 54 | end; 55 | 56 | procedure TPlatformMonitoring.Cleanup; 57 | begin 58 | CloseHandle(FCompletionPort); 59 | FCompletionPort := 0; 60 | end; 61 | 62 | procedure TerminateProc(dwParam: ULONG_PTR); stdcall; 63 | begin 64 | end; 65 | 66 | procedure TPlatformMonitoring.TriggerTerminateEvent; 67 | begin 68 | PostQueuedCompletionStatus(fCompletionPort, 0, 0, Nil); 69 | end; 70 | 71 | procedure TPlatformMonitoring.DoMonitor; 72 | var 73 | BytesTransferred: DWORD; 74 | CompletionKey: nativeuint; 75 | aOverlapped: POverlapped; 76 | Buffer: pbyte; 77 | NotifyInfo: PFILE_NOTIFY_INFORMATION; 78 | Offset: DWORD; 79 | aPath: TPlatformPath; 80 | pData: TFileWatch; 81 | FileName: string; 82 | begin 83 | while not Terminated do 84 | if GetQueuedCompletionStatus(FCompletionPort, BytesTransferred, CompletionKey, aOverlapped, INFINITE) then 85 | begin 86 | // Retrieve the buffer from the OVERLAPPED structure 87 | IF BytesTransferred = 0 THEN 88 | Continue; 89 | aPath := TPlatformPath(CompletionKey); 90 | Buffer := pbyte(APath.Buffer); 91 | NotifyInfo := PFILE_NOTIFY_INFORMATION(Buffer); 92 | 93 | // Process notifications 94 | repeat 95 | // Extract the file name 96 | with FCurrentEventData do 97 | begin 98 | SetString(FileName, NotifyInfo^.FileName, NotifyInfo^.FileNameLength div SizeOf(widechar)); 99 | 100 | pData := FMasterList.GetWatch(IncludeTrailingPathDelimiter(aPath.path) + Filename); 101 | if Assigned(pData) then 102 | begin 103 | Data := pData.Data; 104 | case NotifyInfo^.Action of 105 | FILE_ACTION_MODIFIED: Event := fwscModified; 106 | FILE_ACTION_REMOVED: Event := fwscDeleted; 107 | FILE_ACTION_RENAMED_OLD_NAME: Event := fwscRenamed; 108 | else 109 | Event := fwscNone 110 | end; 111 | SyncDoWatcherEvent; 112 | end; 113 | 114 | // Move to the next notification 115 | Offset := NotifyInfo^.NextEntryOffset; 116 | if Offset = 0 then 117 | Break; 118 | NotifyInfo := PFILE_NOTIFY_INFORMATION(pbyte(NotifyInfo) + Offset); 119 | 120 | end; 121 | 122 | until False; 123 | 124 | // Reissue ReadDirectoryChangesW 125 | ReadChanges(aPath.Handle, aPath.fOverlapped, aPath.Buffer); 126 | end 127 | else 128 | begin 129 | OutputDebugString('GetQueuedCompletionStatus failed'); 130 | Terminate; 131 | end; 132 | end; 133 | 134 | procedure TPlatformMonitoring.StartMonitoringPath(aPath: string; Data: TPlatformPath); 135 | begin 136 | 137 | Data.Handle := CreateFileW(pwidechar(UTF8Decode('\\?\' + Data.Path)), 138 | FILE_LIST_DIRECTORY, 139 | FILE_SHARE_READ or FILE_SHARE_WRITE or FILE_SHARE_DELETE, 140 | nil, 141 | OPEN_EXISTING, 142 | FILE_FLAG_BACKUP_SEMANTICS or FILE_FLAG_OVERLAPPED, 143 | 0); 144 | 145 | if Data.Handle = INVALID_HANDLE_VALUE then 146 | Data.Handle := feInvalidHandle 147 | else 148 | begin 149 | if CreateIoCompletionPort(Data.Handle, FCompletionPort, nativeuint(Data), 0) = 0 then 150 | begin 151 | CloseHandle(Data.Handle); 152 | raise Exception.CreateFmt('Failed to associate directory with IOCP: %s', [Data.Path]); 153 | end; 154 | ZeroMemory(@(Data.fOverlapped), SizeOf(TOverlapped)); 155 | ReadChanges(Data.Handle, Data.fOverlapped, Data.Buffer); 156 | end; 157 | 158 | end; 159 | 160 | procedure TPlatformMonitoring.ReadChanges(const DirectoryHandle: THandle; var Overlapped: TOverlapped; Buffer: pbyte); 161 | begin 162 | ZeroMemory(@Overlapped, SizeOf(TOverlapped)); 163 | Overlapped.hEvent := CreateEvent(nil, True, False, nil); 164 | 165 | if not ReadDirectoryChangesW( 166 | DirectoryHandle, 167 | Buffer, 168 | 4096, 169 | True, // Include subdirectories 170 | FILE_NOTIFY_CHANGE_FILE_NAME or 171 | FILE_NOTIFY_CHANGE_DIR_NAME or 172 | FILE_NOTIFY_CHANGE_ATTRIBUTES or 173 | FILE_NOTIFY_CHANGE_SIZE or 174 | FILE_NOTIFY_CHANGE_LAST_WRITE, 175 | nil, 176 | @Overlapped, 177 | nil 178 | ) then 179 | raise Exception.Create('Failed to issue ReadDirectoryChangesW '+ SysErrorMessage(GetLastError)); 180 | end; 181 | 182 | procedure TPlatformMonitoring.StopMonitoringPath(aPath: string; Data: TPlatformPath); 183 | var 184 | tmpHandle: THANDLE; 185 | begin 186 | if Data.Handle <> feInvalidHandle then 187 | begin 188 | tmpHandle := Data.Handle; 189 | Data.Handle := feInvalidHandle; 190 | CloseHandle(tmpHandle); 191 | CloseHandle(Data.fOverlapped.hEvent); 192 | end; 193 | 194 | end; 195 | 196 | 197 | end. 198 | -------------------------------------------------------------------------------- /src/simplesingleinstance.pas: -------------------------------------------------------------------------------- 1 | { 2 | This file is part of OvoText 3 | Copyright (C) 2011 Marco Caselli 4 | 5 | OvoText is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | 19 | } 20 | {$I codegen.inc} 21 | unit SimpleSingleInstance; 22 | 23 | interface 24 | 25 | uses 26 | Classes, SysUtils, SimpleIPC, singleinstance; 27 | 28 | type 29 | 30 | { TSimpleSingleInstance } 31 | TSimpleSingleInstance = class(TBaseSingleInstance) 32 | private 33 | FDefaultMessage: string; 34 | FGlobal: Boolean; 35 | FID: string; 36 | FServer: TSimpleIPCServer; 37 | FClient: TSimpleIPCClient; 38 | procedure SetDefaultMessage(AValue: string); 39 | procedure SetGlobal(const aGlobal: Boolean); 40 | procedure SetID(const aID: string); 41 | protected 42 | procedure ProcessMessage(ASender: TObject); 43 | function GetIsClient: Boolean; override; 44 | function GetIsServer: Boolean; override; 45 | function GetStartResult: TSingleInstanceStart; override; 46 | public 47 | constructor Create(aOwner: TComponent); override; 48 | public 49 | function Start: TSingleInstanceStart; override; 50 | procedure Stop; override; 51 | procedure ServerCheckMessages; override; 52 | procedure ClientPostParams; override; 53 | procedure ClientPostString(Message: String); 54 | public 55 | // this message will be sent if there are no params in the current instance 56 | property DefaultMessage: string read FDefaultMessage write SetDefaultMessage; 57 | property ID: string read FID write SetID; 58 | property Global: Boolean read FGlobal write SetGlobal; 59 | end; 60 | 61 | implementation 62 | 63 | Resourcestring 64 | SErrSetSingleInstanceIDStarted = 'You cannot change the single instance ID when it''s been started.'; 65 | SErrSetSingleInstanceGlobalStarted = 'You cannot change the single instance global property when it''s been started.'; 66 | SErrStartSingleInstanceStarted = 'You cannot start single instance when it''s been already started.'; 67 | SErrSingleInstanceNotClient = 'Current instance is not a client.'; 68 | 69 | { TSimpleSingleInstance } 70 | 71 | procedure TSimpleSingleInstance.SetGlobal(const aGlobal: Boolean); 72 | begin 73 | if FGlobal = aGlobal then Exit; 74 | if Assigned(FServer) or Assigned(FClient) then 75 | raise ESingleInstance.Create(SErrSetSingleInstanceGlobalStarted); 76 | FGlobal := aGlobal; 77 | 78 | end; 79 | 80 | procedure TSimpleSingleInstance.SetDefaultMessage(AValue: string); 81 | begin 82 | if FDefaultMessage=AValue then Exit; 83 | FDefaultMessage:=AValue; 84 | end; 85 | 86 | procedure TSimpleSingleInstance.SetID(const aID: string); 87 | begin 88 | if FID = aID then Exit; 89 | if Assigned(FServer) or Assigned(FClient) then 90 | raise ESingleInstance.Create(SErrSetSingleInstanceIDStarted); 91 | FID := aID; 92 | 93 | end; 94 | 95 | function TSimpleSingleInstance.GetIsClient: Boolean; 96 | begin 97 | Result:= Assigned(FClient); 98 | end; 99 | 100 | function TSimpleSingleInstance.GetIsServer: Boolean; 101 | begin 102 | Result:= Assigned(FClient); 103 | end; 104 | 105 | function TSimpleSingleInstance.GetStartResult: TSingleInstanceStart; 106 | begin 107 | Result:=inherited GetStartResult; 108 | end; 109 | 110 | constructor TSimpleSingleInstance.Create(aOwner: TComponent); 111 | var 112 | xID: RawByteString; 113 | I: Integer; 114 | begin 115 | inherited Create(aOwner); 116 | 117 | xID := 'SI_'+ExtractFileName(ParamStr(0)); 118 | for I := 1 to Length(xID) do 119 | case xID[I] of 120 | 'a'..'z', 'A'..'Z', '0'..'9', '_': begin end; 121 | else 122 | xID[I] := '_'; 123 | end; 124 | ID := xID; 125 | 126 | FGlobal:= true; 127 | FClient := nil; 128 | FServer := nil; 129 | 130 | end; 131 | 132 | procedure TSimpleSingleInstance.ProcessMessage(ASender: TObject); 133 | var 134 | stl: TStringList; 135 | begin 136 | Stl := TStringList.Create; 137 | try 138 | stl.DelimitedText:= FServer.StringMessage; 139 | 140 | if Assigned(OnServerReceivedParams) then 141 | OnServerReceivedParams(Self, stl); 142 | finally 143 | stl.free; 144 | end; 145 | end; 146 | 147 | function TSimpleSingleInstance.Start: TSingleInstanceStart; 148 | begin 149 | if Assigned(FServer) or Assigned(FClient) then 150 | raise ESingleInstance.Create(SErrStartSingleInstanceStarted); 151 | 152 | FClient := TSimpleIPCClient.Create(Self); 153 | FClient.ServerId := FID; 154 | if FClient.ServerRunning then 155 | begin 156 | Result := siClient; 157 | FClient.Active:=true; 158 | end 159 | else 160 | begin 161 | FreeAndNil(FClient); 162 | FServer := TSimpleIPCServer.Create(Self); 163 | FServer.OnMessage:= @ProcessMessage; 164 | FServer.Global:=FGlobal; 165 | FServer.ThreadTimeOut:=500; 166 | FServer.ServerID:=FID; 167 | FServer.StartServer(false); 168 | Result := siServer; 169 | end; 170 | SetStartResult(Result); 171 | end; 172 | 173 | procedure TSimpleSingleInstance.Stop; 174 | begin 175 | FreeAndNil(FClient); 176 | FreeAndNil(FServer); 177 | end; 178 | 179 | procedure TSimpleSingleInstance.ServerCheckMessages; 180 | begin 181 | FServer.PeekMessage(1, true); 182 | end; 183 | 184 | procedure TSimpleSingleInstance.ClientPostParams; 185 | var 186 | xSL: TStringList; 187 | I: Integer; 188 | begin 189 | if not Assigned(FClient) then 190 | raise ESingleInstance.Create(SErrSingleInstanceNotClient); 191 | 192 | xSL := TStringList.Create; 193 | try 194 | if ParamCount > 0 then 195 | begin 196 | for I := 1 to ParamCount do 197 | xSL.Add(ParamStr(I)); 198 | FClient.SendStringMessage(xSL.DelimitedText); 199 | end 200 | else 201 | if DefaultMessage <> EmptyStr then 202 | FClient.SendStringMessage(DefaultMessage); 203 | finally 204 | xSL.Free; 205 | end; 206 | 207 | end; 208 | 209 | procedure TSimpleSingleInstance.ClientPostString(Message: String); 210 | begin 211 | FClient.SendStringMessage(Message); 212 | end; 213 | 214 | initialization 215 | DefaultSingleInstanceClass:=TSimpleSingleInstance; 216 | 217 | end. 218 | 219 | -------------------------------------------------------------------------------- /src/umacroeditor.pas: -------------------------------------------------------------------------------- 1 | { Ovotext - simple text editor 2 | 3 | Copyright (C) 2015 Marco Caselli <marcocas@gmail.com> 4 | 5 | This source is free software; you can redistribute it and/or modify it under 6 | the terms of the GNU General Public License as published by the Free 7 | Software Foundation; either version 2 of the License, or (at your option) 8 | any later version. 9 | 10 | This code is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 13 | details. 14 | 15 | A copy of the GNU General Public License is available on the World Wide Web 16 | at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing 17 | to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 18 | MA 02111-1307, USA. 19 | } 20 | {$I codegen.inc} 21 | unit uMacroEditor; 22 | 23 | interface 24 | 25 | uses 26 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls, Spin, ComCtrls, ueditor, uActionMacro, 27 | uReplaceMacro, SynEditKeyCmds, SynEdit, ActnList, LCLProc, uMacroRecorder, Stringcostants; 28 | 29 | type 30 | 31 | { TFMacroEditor } 32 | 33 | TFMacroEditor = class(TForm) 34 | btnDelete: TButton; 35 | btnPlay: TButton; 36 | btnRecord: TButton; 37 | btnRecordStop: TButton; 38 | btnRename: TButton; 39 | chkRepeat: TCheckBox; 40 | edRepeat: TSpinEdit; 41 | lbMacroView: TListView; 42 | pnlTop: TPanel; 43 | PanelRepeat: TPanel; 44 | pnlButtons: TPanel; 45 | cbRepeatUntilEof: TCheckBox; 46 | SynEdit1: TSynEdit; 47 | procedure btnDeleteClick(Sender: TObject); 48 | procedure btnPlayClick(Sender: TObject); 49 | procedure btnRecordClick(Sender: TObject); 50 | procedure btnRecordStopClick(Sender: TObject); 51 | procedure btnRenameClick(Sender: TObject); 52 | procedure cbRepeatUntilEofChange(Sender: TObject); 53 | procedure chkRepeatChange(Sender: TObject); 54 | procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 55 | procedure FormShow(Sender: TObject); 56 | procedure lbMacroViewSelectItem(Sender: TObject; Item: TListItem; Selected: Boolean); 57 | private 58 | SynMacroRec: TMacroRecorder; 59 | procedure ReloadMacros; 60 | public 61 | 62 | end; 63 | 64 | Procedure ShowMacroEditor(Recorder: TMacroRecorder); 65 | 66 | implementation 67 | uses 68 | Config; 69 | var 70 | FMacroEditor: TFMacroEditor; 71 | 72 | procedure ShowMacroEditor(Recorder: TMacroRecorder); 73 | begin 74 | if not Assigned(FMacroEditor) then 75 | FMacroEditor := TFMacroEditor.Create(Nil); 76 | FMacroEditor.SynMacroRec:= Recorder; 77 | FMacroEditor.ReloadMacros; 78 | FMacroEditor.Show; 79 | 80 | end; 81 | 82 | 83 | {$R *.lfm} 84 | 85 | { TFMacroEditor } 86 | 87 | procedure TFMacroEditor.btnRecordClick(Sender: TObject); 88 | begin 89 | SynMacroRec.Start; 90 | end; 91 | 92 | procedure TFMacroEditor.btnPlayClick(Sender: TObject); 93 | var 94 | ed : TEditor; 95 | begin 96 | ed := SynMacroRec.Factory.CurrentEditor; 97 | if not Assigned(ed) then 98 | exit; 99 | 100 | ed.SetFocus; 101 | if chkRepeat.Checked then 102 | begin 103 | if cbRepeatUntilEof.Checked then 104 | SynMacroRec.Playback(TMacro(lbMacroView.Selected.Data), True, -1) 105 | else 106 | SynMacroRec.Playback(TMacro(lbMacroView.Selected.Data), True, edRepeat.Value) ; 107 | end 108 | 109 | else 110 | SynMacroRec.Playback(TMacro(lbMacroView.Selected.Data)); 111 | end; 112 | 113 | procedure TFMacroEditor.btnDeleteClick(Sender: TObject); 114 | var 115 | idx : integer; 116 | begin 117 | if not Assigned(lbMacroView.Selected) then 118 | exit; 119 | idx := lbMacroView.Selected.Index; 120 | 121 | if MessageDlg(RSMacro, format(RSMacroDelete, [lbMacroView.Selected.Caption]), mtConfirmation, [mbYes,mbNo], 0) = mrYes then 122 | begin 123 | SynMacroRec.Macros.Remove(TMacro(lbMacroView.Selected.Data)); 124 | ReloadMacros; 125 | if idx < SynMacroRec.Macros.Count then 126 | lbMacroView.Selected := lbMacroView.Items[idx] 127 | else 128 | if (SynMacroRec.Macros.Count <> 0) then 129 | lbMacroView.Selected := lbMacroView.Items[idx-1] 130 | end; 131 | 132 | end; 133 | 134 | procedure TFMacroEditor.btnRecordStopClick(Sender: TObject); 135 | begin 136 | SynMacroRec.Stop; 137 | ReloadMacros; 138 | end; 139 | 140 | procedure TFMacroEditor.btnRenameClick(Sender: TObject); 141 | var 142 | NewName: string; 143 | begin 144 | if not Assigned(lbMacroView.Selected) then 145 | exit; 146 | 147 | NewName := trim(InputBox(RSMacro, RSMacroNewName, lbMacroView.Selected.Caption)); 148 | if (NewName <> '') and (NewName <> lbMacroView.Selected.Caption) then 149 | begin 150 | TMacro(lbMacroView.Selected.Data).Name := NewName; 151 | end; 152 | ReloadMacros; 153 | 154 | end; 155 | 156 | procedure TFMacroEditor.cbRepeatUntilEofChange(Sender: TObject); 157 | begin 158 | edRepeat.Enabled := not cbRepeatUntilEof.Checked; 159 | end; 160 | 161 | procedure TFMacroEditor.chkRepeatChange(Sender: TObject); 162 | begin 163 | cbRepeatUntilEof.Enabled := chkRepeat.Checked; 164 | edRepeat.Enabled := chkRepeat.Checked and not cbRepeatUntilEof.Checked; 165 | 166 | end; 167 | 168 | procedure TFMacroEditor.FormClose(Sender: TObject; var CloseAction: TCloseAction); 169 | begin 170 | SynMacroRec.SaveMacros; 171 | end; 172 | 173 | procedure TFMacroEditor.FormShow(Sender: TObject); 174 | var 175 | DefaultAttr: TFontAttributes; 176 | begin 177 | ReloadMacros; 178 | SynEdit1.Highlighter:= ConfigObj.getHighLighter('.pas'); 179 | SynEdit1.Font.Assign(ConfigObj.Font); 180 | DefaultAttr := ConfigObj.ReadFontAttributes('Schema/Default/Text/', FontAttributes()); 181 | 182 | SynEdit1.Font.Color := DefaultAttr.Foreground; 183 | SynEdit1.Font.Style := DefaultAttr.Styles; 184 | 185 | SynEdit1.Color := DefaultAttr.Background; 186 | 187 | end; 188 | 189 | procedure TFMacroEditor.lbMacroViewSelectItem(Sender: TObject; Item: TListItem; Selected: Boolean); 190 | begin 191 | if Assigned(Item) and selected then 192 | SynEdit1.Lines.Text := TMacro(Item.Data).Commands; 193 | end; 194 | 195 | procedure TFMacroEditor.ReloadMacros; 196 | var 197 | Macro: TMacro; 198 | Item: TListItem; 199 | i: Integer; 200 | begin 201 | lbMacroView.Clear; 202 | for i := 0 to SynMacroRec.Macros.Count - 1 do 203 | begin 204 | Macro := SynMacroRec.Macros[i]; 205 | item := lbMacroView.Items.Add; 206 | item.Caption := Macro.Name; 207 | item.Data := Macro; 208 | item.SubItems.Add(ShortCutToText(Macro.ShortCut)); 209 | end; 210 | SynMacroRec.SignalChange; 211 | end; 212 | 213 | initialization 214 | FMacroEditor := nil; 215 | 216 | finalization 217 | if Assigned(FMacroEditor) then 218 | FMacroEditor.Free; 219 | 220 | end. 221 | 222 | -------------------------------------------------------------------------------- /src/printing/SynEditPrintTypes.pas: -------------------------------------------------------------------------------- 1 | {------------------------------------------------------------------------------- 2 | The contents of this file are subject to the Mozilla Public License 3 | Version 1.1 (the "License"); you may not use this file except in compliance 4 | with the License. You may obtain a copy of the License at 5 | http://www.mozilla.org/MPL/ 6 | 7 | Software distributed under the License is distributed on an "AS IS" basis, 8 | WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for 9 | the specific language governing rights and limitations under the License. 10 | 11 | The Original Code is: SynEditPrintTypes.pas, released 2000-06-01. 12 | 13 | The Initial Author of the Original Code is Morten J. Skovrup. 14 | Portions written by Morten J. Skovrup are copyright 2000 Morten J. Skovrup. 15 | All Rights Reserved. 16 | 17 | Contributors to the SynEdit project are listed in the Contributors.txt file. 18 | 19 | Alternatively, the contents of this file may be used under the terms of the 20 | GNU General Public License Version 2 or later (the "GPL"), in which case 21 | the provisions of the GPL are applicable instead of those above. 22 | If you wish to allow use of your version of this file only under the terms 23 | of the GPL and not to allow others to use your version of this file 24 | under the MPL, indicate your decision by deleting the provisions above and 25 | replace them with the notice and other provisions required by the GPL. 26 | If you do not delete the provisions above, a recipient may use your version 27 | of this file under either the MPL or the GPL. 28 | 29 | $Id: SynEditPrintTypes.pas,v 1.1.1.1 2000/07/08 15:54:06 mghie Exp $ 30 | 31 | You may retrieve the latest version of this file at the SynEdit home page, 32 | located at http://SynEdit.SourceForge.net 33 | 34 | Known Issues: 35 | Wrapping across page boundaries is not supported 36 | -------------------------------------------------------------------------------} 37 | 38 | 39 | {------------------------------------------------------------------------------- 40 | CONTENTS: 41 | Misc types and procedures used in printing and previewing 42 | -------------------------------------------------------------------------------} 43 | 44 | 45 | unit SynEditPrintTypes; 46 | 47 | interface 48 | 49 | uses 50 | Classes, SysUtils; 51 | 52 | const 53 | DefLeft = 25; //Default left margin [mm] 54 | DefRight = 15; //Default right margin [mm] 55 | DefTop = 25; //Default top margin [mm] 56 | DefBottom = 25; //Default bottom margin [mm] 57 | DefHeader = 15; //Default margin from top of paper to bottom of header [mm] 58 | DefFooter = 15; //Default margin from top of footer to bottom of paper [mm] 59 | DefLeftHFTextIndent = 2; //Default Header/footer indent from left margin [mm] 60 | DefRightHFTextIndent = 2; //Default Header/footer indent from right margin [mm] 61 | DefHFInternalMargin = 0.5; //Default Internal margin between Header/footer text and lines [mm] 62 | DefGutter = 0; //Default Binding gutter - added to left or right margin [mm] 63 | type 64 | //Frame around header/footer 65 | TFrameType = (ftLine, ftBox, ftShaded); 66 | TFrameTypes = set of TFrameType; 67 | //Margin units (internally is allways used [mm]) 68 | TUnitSystem = (usMM, usCM, usInch, muThousandthsOfInches); 69 | //Print status events 70 | TSynPrintStatus = (psBegin, psNewPage, psEnd); 71 | TPrintStatusEvent = procedure(Sender: TObject; Status: TSynPrintStatus; 72 | PageNumber: Integer; var Abort: Boolean) of object; 73 | //Event raised when a line is printed (can be used to generate Table of Contents) 74 | TPrintLineEvent = procedure(Sender: TObject; LineNumber, PageNumber: Integer) of object; 75 | TSysCharSet = set of Char; 76 | type 77 | TWrapPos = class 78 | public 79 | Index: Integer; 80 | end; 81 | 82 | function IntToRoman(Value: Integer): string; 83 | 84 | function WrapText(const Line: string; BreakChars: TSysCharSet; 85 | MaxCol: Integer; AList: TList): Boolean; 86 | 87 | implementation 88 | 89 | function WrapText(const Line: string; BreakChars: TSysCharSet; 90 | MaxCol: Integer; AList: TList): Boolean; 91 | //Returns wrapping positions in AList. 92 | var 93 | WrapPos: TWrapPos; 94 | Pos, DPos: Integer; 95 | Found: Boolean; 96 | OrgCount: Integer; 97 | i: Integer; 98 | begin 99 | Result := True; 100 | if Length(Line) <= MaxCol then Exit; 101 | Pos := 1; 102 | DPos := 0; 103 | Found := False; 104 | WrapPos := TWrapPos.Create; 105 | OrgCount := AList.Count; 106 | while Pos <= Length(Line) do begin 107 | if Line[Pos] in BreakChars then begin //We found a possible break 108 | WrapPos.Index := Pos; 109 | Found := True; 110 | end; 111 | {If MaxCol or last character is reached then the wrapping position is 112 | saved - or if no position is found, the procedure failed} 113 | if (Pos - DPos = MaxCol) or (Pos = Length(Line)) then begin 114 | if Found then begin 115 | Found := False; 116 | AList.Add(WrapPos); 117 | DPos := WrapPos.Index; 118 | //If no more wraps needed and not end of line then a new wrap is created 119 | if ((Length(Line) - DPos) > MaxCol) and (Pos < Length(Line)) then 120 | WrapPos := TWrapPos.Create 121 | else 122 | Break; 123 | end 124 | else begin 125 | Result := False; 126 | WrapPos.Free; 127 | //Clear added... 128 | for i := Alist.Count - 1 downto OrgCount do begin 129 | TWrapPos(AList[i]).Free; 130 | AList.Delete(i); 131 | end; 132 | Exit; 133 | end; 134 | end; 135 | Pos := Pos + 1; 136 | end; 137 | end; 138 | 139 | function IntToRoman(Value: Integer): string; 140 | //Integer to Roman - copied on SWAG 141 | begin 142 | Result := ''; 143 | while Value >= 1000 do begin 144 | Result := Result + 'M'; 145 | Value := Value - 1000; 146 | end; { while } 147 | 148 | if Value >= 900 then begin 149 | Result := Result + 'CM'; 150 | Value := Value - 900; 151 | end; { if } 152 | 153 | while Value >= 500 do begin 154 | Result := Result + 'D'; 155 | Value := Value - 500; 156 | end; { while } 157 | 158 | if Value >= 400 then begin 159 | Result := Result + 'CD'; 160 | Value := Value - 400; 161 | end; { if } 162 | 163 | while Value >= 100 do begin 164 | Result := Result + 'C'; 165 | Value := Value - 100; 166 | end; { while } 167 | 168 | if Value >= 90 then begin 169 | Result := Result + 'XC'; 170 | Value := Value - 90; 171 | end; { if } 172 | 173 | while Value >= 50 do begin 174 | Result := Result + 'L'; 175 | Value := Value - 50; 176 | end; { while } 177 | 178 | if Value >= 40 then begin 179 | Result := Result + 'XL'; 180 | Value := Value - 40; 181 | end; { while } 182 | 183 | while Value >= 10 do begin 184 | Result := Result + 'X'; 185 | Value := Value - 10; 186 | end; { while } 187 | 188 | if Value >= 9 then begin 189 | Result := Result + 'IX'; 190 | Value := Value - 9; 191 | end; { if } 192 | 193 | while Value >= 5 do begin 194 | Result := Result + 'V'; 195 | Value := Value - 5; 196 | end; { while } 197 | 198 | if Value >= 4 then begin 199 | Result := Result + 'IV'; 200 | Value := Value - 4; 201 | end; { if } 202 | 203 | while Value > 0 do begin 204 | Result := Result + 'I'; 205 | DEC(Value); 206 | end; { while } 207 | end; 208 | 209 | end. 210 | 211 | -------------------------------------------------------------------------------- /src/udlgsort.lfm: -------------------------------------------------------------------------------- 1 | object dlgSort: TdlgSort 2 | Left = 300 3 | Height = 420 4 | Top = 250 5 | Width = 421 6 | BorderStyle = bsDialog 7 | Caption = 'dlgSort' 8 | ClientHeight = 420 9 | ClientWidth = 421 10 | object ButtonPanel1: TButtonPanel 11 | Left = 6 12 | Height = 34 13 | Top = 380 14 | Width = 409 15 | OKButton.Name = 'OKButton' 16 | OKButton.Caption = 'Sort' 17 | OKButton.OnClick = OKButtonClick 18 | HelpButton.Name = 'HelpButton' 19 | HelpButton.DefaultCaption = True 20 | CloseButton.Name = 'CloseButton' 21 | CloseButton.DefaultCaption = True 22 | CancelButton.Name = 'CancelButton' 23 | CancelButton.DefaultCaption = True 24 | TabOrder = 0 25 | ShowButtons = [pbOK, pbCancel] 26 | end 27 | object rbColumnMode: TRadioButton 28 | AnchorSideTop.Control = pnlGeneral 29 | AnchorSideTop.Side = asrBottom 30 | Left = 8 31 | Height = 19 32 | Top = 89 33 | Width = 405 34 | Align = alTop 35 | BorderSpacing.Around = 8 36 | Caption = 'Sort on fixed columns' 37 | Checked = True 38 | TabOrder = 1 39 | TabStop = True 40 | OnChange = ChangeSortMode 41 | end 42 | object rbDelimitedMode: TRadioButton 43 | AnchorSideLeft.Control = rbColumnMode 44 | AnchorSideTop.Control = pnlColumns 45 | AnchorSideTop.Side = asrBottom 46 | Left = 8 47 | Height = 19 48 | Top = 173 49 | Width = 147 50 | BorderSpacing.Top = 25 51 | Caption = 'Sort delimited text (CSV)' 52 | TabOrder = 2 53 | OnChange = ChangeSortMode 54 | end 55 | object pnlColumns: TPanel 56 | AnchorSideLeft.Control = Owner 57 | AnchorSideTop.Control = rbColumnMode 58 | AnchorSideTop.Side = asrBottom 59 | AnchorSideRight.Control = Owner 60 | AnchorSideRight.Side = asrBottom 61 | Left = 8 62 | Height = 32 63 | Top = 116 64 | Width = 405 65 | Anchors = [akTop, akLeft, akRight] 66 | BorderSpacing.Around = 8 67 | BevelOuter = bvNone 68 | ClientHeight = 32 69 | ClientWidth = 405 70 | TabOrder = 3 71 | object speStart: TSpinEdit 72 | Tag = 1 73 | AnchorSideLeft.Side = asrBottom 74 | AnchorSideTop.Control = pnlColumns 75 | Left = 41 76 | Height = 23 77 | Top = 8 78 | Width = 74 79 | Anchors = [akTop] 80 | BorderSpacing.Around = 8 81 | MinValue = 1 82 | TabOrder = 0 83 | Value = 1 84 | end 85 | object Label1: TLabel 86 | AnchorSideLeft.Control = rbColumnMode 87 | AnchorSideTop.Control = speStart 88 | AnchorSideTop.Side = asrCenter 89 | AnchorSideRight.Control = speStart 90 | Left = 3 91 | Height = 15 92 | Top = 12 93 | Width = 30 94 | Anchors = [akTop, akRight] 95 | BorderSpacing.Left = 16 96 | BorderSpacing.Top = 8 97 | Caption = 'Begin' 98 | end 99 | object speEnd: TSpinEdit 100 | Tag = 1 101 | AnchorSideLeft.Control = Label2 102 | AnchorSideLeft.Side = asrBottom 103 | AnchorSideTop.Control = pnlColumns 104 | Left = 156 105 | Height = 23 106 | Top = 8 107 | Width = 74 108 | Anchors = [akTop] 109 | BorderSpacing.Left = 8 110 | BorderSpacing.Around = 8 111 | MinValue = 1 112 | TabOrder = 1 113 | Value = 1 114 | end 115 | object Label2: TLabel 116 | AnchorSideLeft.Control = speStart 117 | AnchorSideLeft.Side = asrBottom 118 | AnchorSideTop.Control = speEnd 119 | AnchorSideTop.Side = asrCenter 120 | AnchorSideRight.Control = speEnd 121 | Left = 120 122 | Height = 15 123 | Top = 12 124 | Width = 20 125 | Anchors = [akTop, akRight] 126 | BorderSpacing.Left = 8 127 | BorderSpacing.Top = 8 128 | Caption = 'End' 129 | end 130 | end 131 | object pnlDelimited: TPanel 132 | AnchorSideLeft.Control = Owner 133 | AnchorSideTop.Control = rbDelimitedMode 134 | AnchorSideTop.Side = asrBottom 135 | AnchorSideRight.Control = Owner 136 | AnchorSideRight.Side = asrBottom 137 | Left = 8 138 | Height = 169 139 | Top = 200 140 | Width = 405 141 | Anchors = [akTop, akLeft, akRight] 142 | BorderSpacing.Around = 8 143 | BevelOuter = bvNone 144 | ClientHeight = 169 145 | ClientWidth = 405 146 | TabOrder = 4 147 | object Label3: TLabel 148 | AnchorSideLeft.Control = rbDelimitedMode 149 | AnchorSideTop.Control = speColumn 150 | AnchorSideTop.Side = asrCenter 151 | AnchorSideRight.Control = speColumn 152 | Left = -4 153 | Height = 15 154 | Top = 140 155 | Width = 43 156 | Anchors = [akTop, akRight] 157 | BorderSpacing.Around = 8 158 | Caption = 'Column' 159 | end 160 | object speColumn: TSpinEdit 161 | AnchorSideLeft.Control = Label3 162 | AnchorSideLeft.Side = asrBottom 163 | AnchorSideTop.Control = cgDelimiters 164 | AnchorSideTop.Side = asrBottom 165 | Left = 47 166 | Height = 23 167 | Top = 136 168 | Width = 74 169 | Anchors = [akTop] 170 | BorderSpacing.Left = 8 171 | BorderSpacing.Top = 8 172 | TabOrder = 0 173 | Value = 1 174 | end 175 | object cgDelimiters: TCheckGroup 176 | AnchorSideTop.Control = pnlDelimited 177 | Left = 16 178 | Height = 128 179 | Top = 0 180 | Width = 153 181 | AutoFill = True 182 | Caption = 'Delimiters' 183 | ChildSizing.LeftRightSpacing = 6 184 | ChildSizing.TopBottomSpacing = 6 185 | ChildSizing.EnlargeHorizontal = crsHomogenousChildResize 186 | ChildSizing.EnlargeVertical = crsHomogenousChildResize 187 | ChildSizing.ShrinkHorizontal = crsScaleChilds 188 | ChildSizing.ShrinkVertical = crsScaleChilds 189 | ChildSizing.Layout = cclLeftToRightThenTopToBottom 190 | ChildSizing.ControlsPerLine = 1 191 | ClientHeight = 108 192 | ClientWidth = 149 193 | Items.Strings = ( 194 | 'Comma' 195 | 'Semicolon' 196 | 'Tabulation' 197 | 'Space' 198 | 'Custom' 199 | ) 200 | TabOrder = 1 201 | Data = { 202 | 050000000202020202 203 | } 204 | end 205 | object cbQuoteChar: TComboBox 206 | Left = 272 207 | Height = 23 208 | Top = 16 209 | Width = 100 210 | ItemHeight = 15 211 | ItemIndex = 0 212 | Items.Strings = ( 213 | '"' 214 | '''' 215 | '<none>' 216 | ) 217 | Style = csDropDownList 218 | TabOrder = 2 219 | Text = '"' 220 | end 221 | object Label4: TLabel 222 | AnchorSideLeft.Control = rbDelimitedMode 223 | AnchorSideTop.Control = cbQuoteChar 224 | AnchorSideTop.Side = asrCenter 225 | AnchorSideRight.Control = cbQuoteChar 226 | Left = 194 227 | Height = 15 228 | Top = 20 229 | Width = 70 230 | Anchors = [akTop, akRight] 231 | BorderSpacing.Around = 8 232 | Caption = 'Quoting char' 233 | end 234 | object edChar: TMaskEdit 235 | Left = 94 236 | Height = 23 237 | Top = 99 238 | Width = 43 239 | EnableSets = False 240 | MaxLength = 1 241 | TabOrder = 3 242 | EditMask = 'C;1;_' 243 | Text = ' ' 244 | SpaceChar = '_' 245 | end 246 | end 247 | object pnlGeneral: TPanel 248 | Left = 0 249 | Height = 81 250 | Top = 0 251 | Width = 421 252 | Align = alTop 253 | BevelOuter = bvNone 254 | ClientHeight = 81 255 | ClientWidth = 421 256 | TabOrder = 5 257 | object rgOrder: TRadioGroup 258 | Left = 8 259 | Height = 58 260 | Top = 8 261 | Width = 96 262 | AutoFill = True 263 | AutoSize = True 264 | Caption = 'Order' 265 | ChildSizing.LeftRightSpacing = 6 266 | ChildSizing.EnlargeHorizontal = crsHomogenousChildResize 267 | ChildSizing.EnlargeVertical = crsHomogenousChildResize 268 | ChildSizing.ShrinkHorizontal = crsScaleChilds 269 | ChildSizing.ShrinkVertical = crsScaleChilds 270 | ChildSizing.Layout = cclLeftToRightThenTopToBottom 271 | ChildSizing.ControlsPerLine = 1 272 | ClientHeight = 38 273 | ClientWidth = 92 274 | ItemIndex = 0 275 | Items.Strings = ( 276 | 'Ascending' 277 | 'Descending' 278 | ) 279 | TabOrder = 0 280 | end 281 | object cbNumeric: TCheckBox 282 | Left = 120 283 | Height = 19 284 | Top = 17 285 | Width = 338 286 | Caption = 'Sort any value that looks like a number as if it were a number' 287 | TabOrder = 1 288 | end 289 | end 290 | end 291 | -------------------------------------------------------------------------------- /src/replacedialog.lfm: -------------------------------------------------------------------------------- 1 | object CustomReplaceDialog: TCustomReplaceDialog 2 | Left = -1 3 | Height = 350 4 | Top = -1 5 | Width = 583 6 | BorderIcons = [biSystemMenu, biHelp] 7 | Caption = 'Replace Text' 8 | ClientHeight = 350 9 | ClientWidth = 583 10 | Constraints.MinHeight = 184 11 | Constraints.MinWidth = 480 12 | Font.Height = -12 13 | KeyPreview = True 14 | PopupMode = pmAuto 15 | Position = poMainFormCenter 16 | LCLVersion = '4.99.0.0' 17 | OnClose = FormClose 18 | OnCreate = FormCreate 19 | object TextLabel: TLabel 20 | Left = 16 21 | Height = 15 22 | Top = 12 23 | Width = 60 24 | BorderSpacing.Left = 8 25 | BorderSpacing.Top = 14 26 | BorderSpacing.Right = 8 27 | Caption = 'Text to find' 28 | ParentColor = False 29 | end 30 | object ReplaceLabel: TLabel 31 | AnchorSideTop.Side = asrBottom 32 | Left = 8 33 | Height = 1 34 | Top = 45 35 | Width = 1 36 | BorderSpacing.Top = 14 37 | BorderSpacing.Right = 8 38 | ParentColor = False 39 | end 40 | object PanelButtons: TPanel 41 | Left = 583 42 | Height = 304 43 | Top = 0 44 | Width = 0 45 | Align = alRight 46 | AutoSize = True 47 | BevelOuter = bvNone 48 | ChildSizing.LeftRightSpacing = 6 49 | ChildSizing.TopBottomSpacing = 6 50 | ChildSizing.VerticalSpacing = 6 51 | TabOrder = 0 52 | end 53 | object rgSearchMode: TRadioGroup 54 | AnchorSideLeft.Control = Owner 55 | AnchorSideTop.Control = gbOptions 56 | AnchorSideTop.Side = asrBottom 57 | AnchorSideBottom.Side = asrCenter 58 | Left = 6 59 | Height = 105 60 | Top = 192 61 | Width = 232 62 | AutoFill = True 63 | BorderSpacing.Around = 6 64 | Caption = 'Search Mode' 65 | ChildSizing.LeftRightSpacing = 6 66 | ChildSizing.TopBottomSpacing = 6 67 | ChildSizing.EnlargeHorizontal = crsHomogenousChildResize 68 | ChildSizing.EnlargeVertical = crsHomogenousChildResize 69 | ChildSizing.ShrinkHorizontal = crsScaleChilds 70 | ChildSizing.ShrinkVertical = crsScaleChilds 71 | ChildSizing.Layout = cclLeftToRightThenTopToBottom 72 | ChildSizing.ControlsPerLine = 1 73 | ClientHeight = 85 74 | ClientWidth = 228 75 | Items.Strings = ( 76 | 'Normal' 77 | 'Extended' 78 | 'Grep search' 79 | ) 80 | TabOrder = 6 81 | end 82 | object ScopeGroupBox: TGroupBox 83 | AnchorSideLeft.Control = gbOptions 84 | AnchorSideLeft.Side = asrBottom 85 | AnchorSideTop.Side = asrBottom 86 | AnchorSideRight.Control = Owner 87 | AnchorSideRight.Side = asrBottom 88 | Left = 246 89 | Height = 80 90 | Top = 64 91 | Width = 331 92 | Anchors = [akTop, akLeft, akRight] 93 | BorderSpacing.Around = 6 94 | Caption = 'Scope' 95 | ChildSizing.LeftRightSpacing = 6 96 | ChildSizing.EnlargeHorizontal = crsHomogenousChildResize 97 | ChildSizing.EnlargeVertical = crsHomogenousSpaceResize 98 | ChildSizing.ShrinkHorizontal = crsHomogenousSpaceResize 99 | ChildSizing.ShrinkVertical = crsHomogenousSpaceResize 100 | ChildSizing.Layout = cclLeftToRightThenTopToBottom 101 | ChildSizing.ControlsPerLine = 1 102 | ClientHeight = 60 103 | ClientWidth = 327 104 | TabOrder = 5 105 | object SelectedRadioButton: TRadioButton 106 | Left = 6 107 | Height = 19 108 | Top = 8 109 | Width = 315 110 | Caption = 'Selected text' 111 | TabOrder = 0 112 | end 113 | object GlobalRadioButton: TRadioButton 114 | Left = 6 115 | Height = 19 116 | Top = 35 117 | Width = 315 118 | Caption = 'Global' 119 | Checked = True 120 | TabOrder = 1 121 | TabStop = True 122 | end 123 | end 124 | object BtnPanel: TButtonPanel 125 | Left = 6 126 | Height = 34 127 | Top = 310 128 | Width = 571 129 | OKButton.Name = 'OKButton' 130 | OKButton.Caption = 'Replace' 131 | OKButton.OnClick = OKButtonClick 132 | HelpButton.Name = 'HelpButton' 133 | HelpButton.DefaultCaption = True 134 | CloseButton.Name = 'CloseButton' 135 | CloseButton.Caption = 'Replace All' 136 | CloseButton.OnClick = CloseButtonClick 137 | CancelButton.Name = 'CancelButton' 138 | CancelButton.DefaultCaption = True 139 | CancelButton.OnClick = CancelButtonClick 140 | TabOrder = 9 141 | DefaultButton = pbClose 142 | ShowButtons = [pbOK, pbCancel, pbClose] 143 | ShowGlyphs = [] 144 | end 145 | object gbOptions: TGroupBox 146 | AnchorSideLeft.Control = Owner 147 | AnchorSideTop.Side = asrBottom 148 | Left = 6 149 | Height = 122 150 | Top = 64 151 | Width = 234 152 | BorderSpacing.Around = 6 153 | Caption = 'Options' 154 | ClientHeight = 102 155 | ClientWidth = 230 156 | TabOrder = 4 157 | object WholeWordsOnlyCheckBox: TCheckBox 158 | Left = 0 159 | Height = 19 160 | Top = 0 161 | Width = 115 162 | Caption = 'Whole words only' 163 | TabOrder = 0 164 | end 165 | object CaseSensitiveCheckBox: TCheckBox 166 | Left = 0 167 | Height = 19 168 | Top = 23 169 | Width = 93 170 | Caption = 'Case sensitive' 171 | TabOrder = 1 172 | end 173 | object EntireScopeCheckBox: TCheckBox 174 | Left = 0 175 | Height = 19 176 | Top = 46 177 | Width = 107 178 | Caption = 'Search entire file' 179 | TabOrder = 2 180 | end 181 | object PromptOnReplaceCheckBox: TCheckBox 182 | Left = 0 183 | Height = 19 184 | Top = 69 185 | Width = 118 186 | Caption = 'Prompt on replace' 187 | TabOrder = 3 188 | end 189 | end 190 | object cbReplace: TCheckBox 191 | Left = 16 192 | Height = 19 193 | Top = 38 194 | Width = 89 195 | Caption = 'Replace With' 196 | TabOrder = 2 197 | OnChange = cbReplaceChange 198 | end 199 | object EditFind: TComboBox 200 | AnchorSideTop.Side = asrCenter 201 | Left = 130 202 | Height = 23 203 | Top = 5 204 | Width = 366 205 | Anchors = [akTop, akLeft, akRight] 206 | AutoComplete = True 207 | AutoCompleteText = [cbactEnabled, cbactEndOfLineComplete, cbactSearchAscending] 208 | ItemHeight = 15 209 | TabOrder = 1 210 | OnKeyDown = EditFindKeyDown 211 | end 212 | object EditReplace: TComboBox 213 | AnchorSideLeft.Side = asrBottom 214 | AnchorSideTop.Side = asrCenter 215 | Left = 130 216 | Height = 23 217 | Top = 35 218 | Width = 366 219 | Anchors = [akTop, akLeft, akRight] 220 | AutoComplete = True 221 | AutoCompleteText = [cbactEnabled, cbactEndOfLineComplete, cbactSearchAscending] 222 | BorderSpacing.Left = 8 223 | ItemHeight = 15 224 | TabOrder = 3 225 | end 226 | object ToolBar1: TToolBar 227 | Left = 429 228 | Height = 30 229 | Top = 269 230 | Width = 145 231 | Align = alNone 232 | Anchors = [akRight, akBottom] 233 | AutoSize = True 234 | BorderWidth = 1 235 | ButtonHeight = 30 236 | ButtonWidth = 72 237 | EdgeBorders = [] 238 | EdgeInner = esNone 239 | EdgeOuter = esNone 240 | Flat = False 241 | Images = fMain.imgList 242 | TabOrder = 8 243 | object ToolButton1: TToolButton 244 | Left = 73 245 | Top = 0 246 | Action = fMain.SearchFindPrevious 247 | end 248 | object ToolButton2: TToolButton 249 | Left = 1 250 | Top = 0 251 | Action = fMain.SearchFindNext 252 | end 253 | end 254 | object DirectionGroupBox: TGroupBox 255 | AnchorSideLeft.Side = asrBottom 256 | AnchorSideTop.Control = ScopeGroupBox 257 | AnchorSideTop.Side = asrBottom 258 | AnchorSideRight.Control = Owner 259 | AnchorSideRight.Side = asrBottom 260 | Left = 243 261 | Height = 77 262 | Top = 150 263 | Width = 334 264 | Anchors = [akTop, akLeft, akRight] 265 | BorderSpacing.Around = 6 266 | Caption = 'Direction' 267 | ChildSizing.LeftRightSpacing = 6 268 | ChildSizing.EnlargeHorizontal = crsHomogenousChildResize 269 | ChildSizing.EnlargeVertical = crsHomogenousSpaceResize 270 | ChildSizing.ShrinkHorizontal = crsHomogenousSpaceResize 271 | ChildSizing.ShrinkVertical = crsHomogenousSpaceResize 272 | ChildSizing.Layout = cclLeftToRightThenTopToBottom 273 | ChildSizing.ControlsPerLine = 1 274 | ClientHeight = 57 275 | ClientWidth = 330 276 | TabOrder = 7 277 | object BackwardRadioButton: TRadioButton 278 | Left = 6 279 | Height = 19 280 | Top = 7 281 | Width = 318 282 | Caption = 'Backward' 283 | TabOrder = 0 284 | end 285 | object ForwardRadioButton: TRadioButton 286 | Left = 6 287 | Height = 19 288 | Top = 33 289 | Width = 318 290 | Caption = 'Forward' 291 | Checked = True 292 | TabOrder = 1 293 | TabStop = True 294 | end 295 | end 296 | end 297 | -------------------------------------------------------------------------------- /src/printing/syneditprinterinfo.pas: -------------------------------------------------------------------------------- 1 | {------------------------------------------------------------------------------- 2 | The contents of this file are subject to the Mozilla Public License 3 | Version 1.1 (the "License"); you may not use this file except in compliance 4 | with the License. You may obtain a copy of the License at 5 | http://www.mozilla.org/MPL/ 6 | 7 | Software distributed under the License is distributed on an "AS IS" basis, 8 | WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for 9 | the specific language governing rights and limitations under the License. 10 | 11 | The Original Code is: SynEditPrinterInfo.pas, released 2000-06-01. 12 | 13 | The Initial Author of the Original Code is Morten J. Skovrup. 14 | Portions written by Morten J. Skovrup are copyright 2000 Morten J. Skovrup. 15 | All Rights Reserved. 16 | 17 | Contributors to the SynEdit project are listed in the Contributors.txt file. 18 | 19 | Alternatively, the contents of this file may be used under the terms of the 20 | GNU General Public License Version 2 or later (the "GPL"), in which case 21 | the provisions of the GPL are applicable instead of those above. 22 | If you wish to allow use of your version of this file only under the terms 23 | of the GPL and not to allow others to use your version of this file 24 | under the MPL, indicate your decision by deleting the provisions above and 25 | replace them with the notice and other provisions required by the GPL. 26 | If you do not delete the provisions above, a recipient may use your version 27 | of this file under either the MPL or the GPL. 28 | 29 | $Id: SynEditPrinterInfo.pas,v 1.1.1.1 2000/07/08 15:54:05 mghie Exp $ 30 | 31 | You may retrieve the latest version of this file at the SynEdit home page, 32 | located at http://SynEdit.SourceForge.net 33 | 34 | Known Issues: 35 | -------------------------------------------------------------------------------} 36 | 37 | 38 | {------------------------------------------------------------------------------- 39 | CONTENTS: 40 | Class retrieving info about selected printer and paper size. 41 | -------------------------------------------------------------------------------} 42 | 43 | unit SynEditPrinterInfo; 44 | 45 | interface 46 | 47 | uses 48 | Printers, osprinters; 49 | 50 | type 51 | //Printer info class - getting dimensions of paper 52 | TSynEditPrinterInfo = class 53 | private 54 | FPhysicalWidth: Integer; 55 | FPhysicalHeight: Integer; 56 | FPrintableWidth: Integer; 57 | FPrintableHeight: Integer; 58 | FLeftGutter: Integer; 59 | FRightGutter: Integer; 60 | FTopGutter: Integer; 61 | FBottomGutter: Integer; 62 | FXPixPrInch: Integer; 63 | FYPixPrInch: Integer; 64 | FXPixPrmm: Single; 65 | FYPixPrmm: Single; 66 | FIsUpdated: Boolean; 67 | procedure FillDefault; 68 | function GetBottomGutter: Integer; 69 | function GetLeftGutter: Integer; 70 | function GetPhysicalHeight: Integer; 71 | function GetPhysicalWidth: Integer; 72 | function GetPrintableHeight: Integer; 73 | function GetPrintableWidth: Integer; 74 | function GetRightGutter: Integer; 75 | function GetTopGutter: Integer; 76 | function GetXPixPrInch: Integer; 77 | function GetYPixPrInch: Integer; 78 | function GetXPixPrmm: Single; 79 | function GetYPixPrmm: Single; 80 | public 81 | procedure UpdatePrinter; 82 | function PixFromLeft(mmValue: Double): Integer; 83 | function PixFromRight(mmValue: Double): Integer; 84 | function PixFromTop(mmValue: Double): Integer; 85 | function PixFromBottom(mmValue: Double): Integer; 86 | property PhysicalWidth: Integer read GetPhysicalWidth; 87 | property PhysicalHeight: Integer read GetPhysicalHeight; 88 | property PrintableWidth: Integer read GetPrintableWidth; 89 | property PrintableHeight: Integer read GetPrintableHeight; 90 | property LeftGutter: Integer read GetLeftGutter; 91 | property RightGutter: Integer read GetRightGutter; 92 | property TopGutter: Integer read GetTopGutter; 93 | property BottomGutter: Integer read GetBottomGutter; 94 | property XPixPrInch: Integer read GetXPixPrInch; 95 | property YPixPrInch: Integer read GetYPixPrInch; 96 | property XPixPrmm: Single read GetXPixPrmm; 97 | property YPixPrmm: Single read GetYPixPrmm; 98 | end; 99 | 100 | implementation 101 | 102 | { TSynEditPrinterInfo } 103 | 104 | function TSynEditPrinterInfo.PixFromBottom(mmValue: Double): Integer; 105 | begin 106 | if not FIsUpdated then 107 | UpdatePrinter; 108 | Result := Round(mmValue * FYPixPrmm - FBottomGutter); 109 | end; 110 | 111 | function TSynEditPrinterInfo.PixFromLeft(mmValue: Double): Integer; 112 | begin 113 | if not FIsUpdated then 114 | UpdatePrinter; 115 | Result := Round(mmValue * FXPixPrmm - FLeftGutter); 116 | end; 117 | 118 | function TSynEditPrinterInfo.PixFromRight(mmValue: Double): Integer; 119 | begin 120 | if not FIsUpdated then 121 | UpdatePrinter; 122 | Result := Round(mmValue * FXPixPrmm - FRightGutter); 123 | end; 124 | 125 | function TSynEditPrinterInfo.PixFromTop(mmValue: Double): Integer; 126 | begin 127 | if not FIsUpdated then 128 | UpdatePrinter; 129 | Result := Round(mmValue * FYPixPrmm - FTopGutter); 130 | end; 131 | 132 | procedure TSynEditPrinterInfo.FillDefault; 133 | {In case of no printers installed this information is used 134 | (I think it's taken from a HP LaserJet III with A4 paper)} 135 | begin 136 | FPhysicalWidth := 2481; 137 | FPhysicalHeight := 3507; 138 | FPrintableWidth := 2358; 139 | FPrintableHeight := 3407; 140 | FLeftGutter := 65; 141 | FRightGutter := 58; 142 | FTopGutter := 50; 143 | FBottomGutter := 50; 144 | FXPixPrInch := 300; 145 | FYPixPrInch := 300; 146 | FXPixPrmm := FXPixPrInch / 25.4; 147 | FYPixPrmm := FYPixPrInch / 25.4; 148 | end; 149 | 150 | function TSynEditPrinterInfo.GetBottomGutter: Integer; 151 | begin 152 | if not FIsUpdated then 153 | UpdatePrinter; 154 | Result := FBottomGutter; 155 | end; 156 | 157 | function TSynEditPrinterInfo.GetLeftGutter: Integer; 158 | begin 159 | if not FIsUpdated then 160 | UpdatePrinter; 161 | Result := FLeftGutter; 162 | end; 163 | 164 | function TSynEditPrinterInfo.GetPhysicalHeight: Integer; 165 | begin 166 | if not FIsUpdated then 167 | UpdatePrinter; 168 | Result := FPhysicalHeight; 169 | end; 170 | 171 | function TSynEditPrinterInfo.GetPhysicalWidth: Integer; 172 | begin 173 | if not FIsUpdated then 174 | UpdatePrinter; 175 | Result := FPhysicalWidth; 176 | end; 177 | 178 | function TSynEditPrinterInfo.GetPrintableHeight: Integer; 179 | begin 180 | if not FIsUpdated then 181 | UpdatePrinter; 182 | Result := FPrintableHeight; 183 | end; 184 | 185 | function TSynEditPrinterInfo.GetPrintableWidth: Integer; 186 | begin 187 | if not FIsUpdated then 188 | UpdatePrinter; 189 | Result := FPrintableWidth; 190 | end; 191 | 192 | function TSynEditPrinterInfo.GetRightGutter: Integer; 193 | begin 194 | if not FIsUpdated then 195 | UpdatePrinter; 196 | Result := FRightGutter; 197 | end; 198 | 199 | function TSynEditPrinterInfo.GetTopGutter: Integer; 200 | begin 201 | if not FIsUpdated then 202 | UpdatePrinter; 203 | Result := FTopGutter; 204 | end; 205 | 206 | function TSynEditPrinterInfo.GetXPixPrInch: Integer; 207 | begin 208 | if not FIsUpdated then 209 | UpdatePrinter; 210 | Result := FXPixPrInch; 211 | end; 212 | 213 | function TSynEditPrinterInfo.GetXPixPrmm: Single; 214 | begin 215 | if not FIsUpdated then 216 | UpdatePrinter; 217 | Result := FXPixPrmm; 218 | end; 219 | 220 | function TSynEditPrinterInfo.GetYPixPrInch: Integer; 221 | begin 222 | if not FIsUpdated then 223 | UpdatePrinter; 224 | Result := FYPixPrInch; 225 | end; 226 | 227 | function TSynEditPrinterInfo.GetYPixPrmm: Single; 228 | begin 229 | if not FIsUpdated then 230 | UpdatePrinter; 231 | Result := FYPixPrmm; 232 | end; 233 | 234 | procedure TSynEditPrinterInfo.UpdatePrinter; 235 | begin 236 | FIsUpdated := True; 237 | if Printer.Printers.Count <= 0 then begin 238 | FillDefault; 239 | Exit; 240 | end; 241 | FPhysicalWidth := Printer.PaperSize.Width; 242 | FPhysicalHeight := Printer.PaperSize.Height; 243 | FPrintableWidth := Printer.PageWidth; {or GetDeviceCaps(Printer.Handle, HorzRes);} 244 | FPrintableHeight := Printer.PageHeight; {or GetDeviceCaps(Printer.Handle, VertRes);} 245 | FLeftGutter := ((Printer.Canvas) as printer.CanvasClass).LeftMargin; 246 | FTopGutter := ((Printer.Canvas) as printer.CanvasClass).TopMargin; 247 | FRightGutter := FPhysicalWidth - FPrintableWidth - FLeftGutter; 248 | FBottomGutter := FPhysicalHeight - FPrintableHeight - FTopGutter; 249 | FXPixPrInch := Printer.XDPI; //GetDeviceCaps(Printer.Handle, LogPixelsX); 250 | FYPixPrInch := Printer.yDPI;//GetDeviceCaps(Printer.Handle, LogPixelsY); } 251 | FXPixPrmm := FXPixPrInch / 25.4; 252 | FYPixPrmm := FYPixPrInch / 25.4; 253 | end; 254 | 255 | end. 256 | 257 | -------------------------------------------------------------------------------- /src/platform/unix/monitoringthread.pas: -------------------------------------------------------------------------------- 1 | { Ovotext - simple text editor 2 | 3 | Copyright (C) 2015 Marco Caselli <marcocas@gmail.com> 4 | 5 | This source is free software; you can redistribute it and/or modify it under 6 | the terms of the GNU General Public License as published by the Free 7 | Software Foundation; either version 2 of the License, or (at your option) 8 | any later version. 9 | 10 | This code is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 13 | details. 14 | 15 | A copy of the GNU General Public License is available on the World Wide Web 16 | at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing 17 | to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 18 | MA 02111-1307, USA. 19 | } 20 | {$I ..\codegen.inc} 21 | unit monitoringthread; 22 | interface 23 | 24 | uses 25 | Classes, SysUtils, uCheckFileChange, BaseUnix, Linux, platformpath; 26 | 27 | type 28 | 29 | { TPlatformMonitoring } 30 | 31 | TPlatformMonitoring = class(TWatcherThread) 32 | private 33 | FNotifyHandle: THandle; 34 | FEventPipe: TFilDes; 35 | protected 36 | function Init: boolean; override; 37 | procedure Cleanup; override; 38 | procedure TriggerTerminateEvent; override; 39 | procedure DoMonitor; override; 40 | procedure StartMonitoringPath(aPath: string; Data: TPlatformPath); override; 41 | procedure StopMonitoringPath(aPath: string; Data: TPlatformPath); override; 42 | 43 | end; 44 | 45 | implementation 46 | 47 | { TPlatformMonitoring } 48 | 49 | function TPlatformMonitoring.Init: boolean; 50 | begin 51 | 52 | FNotifyHandle := inotify_init(); 53 | Result := FNotifyHandle >= 0; 54 | if not Result then 55 | exit; 56 | // create pipe for user triggered fake event 57 | FEventPipe[0] := -1; 58 | FEventPipe[1] := -1; 59 | if FpPipe(FEventPipe) = 0 then 60 | begin 61 | FpFcntl(FEventPipe[0], F_SETFD, FpFcntl(FEventPipe[0], F_GETFD) or 1); 62 | FpFcntl(FEventPipe[1], F_SETFD, FpFcntl(FEventPipe[1], F_GETFD) or 1); 63 | FpFcntl(FEventPipe[0], F_SetFl, FpFcntl(FEventPipe[0], F_GetFl) or O_NONBLOCK); 64 | FpFcntl(FEventPipe[1], F_SetFl, FpFcntl(FEventPipe[1], F_GetFl) or O_NONBLOCK); 65 | end; 66 | end; 67 | 68 | procedure TPlatformMonitoring.Cleanup; 69 | begin 70 | if FEventPipe[0] <> -1 then 71 | begin 72 | FileClose(FEventPipe[0]); 73 | FEventPipe[0] := -1; 74 | end; 75 | if FEventPipe[1] <> -1 then 76 | begin 77 | FileClose(FEventPipe[1]); 78 | FEventPipe[1] := -1; 79 | end; 80 | if FNotifyHandle <> feInvalidHandle then 81 | begin 82 | FileClose(FNotifyHandle); 83 | FNotifyHandle := feInvalidHandle; 84 | end; 85 | 86 | end; 87 | 88 | procedure TPlatformMonitoring.TriggerTerminateEvent; 89 | var 90 | buf: char; 91 | begin 92 | 93 | if Self.FNotifyHandle <> feInvalidHandle then 94 | begin 95 | buf := #0; 96 | FileWrite(FEventPipe[1], buf, 1); 97 | end; 98 | 99 | end; 100 | 101 | procedure TPlatformMonitoring.DoMonitor; 102 | const 103 | // Buffer size passed to read() must be at least the size of the first event 104 | // to be read from the file descriptor, otherwise Invalid Parameter is returned. 105 | // Event record size is variable, we use maximum possible for a single event. 106 | // Usually it is big enough so that multiple events can be read with single read(). 107 | // The 'name' field is always padded up to multiple of 16 bytes with NULLs. 108 | buffer_size = (sizeof(inotify_event) + MAX_PATH) * 8; 109 | var 110 | bytes_to_parse, p, k, i: integer; 111 | buf: pchar = nil; 112 | ev, v: pinotify_event; 113 | fds: array[0..1] of tpollfd; 114 | pData: TFileWatch; 115 | ret: cint; 116 | ActivePath: TPlatformPath; 117 | begin 118 | if (FNotifyHandle = feInvalidHandle) or 119 | (FEventPipe[0] = -1) or 120 | (FEventPipe[1] = -1) then 121 | Exit; 122 | 123 | try 124 | buf := GetMem(buffer_size); 125 | 126 | // set file descriptors 127 | fds[0].fd := FEventPipe[0]; 128 | fds[0].events := POLLIN; 129 | 130 | fds[1].fd := FNotifyHandle; 131 | fds[1].events := POLLIN; 132 | 133 | while not Terminated do 134 | begin 135 | // wait for events 136 | repeat 137 | ret := fpPoll(@fds[0], Length(fds), -1); 138 | until (ret <> -1) or (fpGetErrNo <> ESysEINTR); 139 | 140 | if ret = -1 then 141 | begin 142 | Exit; 143 | end; { if } 144 | 145 | if (fds[0].revents and POLLIN <> 0) then 146 | begin 147 | // clear pipe 148 | while FileRead(FEventPipe[0], buf^, 1) <> -1 do ; 149 | end; { if } 150 | 151 | if (fds[1].revents and POLLIN = 0) then // inotify handle didn't change, so user triggered 152 | Continue; 153 | 154 | // Read events. 155 | bytes_to_parse := FileRead(FNotifyHandle, buf^, buffer_size); 156 | if bytes_to_parse = -1 then 157 | begin 158 | Continue; 159 | end; { if } 160 | 161 | // parse events and print them 162 | p := 0; 163 | while p < bytes_to_parse do 164 | begin 165 | ev := pinotify_event(buf + p); 166 | 167 | for ActivePath in Paths.Values do 168 | begin 169 | if ev^.wd = ActivePath.Handle then 170 | begin 171 | with FCurrentEventData do 172 | begin 173 | FileName := StrPas(PChar(@ev^.Name)); 174 | pData := FMasterList.GetWatch(IncludeTrailingPathDelimiter(ActivePath.path)+ Filename); 175 | if not Assigned(pData) then 176 | Continue; 177 | Data := pData.Data; 178 | // IN_MOVED_FROM is converted to FileDelete. 179 | // IN_MOVED_TO is converted to FileCreate. 180 | // There is no guarantee we will receive as sequence of 181 | // IN_MOVED_FROM, IN_MOVED_TO as the events are only sent 182 | // if the source and destination directories respectively 183 | // are being watched. 184 | 185 | if (ev^.mask and (IN_IGNORED or 186 | IN_Q_OVERFLOW)) <> 0 then 187 | begin 188 | // Ignore this event. 189 | Break; 190 | end 191 | else if (ev^.mask and (IN_ACCESS or 192 | IN_MODIFY or 193 | IN_ATTRIB or 194 | IN_CLOSE or 195 | IN_OPEN or 196 | IN_CLOSE_WRITE or 197 | IN_CLOSE_NOWRITE)) <> 0 then 198 | begin 199 | Event := fwscModified; 200 | end 201 | else if (ev^.mask and IN_DELETE) <> 0 then 202 | begin 203 | Event := fwscDeleted; 204 | end 205 | else if (ev^.mask and IN_MOVED_FROM) <> 0 then 206 | begin 207 | Event := fwscDeleted; 208 | // Try to find related event 209 | k := p + sizeof(inotify_event) + ev^.len; 210 | while (k < bytes_to_parse) do 211 | begin 212 | v := pinotify_event(buf + k); 213 | if (v^.mask and IN_MOVED_TO) <> 0 then 214 | begin 215 | // Same cookie and path 216 | if (v^.cookie = ev^.cookie) and (v^.wd = ev^.wd) then 217 | begin 218 | v^.mask := IN_IGNORED; 219 | Event := fwscRenamed; 220 | NewName := StrPas(PChar(@v^.Name)); 221 | Break; 222 | end; 223 | end; 224 | k := k + sizeof(inotify_event) + v^.len; 225 | end; 226 | end 227 | else if (ev^.mask and (IN_DELETE_SELF or 228 | IN_MOVE_SELF)) <> 0 then 229 | begin 230 | // Watched file/directory was deleted or moved. 231 | // Event := fswSelfDeleted; 232 | end 233 | else 234 | begin 235 | Event := fwscNone; 236 | end; 237 | ; 238 | end; 239 | 240 | // call event handler 241 | SyncDoWatcherEvent; 242 | 243 | Break; 244 | end; { if } 245 | end; { for } 246 | 247 | p := p + sizeof(inotify_event) + ev^.len; 248 | end; { while } 249 | 250 | end; { while } 251 | 252 | finally 253 | if Assigned(buf) then 254 | FreeMem(buf); 255 | end; { try - finally } 256 | 257 | end; 258 | 259 | procedure TPlatformMonitoring.StartMonitoringPath(aPath: string; Data: TPlatformPath); 260 | var 261 | hNotifyFilter: cuint32 = IN_DELETE_SELF or IN_MOVE_SELF; 262 | begin 263 | hNotifyFilter := hNotifyFilter or IN_CREATE or IN_DELETE or IN_MOVE; 264 | hNotifyFilter := hNotifyFilter or IN_ATTRIB or IN_MODIFY; 265 | 266 | Data.Handle := inotify_add_watch(FNotifyHandle, PChar(aPath), hNotifyFilter); 267 | if Data.Handle < 0 then 268 | begin 269 | Data.Handle := feInvalidHandle; 270 | end; 271 | end; 272 | 273 | procedure TPlatformMonitoring.StopMonitoringPath(aPath: string; Data: TPlatformPath); 274 | begin 275 | if Data.Handle <> feInvalidHandle then 276 | begin 277 | inotify_rm_watch(FNotifyHandle, Data.Handle); 278 | end; 279 | 280 | end; 281 | 282 | 283 | end. 284 | -------------------------------------------------------------------------------- /src/highlighters/SynExportRTF.pas: -------------------------------------------------------------------------------- 1 | {------------------------------------------------------------------------------- 2 | The contents of this file are subject to the Mozilla Public License 3 | Version 1.1 (the "License"); you may not use this file except in compliance 4 | with the License. You may obtain a copy of the License at 5 | http://www.mozilla.org/MPL/ 6 | 7 | Software distributed under the License is distributed on an "AS IS" basis, 8 | WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for 9 | the specific language governing rights and limitations under the License. 10 | 11 | The Original Code is: SynExportRTF.pas, released 2000-04-16. 12 | 13 | The Original Code is partly based on the mwRTFExport.pas file from the 14 | mwEdit component suite by Martin Waldenburg and other developers, the Initial 15 | Author of this file is Michael Hieke. 16 | Portions created by Michael Hieke are Copyright 2000 Michael Hieke. 17 | Portions created by James D. Jacobson are Copyright 1999 Martin Waldenburg. 18 | All Rights Reserved. 19 | 20 | Contributors to the SynEdit project are listed in the Contributors.txt file. 21 | 22 | Alternatively, the contents of this file may be used under the terms of the 23 | GNU General Public License Version 2 or later (the "GPL"), in which case 24 | the provisions of the GPL are applicable instead of those above. 25 | If you wish to allow use of your version of this file only under the terms 26 | of the GPL and not to allow others to use your version of this file 27 | under the MPL, indicate your decision by deleting the provisions above and 28 | replace them with the notice and other provisions required by the GPL. 29 | If you do not delete the provisions above, a recipient may use your version 30 | of this file under either the MPL or the GPL. 31 | 32 | $Id: SynExportRTF.pas,v 1.1.1.1 2000/07/08 15:54:05 mghie Exp $ 33 | 34 | You may retrieve the latest version of this file at the SynEdit home page, 35 | located at http://SynEdit.SourceForge.net 36 | 37 | Known Issues: 38 | -------------------------------------------------------------------------------} 39 | {$I codegen.inc} 40 | unit SynExportRTF; 41 | 42 | interface 43 | 44 | uses 45 | Classes, 46 | LCLIntf, LCLType, Graphics, ClipBrd, 47 | SynEditExport; 48 | 49 | type 50 | 51 | { TSynExporterRTF } 52 | 53 | TSynExporterRTF = class(TSynCustomExporter) 54 | private 55 | fAttributesChanged: boolean; 56 | fListColors: TList; 57 | function ColorToRTF(AColor: TColor): string; 58 | function GetColorIndex(AColor: TColor): integer; 59 | protected 60 | procedure FormatAfterLastAttribute; override; 61 | procedure FormatAttributeDone(BackgroundChanged, ForegroundChanged: boolean; 62 | FontStylesChanged: TFontStyles); override; 63 | procedure FormatAttributeInit(BackgroundChanged, ForegroundChanged: boolean; 64 | FontStylesChanged: TFontStyles); override; 65 | procedure FormatNewLine; override; 66 | function GetFooter: string; override; 67 | function GetFormatName: string; override; 68 | function GetHeader: string; override; 69 | procedure FormatBeforeFirstAttribute(BackgroundChanged, 70 | ForegroundChanged: boolean; FontStylesChanged: TFontStyles); override; 71 | {$IFDEF SYN_MBCSSUPPORT} 72 | function ReplaceMBCS(Char1, Char2: char): string; override; 73 | {$ENDIF} 74 | public 75 | constructor Create(AOwner: TComponent); override; 76 | destructor Destroy; override; 77 | procedure Clear; override; 78 | published 79 | property Color; 80 | property DefaultFilter; 81 | property Font; 82 | property Highlighter; 83 | property Title; 84 | property UseBackground; 85 | end; 86 | 87 | implementation 88 | 89 | uses 90 | SysUtils, 91 | SynEditStrConst,SynEditStrConstExtra; 92 | 93 | { TSynExporterRTF } 94 | 95 | constructor TSynExporterRTF.Create(AOwner: TComponent); 96 | {$ifdef windows} 97 | const ClipboardFormat_RTF = 'Rich Text Format'; 98 | {$endif} 99 | {$ifdef Linux} 100 | const ClipboardFormat_RTF = 'text/rtf'; 101 | {$endif} 102 | {$ifdef darwin} 103 | const ClipboardFormat_RTF = 'text/rtf'; 104 | {$endif} 105 | begin 106 | inherited Create(AOwner); 107 | fListColors := TList.Create; 108 | fDefaultFilter := SYNS_FilterRTF; 109 | fClipboardFormat := RegisterClipboardFormat(ClipboardFormat_RTF); 110 | // setup array of chars to be replaced 111 | fReplaceReserved['\'] := '\\'; 112 | fReplaceReserved['{'] := '\{'; 113 | fReplaceReserved['}'] := '\}'; 114 | end; 115 | 116 | destructor TSynExporterRTF.Destroy; 117 | begin 118 | fListColors.Free; 119 | fListColors := nil; 120 | inherited Destroy; 121 | end; 122 | 123 | procedure TSynExporterRTF.Clear; 124 | begin 125 | inherited Clear; 126 | if Assigned(fListColors) then 127 | fListColors.Clear; 128 | end; 129 | 130 | function TSynExporterRTF.ColorToRTF(AColor: TColor): string; 131 | var 132 | Col: Integer; 133 | begin 134 | Col := ColorToRGB(AColor); 135 | Result := Format('\red%d\green%d\blue%d;', [GetRValue(Col), GetGValue(Col), 136 | GetBValue(Col)]); 137 | end; 138 | 139 | procedure TSynExporterRTF.FormatAfterLastAttribute; 140 | begin 141 | // no need to reset the font style here... 142 | end; 143 | 144 | procedure TSynExporterRTF.FormatAttributeDone(BackgroundChanged, 145 | ForegroundChanged: boolean; FontStylesChanged: TFontStyles); 146 | const 147 | FontTags: array[TFontStyle] of string = ('\b0', '\i0', '\ul0', '\strike0'); 148 | var 149 | AStyle: TFontStyle; 150 | begin 151 | // nothing to do about the color, but reset the font style 152 | for AStyle := Low(TFontStyle) to High(TFontStyle) do begin 153 | if AStyle in FontStylesChanged then begin 154 | fAttributesChanged := TRUE; 155 | AddData(FontTags[AStyle]); 156 | end; 157 | end; 158 | end; 159 | 160 | procedure TSynExporterRTF.FormatAttributeInit(BackgroundChanged, 161 | ForegroundChanged: boolean; FontStylesChanged: TFontStyles); 162 | const 163 | FontTags: array[TFontStyle] of string = ('\b', '\i', '\ul', '\strike'); 164 | var 165 | AStyle: TFontStyle; 166 | begin 167 | // text color 168 | if ForegroundChanged then begin 169 | AddData(Format('\cf%d', [GetColorIndex(fLastFG)])); 170 | fAttributesChanged := TRUE; 171 | end; 172 | // background color 173 | 174 | if BackgroundChanged or fUseBackground then begin 175 | AddData(Format('\chshdng0\chcbpat%0:d\cb%0:d', [GetColorIndex(fLastBG)])); 176 | fAttributesChanged := TRUE; 177 | end; 178 | 179 | // font styles 180 | for AStyle := Low(TFontStyle) to High(TFontStyle) do 181 | if AStyle in FontStylesChanged then begin 182 | AddData(FontTags[AStyle]); 183 | fAttributesChanged := TRUE; 184 | end; 185 | if fAttributesChanged then begin 186 | AddData(' '); 187 | fAttributesChanged := FALSE; 188 | end; 189 | end; 190 | 191 | procedure TSynExporterRTF.FormatNewLine; 192 | begin 193 | AddData(#13#10'\par '); 194 | end; 195 | 196 | function TSynExporterRTF.GetColorIndex(AColor: TColor): integer; 197 | begin 198 | Result := fListColors.IndexOf(pointer(ptruint(AColor))); 199 | if Result = -1 then 200 | Result := fListColors.Add(pointer(PtrUInt(AColor))); 201 | end; 202 | 203 | function TSynExporterRTF.GetFooter: string; 204 | begin 205 | Result := '}'; 206 | end; 207 | 208 | function TSynExporterRTF.GetFormatName: string; 209 | begin 210 | Result := SYNS_ExporterFormatRTF; 211 | end; 212 | 213 | function TSynExporterRTF.GetHeader: string; 214 | var 215 | i: integer; 216 | 217 | function GetFontTable: string; 218 | {$IFDEF SYN_MBCSSUPPORT} 219 | var 220 | IsSpace: boolean; 221 | {$ENDIF} 222 | begin 223 | {$IFDEF SYN_MBCSSUPPORT} 224 | if ByteType(Font.Name, 1) <> mbSingleByte then begin 225 | Result := '{\fonttbl{\f0\fnil\fcharset134 ' + 226 | ReplaceReservedChars(Font.Name, IsSpace) 227 | end else 228 | {$ENDIF} 229 | Result := '{\fonttbl{\f0\fmodern ' + Font.Name; 230 | Result := Result + ';}}'#13#10; 231 | end; 232 | 233 | begin 234 | Result := '{\rtf1\ansi\deff0\deftab720' + GetFontTable; 235 | // all the colors 236 | Result := Result + '{\colortbl'; 237 | for i := 0 to fListColors.Count - 1 do 238 | Result := Result + ColorToRTF(TColor(UIntPtr(fListColors[i]))); 239 | Result := Result + '}'#13#10; 240 | // title and creator comment 241 | Result := Result + '{\info{\comment Generated by the SynEdit RTF ' + 242 | 'exporter}'#13#10; 243 | Result := Result + '{\title ' + fTitle + '}}'#13#10; 244 | Result := Result + Format('\deflang1033\pard\plain\f0\fs%d ', [2 * Font.Size]); 245 | end; 246 | 247 | procedure TSynExporterRTF.FormatBeforeFirstAttribute(BackgroundChanged, 248 | ForegroundChanged: boolean; FontStylesChanged: TFontStyles); 249 | const 250 | FontTags: array[TFontStyle] of string = ('\b', '\i', '\ul', '\strike'); 251 | var 252 | AStyle: TFontStyle; 253 | begin 254 | // text color 255 | if ForegroundChanged then begin 256 | AddData(Format('\cf%d', [GetColorIndex(fLastFG)])); 257 | fAttributesChanged := TRUE; 258 | end; 259 | // background color 260 | if BackgroundChanged then begin 261 | AddData(Format('\chshdng0\chcbpat%0:d\cb%0:d', [GetColorIndex(fLastBG)])); 262 | fAttributesChanged := TRUE; 263 | end; 264 | // font styles 265 | for AStyle := Low(TFontStyle) to High(TFontStyle) do 266 | if AStyle in FontStylesChanged then begin 267 | AddData(FontTags[AStyle]); 268 | fAttributesChanged := TRUE; 269 | end; 270 | if fAttributesChanged then begin 271 | AddData(' '); 272 | fAttributesChanged := FALSE; 273 | end; 274 | end; 275 | 276 | {$IFDEF SYN_MBCSSUPPORT} 277 | function TSynExporterRTF.ReplaceMBCS(Char1, Char2: char): string; 278 | begin 279 | Result := Format('\''%x\''%x ', [Char1, Char2]); 280 | end; 281 | {$ENDIF} 282 | 283 | end. 284 | -------------------------------------------------------------------------------- /src/cmdlineparser.pas: -------------------------------------------------------------------------------- 1 | { Ovotext - simple text editor 2 | 3 | Copyright (C) 2015 Marco Caselli <marcocas@gmail.com> 4 | 5 | This source is free software; you can redistribute it and/or modify it under 6 | the terms of the GNU General Public License as published by the Free 7 | Software Foundation; either version 2 of the License, or (at your option) 8 | any later version. 9 | 10 | This code is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 13 | details. 14 | 15 | A copy of the GNU General Public License is available on the World Wide Web 16 | at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing 17 | to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 18 | MA 02111-1307, USA. 19 | } 20 | {$I codegen.inc} 21 | {$modeswitch ADVANCEDRECORDS} 22 | unit CmdLineParser; 23 | 24 | interface 25 | 26 | uses 27 | SysUtils, Classes, Generics.Collections; 28 | 29 | type 30 | // Option definition for mapping short and long forms 31 | TOptionDef = record 32 | ShortForm: string; 33 | LongForm: string; 34 | Description: string; 35 | HasValue: boolean; 36 | end; 37 | 38 | // Class to handle Linux-style command line parameters 39 | 40 | { TCmdLineParser } 41 | 42 | TCmdLineParser = class 43 | private 44 | type tIntDictionary = specialize TDictionary<string, string>; 45 | private 46 | FOptions: TIntDictionary; 47 | FArguments: TStringList; 48 | FOptionDefs: specialize TArray<TOptionDef>; 49 | FParsed: boolean; 50 | 51 | procedure ParseParameters(Params: TStringList); 52 | function IsShortOption(const AParam: string): boolean; 53 | function IsLongOption(const AParam: string): boolean; 54 | function ExtractOptionName(const AParam: string): string; 55 | function ExtractOptionValue(const AParam: string): string; 56 | function FindOptionDef(const AOption: string): integer; 57 | function NormalizeOptionName(const AOption: string): string; 58 | 59 | public 60 | constructor Create; 61 | destructor Destroy; override; 62 | 63 | // Define option mappings (call this before Parse) 64 | procedure DefineOption(const AShort, ALong, ADescription: string; AHasValue: boolean = False); 65 | 66 | // Parse command line parameters 67 | procedure ParseParamStr; 68 | 69 | // Parse From an already available list 70 | procedure Parse(Params: TStringList); 71 | 72 | // Check if an option exists (works with both short and long forms) 73 | function HasOption(const AOption: string): boolean; 74 | 75 | // Get option value (returns empty string if not found) 76 | function GetOptionValue(const AOption: string): string; 77 | 78 | // Get option value with default 79 | function GetOptionValue(const AOption: string; const ADefault: string): string; overload; 80 | 81 | // Get all non-option arguments 82 | function GetArguments: TStringList; 83 | 84 | // Get argument by index 85 | function GetArgument(AIndex: integer): string; 86 | 87 | // Get number of arguments 88 | function ArgumentCount: integer; 89 | 90 | // Properties 91 | property Options: TIntDictionary read FOptions; 92 | property Arguments: TStringList read FArguments; 93 | end; 94 | 95 | implementation 96 | 97 | constructor TCmdLineParser.Create; 98 | begin 99 | inherited Create; 100 | FOptions := TIntDictionary.Create; 101 | FArguments := TStringList.Create; 102 | FParsed := False; 103 | 104 | // Define some common options by default 105 | SetLength(FOptionDefs, 0); 106 | DefineOption('h', 'help', 'Show help message', False); 107 | DefineOption('c', 'column', 'Navigate to colum', False); 108 | DefineOption('r', 'row', 'Navigate to row ', True); 109 | 110 | end; 111 | 112 | destructor TCmdLineParser.Destroy; 113 | begin 114 | FOptions.Free; 115 | FArguments.Free; 116 | inherited Destroy; 117 | end; 118 | 119 | procedure TCmdLineParser.DefineOption(const AShort, ALong, ADescription: string; AHasValue: boolean = False); 120 | var 121 | optDef: TOptionDef; 122 | begin 123 | optDef.ShortForm := AShort; 124 | optDef.LongForm := ALong; 125 | optDef.Description := ADescription; 126 | optDef.HasValue := AHasValue; 127 | 128 | SetLength(FOptionDefs, Length(FOptionDefs) + 1); 129 | FOptionDefs[High(FOptionDefs)] := optDef; 130 | end; 131 | 132 | function TCmdLineParser.FindOptionDef(const AOption: string): integer; 133 | var 134 | i: integer; 135 | begin 136 | Result := -1; 137 | for i := 0 to High(FOptionDefs) do 138 | if (FOptionDefs[i].ShortForm = AOption) or (FOptionDefs[i].LongForm = AOption) then 139 | begin 140 | Result := i; 141 | Break; 142 | end; 143 | end; 144 | 145 | function TCmdLineParser.NormalizeOptionName(const AOption: string): string; 146 | var 147 | idx: integer; 148 | begin 149 | // Always return the long form as the normalized name 150 | idx := FindOptionDef(AOption); 151 | if idx >= 0 then 152 | Result := FOptionDefs[idx].LongForm 153 | else 154 | Result := AOption; // If not found in definitions, use as-is 155 | end; 156 | 157 | procedure TCmdLineParser.ParseParamStr; 158 | var 159 | Params: TStringList; 160 | i: Integer; 161 | begin 162 | if not FParsed then 163 | begin 164 | Params := TStringList.Create; 165 | try 166 | for i := 0 to ParamCount - 1 do 167 | Params.Add(ParamStr(i)); 168 | 169 | ParseParameters(Params); 170 | finally 171 | Params.Free; 172 | end; 173 | FParsed := True; 174 | end; 175 | end; 176 | 177 | procedure TCmdLineParser.Parse(Params: TStringList); 178 | begin 179 | ParseParameters(Params); 180 | FParsed := True; 181 | 182 | end; 183 | 184 | procedure TCmdLineParser.ParseParameters(Params: TStringList); 185 | var 186 | i: integer; 187 | param, nextParam: string; 188 | optionName, optionValue: string; 189 | begin 190 | FOptions.Clear; 191 | FArguments.Clear; 192 | 193 | i := 1; 194 | while i < Params.Count do 195 | begin 196 | param := Params[i]; 197 | 198 | if IsShortOption(param) or IsLongOption(param) then 199 | begin 200 | optionName := NormalizeOptionName(ExtractOptionName(param)); 201 | optionValue := ExtractOptionValue(param); 202 | 203 | // If no value in current parameter, check next parameter 204 | if (optionValue = '') and (i < Params.Count) then 205 | begin 206 | nextParam := Params[i + 1]; 207 | // If next param is not an option, use it as value 208 | if not (IsShortOption(nextParam) or IsLongOption(nextParam)) then 209 | begin 210 | optionValue := nextParam; 211 | Inc(i); // Skip next parameter since we used it as value 212 | end; 213 | end; 214 | 215 | FOptions.AddOrSetValue(optionName, optionValue); 216 | end 217 | else 218 | FArguments.Add(param)// Regular argument 219 | ; 220 | 221 | Inc(i); 222 | end; 223 | end; 224 | 225 | function TCmdLineParser.IsShortOption(const AParam: string): boolean; 226 | begin 227 | Result := (Length(AParam) >= 2) and (AParam[1] = '-') and (AParam[2] <> '-'); 228 | end; 229 | 230 | function TCmdLineParser.IsLongOption(const AParam: string): boolean; 231 | begin 232 | Result := (Length(AParam) >= 3) and (Copy(AParam, 1, 2) = '--'); 233 | end; 234 | 235 | function TCmdLineParser.ExtractOptionName(const AParam: string): string; 236 | var 237 | equalPos: integer; 238 | begin 239 | if IsLongOption(AParam) then 240 | Result := Copy(AParam, 3, Length(AParam) - 2)// Remove -- 241 | 242 | else if IsShortOption(AParam) then 243 | Result := Copy(AParam, 2, Length(AParam) - 1)// Remove - 244 | 245 | else 246 | Result := AParam; 247 | 248 | // Handle --option=value format 249 | equalPos := Pos('=', Result); 250 | if equalPos > 0 then 251 | Result := Copy(Result, 1, equalPos - 1); 252 | end; 253 | 254 | function TCmdLineParser.ExtractOptionValue(const AParam: string): string; 255 | var 256 | equalPos: integer; 257 | optionPart: string; 258 | begin 259 | Result := ''; 260 | 261 | if IsLongOption(AParam) then 262 | optionPart := Copy(AParam, 3, Length(AParam) - 2) 263 | else if IsShortOption(AParam) then 264 | optionPart := Copy(AParam, 2, Length(AParam) - 1) 265 | else 266 | Exit; 267 | 268 | equalPos := Pos('=', optionPart); 269 | if equalPos > 0 then 270 | Result := Copy(optionPart, equalPos + 1, Length(optionPart) - equalPos); 271 | end; 272 | 273 | function TCmdLineParser.HasOption(const AOption: string): boolean; 274 | var 275 | normalizedName: string; 276 | begin 277 | ParseParamStr; 278 | normalizedName := NormalizeOptionName(AOption); 279 | Result := FOptions.ContainsKey(normalizedName); 280 | end; 281 | 282 | function TCmdLineParser.GetOptionValue(const AOption: string): string; 283 | var 284 | normalizedName: string; 285 | begin 286 | ParseParamStr; 287 | normalizedName := NormalizeOptionName(AOption); 288 | if FOptions.ContainsKey(normalizedName) then 289 | Result := FOptions[normalizedName] 290 | else 291 | Result := ''; 292 | end; 293 | 294 | function TCmdLineParser.GetOptionValue(const AOption: string; const ADefault: string): string; 295 | begin 296 | Result := GetOptionValue(AOption); 297 | if Result = '' then 298 | Result := ADefault; 299 | end; 300 | 301 | function TCmdLineParser.GetArguments: TStringList; 302 | begin 303 | ParseParamStr; 304 | Result := FArguments; 305 | end; 306 | 307 | function TCmdLineParser.GetArgument(AIndex: integer): string; 308 | begin 309 | ParseParamStr; 310 | if (AIndex >= 0) and (AIndex < FArguments.Count) then 311 | Result := FArguments[AIndex] 312 | else 313 | Result := ''; 314 | end; 315 | 316 | function TCmdLineParser.ArgumentCount: integer; 317 | begin 318 | ParseParamStr; 319 | Result := FArguments.Count; 320 | end; 321 | 322 | 323 | end. 324 | 325 | -------------------------------------------------------------------------------- /src/replacedialog.pas: -------------------------------------------------------------------------------- 1 | { Ovotext - simple text editor 2 | 3 | Copyright (C) 2015 Marco Caselli <marcocas@gmail.com> 4 | 5 | This source is free software; you can redistribute it and/or modify it under 6 | the terms of the GNU General Public License as published by the Free 7 | Software Foundation; either version 2 of the License, or (at your option) 8 | any later version. 9 | 10 | This code is distributed in the hope that it will be useful, but WITHOUT ANY 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 13 | details. 14 | 15 | A copy of the GNU General Public License is available on the World Wide Web 16 | at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing 17 | to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 18 | MA 02111-1307, USA. 19 | } 20 | {$I codegen.inc} 21 | unit ReplaceDialog; 22 | 23 | interface 24 | 25 | uses 26 | Classes, SysUtils, TypInfo, Forms, Controls, Graphics, Dialogs, lcltype, 27 | Buttons, StdCtrls, ExtCtrls, ButtonPanel, Arrow, ComCtrls, Config, SynEditTypes; 28 | 29 | type 30 | 31 | { TCustomReplaceDialog } 32 | 33 | { TMyReplaceDialog } 34 | TSearchMode = (smNormal, smExtended, smRegexp); 35 | 36 | TMySynSearchOption = (ssoMatchCase, ssoWholeWord, 37 | ssoBackwards, 38 | ssoEntireScope, ssoSelectedOnly, 39 | ssoReplace, ssoReplaceAll, 40 | ssoPrompt, 41 | ssoSearchInReplacement, // continue search-replace in replacement (with ssoReplaceAll) // replace recursive 42 | ssoRegExpr, ssoRegExprMultiLine, 43 | ssoFindContinue, ssoExtended); 44 | TMySynSearchOptions = set of TMySynSearchOption; 45 | 46 | 47 | TCustomReplaceDialog = class(TForm) 48 | BackwardRadioButton: TRadioButton; 49 | BtnPanel: TButtonPanel; 50 | CaseSensitiveCheckBox: TCheckBox; 51 | cbReplace: TCheckBox; 52 | DirectionGroupBox: TGroupBox; 53 | EditFind: TComboBox; 54 | EditReplace: TComboBox; 55 | EntireScopeCheckBox: TCheckBox; 56 | ForwardRadioButton: TRadioButton; 57 | GlobalRadioButton: TRadioButton; 58 | gbOptions: TGroupBox; 59 | PromptOnReplaceCheckBox: TCheckBox; 60 | ScopeGroupBox: TGroupBox; 61 | rgSearchMode: TRadioGroup; 62 | PanelButtons: TPanel; 63 | SelectedRadioButton: TRadioButton; 64 | TextLabel: TLabel; 65 | ReplaceLabel: TLabel; 66 | ToolBar1: TToolBar; 67 | ToolButton1: TToolButton; 68 | ToolButton2: TToolButton; 69 | WholeWordsOnlyCheckBox: TCheckBox; 70 | procedure CancelButtonClick(Sender: TObject); 71 | procedure cbReplaceChange(Sender: TObject); 72 | procedure CloseButtonClick(Sender: TObject); 73 | procedure EditFindKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); 74 | procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 75 | procedure FormCreate(Sender: TObject); 76 | procedure OKButtonClick(Sender: TObject); 77 | private 78 | FOnFind: TNotifyEvent; 79 | FOnReplace: TNotifyEvent; 80 | fReplaceAllClickedLast: boolean; 81 | FOptions: TMYSynSearchOptions; 82 | procedure Find; 83 | function GetFindText: string; 84 | function GetOptions: TMySynSearchOptions; 85 | function GetReplaceText: string; 86 | procedure LoadHistory; 87 | procedure Replace; 88 | procedure SaveHistory; 89 | procedure SetFindText(AValue: string); 90 | procedure SetOptions(AValue: TMySynSearchOptions); 91 | procedure SetReplaceText(AValue: string); 92 | 93 | public 94 | constructor Create(TheOwner: TComponent); override; 95 | property FindText: string read GetFindText write SetFindText; 96 | property ReplaceText: string read GetReplaceText write SetReplaceText; 97 | property OnReplace: TNotifyEvent read FOnReplace write FOnReplace; 98 | property OnFind: TNotifyEvent read FOnFind write FOnFind; 99 | property Options: TMySynSearchOptions read GetOptions write SetOptions; 100 | 101 | end; 102 | 103 | ResourceString 104 | rsFIND = 'Find'; 105 | rsREPLACE = 'Replace'; 106 | lisUEReplaceThisOccurrenceOfWith = 'Replace this occurrence of "%s"%s with "%s"?'; 107 | 108 | implementation 109 | 110 | {$R *.lfm} 111 | 112 | procedure TCustomReplaceDialog.SaveHistory; 113 | begin 114 | ConfigObj.WriteStrings('History','Find', EditFind.Items); 115 | ConfigObj.WriteStrings('History','Replace', EditReplace.Items); 116 | ConfigObj.ConfigHolder.Find('History/Options', true).AsString:=SetToString(PTypeInfo(TypeInfo(TmySynSearchOptions)), LongInt(GetOptions), true); 117 | 118 | end; 119 | 120 | Procedure TCustomReplaceDialog.LoadHistory; 121 | var 122 | tmp: string; 123 | begin 124 | ConfigObj.ReadStrings('History','Find', EditFind.Items); 125 | ConfigObj.ReadStrings('History','Replace', EditReplace.Items); 126 | try 127 | tmp := Configobj.ConfigHolder.GetValueDef('History/Options', ''); 128 | FOptions := TMySynSearchOptions(StringToSet(PTypeInfo(TypeInfo(TMySynSearchOptions)), tmp)); 129 | except 130 | FOptions := [ssoReplace, ssoEntireScope]; 131 | end; 132 | 133 | SetOptions(FOptions); 134 | 135 | end; 136 | 137 | procedure TCustomReplaceDialog.Replace; 138 | begin 139 | SaveHistory; 140 | if Assigned(FOnReplace) then 141 | FOnReplace(Self); 142 | end; 143 | 144 | procedure TCustomReplaceDialog.SetFindText(AValue: string); 145 | begin 146 | EditFind.Text := AValue; 147 | end; 148 | 149 | procedure TCustomReplaceDialog.OKButtonClick(Sender: TObject); 150 | begin 151 | fReplaceAllClickedLast := false; 152 | EditFind.AddHistoryItem(EditFind.Text,10,true,true); 153 | EditReplace.AddHistoryItem(EditReplace.Text,10,true,true); 154 | Replace; 155 | ModalResult := mrNone; 156 | end; 157 | 158 | procedure TCustomReplaceDialog.CloseButtonClick(Sender: TObject); 159 | begin 160 | fReplaceAllClickedLast := True; 161 | EditFind.AddHistoryItem(EditFind.Text,10,true,true); 162 | EditReplace.AddHistoryItem(EditReplace.Text,10,true,true); 163 | Replace; 164 | ModalResult := mrNone; 165 | end; 166 | 167 | procedure TCustomReplaceDialog.EditFindKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); 168 | begin 169 | if (Key = VK_RETURN) and not cbReplace.Checked then 170 | Find; 171 | end; 172 | 173 | procedure TCustomReplaceDialog.FormClose(Sender: TObject; var CloseAction: TCloseAction); 174 | begin 175 | SaveHistory; 176 | end; 177 | 178 | procedure TCustomReplaceDialog.FormCreate(Sender: TObject); 179 | begin 180 | LoadHistory; 181 | end; 182 | 183 | procedure TCustomReplaceDialog.CancelButtonClick(Sender: TObject); 184 | begin 185 | ModalResult := mrCancel; 186 | SaveHistory; 187 | Close; 188 | end; 189 | 190 | procedure TCustomReplaceDialog.cbReplaceChange(Sender: TObject); 191 | begin 192 | if cbReplace.Checked then 193 | Options:=Options + [ssoReplace] 194 | else 195 | Options:=Options - [ssoReplace]; 196 | 197 | end; 198 | 199 | procedure TCustomReplaceDialog.Find; 200 | begin 201 | SaveHistory; 202 | if Assigned(FOnFind) then 203 | FOnFind(Self); 204 | end; 205 | 206 | function TCustomReplaceDialog.GetFindText: string; 207 | begin 208 | Result := EditFind.Text; 209 | end; 210 | 211 | 212 | procedure TCustomReplaceDialog.SetOptions(AValue: TMySynSearchOptions); 213 | begin 214 | CaseSensitiveCheckBox.Checked := ssoMatchCase in AValue; 215 | WholeWordsOnlyCheckBox.Checked := ssoWholeWord in AValue; 216 | if ssoRegExpr in AValue then 217 | rgSearchMode.ItemIndex := 2 218 | else 219 | if ssoExtended in AValue then 220 | rgSearchMode.ItemIndex := 1 221 | else 222 | rgSearchMode.ItemIndex := 0; 223 | 224 | cbReplace.Checked := ssoReplace in AValue; 225 | PromptOnReplaceCheckBox.Checked := ssoPrompt in AValue; 226 | 227 | if ssoSelectedOnly in AValue then 228 | SelectedRadioButton.Checked := True 229 | else 230 | GlobalRadioButton.Checked := True; 231 | 232 | if ssoBackwards in AValue then 233 | BackwardRadioButton.Checked := True 234 | else 235 | ForwardRadioButton.Checked := True; 236 | 237 | if ssoReplace in AValue then 238 | BtnPanel.ShowButtons := BtnPanel.ShowButtons + [pbClose] 239 | else 240 | BtnPanel.ShowButtons := BtnPanel.ShowButtons - [pbClose]; 241 | 242 | EditReplace.Enabled := ssoReplace in AValue; 243 | PromptOnReplaceCheckBox.Enabled := ssoReplace in AValue; 244 | fReplaceAllClickedLast := ssoReplaceAll in AValue; 245 | 246 | if ssoReplace in AValue then 247 | begin 248 | Caption := rsREPLACE; 249 | BtnPanel.OKButton.Caption := rsREPLACE; 250 | end 251 | else 252 | begin 253 | Caption := rsFIND; 254 | BtnPanel.OKButton.Caption := rsFIND; 255 | end; 256 | 257 | end; 258 | 259 | procedure TCustomReplaceDialog.SetReplaceText(AValue: string); 260 | begin 261 | EditReplace.Text := AValue; 262 | end; 263 | 264 | constructor TCustomReplaceDialog.Create(TheOwner: TComponent); 265 | begin 266 | inherited Create(TheOwner); 267 | EditFind.Text := ''; 268 | EditReplace.Text := ''; 269 | BtnPanel.CloseButton.Kind := bkCustom; 270 | BtnPanel.OkButton.Kind := bkCustom; 271 | end; 272 | 273 | function TCustomReplaceDialog.GetOptions: TMySynSearchOptions; 274 | begin 275 | Result := []; 276 | if CaseSensitiveCheckBox.Checked then 277 | Include(Result, ssoMatchCase); 278 | if WholeWordsOnlyCheckBox.Checked then 279 | Include(Result, ssoWholeWord); 280 | 281 | case rgSearchMode.ItemIndex of 282 | 0:; 283 | 1: Include(Result, ssoExtended); 284 | 2: Include(Result, ssoRegExpr); 285 | end; 286 | 287 | if PromptOnReplaceCheckBox.Checked then 288 | Include(Result, ssoPrompt); 289 | 290 | if SelectedRadioButton.Checked then 291 | include(Result, ssoSelectedOnly); 292 | if BackwardRadioButton.Checked then 293 | include(Result, ssoBackwards); 294 | if pbClose in BtnPanel.ShowButtons then 295 | include(Result, ssoReplace); 296 | if fReplaceAllClickedLast then 297 | include(Result, ssoReplaceAll); 298 | end; 299 | 300 | function TCustomReplaceDialog.GetReplaceText: string; 301 | begin 302 | Result := EditReplace.Text; 303 | end; 304 | 305 | 306 | end. 307 | --------------------------------------------------------------------------------