| 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: SynUniHighlighter.pas, released 2003-01 |
| 12 |
All Rights Reserved. |
| 13 |
|
| 14 |
Alternatively, the contents of this file may be used under the terms of the |
| 15 |
GNU General Public License Version 2 or later (the "GPL"), in which case |
| 16 |
the provisions of the GPL are applicable instead of those above. |
| 17 |
If you wish to allow use of your version of this file only under the terms |
| 18 |
of the GPL and not to allow others to use your version of this file |
| 19 |
under the MPL, indicate your decision by deleting the provisions above and |
| 20 |
replace them with the notice and other provisions required by the GPL. |
| 21 |
If you do not delete the provisions above, a recipient may use your version |
| 22 |
of this file under either the MPL or the GPL. |
| 23 |
|
| 24 |
{ |
| 25 |
@abstract(Desginer for TSynUniSyn) |
| 26 |
@authors(Vit [[email protected]], Fantasist [[email protected]], |
| 27 |
Vitalik [[email protected]]) |
| 28 |
@created(2003) |
| 29 |
@lastmod(2004-05-12) |
| 30 |
} |
| 31 |
|
| 32 |
(****************************************************************************** |
| 33 |
Authors: Vit (Vitaly Nevzorov [email protected]) |
| 34 |
Fantasist (Kirill Burtsev [email protected]) |
| 35 |
Vitalik (Vitaly Lyapota [email protected]) |
| 36 |
Official Site: www.delphist.com |
| 37 |
With all questions, please visit www.delphist.com/forum |
| 38 |
******************************************************************************) |
| 39 |
|
| 40 |
unit SynUniDesigner; |
| 41 |
|
| 42 |
//================== SCHMaster ================== |
| 43 |
{$IFNDEF FPC} |
| 44 |
//23.02.2012, Alex Dr., SynPlus is plugin for TC... |
| 45 |
{$DEFINE SYNPLUS} |
| 46 |
{$ENDIF} |
| 47 |
//=============================================== |
| 48 |
|
| 49 |
{$IFNDEF FPC} |
| 50 |
{$I SynEdit.inc} |
| 51 |
{$ELSE} |
| 52 |
{$IFNDEF SYN_LAZARUS} |
| 53 |
{$define SYN_LAZARUS} |
| 54 |
{$ENDIF} |
| 55 |
{$ENDIF} |
| 56 |
|
| 57 |
interface |
| 58 |
|
| 59 |
uses |
| 60 |
{$IFDEF SYN_CLX} |
| 61 |
Types, kTextDrawer, QGraphics, QControls, QForms, QExtCtrls, QStdCtrls, |
| 62 |
QComCtrls, QImgList, QDialogs, QMenus, |
| 63 |
{$ELSE} |
| 64 |
{$IFNDEF FPC} |
| 65 |
Windows, Messages, Registry, |
| 66 |
{$ELSE} |
| 67 |
LMessages, LCLType, |
| 68 |
{$ENDIF} |
| 69 |
Graphics, Controls, Forms, ExtCtrls, StdCtrls, ComCtrls, Dialogs, Menus, |
| 70 |
{$ENDIF} |
| 71 |
Classes, SysUtils, SynEdit, SynEditHighlighter, SynUniHighlighter, |
| 72 |
SynUniClasses, SynUniRules, Clipbrd, ImgList, Inifiles, Buttons, |
| 73 |
SynUniImport, SynUniImportEditPlus, SynUniImportUltraEdit; |
| 74 |
|
| 75 |
type |
| 76 |
{$IFDEF SYN_CLX} |
| 77 |
TNodeText = WideString; |
| 78 |
{$ELSE} |
| 79 |
TNodeText = string; |
| 80 |
{$ENDIF} |
| 81 |
|
| 82 |
TNodeType = (ntRangeLink, ntRange, ntRoot, ntKeywords, ntSet, ntNone); |
| 83 |
TAddKind = (akAdd, akInsert, akReplace); |
| 84 |
TRangeType = (rtRange, rtRoot, rtLink); |
| 85 |
|
| 86 |
{ TfmDesigner } |
| 87 |
|
| 88 |
TfmDesigner = class(TForm) |
| 89 |
MenuItem10: TMenuItem; |
| 90 |
//==================== P O P U P M E N U S ============================== |
| 91 |
//=== popStandard ======================================================== |
| 92 |
popStandard: TPopupMenu; |
| 93 |
popUndo: TMenuItem; |
| 94 |
N1: TMenuItem; |
| 95 |
popCut: TMenuItem; |
| 96 |
popCopy: TMenuItem; |
| 97 |
popPaste: TMenuItem; |
| 98 |
popDelete: TMenuItem; |
| 99 |
N2: TMenuItem; |
| 100 |
popSelectAll: TMenuItem; |
| 101 |
//=== popSampleMemoMenu ================================================== |
| 102 |
popSampleMemoMenu: TPopupMenu; |
| 103 |
AddselectedtoKeywords1: TMenuItem; |
| 104 |
N7: TMenuItem; |
| 105 |
Undo1: TMenuItem; |
| 106 |
N5: TMenuItem; |
| 107 |
Cut1: TMenuItem; |
| 108 |
Copy1: TMenuItem; |
| 109 |
Paste1: TMenuItem; |
| 110 |
Delete1: TMenuItem; |
| 111 |
N6: TMenuItem; |
| 112 |
SelectAll1: TMenuItem; |
| 113 |
//=== popOpenTagMenu ===================================================== |
| 114 |
popOpenTagMenu: TPopupMenu; |
| 115 |
Closemenu1: TMenuItem; |
| 116 |
N3: TMenuItem; |
| 117 |
Opentagisfirstsymbolsonline1: TMenuItem; |
| 118 |
Opentagisfirstnonspacesymbolsonline1: TMenuItem; |
| 119 |
N4: TMenuItem; |
| 120 |
Opentagispartofterm1: TMenuItem; |
| 121 |
Opentagispartoftermonlyrightside1: TMenuItem; |
| 122 |
Opentagispartoftermonlyleftside1: TMenuItem; |
| 123 |
Opentagisnotpartofterm1: TMenuItem; |
| 124 |
//=== popCloseTagMenu ==================================================== |
| 125 |
popCloseTagMenu: TPopupMenu; |
| 126 |
MenuItem1: TMenuItem; |
| 127 |
MenuItem2: TMenuItem; |
| 128 |
MenuItem3: TMenuItem; |
| 129 |
MenuItem4: TMenuItem; |
| 130 |
MenuItem5: TMenuItem; |
| 131 |
MenuItem6: TMenuItem; |
| 132 |
MenuItem7: TMenuItem; |
| 133 |
MenuItem8: TMenuItem; |
| 134 |
MenuItem9: TMenuItem; |
| 135 |
//=== popRootMenu ======================================================== |
| 136 |
popRootMenu: TPopupMenu; |
| 137 |
rootCut: TMenuItem; |
| 138 |
rootCopy: TMenuItem; |
| 139 |
rootPaste: TMenuItem; |
| 140 |
rootPasteAndReplace: TMenuItem; |
| 141 |
rootBreak1: TMenuItem; |
| 142 |
rootLoadFromFile: TMenuItem; |
| 143 |
rootSaveToFile: TMenuItem; |
| 144 |
rootBreak2: TMenuItem; |
| 145 |
rootAddRange: TMenuItem; |
| 146 |
rootAddKeywords: TMenuItem; |
| 147 |
rootAddSetto: TMenuItem; |
| 148 |
rootBreak3: TMenuItem; |
| 149 |
rootRename: TMenuItem; |
| 150 |
rootDeleteAll: TMenuItem; |
| 151 |
rootBreak4: TMenuItem; |
| 152 |
rootInfo: TMenuItem; |
| 153 |
//=== popRangeMenu ======================================================= |
| 154 |
popRangeMenu: TPopupMenu; |
| 155 |
rangeBack: TMenuItem; |
| 156 |
rangeBreak1: TMenuItem; |
| 157 |
rangeCut: TMenuItem; |
| 158 |
rangeCopy: TMenuItem; |
| 159 |
rangePaste: TMenuItem; |
| 160 |
rangePasteAndReplace: TMenuItem; |
| 161 |
rangePasteNextTo: TMenuItem; |
| 162 |
rangeBreak2: TMenuItem; |
| 163 |
rangeLoadFromFile: TMenuItem; |
| 164 |
rangeSaveToFile: TMenuItem; |
| 165 |
rangeBreak3: TMenuItem; |
| 166 |
rangeAddRange: TMenuItem; |
| 167 |
rangeAddKeywords: TMenuItem; |
| 168 |
rangeAddSet: TMenuItem; |
| 169 |
rangeBreak4: TMenuItem; |
| 170 |
rangeRename: TMenuItem; |
| 171 |
rangeDelete: TMenuItem; |
| 172 |
//=== popKeywordsMenu ==================================================== |
| 173 |
popKeywordsMenu: TPopupMenu; |
| 174 |
keywordsBack: TMenuItem; |
| 175 |
keywordsBreak1: TMenuItem; |
| 176 |
keywordsCut: TMenuItem; |
| 177 |
keywordsCopy: TMenuItem; |
| 178 |
keywordsPaste: TMenuItem; |
| 179 |
keywordsPasteAndReplace: TMenuItem; |
| 180 |
keywordsBreak2: TMenuItem; |
| 181 |
keywordsLoadFromFile: TMenuItem; |
| 182 |
keywordsSaveToFile: TMenuItem; |
| 183 |
keywordsBreak3: TMenuItem; |
| 184 |
keywordsRename: TMenuItem; |
| 185 |
keywordsDelete: TMenuItem; |
| 186 |
//=== popSetMenu ========================================================= |
| 187 |
popSetMenu: TPopupMenu; |
| 188 |
setBack: TMenuItem; |
| 189 |
setBreak1: TMenuItem; |
| 190 |
setCut: TMenuItem; |
| 191 |
setCopy: TMenuItem; |
| 192 |
setPaste: TMenuItem; |
| 193 |
setPasteAndReplace: TMenuItem; |
| 194 |
setBreak2: TMenuItem; |
| 195 |
setLoadFromFile: TMenuItem; |
| 196 |
setSaveToFile: TMenuItem; |
| 197 |
setBreak3: TMenuItem; |
| 198 |
setRename: TMenuItem; |
| 199 |
setDelete: TMenuItem; |
| 200 |
//=== popPanels ========================================================== |
| 201 |
popPanels: TPopupMenu; |
| 202 |
RulesTree1: TMenuItem; |
| 203 |
Properties1: TMenuItem; |
| 204 |
Attributes1: TMenuItem; |
| 205 |
Sampletext1: TMenuItem; |
| 206 |
Buttons1: TMenuItem; |
| 207 |
//=== Popup Menus ======================================================== |
| 208 |
popColorStd: TPopupMenu; |
| 209 |
popColorAdv: TPopupMenu; |
| 210 |
popColorSys: TPopupMenu; |
| 211 |
//===================== C O M P O N E N T S ============================== |
| 212 |
//=== Top panel ========================================================== |
| 213 |
pTop: TPanel; |
| 214 |
SplitterBottom: TSplitter; |
| 215 |
//=== Panel "Rules' Tree" ================================================ |
| 216 |
pLeft: TPanel; |
| 217 |
SplitterLeft: TSplitter; |
| 218 |
pLeftParentCapt: TPanel; |
| 219 |
lbRootMenu: TLabel; |
| 220 |
pLeftCapt: TPanel; |
| 221 |
Bevel1: TBevel; |
| 222 |
pTree: TPanel; |
| 223 |
Tree: TTreeView; |
| 224 |
//=== Panel "Attributes" ================================================= |
| 225 |
pRight: TPanel; |
| 226 |
SplitterRight: TSplitter; |
| 227 |
pRightCapt: TPanel; |
| 228 |
Bevel2: TBevel; |
| 229 |
pAttri: TPanel; |
| 230 |
//=== Panel "Proprties" ================================================== |
| 231 |
pMiddle: TPanel; |
| 232 |
pMiddleParentCapt: TPanel; |
| 233 |
lbPropBack: TLabel; |
| 234 |
lbRuleMenu: TLabel; |
| 235 |
pMiddleCapt: TPanel; |
| 236 |
Bevel4: TBevel; |
| 237 |
//=== "Root" page ======================================================== |
| 238 |
PageControl: TPageControl; |
| 239 |
tabRoot: TTabSheet; |
| 240 |
chCaseRoot: TCheckBox; |
| 241 |
chEnabledRoot: TCheckBox; |
| 242 |
lbDelimitersRoot: TLabel; |
| 243 |
edDelimitersRoot: TEdit; |
| 244 |
pRootButtons: TPanel; |
| 245 |
btAddRangeRoot: TButton; |
| 246 |
btAddKeywordsRoot: TButton; |
| 247 |
btAddSetRoot: TButton; |
| 248 |
//=== "Range" page ======================================================= |
| 249 |
tabRange: TTabSheet; |
| 250 |
chCaseRange: TCheckBox; |
| 251 |
chEnabledRange: TCheckBox; |
| 252 |
btChooseRule: TButton; |
| 253 |
lbRangeFrom: TLabel; |
| 254 |
edFrom: TEdit; |
| 255 |
btFromList: TButton; |
| 256 |
btFromMenu: TButton; |
| 257 |
chFromEOL: TCheckBox; |
| 258 |
lbRangeTo: TLabel; |
| 259 |
edTo: TEdit; |
| 260 |
btToList: TButton; |
| 261 |
btToMenu: TButton; |
| 262 |
chToEOL: TCheckBox; |
| 263 |
chCloseOnWord: TCheckBox; |
| 264 |
chCloseOnEOL: TCheckBox; |
| 265 |
chCloseParent: TCheckBox; |
| 266 |
lbDelimitersRange: TLabel; |
| 267 |
edDelimitersRange: TEdit; |
| 268 |
pRangeButtons: TPanel; |
| 269 |
btAddRange: TButton; |
| 270 |
btAddKeywords: TButton; |
| 271 |
btAddSet: TButton; |
| 272 |
//=== "Keywords" page ==================================================== |
| 273 |
tabKeywords: TTabSheet; |
| 274 |
Memo: TMemo; |
| 275 |
pProp: TPanel; |
| 276 |
chEnabledKeyList: TCheckBox; |
| 277 |
btSort_old: TButton; |
| 278 |
btLowerCase_old: TButton; |
| 279 |
btSpacesToEol_old: TButton; |
| 280 |
lbKeywordCount: TLabel; |
| 281 |
//=== "Set" page ========================================================= |
| 282 |
tabSet: TTabSheet; |
| 283 |
chAnyStart: TCheckBox; |
| 284 |
chEnabledSet: TCheckBox; |
| 285 |
lbSymbSet: TLabel; |
| 286 |
edSymbSet: TEdit; |
| 287 |
//=== Panel "Sample text" ================================================ |
| 288 |
pBottom: TPanel; |
| 289 |
pBottomParentCapt: TPanel; |
| 290 |
lbSampMin: TLabel; |
| 291 |
lbSampMax: TLabel; |
| 292 |
pBottomCapt: TPanel; |
| 293 |
Bevel5: TBevel; |
| 294 |
SampleMemo: TSynEdit; |
| 295 |
//=== Panel with "finish" buttons ======================================== |
| 296 |
StatusBar: TStatusBar; |
| 297 |
pButtons: TPanel; |
| 298 |
SplitterButtons: TSplitter; |
| 299 |
btOk: TButton; |
| 300 |
btCancel: TButton; |
| 301 |
btApply: TButton; |
| 302 |
//=== Invisible components =============================================== |
| 303 |
SynUniSyn: TSynUniSyn; |
| 304 |
listImages: TImageList; |
| 305 |
listRules: TImageList; |
| 306 |
listColors16: TImageList; |
| 307 |
listColors40: TImageList; |
| 308 |
listColorsSys: TImageList; |
| 309 |
OpenDialog: TOpenDialog; |
| 310 |
SaveDialog: TSaveDialog; |
| 311 |
tabSeveralRules: TTabSheet; |
| 312 |
Label1: TLabel; |
| 313 |
btSort: TSpeedButton; |
| 314 |
btLowerCase: TSpeedButton; |
| 315 |
btSpacesToEol: TSpeedButton; |
| 316 |
PageControl1: TPageControl; |
| 317 |
TabSheet1: TTabSheet; |
| 318 |
chStrikeOut: TCheckBox; |
| 319 |
chUnderline: TCheckBox; |
| 320 |
chItalic: TCheckBox; |
| 321 |
chBold: TCheckBox; |
| 322 |
pForeColorBox: TPanel; |
| 323 |
pForeColor: TPanel; |
| 324 |
pForeColorArrow: TPanel; |
| 325 |
pBackColorBox: TPanel; |
| 326 |
pBackColor: TPanel; |
| 327 |
pBackColorArrow: TPanel; |
| 328 |
chForeground: TCheckBox; |
| 329 |
chBackground: TCheckBox; |
| 330 |
TabSheet2: TTabSheet; |
| 331 |
CheckBox1: TCheckBox; |
| 332 |
CheckBox2: TCheckBox; |
| 333 |
CheckBox3: TCheckBox; |
| 334 |
CheckBox4: TCheckBox; |
| 335 |
Panel2: TPanel; |
| 336 |
Panel3: TPanel; |
| 337 |
Panel4: TPanel; |
| 338 |
Panel5: TPanel; |
| 339 |
Panel6: TPanel; |
| 340 |
Panel7: TPanel; |
| 341 |
CheckBox5: TCheckBox; |
| 342 |
CheckBox6: TCheckBox; |
| 343 |
CheckBox7: TCheckBox; |
| 344 |
Button1: TButton; |
| 345 |
CheckBox8: TCheckBox; |
| 346 |
Bevel6: TBevel; |
| 347 |
Label3: TLabel; |
| 348 |
edStylesFile: TEdit; |
| 349 |
btStylesFile: TButton; |
| 350 |
cbStyle: TComboBox; |
| 351 |
Label2: TLabel; |
| 352 |
Label4: TLabel; |
| 353 |
Label5: TLabel; |
| 354 |
ComboBox2: TComboBox; |
| 355 |
OpenDialog2: TOpenDialog; |
| 356 |
Button3: TButton; |
| 357 |
Button4: TButton; |
| 358 |
Label6: TLabel; |
| 359 |
|
| 360 |
//============================ M E T O D S =================================== |
| 361 |
//=== Form events ============================================================ |
| 362 |
procedure FormCreate(Sender: TObject); |
| 363 |
procedure FormShow(Sender: TObject); |
| 364 |
procedure FormKeyPress(Sender: TObject; var Key: Char); |
| 365 |
procedure FormKeyDown(Sender: TObject; var Key: Word; |
| 366 |
Shift: TShiftState); |
| 367 |
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); |
| 368 |
//=== Translate ============================================================== |
| 369 |
procedure OldTranslate(LangFile: String); //SCHMaster 2004 |
| 370 |
procedure Translate(LangFile: String); |
| 371 |
//=== TreeView =============================================================== |
| 372 |
procedure TreeEdited(Sender: TObject; Node: TTreeNode; var S: String); |
| 373 |
procedure TreeKeyDown(Sender: TObject; var Key: Word; |
| 374 |
Shift: TShiftState); |
| 375 |
procedure TreeMouseDown(Sender: TObject; Button: TMouseButton; |
| 376 |
Shift: TShiftState; X, Y: Integer); |
| 377 |
procedure TreeMouseUp(Sender: TObject; Button: TMouseButton; |
| 378 |
Shift: TShiftState; X, Y: Integer); |
| 379 |
procedure TreeChange(Sender: TObject; Node: TTreeNode); |
| 380 |
//=== Fill Tree with Rules =================================================== |
| 381 |
procedure FillTree; |
| 382 |
procedure SetNodeData(Node: TTreeNode; Rule: TAbstractRule; Root: boolean = False); |
| 383 |
function TreeAddRule(ParentNode: TTreeNode; Rule: TSynRule; |
| 384 |
AddKind: TAddKind = akAdd): TTreeNode; |
| 385 |
function TreeAddRangeLink(Node: TTreeNode; RangeLink: TSynRangeLink; |
| 386 |
AddKind: TAddKind = akAdd): TTreeNode; |
| 387 |
function TreeAddRange(Node: TTreeNode; Range: TSynRange; |
| 388 |
AddKind: TAddKind = akAdd): TTreeNode; |
| 389 |
function TreeAddKeyList(Node: TTreeNode; Keyword: TSynKeyList; |
| 390 |
AddKind: TAddKind = akAdd): TTreeNode; |
| 391 |
function TreeAddSet(Node: TTreeNode; SymbSet: TSynSet; |
| 392 |
AddKind: TAddKind = akAdd): TTreeNode; |
| 393 |
//=== Adding RangeLink ======================================================= |
| 394 |
procedure DoAddRangeLinkToRoot(Sender: TObject); |
| 395 |
procedure DoAddRangeLink(Sender: TObject); |
| 396 |
procedure AddingRangeLink(ParentNode: TTreeNode); |
| 397 |
//=== Adding Range =========================================================== |
| 398 |
procedure DoAddRangeToRoot(Sender: TObject); |
| 399 |
procedure DoAddRange(Sender: TObject); |
| 400 |
procedure AddingRange(ParentNode: TTreeNode); |
| 401 |
//=== Adding KeyList ========================================================= |
| 402 |
procedure DoAddKeywordToRoot(Sender:TObject); |
| 403 |
procedure DoAddKeyword(Sender: TObject); |
| 404 |
procedure AddingKeyWord(ParentNode: TTreeNode); |
| 405 |
//=== Adding Set ============================================================= |
| 406 |
procedure DoAddSetToRoot(Sender:TObject); |
| 407 |
procedure DoAddSet(Sender: TObject); |
| 408 |
procedure AddingSet(ParentNode: TTreeNode); |
| 409 |
//=== Delete and Rename Rules ================================================ |
| 410 |
procedure DoDeleteNode(Sender: TObject); |
| 411 |
procedure DeleteNode(Node: TTreeNode; OnlyChilds: boolean = False); |
| 412 |
procedure DoRenameNode(Sender: TObject); |
| 413 |
//=== Useful functions... ==================================================== |
| 414 |
function GetNodeType(Node: TTreeNode): TNodeType; |
| 415 |
procedure TotalUpdate; |
| 416 |
procedure Modified(State: boolean = True); |
| 417 |
//=== KeyList Tools ========================================================== |
| 418 |
procedure btSort_oldClick(Sender: TObject); |
| 419 |
procedure btLowerCase_oldClick(Sender: TObject); |
| 420 |
procedure btSpacesToEol_oldClick(Sender: TObject); |
| 421 |
//=== Finish buttons ========================================================= |
| 422 |
procedure btOkClick(Sender: TObject); |
| 423 |
procedure btCancelClick(Sender: TObject); |
| 424 |
procedure btApplyClick(Sender: TObject); |
| 425 |
//=== Work with schemes ====================================================== |
| 426 |
{ procedure btNewSchemeClick(Sender: TObject); |
| 427 |
procedure btDelSchemeClick(Sender: TObject); |
| 428 |
procedure cbSchemeChange(Sender: TObject); |
| 429 |
procedure cbSchemeSelect(Sender: TObject);} |
| 430 |
//=== Rules changed ========================================================== |
| 431 |
procedure RootChange(Sender: TObject); |
| 432 |
procedure RangeChange(Sender: TObject); |
| 433 |
procedure KeywordsChange(Sender: TObject); |
| 434 |
procedure SetChange(Sender: TObject); |
| 435 |
//=== Wotk with Attributes =================================================== |
| 436 |
procedure AttributesChanged(Sender: TObject); |
| 437 |
procedure SetDefaultAttributes(Node: TTreeNode); |
| 438 |
procedure SetControlAttributes(Node: TTreeNode; AlreadyUpdate: boolean = False); |
| 439 |
procedure SetAttributes(Node: TTreeNode); |
| 440 |
|
| 441 |
//============================ D E S I G N =================================== |
| 442 |
//=== Splitter CanResize ===================================================== |
| 443 |
procedure SplitterBottomCanResize(Sender: TObject; |
| 444 |
var NewSize: Integer; var Accept: Boolean); |
| 445 |
procedure SplitterCannotResize(Sender: TObject; |
| 446 |
var NewSize: Integer; var Accept: Boolean); |
| 447 |
//=== Label Mouse Leave/Enter ================================================ |
| 448 |
procedure LabelMouseLeave(Sender: TObject); |
| 449 |
procedure LabelMouseEnter(Sender: TObject); |
| 450 |
procedure LabelContextPopup(Sender: TObject; MousePos: TPoint; |
| 451 |
var Handled: Boolean); |
| 452 |
//=== CheckBox =============================================================== |
| 453 |
procedure CheckBoxMouseDown(Sender: TObject; Button: TMouseButton; |
| 454 |
Shift: TShiftState; X, Y: Integer); |
| 455 |
procedure DontNeedContextPopup(Sender: TObject; MousePos: TPoint; |
| 456 |
var Handled: Boolean); |
| 457 |
//=== Show/Hide panels ======================================================= |
| 458 |
procedure ShowHideTree(Sender: TObject); |
| 459 |
procedure ShowHideProp(Sender: TObject); |
| 460 |
procedure ShowHideAttr(Sender: TObject); |
| 461 |
procedure ShowHideSamp(Sender: TObject); |
| 462 |
procedure PanelDblClick(Sender: TObject); |
| 463 |
//=== Middle panel Resize ==================================================== |
| 464 |
procedure pMiddleResize(Sender: TObject); |
| 465 |
//=== Push label clicks ====================================================== |
| 466 |
procedure lbPropBackClick(Sender: TObject); |
| 467 |
procedure lbRootMenuClick(Sender: TObject); |
| 468 |
procedure lbRuleMenuClick(Sender: TObject); |
| 469 |
procedure lbSampMaxClick(Sender: TObject); |
| 470 |
//procedure lbSampRestoreClick(Sender: TObject); |
| 471 |
procedure lbSampMinClick(Sender: TObject); |
| 472 |
|
| 473 |
//============================ P O P U P S =================================== |
| 474 |
//=== Standard PopupMenu ===================================================== |
| 475 |
procedure SetPopupMenuEnables(Edit: TCustomEdit; popMenu: TPopupMenu); |
| 476 |
procedure EditKeyDown(Sender: TObject; var Key: Word; |
| 477 |
Shift: TShiftState); |
| 478 |
procedure EditContextPopup(Sender: TObject; MousePos: TPoint; |
| 479 |
var Handled: Boolean); |
| 480 |
procedure popCopyClick(Sender: TObject); |
| 481 |
procedure popUndoClick(Sender: TObject); |
| 482 |
procedure popCutClick(Sender: TObject); |
| 483 |
procedure popPasteClick(Sender: TObject); |
| 484 |
procedure popDeleteClick(Sender: TObject); |
| 485 |
procedure popSelectAllClick(Sender: TObject); |
| 486 |
//=== Sample Memo PopupMenu ================================================== |
| 487 |
procedure SetPopupMenuEnables2(Edit: TCustomSynEdit; popMenu: TPopupMenu); |
| 488 |
procedure SampleMemoKeyDown(Sender: TObject; var Key: Word; |
| 489 |
Shift: TShiftState); |
| 490 |
procedure SampleMemoMouseDown(Sender: TObject; Button: TMouseButton; |
| 491 |
Shift: TShiftState; X, Y: Integer); |
| 492 |
procedure Undo1Click(Sender: TObject); |
| 493 |
procedure Cut1Click(Sender: TObject); |
| 494 |
procedure Copy1Click(Sender: TObject); |
| 495 |
procedure Paste1Click(Sender: TObject); |
| 496 |
procedure Delete1Click(Sender: TObject); |
| 497 |
procedure SelectAll1Click(Sender: TObject); |
| 498 |
procedure AddselectedtoKeywords1Click(Sender: TObject); |
| 499 |
procedure popSampleMemoMenuPopup(Sender: TObject); |
| 500 |
//=== Tag Menu Clicks... ===================================================== |
| 501 |
procedure btTagMenuClick(Sender: TObject); |
| 502 |
procedure miTagMenuClick(Sender: TObject); |
| 503 |
procedure miOpenTagMenuClick(Sender: TObject); |
| 504 |
procedure miCloseTagMenuClick(Sender: TObject); |
| 505 |
//=== ColorBox Clicks... ===================================================== |
| 506 |
procedure PanelColorChange(Sender: TObject); |
| 507 |
procedure miColor16Click(Sender: TObject); |
| 508 |
procedure miColorSysClick(Sender: TObject); |
| 509 |
procedure miColor40Click(Sender: TObject); |
| 510 |
{$IFNDEF FPC} |
| 511 |
procedure Color40MeasureItem(Sender: TObject; ACanvas: TCanvas; |
| 512 |
var Width, Height: Integer); |
| 513 |
{$ELSE} |
| 514 |
procedure Color40MeasureItem(Sender: TObject; ACanvas: TCanvas; |
| 515 |
var AWidth, AHeight: Integer); |
| 516 |
{$ENDIF} |
| 517 |
procedure pColorMouseUp(Sender: TObject; Button: TMouseButton; |
| 518 |
Shift: TShiftState; X, Y: Integer); |
| 519 |
procedure pColorArrowMouseUp(Sender: TObject; Button: TMouseButton; |
| 520 |
Shift: TShiftState; X, Y: Integer); |
| 521 |
//=== TabSheet showing ======================================================= |
| 522 |
procedure tabRootShow(Sender: TObject); |
| 523 |
procedure tabRangeShow(Sender: TObject); |
| 524 |
procedure tabKeywordsShow(Sender: TObject); |
| 525 |
procedure tabSetShow(Sender: TObject); |
| 526 |
//=== Work with files ======================================================== |
| 527 |
// procedure LoadFromFileClick(Sender: TObject); |
| 528 |
procedure rootSaveToFileClick(Sender: TObject); |
| 529 |
procedure rootLoadFromFileClick(Sender: TObject); |
| 530 |
procedure rangeLoadFromFileClick(Sender: TObject); |
| 531 |
procedure rangeSaveToFileClick(Sender: TObject); |
| 532 |
//=== Clipboard ============================================================== |
| 533 |
procedure StreamToClipboard(Stream: TStream); |
| 534 |
function GetClipboardAsStream: TMemoryStream; |
| 535 |
//=== Root range ============================================================= |
| 536 |
procedure rootCutClick(Sender: TObject); |
| 537 |
procedure rootCopyClick(Sender: TObject); |
| 538 |
procedure rootPasteInsideClick(Sender: TObject); |
| 539 |
procedure rootPasteAndReplaceClick(Sender: TObject); |
| 540 |
//=== Other rules ============================================================ |
| 541 |
procedure rangeCutClick(Sender: TObject); |
| 542 |
procedure rangeCopyClick(Sender: TObject); |
| 543 |
procedure rangePasteInsideClick(Sender: TObject); |
| 544 |
procedure rangePasteAndReplaceClick(Sender: TObject); |
| 545 |
procedure rangePasteNextToClick(Sender: TObject); |
| 546 |
|
| 547 |
//=== NOT SORTED ============================================================= |
| 548 |
procedure rootInfoClick(Sender: TObject); |
| 549 |
procedure TreeClick(Sender: TObject); |
| 550 |
procedure btStylesFileClick(Sender: TObject); |
| 551 |
|
| 552 |
private |
| 553 |
{ Private declarations } |
| 554 |
public |
| 555 |
{ Public declarations } |
| 556 |
popPropMenu: TPopupMenu; |
| 557 |
OriginalSyn: TSynUniSyn; |
| 558 |
ForceClose: boolean; |
| 559 |
UpdatingControls: boolean; |
| 560 |
ShowDialog: boolean; |
| 561 |
_Modified, _Confirm, _DeleteNode, _SaveChanges, _EnterName, _DeleteScheme, |
| 562 |
_Lines, _Name, _Extensions, _Version, _Date, _Author, _Mail, _Web, |
| 563 |
_Copyright, _Company, _Remark: string; |
| 564 |
end; |
| 565 |
|
| 566 |
TSynUniDesigner = class(TObject) |
| 567 |
private |
| 568 |
Form: TfmDesigner; |
| 569 |
//=== Standard metods ======================================================== |
| 570 |
function Execute(FormTitle: string; LangFile: string): boolean; |
| 571 |
procedure SetSample(const Value: string); |
| 572 |
function GetSample: string; |
| 573 |
procedure SetTitle(const Value: string); |
| 574 |
function GetTitle: string; |
| 575 |
public |
| 576 |
constructor Create(Highlighter: TSynUniSyn); |
| 577 |
destructor Destroy; override; |
| 578 |
property Title: string read GetTitle write SetTitle; |
| 579 |
property Sample: string read GetSample write SetSample; |
| 580 |
class function EditHighlighter(OriginalSyn: TSynUniSyn; |
| 581 |
FormTitle: string = ''; LangFile: string = ''): boolean; |
| 582 |
end; |
| 583 |
|
| 584 |
implementation |
| 585 |
|
| 586 |
{$R *.dfm} |
| 587 |
|
| 588 |
{$IFDEF SYN_CLX} |
| 589 |
uses Qt; |
| 590 |
|
| 591 |
const |
| 592 |
VK_F1 = Key_F1; |
| 593 |
VK_F2 = Key_F2; |
| 594 |
VK_RETURN = Key_Return; |
| 595 |
VK_DELETE = Key_Delete; |
| 596 |
{$ENDIF} |
| 597 |
|
| 598 |
const Colors16: array [0..15] of TColor = (clBlack, clMaroon, clGreen, clOlive, |
| 599 |
clNavy, clPurple, clTeal, clGray, clSilver, clRed, clLime, clYellow, |
| 600 |
clBlue, clFuchsia, clAqua, clWhite); |
| 601 |
const Colors16s: array [0..15] of string = ('Black', 'Maroon', 'Green', 'Olive', |
| 602 |
'Navy', 'Purple', 'Teal', 'Gray', 'Silver', 'Red', 'Lime', 'Yellow', |
| 603 |
'Blue', 'Fuchsia', 'Aqua', 'White'); |
| 604 |
const Colors40: array [0..39] of TColor = ( |
| 605 |
$000000, $000080, $0000FF, $FF00FF, $CC99FF, |
| 606 |
$003399, $0066FF, $0099FF, $00CCFF, $99CCFF, |
| 607 |
$003333, $008080, $00CC99, $00FFFF, $99FFFF, |
| 608 |
$003300, $008000, $669933, $00FF00, $CCFFCC, |
| 609 |
$663300, $808000, $CCCC33, $FFFF00, $FFFFCC, |
| 610 |
$800000, $FF0000, $FF6633, $FFCC00, $FFCC99, |
| 611 |
$993333, $996666, $800080, $663399, $FF99CC, |
| 612 |
$333333, $808080, $969696, $C0C0C0, $FFFFFF); |
| 613 |
const ColorsSys: array [0..27] of TColor = (clActiveBorder, clActiveCaption, |
| 614 |
clAppWorkSpace, clBackground, clBtnFace, clBtnHighlight, clBtnShadow, |
| 615 |
clBtnText, clCaptionText, clDefault, clGradientActiveCaption, |
| 616 |
clGradientInactiveCaption, clGrayText, clHighlight, clHighlightText, |
| 617 |
clInactiveBorder, clInactiveCaption, clInactiveCaptionText, |
| 618 |
clInfoBk, clInfoText, clMenu, clMenuText, clScrollBar, cl3DDkShadow, |
| 619 |
cl3DLight, clWindow, clWindowFrame, clWindowText); |
| 620 |
|
| 621 |
const |
| 622 |
_pTopHeight = 210; |
| 623 |
|
| 624 |
function GetFontStyle(Bold, Italic, Underline, StrikeOut: boolean): TFontStyles; |
| 625 |
begin |
| 626 |
Result := []; |
| 627 |
if Bold then Result := Result + [fsBold]; |
| 628 |
if Italic then Result := Result + [fsItalic]; |
| 629 |
if Underline then Result := Result + [fsUnderline]; |
| 630 |
if Strikeout then Result := Result + [fsStrikeOut]; |
| 631 |
end; |
| 632 |
|
| 633 |
constructor TSynUniDesigner.Create(Highlighter: TSynUniSyn); |
| 634 |
(*{$IFNDEF SYN_CLX}Tree.HideSelection:=False;Tree.RightClickSelect:=True;{$ENDIF}*) |
| 635 |
begin |
| 636 |
inherited Create; |
| 637 |
Form := TfmDesigner.Create(nil); |
| 638 |
Form.OriginalSyn := Highlighter; |
| 639 |
{popRangeMenu.Items.Items[1].Caption := '&Go to subnode';} |
| 640 |
{Tree.DragMode := dmAutomatic;} |
| 641 |
{CreateButtonLabel(lbSampRestore, pBottomParentCapt, alRight, #50, 'Restore');} |
| 642 |
end; |
| 643 |
|
| 644 |
(*procedure TSynUniDesigner.DelimDblClick(Sender: TObject); |
| 645 |
begin |
| 646 |
(Sender as TEdit).Text := Set2String( DefaultTermSymbols ); |
| 647 |
end;*) |
| 648 |
|
| 649 |
destructor TSynUniDesigner.Destroy; |
| 650 |
begin |
| 651 |
Form.SampleMemo.Highlighter := nil; |
| 652 |
Form.SampleMemo.Free; |
| 653 |
Form.Free; |
| 654 |
inherited; |
| 655 |
end; |
| 656 |
|
| 657 |
class function TSynUniDesigner.EditHighlighter(OriginalSyn: TSynUniSyn; FormTitle: string; LangFile: string): boolean; |
| 658 |
begin |
| 659 |
with Create(OriginalSyn) do begin |
| 660 |
Result := Execute(FormTitle, LangFile); |
| 661 |
Free; |
| 662 |
end; |
| 663 |
end; |
| 664 |
|
| 665 |
//=== Standard metods ======================================================== |
| 666 |
procedure TSynUniDesigner.SetSample(const Value: string); |
| 667 |
begin |
| 668 |
Form.SampleMemo.Text := Value; |
| 669 |
end; |
| 670 |
|
| 671 |
function TSynUniDesigner.GetSample: string; |
| 672 |
begin |
| 673 |
Result := Form.SampleMemo.Text; |
| 674 |
end; |
| 675 |
|
| 676 |
procedure TSynUniDesigner.SetTitle(const Value: string); |
| 677 |
begin |
| 678 |
Form.Caption := Value; |
| 679 |
end; |
| 680 |
|
| 681 |
function TSynUniDesigner.GetTitle: string; |
| 682 |
begin |
| 683 |
Result := Form.Caption; |
| 684 |
end; |
| 685 |
|
| 686 |
|
| 687 |
//================== SCHMaster ================== |
| 688 |
{$IFDEF SYNPLUS} |
| 689 |
function TSynUniDesigner.Execute(FormTitle: string; LangFile: string): boolean; |
| 690 |
var |
| 691 |
msg : TMsg; |
| 692 |
TcClosed: boolean; |
| 693 |
begin |
| 694 |
///////////////////////// |
| 695 |
if FormTitle <> '' then Title := FormTitle; |
| 696 |
Form.Translate(LangFile); |
| 697 |
TcClosed := False; |
| 698 |
Form.ModalResult := mrNone; |
| 699 |
Form.Show; |
| 700 |
|
| 701 |
while (Form.ModalResult = mrNone) do begin |
| 702 |
GetMessage({$IFDEF FPC} @ {$ENDIF}msg, 0, 0, 0); |
| 703 |
if (msg.message = WM_QUIT) then begin |
| 704 |
TcClosed := True; |
| 705 |
Form.ModalResult := mrCancel; |
| 706 |
result:=False; |
| 707 |
end else begin |
| 708 |
Result := (Form.ModalResult = mrOk); |
| 709 |
TranslateMessage({$IFDEF FPC} @ {$ENDIF}msg); |
| 710 |
DispatchMessage({$IFDEF FPC} @ {$ENDIF}msg); |
| 711 |
end; |
| 712 |
end; |
| 713 |
|
| 714 |
Result := (Form.ModalResult = mrOk); |
| 715 |
if TcClosed then |
| 716 |
PostMessage(msg.hwnd, msg.message, msg.wParam, msg.lParam); |
| 717 |
///////////////////////// |
| 718 |
end; |
| 719 |
{$ELSE} |
| 720 |
function TSynUniDesigner.Execute(FormTitle: string; LangFile: string): boolean; |
| 721 |
begin |
| 722 |
if FormTitle <> '' then Title := FormTitle; |
| 723 |
Form.Translate(LangFile); |
| 724 |
Result := (Form.ShowModal = mrOk); |
| 725 |
end; |
| 726 |
{$ENDIF} |
| 727 |
//=============================================== |
| 728 |
|
| 729 |
|
| 730 |
|
| 731 |
|
| 732 |
/// /// |
| 733 |
/// NNNN NNNN EEEEEEEEEEE WWWW WWWW $$$ $$$ $$$ /// |
| 734 |
/// NNNN NN EE EE WW WW $$$$$ $$$$$ $$$$$ /// |
| 735 |
/// NN NN NN EE E E WW WW $$$$$ $$$$$ $$$$$ /// |
| 736 |
/// NN NN NN EEEEEE WW WW WW $$$$$ $$$$$ $$$$$ /// |
| 737 |
/// NN NN NN EE T T WW WWWW WW $$$ $$$ $$$ /// |
| 738 |
/// NN NNNN EE TT WWW WWWW /// |
| 739 |
/// NNNN NNNN EEEETTTTTTT WW WW $$$ $$$ $$$ /// |
| 740 |
/// /// |
| 741 |
//============================ M E T O D S =================================== |
| 742 |
//=== Form events ============================================================ |
| 743 |
procedure TfmDesigner.FormCreate(Sender: TObject); |
| 744 |
|
| 745 |
procedure AddBitmap(ImageList: TImageList; aColor: TColor; aSize: integer; aSymbol: string); |
| 746 |
var Bitmap: TBitmap; |
| 747 |
begin |
| 748 |
Bitmap := TBitmap.Create; |
| 749 |
with Bitmap do begin |
| 750 |
Width := 16; Height := 16; |
| 751 |
end; |
| 752 |
with Bitmap.Canvas do begin |
| 753 |
Font.Name := 'Marlett'; Font.Color := aColor; |
| 754 |
Font.Size := aSize; |
| 755 |
{$IFNDEF FPC} |
| 756 |
TextOut(1, 1, aSymbol); |
| 757 |
{$ELSE} |
| 758 |
TextOut(0, 0, aSymbol); |
| 759 |
{$ENDIF} |
| 760 |
ImageList.AddMasked(Bitmap, clWhite); |
| 761 |
end; |
| 762 |
Bitmap.Free; |
| 763 |
end; |
| 764 |
|
| 765 |
procedure AddBitmapColor(out ImageList: TImageList; aColor: TColor); |
| 766 |
var Bitmap: TBitmap; |
| 767 |
begin |
| 768 |
Bitmap := TBitmap.Create; |
| 769 |
with Bitmap do begin |
| 770 |
Width := 16; Height := 16; |
| 771 |
end; |
| 772 |
with Bitmap.Canvas do begin |
| 773 |
Brush.Color := clBtnFace; FillRect(Rect(0, 0, 16, 16)); |
| 774 |
Brush.Color := aColor; Rectangle(1, 1, 15, 15); |
| 775 |
ImageList.AddMasked(Bitmap, clBtnFace); |
| 776 |
end; |
| 777 |
Bitmap.Free; |
| 778 |
end; |
| 779 |
|
| 780 |
procedure CreateMenuItem(out popMenu: TPopupMenu; aCaption: TCaption; |
| 781 |
aOnClick: TNotifyEvent; aImageIndex: integer); overload; |
| 782 |
begin |
| 783 |
popMenu.Items.Add(TMenuItem.Create(Self)); |
| 784 |
with popMenu.Items.Items[popMenu.Items.Count-1] do begin |
| 785 |
Caption := aCaption; ImageIndex := aImageIndex; OnClick := aOnClick; |
| 786 |
end; |
| 787 |
end; |
| 788 |
|
| 789 |
var |
| 790 |
i: integer; |
| 791 |
begin |
| 792 |
ForceClose := False; |
| 793 |
UpdatingControls := False; |
| 794 |
ShowDialog := True; |
| 795 |
|
| 796 |
_DeleteNode := 'Are you sure you want to delete "%s"?'; |
| 797 |
_SaveChanges := 'Save changes in highlight rools?'; |
| 798 |
_EnterName := 'Enter Scheme Name:'; |
| 799 |
_DeleteScheme := 'Delete current color scheme?'; |
| 800 |
_Modified := 'Modified'; |
| 801 |
_Confirm := 'Confirm'; |
| 802 |
_Lines := 'Lines: %d'; |
| 803 |
_Name := 'Name: %s'; |
| 804 |
_Extensions := 'Extensions: %s'; |
| 805 |
_Version := 'Version: %s'; |
| 806 |
_Date := 'Date: %s'; |
| 807 |
_Author := 'Author: %s'; |
| 808 |
_Mail := 'Mail: %s'; |
| 809 |
_Web := 'Web: %s'; |
| 810 |
_Copyright := 'Copyright: %s'; |
| 811 |
_Company := 'Company: %s'; |
| 812 |
_Remark := 'Remark: %s'; |
| 813 |
|
| 814 |
Caption := 'Unihighlighter Designer © Fantasist, Vit, Vitalik (2002-2004)'; |
| 815 |
if SynUniSyn.Info.General.Name <> '' then |
| 816 |
Caption := Caption + ' - [' + SynUniSyn.Info.General.Name + ']'; |
| 817 |
|
| 818 |
popColorStd.Images := listColors16; |
| 819 |
for i := 0 to 15 do begin |
| 820 |
AddBitmapColor(listColors16, Colors16[i]); |
| 821 |
CreateMenuItem(popColorStd, Colors16s[i], miColor16Click, i); |
| 822 |
end; |
| 823 |
|
| 824 |
{$note May be error...} |
| 825 |
{$IFNDEF FPC} |
| 826 |
popColorStd.Items[8].Break := {$IFDEF FPC} @ {$ENDIF}mbBarBreak; |
| 827 |
{$ENDIF} |
| 828 |
|
| 829 |
popColorAdv.Images := listColors40; |
| 830 |
for i := 0 to 39 do begin |
| 831 |
AddBitmapColor(listColors40, Colors40[i]); |
| 832 |
CreateMenuItem(popColorAdv, '', miColor40Click, i); |
| 833 |
{$note May be error...} |
| 834 |
{$IFNDEF FPC} |
| 835 |
popColorAdv.Items.Items[i].OnMeasureItem := Color40MeasureItem; |
| 836 |
{$ENDIF} |
| 837 |
end; |
| 838 |
{$note May be error...} |
| 839 |
{$IFNDEF FPC} |
| 840 |
for i := 1 to 7 do |
| 841 |
popColorAdv.Items[5*i].Break := mbBreak; |
| 842 |
{$ENDIF} |
| 843 |
|
| 844 |
popColorSys.Images := listColorsSys; |
| 845 |
for i := 0 to 27 do begin |
| 846 |
AddBitmapColor(listColorsSys, ColorsSys[i]); |
| 847 |
CreateMenuItem(popColorSys, ColorToString(ColorsSys[i]), miColorSysClick, i); |
| 848 |
end; |
| 849 |
{$note May be error...} |
| 850 |
{$IFNDEF FPC} |
| 851 |
popColorSys.Items[14].Break := mbBarBreak; |
| 852 |
{$ENDIF} |
| 853 |
|
| 854 |
AddBitmap(listRules, clRed, 14, #52); //: Image0: 'Root Range' |
| 855 |
AddBitmap(listRules, clGreen, 14, #52); //: Image1: 'Range' |
| 856 |
AddBitmap(listRules, clBlue, 14, #104); //: Image2: 'Keyword' |
| 857 |
AddBitmap(listRules, clMaroon, 14, #104); //: Image3: 'Set' |
| 858 |
AddBitmap(listRules, clOlive, 14, #52); //: Image1: 'RangeLink' |
| 859 |
AddBitmap(listRules, clOlive, 14, #52); //: Image4: 'Conteiner' |
| 860 |
|
| 861 |
{ cbScheme.Items.AddStrings(SynUniSyn.SchemesList); |
| 862 |
cbScheme.ItemIndex := SynUniSyn.SchemeIndex;} |
| 863 |
|
| 864 |
SampleMemo.Highlighter := SynUniSyn; |
| 865 |
SampleMemo.Lines.Text := SynUniSyn.Info.Sample.Text; |
| 866 |
end; |
| 867 |
|
| 868 |
procedure TfmDesigner.FormShow(Sender: TObject); |
| 869 |
var |
| 870 |
Stream: TMemoryStream; |
| 871 |
begin |
| 872 |
Stream := TMemoryStream.Create; |
| 873 |
try |
| 874 |
OriginalSyn.SaveToStream(Stream); |
| 875 |
OriginalSyn.SaveToFile('r:\test.xml'); |
| 876 |
Stream.Position := 0; |
| 877 |
try |
| 878 |
if Stream.Size <> 0 then SynUniSyn.LoadFromStream(Stream, False); |
| 879 |
Stream.Clear; |
| 880 |
SampleMemo.Text := OriginalSyn.Info.Sample.Text; |
| 881 |
finally end; |
| 882 |
finally |
| 883 |
Stream.Free; |
| 884 |
end; |
| 885 |
|
| 886 |
FillTree; |
| 887 |
Tree.Selected := Tree.Items[0]; |
| 888 |
TreeChange(nil, Tree.Selected); |
| 889 |
Tree.Items[0].Expand(False); |
| 890 |
end; |
| 891 |
|
| 892 |
procedure TfmDesigner.FormKeyPress(Sender: TObject; var Key: Char); |
| 893 |
begin |
| 894 |
if (Key = #27) and (not Tree.IsEditing) then Close; |
| 895 |
end; |
| 896 |
|
| 897 |
procedure TfmDesigner.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); |
| 898 |
begin |
| 899 |
if Key = VK_F1 then |
| 900 |
if ssCtrl in Shift then |
| 901 |
rootInfoClick(Sender) |
| 902 |
else |
| 903 |
Application.MessageBox('UniHighlighter Component'+#13#10#13#10+ |
| 904 |
'Copyright © 2002-2004:'+#13#10+ |
| 905 |
'Fantasist ([email protected])'+#13#10+ |
| 906 |
'Vit ([email protected])'+#13#10+ |
| 907 |
'Vitalik ([email protected])'+#13#10#13#10+ |
| 908 |
'Official Web Site: www.delphist.com'{+#13#10#13#10+ |
| 909 |
'Thanks to:'+#13#10+ |
| 910 |
'P@VeL, '+ |
| 911 |
'bouville, '+ |
| 912 |
'StayAtHome, '+ |
| 913 |
'Jasny, '+ |
| 914 |
'SCHMaster'}, |
| 915 |
'About...', MB_ICONINFORMATION) |
| 916 |
else |
| 917 |
if (ssAlt in Shift) and (ssShift in Shift) and (ssCtrl in Shift) and (Key = VK_F12) then begin |
| 918 |
edStylesFile.Enabled := True; |
| 919 |
btStylesFile.Enabled := True; |
| 920 |
cbStyle.Enabled := True; |
| 921 |
end; |
| 922 |
end; |
| 923 |
|
| 924 |
procedure TfmDesigner.FormCloseQuery(Sender: TObject; var CanClose: Boolean); |
| 925 |
var |
| 926 |
Choise: integer; |
| 927 |
begin |
| 928 |
if Tree.IsEditing then Tree.Selected.EndEdit(False); |
| 929 |
if ModalResult = mrOk then Exit; |
| 930 |
if btApply.Enabled then begin |
| 931 |
if ForceClose then Exit; |
| 932 |
Choise := Application.MessageBox(PChar(_SaveChanges), PChar(_Confirm), MB_YESNOCANCEL+MB_ICONQUESTION); |
| 933 |
if Choise = ID_YES then begin |
| 934 |
btApplyClick(Sender); |
| 935 |
ModalResult := mrOk |
| 936 |
end |
| 937 |
else if Choise = ID_NO then |
| 938 |
ModalResult := mrCancel |
| 939 |
else |
| 940 |
CanClose := False; |
| 941 |
end |
| 942 |
else |
| 943 |
ModalResult := mrCancel; |
| 944 |
|
| 945 |
//================== SCHMaster ================== |
| 946 |
{$IFDEF SYNPLUS} |
| 947 |
if ModalResult = mrNone then |
| 948 |
ModalResult:=mrCancel; |
| 949 |
{$ENDIF} |
| 950 |
//=============================================== |
| 951 |
end; |
| 952 |
|
| 953 |
//=== Translate ============================================================== |
| 954 |
procedure TfmDesigner.OldTranslate(LangFile: String); //SCHMaster 2004 |
| 955 |
var |
| 956 |
L: TStringList; |
| 957 |
begin |
| 958 |
L := TStringList.Create; |
| 959 |
if (LangFile <> '') and FileExists(LangFile) then |
| 960 |
L.LoadFromFile(LangFile); |
| 961 |
|
| 962 |
if Length(L.Values['2000'])>2 then Caption := L.Values['2000'] + ' - [' + SynUniSyn.Info.General.Name + ']'; |
| 963 |
with popPanels do begin |
| 964 |
if Length(L.Values['2001'])>2 then Items[0].Caption := L.Values['2001']; |
| 965 |
if Length(L.Values['2002'])>2 then Items[1].Caption := L.Values['2002']; |
| 966 |
if Length(L.Values['2003'])>2 then Items[2].Caption := L.Values['2003']; |
| 967 |
if Length(L.Values['2004'])>2 then Items[3].Caption := L.Values['2004']; |
| 968 |
end; |
| 969 |
|
| 970 |
if Length(L.Values['2010'])>2 then btOk.Caption := L.Values['2010']; |
| 971 |
if Length(L.Values['2011'])>2 then btCancel.Caption := L.Values['2011']; |
| 972 |
if Length(L.Values['2012'])>2 then btApply.Caption := L.Values['2012']; |
| 973 |
|
| 974 |
with popStandard do begin |
| 975 |
if Length(L.Values['2013'])>2 then Items[0].Caption := L.Values['2013']; |
| 976 |
if Length(L.Values['2014'])>2 then Items[2].Caption := L.Values['2014']; |
| 977 |
if Length(L.Values['2015'])>2 then Items[3].Caption := L.Values['2015']; |
| 978 |
if Length(L.Values['2016'])>2 then Items[4].Caption := L.Values['2016']; |
| 979 |
if Length(L.Values['2017'])>2 then Items[5].Caption := L.Values['2017']; |
| 980 |
if Length(L.Values['2018'])>2 then Items[7].Caption := L.Values['2018']; |
| 981 |
end; |
| 982 |
|
| 983 |
with popSampleMemoMenu do begin |
| 984 |
if Length(L.Values['2013'])>2 then Items[2].Caption := L.Values['2013']; |
| 985 |
if Length(L.Values['2014'])>2 then Items[4].Caption := L.Values['2014']; |
| 986 |
if Length(L.Values['2015'])>2 then Items[5].Caption := L.Values['2015']; |
| 987 |
if Length(L.Values['2016'])>2 then Items[6].Caption := L.Values['2016']; |
| 988 |
if Length(L.Values['2017'])>2 then Items[7].Caption := L.Values['2017']; |
| 989 |
if Length(L.Values['2018'])>2 then Items[9].Caption := L.Values['2018']; |
| 990 |
end; |
| 991 |
|
| 992 |
if Length(L.Values['2020'])>2 then _Modified := L.Values['2020']; |
| 993 |
if Length(L.Values['2030'])>2 then _DeleteNode := L.Values['2030']; |
| 994 |
if Length(L.Values['2031'])>2 then _SaveChanges := L.Values['2031']; |
| 995 |
if Length(L.Values['2032'])>2 then _EnterName := L.Values['2032']; |
| 996 |
if Length(L.Values['2033'])>2 then _DeleteScheme := L.Values['2033']; |
| 997 |
if Length(L.Values['2034'])>2 then _Confirm := L.Values['2034']; |
| 998 |
|
| 999 |
if Length(L.Values['2100'])>2 then pLeftCapt.Caption := L.Values['2100']; |
| 1000 |
if Length(L.Values['2200'])>2 then pMiddleCapt.Caption := L.Values['2200']; |
| 1001 |
if Length(L.Values['2201'])>2 then lbPropBack.Hint := L.Values['2201']; |
| 1002 |
if Length(L.Values['2202'])>2 then lbRuleMenu.Hint := L.Values['2202']; |
| 1003 |
|
| 1004 |
with popRootMenu do begin |
| 1005 |
if Length(L.Values['2305'])>2 then Items[8].Caption := L.Values['2305']; |
| 1006 |
if Length(L.Values['2306'])>2 then Items[9].Caption := L.Values['2306']; |
| 1007 |
if Length(L.Values['2307'])>2 then Items[10].Caption := L.Values['2307']; |
| 1008 |
if Length(L.Values['2204'])>2 then Items[13].Caption := L.Values['2204']; |
| 1009 |
end; |
| 1010 |
with popRangeMenu do begin |
| 1011 |
if Length(L.Values['2203'])>2 then Items[0].Caption := L.Values['2203']; |
| 1012 |
if Length(L.Values['2204'])>2 then Items[16].Caption := L.Values['2204']; |
| 1013 |
if Length(L.Values['2406'])>2 then Items[11].Caption := L.Values['2406']; |
| 1014 |
if Length(L.Values['2407'])>2 then Items[12].Caption := L.Values['2407']; |
| 1015 |
if Length(L.Values['2408'])>2 then Items[13].Caption := L.Values['2408']; |
| 1016 |
end; |
| 1017 |
with popKeywordsMenu do begin |
| 1018 |
if Length(L.Values['2203'])>2 then Items[0].Caption := L.Values['2203']; |
| 1019 |
if Length(L.Values['2204'])>2 then Items[11].Caption := L.Values['2204']; |
| 1020 |
end; |
| 1021 |
with popSetMenu do begin |
| 1022 |
if Length(L.Values['2203'])>2 then Items[0].Caption := L.Values['2203']; |
| 1023 |
if Length(L.Values['2204'])>2 then Items[11].Caption := L.Values['2204']; |
| 1024 |
end; |
| 1025 |
|
| 1026 |
if Length(L.Values['2300'])>2 then chCaseRoot.Caption := L.Values['2300']; |
| 1027 |
if Length(L.Values['2300'])>2 then chCaseRange.Caption := L.Values['2300']; |
| 1028 |
if Length(L.Values['2301'])>2 then btAddRangeRoot.Caption := L.Values['2301']; |
| 1029 |
if Length(L.Values['2301'])>2 then btAddRange.Caption := L.Values['2301']; |
| 1030 |
if Length(L.Values['2302'])>2 then btAddKeywordsRoot.Caption := L.Values['2302']; |
| 1031 |
if Length(L.Values['2302'])>2 then btAddKeywords.Caption := L.Values['2302']; |
| 1032 |
if Length(L.Values['2303'])>2 then btAddSetRoot.Caption := L.Values['2303']; |
| 1033 |
if Length(L.Values['2303'])>2 then btAddSet.Caption := L.Values['2303']; |
| 1034 |
if Length(L.Values['2304'])>2 then lbDelimitersRoot.Caption := L.Values['2304']; |
| 1035 |
if Length(L.Values['2304'])>2 then lbDelimitersRange.Caption := L.Values['2304']; |
| 1036 |
|
| 1037 |
if Length(L.Values['2400'])>2 then lbRangeFrom.Caption := L.Values['2400']; |
| 1038 |
if Length(L.Values['2401'])>2 then lbRangeTo.Caption := L.Values['2401']; |
| 1039 |
if Length(L.Values['2402'])>2 then chCloseOnWord.Caption := L.Values['2402']; |
| 1040 |
if Length(L.Values['2403'])>2 then chCloseOnEOL.Caption := L.Values['2403']; |
| 1041 |
if Length(L.Values['2404'])>2 then chCloseParent.Caption := L.Values['2404']; |
| 1042 |
|
| 1043 |
if Length(L.Values['2501'])>2 then btSort.Hint := L.Values['2501']; |
| 1044 |
if Length(L.Values['2502'])>2 then btLowercase.Hint := L.Values['2502']; |
| 1045 |
if Length(L.Values['2503'])>2 then btSpacesToEol.Hint := L.Values['2503']; |
| 1046 |
|
| 1047 |
if Length(L.Values['2600'])>2 then lbSymbSet.Caption := L.Values['2600']; |
| 1048 |
|
| 1049 |
if Length(L.Values['2700'])>2 then pRightCapt.Caption := L.Values['2700']; |
| 1050 |
if Length(L.Values['2701'])>2 then chForeground.Caption := L.Values['2701']; |
| 1051 |
if Length(L.Values['2702'])>2 then chBackground.Caption := L.Values['2702']; |
| 1052 |
if Length(L.Values['2703'])>2 then chBold.Caption := L.Values['2703']; |
| 1053 |
if Length(L.Values['2704'])>2 then chItalic.Caption := L.Values['2704']; |
| 1054 |
if Length(L.Values['2705'])>2 then chUnderline.Caption := L.Values['2705']; |
| 1055 |
if Length(L.Values['2706'])>2 then chStrikeOut.Caption := L.Values['2706']; |
| 1056 |
{ if Length(L.Values['2707'])>2 then lbScheme.Caption := L.Values['2707']; |
| 1057 |
if Length(L.Values['2708'])>2 then btNewScheme.Caption := L.Values['2708']; |
| 1058 |
if Length(L.Values['2709'])>2 then btDelScheme.Caption := L.Values['2709'];} |
| 1059 |
|
| 1060 |
if Length(L.Values['2800'])>2 then pBottomCapt.Caption := L.Values['2800']; |
| 1061 |
if Length(L.Values['2801'])>2 then lbSampMin.Hint := L.Values['2801']; |
| 1062 |
if Length(L.Values['2802'])>2 then lbSampMax.Hint := L.Values['2802']; |
| 1063 |
|
| 1064 |
L.Free; |
| 1065 |
end; |
| 1066 |
|
| 1067 |
procedure TfmDesigner.Translate(LangFile: String); |
| 1068 |
var |
| 1069 |
L: TStringList; |
| 1070 |
Ini: TIniFile; |
| 1071 |
i: integer; |
| 1072 |
begin |
| 1073 |
L := TStringList.Create; |
| 1074 |
if (LangFile = '') or not FileExists(LangFile) then |
| 1075 |
Exit; |
| 1076 |
{ else |
| 1077 |
if ExtractFileExt(LangFile) = '.lng' then begin |
| 1078 |
OldTranslate(LangFile); Exit; |
| 1079 |
end else |
| 1080 |
Ini := TIniFile.Create(LangFile);} |
| 1081 |
|
| 1082 |
OldTranslate(LangFile); |
| 1083 |
Ini := TIniFile.Create(LangFile); |
| 1084 |
|
| 1085 |
Ini.ReadSectionValues('Form', L); |
| 1086 |
if Length(L.Values['Caption' ]) > 0 then Caption := L.Values['Caption' ]; |
| 1087 |
if Length(L.Values[btOk.Caption ]) > 0 then btOk.Caption := L.Values[btOk.Caption ]; |
| 1088 |
if Length(L.Values[btCancel.Caption ]) > 0 then btCancel.Caption := L.Values[btCancel.Caption ]; |
| 1089 |
if Length(L.Values[btApply.Caption ]) > 0 then btApply.Caption := L.Values[btApply.Caption ]; |
| 1090 |
if Length(L.Values[_Modified ]) > 0 then _Modified := L.Values[_Modified ]; |
| 1091 |
if Length(L.Values[_Name ]) > 0 then _Name := L.Values[_Name ]; |
| 1092 |
if Length(L.Values[_Extensions ]) > 0 then _Extensions := L.Values[_Extensions ]; |
| 1093 |
if Length(L.Values[_Version ]) > 0 then _Version := L.Values[_Version ]; |
| 1094 |
if Length(L.Values[_Date ]) > 0 then _Date := L.Values[_Date ]; |
| 1095 |
if Length(L.Values[_Author ]) > 0 then _Author := L.Values[_Author ]; |
| 1096 |
if Length(L.Values[_Mail ]) > 0 then _Mail := L.Values[_Mail ]; |
| 1097 |
if Length(L.Values[_Web ]) > 0 then _Web := L.Values[_Web ]; |
| 1098 |
if Length(L.Values[_Copyright ]) > 0 then _Copyright := L.Values[_Copyright ]; |
| 1099 |
if Length(L.Values[_Company ]) > 0 then _Company := L.Values[_Company ]; |
| 1100 |
if Length(L.Values[_Remark ]) > 0 then _Remark := L.Values[_Remark ]; |
| 1101 |
if Length(L.Values[_DeleteNode ]) > 0 then _DeleteNode := L.Values[_DeleteNode ]; |
| 1102 |
if Length(L.Values[_SaveChanges ]) > 0 then _SaveChanges := L.Values[_SaveChanges ]; |
| 1103 |
if Length(L.Values[_EnterName ]) > 0 then _EnterName := L.Values[_EnterName ]; |
| 1104 |
if Length(L.Values[_DeleteScheme ]) > 0 then _DeleteScheme := L.Values[_DeleteScheme ]; |
| 1105 |
if Length(L.Values[_Confirm ]) > 0 then _Confirm := L.Values[_Confirm ]; |
| 1106 |
|
| 1107 |
Ini.ReadSectionValues('popPanels', L); |
| 1108 |
with popPanels do for i := 0 to 4 do |
| 1109 |
if Length(L.Values[Items[i].Caption]) > 0 then Items[i].Caption := L.Values[Items[i].Caption]; |
| 1110 |
|
| 1111 |
Ini.ReadSectionValues('popStandard', L); |
| 1112 |
with popStandard do for i := 0 to 7 do |
| 1113 |
if Length(L.Values[Items[i].Caption]) > 0 then Items[i].Caption := L.Values[Items[i].Caption]; |
| 1114 |
|
| 1115 |
Ini.ReadSectionValues('popTagMenus', L); |
| 1116 |
with popOpenTagMenu do for i := 0 to 8 do |
| 1117 |
if Length(L.Values[Items[i].Caption]) > 0 then Items[i].Caption := L.Values[Items[i].Caption]; |
| 1118 |
|
| 1119 |
Ini.ReadSectionValues('popTagMenus', L); |
| 1120 |
with popCloseTagMenu do for i := 0 to 8 do |
| 1121 |
if Length(L.Values[Items[i].Caption]) > 0 then Items[i].Caption := L.Values[Items[i].Caption]; |
| 1122 |
|
| 1123 |
Ini.ReadSectionValues('popRootMenu', L); |
| 1124 |
with popRootMenu do for i := 0 to 15 do |
| 1125 |
if Length(L.Values[Items[i].Caption]) > 0 then Items[i].Caption := L.Values[Items[i].Caption]; |
| 1126 |
|
| 1127 |
Ini.ReadSectionValues('popRangeMenu', L); |
| 1128 |
with popRangeMenu do for i := 0 to 16 do |
| 1129 |
if Length(L.Values[Items[i].Caption]) > 0 then Items[i].Caption := L.Values[Items[i].Caption]; |
| 1130 |
|
| 1131 |
Ini.ReadSectionValues('popKeywordsMenu', L); |
| 1132 |
with popKeywordsMenu do for i := 0 to 11 do |
| 1133 |
if Length(L.Values[Items[i].Caption]) > 0 then Items[i].Caption := L.Values[Items[i].Caption]; |
| 1134 |
|
| 1135 |
Ini.ReadSectionValues('popSetMenu', L); |
| 1136 |
with popSetMenu do for i := 0 to 11 do |
| 1137 |
if Length(L.Values[Items[i].Caption]) > 0 then Items[i].Caption := L.Values[Items[i].Caption]; |
| 1138 |
|
| 1139 |
Ini.ReadSectionValues('popSampleMemoMenu', L); |
| 1140 |
with popSampleMemoMenu do for i := 0 to 9 do |
| 1141 |
if Length(L.Values[Items[i].Caption]) > 0 then Items[i].Caption := L.Values[Items[i].Caption]; |
| 1142 |
|
| 1143 |
Ini.ReadSectionValues('popColorStd', L); |
| 1144 |
with popColorStd do for i := 0 to 15 do |
| 1145 |
if Length(L.Values[Items[i].Caption]) > 0 then Items[i].Caption := L.Values[Items[i].Caption]; |
| 1146 |
|
| 1147 |
Ini.ReadSectionValues('pLeft', L); |
| 1148 |
if Length(L.Values[pLeftCapt.Caption ]) > 0 then pLeftCapt.Caption := L.Values[pLeftCapt.Caption ]; |
| 1149 |
if Length(L.Values[lbRootMenu.Hint ]) > 0 then lbRootMenu.Hint := L.Values[lbRootMenu.Hint ]; |
| 1150 |
|
| 1151 |
Ini.ReadSectionValues('pMiddle', L); |
| 1152 |
if Length(L.Values[pMiddleCapt.Caption ]) > 0 then pMiddleCapt.Caption := L.Values[pMiddleCapt.Caption ]; |
| 1153 |
if Length(L.Values[lbPropBack.Hint ]) > 0 then lbPropBack.Hint := L.Values[lbPropBack.Hint ]; |
| 1154 |
if Length(L.Values[lbRuleMenu.Hint ]) > 0 then lbRuleMenu.Hint := L.Values[lbRuleMenu.Hint ]; |
| 1155 |
|
| 1156 |
Ini.ReadSectionValues('tabRoot', L); |
| 1157 |
if Length(L.Values[chCaseRoot.Caption ]) > 0 then chCaseRoot.Caption := L.Values[chCaseRoot.Caption ]; |
| 1158 |
if Length(L.Values[chEnabledRoot.Caption ]) > 0 then chEnabledRoot.Caption := L.Values[chEnabledRoot.Caption ]; |
| 1159 |
if Length(L.Values[lbDelimitersRoot.Caption ]) > 0 then lbDelimitersRoot.Caption := L.Values[lbDelimitersRoot.Caption ]; |
| 1160 |
if Length(L.Values[btAddRangeRoot.Caption ]) > 0 then btAddRangeRoot.Caption := L.Values[btAddRangeRoot.Caption ]; |
| 1161 |
if Length(L.Values[btAddKeywordsRoot.Caption ]) > 0 then btAddKeywordsRoot.Caption := L.Values[btAddKeywordsRoot.Caption ]; |
| 1162 |
if Length(L.Values[btAddSetRoot.Caption ]) > 0 then btAddSetRoot.Caption := L.Values[btAddSetRoot.Caption ]; |
| 1163 |
|
| 1164 |
Ini.ReadSectionValues('tabRange', L); |
| 1165 |
if Length(L.Values[chCaseRange.Caption ]) > 0 then chCaseRange.Caption := L.Values[chCaseRange.Caption ]; |
| 1166 |
if Length(L.Values[chEnabledRange.Caption ]) > 0 then chEnabledRange.Caption := L.Values[chEnabledRange.Caption ]; |
| 1167 |
if Length(L.Values[lbRangeFrom.Caption ]) > 0 then lbRangeFrom.Caption := L.Values[lbRangeFrom.Caption ]; |
| 1168 |
if Length(L.Values[lbRangeTo.Caption ]) > 0 then lbRangeTo.Caption := L.Values[lbRangeTo.Caption ]; |
| 1169 |
if Length(L.Values[chCloseOnWord.Caption ]) > 0 then chCloseOnWord.Caption := L.Values[chCloseOnWord.Caption ]; |
| 1170 |
if Length(L.Values[chCloseOnEol.Caption ]) > 0 then chCloseOnEol.Caption := L.Values[chCloseOnEol.Caption ]; |
| 1171 |
if Length(L.Values[chCloseParent.Caption ]) > 0 then chCloseParent.Caption := L.Values[chCloseParent.Caption ]; |
| 1172 |
if Length(L.Values[lbDelimitersRange.Caption ]) > 0 then lbDelimitersRange.Caption := L.Values[lbDelimitersRange.Caption ]; |
| 1173 |
if Length(L.Values[btAddRange.Caption ]) > 0 then btAddRange.Caption := L.Values[btAddRange.Caption ]; |
| 1174 |
if Length(L.Values[btAddKeywords.Caption ]) > 0 then btAddKeywords.Caption := L.Values[btAddKeywords.Caption ]; |
| 1175 |
if Length(L.Values[btAddSet.Caption ]) > 0 then btAddSet.Caption := L.Values[btAddSet.Caption ]; |
| 1176 |
|
| 1177 |
Ini.ReadSectionValues('tabKeywords', L); |
| 1178 |
if Length(L.Values[chEnabledKeyList.Caption ]) > 0 then chEnabledKeyList.Caption := L.Values[chEnabledKeyList.Caption ]; |
| 1179 |
if Length(L.Values[btSort.Hint ]) > 0 then btSort.Hint := L.Values[btSort.Hint ]; |
| 1180 |
if Length(L.Values[btLowerCase.Hint ]) > 0 then btLowerCase.Hint := L.Values[btLowerCase.Hint ]; |
| 1181 |
if Length(L.Values[btSpacesToEol.Hint ]) > 0 then btSpacesToEol.Hint := L.Values[btSpacesToEol.Hint ]; |
| 1182 |
if Length(L.Values[_Lines ]) > 0 then _Lines := L.Values[_Lines ]; |
| 1183 |
|
| 1184 |
Ini.ReadSectionValues('tabSet', L); |
| 1185 |
if Length(L.Values[chEnabledSet.Caption ]) > 0 then chEnabledSet.Caption := L.Values[chEnabledSet.Caption ]; |
| 1186 |
if Length(L.Values[lbSymbSet.Caption ]) > 0 then lbSymbSet.Caption := L.Values[lbSymbSet.Caption ]; |
| 1187 |
|
| 1188 |
Ini.ReadSectionValues('tabSeveralRules', L); |
| 1189 |
if Length(L.Values[Label1.Caption]) > 0 then Label1.Caption := L.Values[Label1.Caption]; |
| 1190 |
|
| 1191 |
Ini.ReadSectionValues('pRight', L); |
| 1192 |
if Length(L.Values[pRightCapt.Caption ]) > 0 then pRightCapt.Caption := L.Values[pRightCapt.Caption ]; |
| 1193 |
if Length(L.Values[chForeground.Caption ]) > 0 then chForeground.Caption := L.Values[chForeground.Caption ]; |
| 1194 |
if Length(L.Values[chBackground.Caption ]) > 0 then chBackground.Caption := L.Values[chBackground.Caption ]; |
| 1195 |
if Length(L.Values[chBold.Caption ]) > 0 then chBold.Caption := L.Values[chBold.Caption ]; |
| 1196 |
if Length(L.Values[chItalic.Caption ]) > 0 then chItalic.Caption := L.Values[chItalic.Caption ]; |
| 1197 |
if Length(L.Values[chUnderline.Caption ]) > 0 then chUnderline.Caption := L.Values[chUnderline.Caption ]; |
| 1198 |
if Length(L.Values[chStrikeOut.Caption ]) > 0 then chStrikeOut.Caption := L.Values[chStrikeOut.Caption ]; |
| 1199 |
{ |
| 1200 |
if Length(L.Values[lbScheme.Caption ]) > 0 then lbScheme.Caption := L.Values[lbScheme.Caption ]; |
| 1201 |
if Length(L.Values[btNewScheme.Caption ]) > 0 then btNewScheme.Caption := L.Values[btNewScheme.Caption ]; |
| 1202 |
if Length(L.Values[btDelScheme.Caption ]) > 0 then btDelScheme.Caption := L.Values[btDelScheme.Caption ]; |
| 1203 |
} |
| 1204 |
Ini.ReadSectionValues('pBottom', L); |
| 1205 |
if Length(L.Values[pBottomCapt.Caption ]) > 0 then pBottomCapt.Caption := L.Values[pBottomCapt.Caption ]; |
| 1206 |
if Length(L.Values[lbSampMin.Hint ]) > 0 then lbSampMin.Hint := L.Values[lbSampMin.Hint ]; |
| 1207 |
if Length(L.Values[lbSampMax.Hint ]) > 0 then lbSampMax.Hint := L.Values[lbSampMax.Hint ]; |
| 1208 |
{ |
| 1209 |
if Length(L.Values[]) > 0 then := L.Values[]; |
| 1210 |
if Length(L.Values[]) > 0 then := L.Values[]; |
| 1211 |
} |
| 1212 |
L.Free; |
| 1213 |
end; |
| 1214 |
|
| 1215 |
//=== TreeView =============================================================== |
| 1216 |
procedure TfmDesigner.TreeEdited(Sender: TObject; Node: TTreeNode; |
| 1217 |
var S: TNodeText); |
| 1218 |
begin |
| 1219 |
if Node.Data = nil then Exit; |
| 1220 |
if TObject(Node.Data) is TSynRange then TSynRange(Node.Data).Name := S; |
| 1221 |
if TObject(Node.Data) is TSynKeyList then TSynKeyList(Node.Data).Name := S; |
| 1222 |
if TObject(Node.Data) is TSynSet then TSynSet(Node.Data).Name := S; |
| 1223 |
Modified(); |
| 1224 |
end; |
| 1225 |
|
| 1226 |
procedure TfmDesigner.TreeKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); |
| 1227 |
begin |
| 1228 |
if Key = VK_DELETE then DoDeleteNode(Sender) else |
| 1229 |
if Key = VK_F2 then DoRenameNode(Sender) else |
| 1230 |
if popPropMenu = popRootMenu then |
| 1231 |
if (Key = ord('X')) and (ssCtrl in Shift) then rootCutClick(Sender) else |
| 1232 |
if (Key = ord('C')) and (ssCtrl in Shift) then rootCopyClick(Sender) else |
| 1233 |
if (Key = ord('V')) and (ssCtrl in Shift) then rootPasteInsideClick(Sender) else |
| 1234 |
else |
| 1235 |
if popPropMenu = popRangeMenu then |
| 1236 |
if (Key = ord('X')) and (ssCtrl in Shift) then rangeCutClick(Sender) else |
| 1237 |
if (Key = ord('C')) and (ssCtrl in Shift) then rangeCopyClick(Sender) else |
| 1238 |
if (Key = ord('V')) and (ssCtrl in Shift) then rangePasteInsideClick(Sender) else |
| 1239 |
else |
| 1240 |
if (popPropMenu = popKeywordsMenu) or (popPropMenu = popSetMenu) then |
| 1241 |
if (Key = ord('X')) and (ssCtrl in Shift) then rangeCutClick(Sender) else |
| 1242 |
if (Key = ord('C')) and (ssCtrl in Shift) then rangeCopyClick(Sender) else |
| 1243 |
if (Key = ord('V')) and (ssCtrl in Shift) then rangePasteNextToClick(Sender) else |
| 1244 |
else |
| 1245 |
end; |
| 1246 |
|
| 1247 |
procedure TfmDesigner.TreeMouseDown(Sender: TObject; |
| 1248 |
Button: TMouseButton; Shift: TShiftState; X, Y: Integer); |
| 1249 |
//: Handle Right Mouse Up on the Tree |
| 1250 |
var |
| 1251 |
iNode: TTreeNode; |
| 1252 |
begin |
| 1253 |
if Button <> mbRight then |
| 1254 |
Exit; |
| 1255 |
// Tree.PopupMenu := nil; |
| 1256 |
// iNode := Tree.GetNodeAt( X, Y ); |
| 1257 |
iNode := Tree.GetNodeAt( X, Y ); |
| 1258 |
// Tree.PopupMenu := popRuleMenu; |
| 1259 |
// Tree.Items.Item[0].Focused := True; |
| 1260 |
// TreeChange(Sender, iNode); |
| 1261 |
if iNode <> nil then begin |
| 1262 |
iNode.Selected := True; |
| 1263 |
TreeChange(Sender, Tree.Selected); |
| 1264 |
// TreeChange(Sender, iNode); |
| 1265 |
// popRuleMenu.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y); |
| 1266 |
end; |
| 1267 |
end; |
| 1268 |
|
| 1269 |
procedure TfmDesigner.TreeMouseUp(Sender: TObject; |
| 1270 |
Button: TMouseButton; Shift: TShiftState; X, Y: Integer); |
| 1271 |
//: Handle Right Mouse Up on the Tree |
| 1272 |
//: ??? Переделать ??? |
| 1273 |
var |
| 1274 |
iNode: TTreeNode; |
| 1275 |
begin |
| 1276 |
if Button <> mbRight then |
| 1277 |
Exit; |
| 1278 |
iNode := Tree.GetNodeAt( X, Y ); |
| 1279 |
// TreeChange(Sender, iNode); |
| 1280 |
if iNode <> nil then |
| 1281 |
iNode.Selected := True; |
| 1282 |
TreeChange(Sender, Tree.Selected); |
| 1283 |
{ case GetNodeType(Tree.Selected) of |
| 1284 |
ntRoot: popRootMenu.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y); |
| 1285 |
ntRange: popRangeMenu.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y); |
| 1286 |
ntKeywords: popKeywordsMenu.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y); |
| 1287 |
ntSet: popSetMenu.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y); |
| 1288 |
end;} |
| 1289 |
popPropMenu.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y); |
| 1290 |
// TreeChange(Sender, iNode); |
| 1291 |
// popRuleMenu.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y); |
| 1292 |
end; |
| 1293 |
|
| 1294 |
|
| 1295 |
procedure TfmDesigner.TreeClick(Sender: TObject); |
| 1296 |
begin |
| 1297 |
TreeChange(Sender, Tree.Selected); |
| 1298 |
end; |
| 1299 |
|
| 1300 |
procedure TfmDesigner.TreeChange(Sender: TObject; Node: TTreeNode); |
| 1301 |
var |
| 1302 |
Range: TSynRange; |
| 1303 |
Symbol: string; |
| 1304 |
len: integer; |
| 1305 |
// list: TList; |
| 1306 |
begin |
| 1307 |
UpdatingControls := True; |
| 1308 |
// ListBox1.Clear; |
| 1309 |
// list := TList.Create; |
| 1310 |
// Tree.GetSelections(list); |
| 1311 |
{ for i := 0 to list.Count-1 do |
| 1312 |
ListBox1.Items.Add(TTreeNode(list.Items[i]).Text); |
| 1313 |
list.Free;} |
| 1314 |
if Tree.SelectionCount > 1 then |
| 1315 |
PageControl.ActivePage := tabSeveralRules |
| 1316 |
else |
| 1317 |
if Tree.SelectionCount = 1 then begin |
| 1318 |
// Tree.Selected := TTreeNode(list.Items[0]); |
| 1319 |
case GetNodeType(Node) of |
| 1320 |
ntRange, ntRangeLink: begin |
| 1321 |
if (TObject(Node.Data) is TSynRangeLink) then |
| 1322 |
Range := TSynRangeLink(Node.Data).Range |
| 1323 |
else |
| 1324 |
Range := TSynRange(Node.Data); |
| 1325 |
with Range do begin |
| 1326 |
Symbol := fRule.fOpenSymbol.Symbol; |
| 1327 |
edFrom.Text := Symbol; |
| 1328 |
len := length(Symbol); |
| 1329 |
if len > 0 then |
| 1330 |
chFromEOL.Checked := Symbol[len] = #0 |
| 1331 |
else |
| 1332 |
chFromEOL.Checked := False; |
| 1333 |
|
| 1334 |
Symbol := fRule.fCloseSymbol.Symbol; |
| 1335 |
edTo.Text := Symbol; |
| 1336 |
len := length(Symbol); |
| 1337 |
if len > 0 then |
| 1338 |
chToEOL.Checked := Symbol[len] = #0 |
| 1339 |
else |
| 1340 |
chToEOL.Checked := False; |
| 1341 |
|
| 1342 |
chEnabledRange.Checked := Enabled; |
| 1343 |
chCloseOnWord.Checked := fRule.fCloseOnTerm; |
| 1344 |
chCloseOnEOL.Checked := fRule.fCloseOnEol; |
| 1345 |
chCloseParent.Checked := fRule.fAllowPredClose; |
| 1346 |
chCaseRange.Checked := CaseSensitive; |
| 1347 |
edDelimitersRange.Text := SetToStr(TermSymbols); |
| 1348 |
popOpenTagMenu.Items.Items[2].Checked := fRule.fOpenSymbol.StartLine = slFirst; |
| 1349 |
popOpenTagMenu.Items.Items[3].Checked := fRule.fOpenSymbol.StartLine = slFirstNonSpace; |
| 1350 |
popCloseTagMenu.Items.Items[2].Checked := fRule.fCloseSymbol.StartLine = slFirst; |
| 1351 |
popCloseTagMenu.Items.Items[3].Checked := fRule.fCloseSymbol.StartLine = slFirstNonSpace; |
| 1352 |
if fRule.fOpenSymbol.StartType = stAny then |
| 1353 |
if fRule.fOpenSymbol.BrakeType = btAny then |
| 1354 |
popOpenTagMenu.Items.Items[5].Checked := True |
| 1355 |
else |
| 1356 |
popOpenTagMenu.Items.Items[7].Checked := True |
| 1357 |
else |
| 1358 |
if fRule.fOpenSymbol.BrakeType = btAny then |
| 1359 |
popOpenTagMenu.Items.Items[6].Checked := True |
| 1360 |
else |
| 1361 |
popOpenTagMenu.Items.Items[8].Checked := True; |
| 1362 |
if fRule.fCloseSymbol.StartType = stAny then |
| 1363 |
if fRule.fCloseSymbol.BrakeType = btAny then |
| 1364 |
popCloseTagMenu.Items.Items[5].Checked := True |
| 1365 |
else |
| 1366 |
popCloseTagMenu.Items.Items[7].Checked := True |
| 1367 |
else |
| 1368 |
if fRule.fCloseSymbol.BrakeType = btAny then |
| 1369 |
popCloseTagMenu.Items.Items[6].Checked := True |
| 1370 |
else |
| 1371 |
popCloseTagMenu.Items.Items[8].Checked := True; |
| 1372 |
SetControlAttributes(Node, True); |
| 1373 |
PageControl.ActivePage := tabRange; |
| 1374 |
end; |
| 1375 |
end; |
| 1376 |
ntRoot: begin |
| 1377 |
chEnabledRoot.Checked := TSynRange(Node.data).Enabled; |
| 1378 |
SetControlAttributes(Node, True); |
| 1379 |
chCaseRoot.Checked := TSynRange(Node.data).CaseSensitive; |
| 1380 |
edStylesFile.Text := SynUniSyn.SchemeFileName; |
| 1381 |
edDelimitersRoot.text := SetToStr(TSynRange(Node.data).TermSymbols); |
| 1382 |
PageControl.ActivePage := tabRoot; |
| 1383 |
end; |
| 1384 |
ntKeywords: begin |
| 1385 |
chEnabledKeyList.Checked := TSynKeyList(Node.Data).Enabled; |
| 1386 |
Memo.Lines.Assign(TSynKeyList(Node.Data).KeyList); |
| 1387 |
SetControlAttributes(Node, True); |
| 1388 |
PageControl.ActivePage := tabKeywords; |
| 1389 |
end; |
| 1390 |
ntSet: begin |
| 1391 |
chEnabledSet.Checked := TSynSet(Node.Data).Enabled; |
| 1392 |
SetControlAttributes(Node, True); |
| 1393 |
edSymbSet.Text := SetToStr(TSynSet(Node.Data).SymbSet); |
| 1394 |
PageControl.ActivePage := tabSet; |
| 1395 |
end; |
| 1396 |
end; |
| 1397 |
end; |
| 1398 |
UpdatingControls := False; |
| 1399 |
end; |
| 1400 |
|
| 1401 |
//=== Fill Tree with Rules =================================================== |
| 1402 |
procedure TfmDesigner.FillTree; //: Fill Tree with Rules |
| 1403 |
begin |
| 1404 |
TreeAddRange(nil, SynUniSyn.MainRules); |
| 1405 |
end; |
| 1406 |
|
| 1407 |
procedure TfmDesigner.SetNodeData(Node: TTreeNode; Rule: TAbstractRule; Root: boolean); |
| 1408 |
begin |
| 1409 |
if Root then begin |
| 1410 |
Node.ImageIndex := 0; |
| 1411 |
Node.SelectedIndex := 0; |
| 1412 |
end |
| 1413 |
else if Rule is TSynRangeLink then begin |
| 1414 |
Node.ImageIndex := 4; |
| 1415 |
Node.SelectedIndex := 4; |
| 1416 |
end |
| 1417 |
else if Rule is TSynRange then begin |
| 1418 |
Node.ImageIndex := 1; |
| 1419 |
Node.SelectedIndex := 1; |
| 1420 |
end else |
| 1421 |
if Rule is TSynKeyList then begin |
| 1422 |
Node.ImageIndex := 2; |
| 1423 |
Node.SelectedIndex := 2; |
| 1424 |
end else |
| 1425 |
if Rule is TSynSet then begin |
| 1426 |
Node.ImageIndex := 3; |
| 1427 |
Node.SelectedIndex := 3; |
| 1428 |
end else |
| 1429 |
raise Exception.Create(ClassName + '.SetNodeData - Unknown rule to set node!'); |
| 1430 |
Node.Data := Rule; |
| 1431 |
end; |
| 1432 |
|
| 1433 |
function TfmDesigner.TreeAddRule(ParentNode: TTreeNode; Rule: TSynRule; AddKind: TAddKind): TTreeNode; |
| 1434 |
begin |
| 1435 |
// if Rule is TSynRangeLink then Result:= TreeAddRangeLink(ParentNode, TSynRangeLink(Rule), AddKind) else |
| 1436 |
if Rule is TSynRange then Result:= TreeAddRange(ParentNode, TSynRange(Rule), AddKind) else |
| 1437 |
if Rule is TSynKeyList then Result:= TreeAddKeyList(ParentNode, TSynKeyList(Rule), AddKind) else |
| 1438 |
if Rule is TSynSet then Result:= TreeAddSet(ParentNode, TSynSet(Rule), AddKind) else |
| 1439 |
raise Exception.Create(ClassName + '.TreeAddRule - Unknown rule to add!'); |
| 1440 |
end; |
| 1441 |
|
| 1442 |
function TfmDesigner.TreeAddRangeLink(Node: TTreeNode; RangeLink: TSynRangeLink; AddKind: TAddKind): TTreeNode; |
| 1443 |
begin |
| 1444 |
Result := Tree.Items.AddChild(Node, RangeLink.Range.Name); |
| 1445 |
SetNodeData(Result, RangeLink); |
| 1446 |
end; |
| 1447 |
|
| 1448 |
function TfmDesigner.TreeAddRange(Node: TTreeNode; Range: TSynRange; AddKind: TAddKind): TTreeNode; |
| 1449 |
var |
| 1450 |
i, ind: integer; |
| 1451 |
begin |
| 1452 |
if AddKind = akReplace then |
| 1453 |
Result := Node |
| 1454 |
else |
| 1455 |
if Node = nil then begin |
| 1456 |
Result := Tree.Items.Add(nil, Range.Name); |
| 1457 |
SetNodeData(Result, Range, True); |
| 1458 |
end |
| 1459 |
else begin |
| 1460 |
if AddKind = akInsert then begin |
| 1461 |
ind := Node.Index; |
| 1462 |
{$IFNDEF FPC} |
| 1463 |
Result := Tree.Items.Insert(Node.Parent.Item[ind], Range.Name) |
| 1464 |
{$ELSE} |
| 1465 |
Result := Tree.Items.Insert(Node.Parent.Items[ind], Range.Name) |
| 1466 |
{$ENDIF} |
| 1467 |
end else |
| 1468 |
Result := Tree.Items.AddChild(Node, Range.Name); |
| 1469 |
SetNodeData(Result, Range); |
| 1470 |
end; |
| 1471 |
|
| 1472 |
for i := 0 to Range.KeyListCount-1 do TreeAddKeyList(Result, Range.KeyLists[i]); |
| 1473 |
for i := 0 to Range.SetCount-1 do TreeAddSet(Result, Range.Sets[i]); |
| 1474 |
for i := 0 to Range.RangeCount-1 do TreeAddRange(Result, Range.Ranges[i]); |
| 1475 |
end; |
| 1476 |
|
| 1477 |
function TfmDesigner.TreeAddKeyList(Node: TTreeNode; Keyword: TSynKeyList; AddKind: TAddKind): TTreeNode; |
| 1478 |
var |
| 1479 |
i, ind: integer; |
| 1480 |
NeedToInsert: boolean; |
| 1481 |
begin |
| 1482 |
if AddKind = akReplace then |
| 1483 |
Result := Node |
| 1484 |
else |
| 1485 |
if AddKind = akInsert then begin |
| 1486 |
ind := Node.Index; |
| 1487 |
{$IFNDEF FPC} |
| 1488 |
Result := Tree.Items.Insert(Node.Parent.Item[ind], Keyword.Name) |
| 1489 |
{$ELSE} |
| 1490 |
Result := Tree.Items.Insert(Node.Parent.Items[ind], Keyword.Name) |
| 1491 |
{$ENDIF} |
| 1492 |
end else |
| 1493 |
if Node.Count = 0 then |
| 1494 |
Result := Tree.Items.AddChild(Node, Keyword.Name) |
| 1495 |
else begin |
| 1496 |
NeedToInsert := False; |
| 1497 |
for i := 0 to Node.Count-1 do |
| 1498 |
{$IFNDEF FPC} |
| 1499 |
if (TObject(Node.Item[i].Data) is TSynRange) or (TObject(Node.Item[i].Data) is TSynSet) then begin |
| 1500 |
{$ELSE} |
| 1501 |
if (TObject(Node.Items[i].Data) is TSynRange) or (TObject(Node.Items[i].Data) is TSynSet) then begin |
| 1502 |
{$ENDIF} |
| 1503 |
NeedToInsert := True; break; end; |
| 1504 |
{$IFNDEF FPC} |
| 1505 |
if NeedToInsert then Result := Tree.Items.Insert(Node.Item[i], Keyword.Name) |
| 1506 |
{$ELSE} |
| 1507 |
if NeedToInsert then Result := Tree.Items.Insert(Node.Items[i], Keyword.Name) |
| 1508 |
{$ENDIF} |
| 1509 |
else Result := Tree.Items.AddChild(Node, Keyword.Name); |
| 1510 |
end; |
| 1511 |
|
| 1512 |
SetNodeData(Result, Keyword); |
| 1513 |
end; |
| 1514 |
|
| 1515 |
function TfmDesigner.TreeAddSet(Node: TTreeNode; SymbSet: TSynSet; AddKind: TAddKind): TTreeNode; |
| 1516 |
var |
| 1517 |
i, ind: integer; |
| 1518 |
NeedToInsert: boolean; |
| 1519 |
begin |
| 1520 |
if AddKind = akReplace then |
| 1521 |
Result := Node |
| 1522 |
else |
| 1523 |
if AddKind = akInsert then begin |
| 1524 |
ind := Node.Index; |
| 1525 |
{$IFNDEF FPC} |
| 1526 |
Result := Tree.Items.Insert(Node.Parent.Item[ind], SymbSet.Name) |
| 1527 |
{$ELSE} |
| 1528 |
Result := Tree.Items.Insert(Node.Parent.Items[ind], SymbSet.Name) |
| 1529 |
{$ENDIF} |
| 1530 |
end else |
| 1531 |
if Node.Count = 0 then |
| 1532 |
Result := Tree.Items.AddChild(Node, SymbSet.Name) |
| 1533 |
else begin |
| 1534 |
NeedToInsert := False; |
| 1535 |
for i := 0 to Node.Count-1 do |
| 1536 |
{$IFNDEF FPC} |
| 1537 |
if TObject(Node.Item[i].Data) is TSynRange then begin |
| 1538 |
{$ELSE} |
| 1539 |
if TObject(Node.Items[i].Data) is TSynRange then begin |
| 1540 |
{$ENDIF} |
| 1541 |
NeedToInsert := True; break; end; |
| 1542 |
{$IFNDEF FPC} |
| 1543 |
if NeedToInsert then Result := Tree.Items.Insert(Node.Item[i], SymbSet.Name) |
| 1544 |
{$ELSE} |
| 1545 |
if NeedToInsert then Result := Tree.Items.Insert(Node.Items[i], SymbSet.Name) |
| 1546 |
{$ENDIF} |
| 1547 |
else Result := Tree.Items.AddChild(Node, SymbSet.Name); |
| 1548 |
end; |
| 1549 |
|
| 1550 |
SetNodeData(Result, SymbSet); |
| 1551 |
end; |
| 1552 |
|
| 1553 |
//=== Adding RangeLink ======================================================= |
| 1554 |
procedure TfmDesigner.DoAddRangeLinkToRoot(Sender:TObject); //: Click on button |
| 1555 |
begin |
| 1556 |
AddingRangeLink(Tree.Items[0]); |
| 1557 |
Modified(); |
| 1558 |
end; |
| 1559 |
|
| 1560 |
procedure TfmDesigner.DoAddRangeLink(Sender: TObject); //: Click on button |
| 1561 |
begin |
| 1562 |
AddingRangeLink(Tree.Selected); |
| 1563 |
Modified(); |
| 1564 |
end; |
| 1565 |
|
| 1566 |
procedure TfmDesigner.AddingRangeLink(ParentNode: TTreeNode); |
| 1567 |
var Node: TTreeNode; |
| 1568 |
RangeLink: TSynRangeLink; |
| 1569 |
// i: integer; |
| 1570 |
begin |
| 1571 |
RangeLink := TSynRangeLink.Create(SynUniSyn.MainRules.Ranges[6]); |
| 1572 |
TSynRange(ParentNode.Data).AddRangeLink(RangeLink); |
| 1573 |
Node := TreeAddRangeLink(ParentNode, RangeLink); |
| 1574 |
with Node do begin |
| 1575 |
Expand(False); |
| 1576 |
Selected := True; |
| 1577 |
Tree.SetFocus; |
| 1578 |
EditText; |
| 1579 |
end; |
| 1580 |
{ Range.ClearAttributes(); |
| 1581 |
for i := 0 to SynUniSyn.SchemesList.Count-1 do begin |
| 1582 |
TSynRange(ParentNode.Data).SetAttributesIndex(i); |
| 1583 |
Range.AddAttribute(); |
| 1584 |
SetDefaultAttributes(Node); |
| 1585 |
end; |
| 1586 |
TSynRange(ParentNode.Data).SetAttributesIndex(SynUniSyn.SchemeIndex);} |
| 1587 |
SetControlAttributes(Node); |
| 1588 |
end; |
| 1589 |
|
| 1590 |
//=== Adding Range =========================================================== |
| 1591 |
procedure TfmDesigner.DoAddRangeToRoot(Sender:TObject); //: Click on button |
| 1592 |
begin |
| 1593 |
AddingRange(Tree.Items[0]); |
| 1594 |
Modified(); |
| 1595 |
end; |
| 1596 |
|
| 1597 |
procedure TfmDesigner.DoAddRange(Sender: TObject); //: Click on button |
| 1598 |
begin |
| 1599 |
AddingRange(Tree.Selected); |
| 1600 |
Modified(); |
| 1601 |
end; |
| 1602 |
|
| 1603 |
procedure TfmDesigner.AddingRange(ParentNode: TTreeNode); |
| 1604 |
var Node: TTreeNode; |
| 1605 |
Range: TSynRange; |
| 1606 |
i: integer; |
| 1607 |
begin |
| 1608 |
if ParentNode = nil then begin //Never happened ??? |
| 1609 |
Tree.Items.Clear; |
| 1610 |
Node := Tree.Items.Add(nil, _Root); |
| 1611 |
SynUniSyn.MainRules.Name := _Root; |
| 1612 |
Node.Data := SynUniSyn.MainRules; |
| 1613 |
Node.ImageIndex := 0; |
| 1614 |
Node.SelectedIndex := 0; |
| 1615 |
Exit; |
| 1616 |
end |
| 1617 |
else begin |
| 1618 |
Range := TSynRange.Create; |
| 1619 |
Range.Name := _New; |
| 1620 |
TSynRange(ParentNode.Data).AddRange(Range); |
| 1621 |
Node := TreeAddRange(ParentNode, Range); |
| 1622 |
with Node do begin |
| 1623 |
Expand(False); |
| 1624 |
Selected := True; |
| 1625 |
Tree.SetFocus; |
| 1626 |
EditText; |
| 1627 |
end; |
| 1628 |
end; |
| 1629 |
// Range.ClearAttributes(); |
| 1630 |
for i := 0 to SynUniSyn.SchemesList.Count-1 do begin |
| 1631 |
// TSynRange(ParentNode.Data).SetAttributesIndex(i); |
| 1632 |
// Range.AddAttribute(); |
| 1633 |
SetDefaultAttributes(Node); |
| 1634 |
end; |
| 1635 |
// TSynRange(ParentNode.Data).SetAttributesIndex(SynUniSyn.SchemeIndex); |
| 1636 |
SetControlAttributes(Node); |
| 1637 |
end; |
| 1638 |
|
| 1639 |
//=== Adding KeyList ========================================================= |
| 1640 |
procedure TfmDesigner.DoAddKeywordToRoot(Sender:TObject); //: Click on button |
| 1641 |
begin |
| 1642 |
AddingKeyword(Tree.Items[0]); |
| 1643 |
Modified(); |
| 1644 |
end; |
| 1645 |
|
| 1646 |
procedure TfmDesigner.DoAddKeyword(Sender: TObject); //: Click on button |
| 1647 |
begin |
| 1648 |
AddingKeyWord(Tree.selected); |
| 1649 |
Modified(); |
| 1650 |
end; |
| 1651 |
|
| 1652 |
procedure TfmDesigner.AddingKeyWord(ParentNode: TTreeNode); |
| 1653 |
var Node: TTreeNode; |
| 1654 |
Keyword: TSynKeyList; |
| 1655 |
i: integer; |
| 1656 |
begin |
| 1657 |
Keyword := TSynKeyList.Create; |
| 1658 |
Keyword.Name := _New; |
| 1659 |
Node := TreeAddKeyList(ParentNode, Keyword); |
| 1660 |
with Node do begin |
| 1661 |
Expand(False); |
| 1662 |
Selected := True; |
| 1663 |
Tree.SetFocus; |
| 1664 |
EditText; |
| 1665 |
end; |
| 1666 |
// Keyword.ClearAttributes(); |
| 1667 |
for i := 0 to SynUniSyn.SchemesList.Count-1 do begin |
| 1668 |
// TSynRange(ParentNode.Data).SetAttributesIndex(i); |
| 1669 |
// Keyword.AddAttribute(); |
| 1670 |
SetDefaultAttributes(Node); |
| 1671 |
end; |
| 1672 |
// TSynRange(ParentNode.Data).SetAttributesIndex(SynUniSyn.SchemeIndex); |
| 1673 |
TSynRange(ParentNode.Data).AddKeyList(Keyword); |
| 1674 |
SetControlAttributes(Node); |
| 1675 |
end; |
| 1676 |
|
| 1677 |
//=== Adding Set ============================================================= |
| 1678 |
procedure TfmDesigner.DoAddSetToRoot(Sender:TObject); //: Click on button |
| 1679 |
begin |
| 1680 |
AddingSet(Tree.Items[0]); |
| 1681 |
Modified(); |
| 1682 |
end; |
| 1683 |
|
| 1684 |
procedure TfmDesigner.DoAddSet(Sender: TObject); //: Click on button |
| 1685 |
begin |
| 1686 |
AddingSet(Tree.Selected); |
| 1687 |
Modified(); |
| 1688 |
end; |
| 1689 |
|
| 1690 |
procedure TfmDesigner.AddingSet(ParentNode: TTreeNode); |
| 1691 |
var |
| 1692 |
Node: TTreeNode; |
| 1693 |
SymbolSet: TSynSet; |
| 1694 |
i: integer; |
| 1695 |
begin |
| 1696 |
SymbolSet := TSynSet.Create; |
| 1697 |
SymbolSet.Name := _New; |
| 1698 |
TSynRange(ParentNode.data).AddSet(SymbolSet); |
| 1699 |
Node := TreeAddSet(ParentNode, SymbolSet); |
| 1700 |
with Node do begin |
| 1701 |
Expand(False); |
| 1702 |
Selected := True; |
| 1703 |
Tree.SetFocus; |
| 1704 |
EditText; |
| 1705 |
end; |
| 1706 |
// SymbolSet.ClearAttributes(); |
| 1707 |
for i := 0 to SynUniSyn.SchemesList.Count-1 do begin |
| 1708 |
// TSynRange(ParentNode.Data).SetAttributesIndex(i); |
| 1709 |
// SymbolSet.AddAttribute(); |
| 1710 |
SetDefaultAttributes(Node); |
| 1711 |
end; |
| 1712 |
// TSynRange(ParentNode.Data).SetAttributesIndex(SynUniSyn.SchemeIndex); |
| 1713 |
SetControlAttributes(Node); |
| 1714 |
end; |
| 1715 |
|
| 1716 |
//=== Delete and Rename Rules ================================================ |
| 1717 |
procedure TfmDesigner.DoDeleteNode(Sender: TObject); |
| 1718 |
begin |
| 1719 |
if not Tree.IsEditing then |
| 1720 |
if not ShowDialog or (Application.MessageBox(PChar(Format(_DeleteNode,[Tree.Selected.Text])), PChar(_Confirm), MB_YESNOCANCEL+MB_ICONQUESTION) = ID_YES) then begin |
| 1721 |
DeleteNode(Tree.Selected); |
| 1722 |
TotalUpdate; |
| 1723 |
Modified(); |
| 1724 |
end; |
| 1725 |
ShowDialog := True; |
| 1726 |
end; |
| 1727 |
|
| 1728 |
procedure TfmDesigner.DeleteNode(Node: TTreeNode; OnlyChilds: boolean); |
| 1729 |
begin |
| 1730 |
//Node.DeleteChildren; - когда-нить исправить! |
| 1731 |
while Node.Count > 0 do |
| 1732 |
DeleteNode(Node[0]); |
| 1733 |
if (TSynRange(Node.Data) <> SynUniSyn.MainRules) and not OnlyChilds then begin |
| 1734 |
if TObject(Node.Data) is TSynRange then |
| 1735 |
TSynRange(Node.Parent.Data).DeleteRange(TSynRange(Node.Data)) |
| 1736 |
else |
| 1737 |
if TObject(Node.Data) is TSynKeyList then |
| 1738 |
TSynRange(Node.Parent.Data).DeleteKeyList(TSynKeyList(Node.Data)) |
| 1739 |
else |
| 1740 |
if TObject(Node.Data) is TSynSet then |
| 1741 |
TSynRange(Node.Parent.Data).DeleteSet(TSynSet(Node.Data)); |
| 1742 |
Node.Delete; |
| 1743 |
end; |
| 1744 |
end; |
| 1745 |
|
| 1746 |
procedure TfmDesigner.DoRenameNode(Sender: TObject); |
| 1747 |
begin |
| 1748 |
Tree.Selected.EditText; |
| 1749 |
end; |
| 1750 |
|
| 1751 |
//=== Usefuk functions... ==================================================== |
| 1752 |
function TfmDesigner.GetNodeType(Node: TTreeNode): TNodeType; |
| 1753 |
begin |
| 1754 |
Result := ntNone; |
| 1755 |
if Node <> nil then |
| 1756 |
if (TObject(Node.Data) is TSynRange) and (Node.Level = 0) then Result := ntRoot else |
| 1757 |
if (TObject(Node.Data) is TSynRangeLink) then Result := ntRangeLink else |
| 1758 |
if (TObject(Node.Data) is TSynRange) then Result := ntRange else |
| 1759 |
if (TObject(Node.Data) is TSynKeyList) then Result := ntKeywords else |
| 1760 |
if (TObject(Node.Data) is TSynSet) then Result := ntSet; |
| 1761 |
end; |
| 1762 |
|
| 1763 |
procedure TfmDesigner.TotalUpdate; |
| 1764 |
begin |
| 1765 |
SynUniSyn.Reset; |
| 1766 |
SynUniSyn.MainRules.Reset; |
| 1767 |
SynUniSyn.ResetRange; |
| 1768 |
SynUniSyn.Prepare; |
| 1769 |
SampleMemo.Highlighter := nil; |
| 1770 |
SampleMemo.Highlighter := SynUniSyn; |
| 1771 |
SampleMemo.Refresh; |
| 1772 |
end; |
| 1773 |
|
| 1774 |
procedure TfmDesigner.Modified(State: boolean = True); |
| 1775 |
begin |
| 1776 |
if State then begin |
| 1777 |
btApply.Enabled := True; |
| 1778 |
StatusBar.Panels.Items[0].Text := _Modified; |
| 1779 |
end else begin |
| 1780 |
btApply.Enabled := False; |
| 1781 |
StatusBar.Panels.Items[0].Text := ''; |
| 1782 |
end; |
| 1783 |
end; |
| 1784 |
|
| 1785 |
//=== KeyList Tools ========================================================== |
| 1786 |
procedure TfmDesigner.btSort_oldClick(Sender: TObject); |
| 1787 |
var i: integer; |
| 1788 |
begin |
| 1789 |
With TStringList.Create do |
| 1790 |
try |
| 1791 |
Sorted := True; |
| 1792 |
Duplicates := dupIgnore; |
| 1793 |
for i := 0 to Memo.Lines.Count-1 do |
| 1794 |
if Trim(Memo.Lines[i]) <> '' then |
| 1795 |
Add(Trim(Memo.Lines[i])); |
| 1796 |
Sort; |
| 1797 |
Memo.Text := Trim(Text); |
| 1798 |
finally |
| 1799 |
Free; |
| 1800 |
end; |
| 1801 |
end; |
| 1802 |
|
| 1803 |
procedure TfmDesigner.btLowerCase_oldClick(Sender: TObject); |
| 1804 |
begin |
| 1805 |
Memo.text := LowerCase(Memo.Text); |
| 1806 |
end; |
| 1807 |
|
| 1808 |
procedure TfmDesigner.btSpacesToEol_oldClick(Sender: TObject); |
| 1809 |
begin |
| 1810 |
Memo.text := StringReplace(Memo.Text, ' ', #13#10, [rfReplaceAll]); |
| 1811 |
end; |
| 1812 |
|
| 1813 |
//=== Finish buttons ========================================================= |
| 1814 |
procedure TfmDesigner.btOkClick(Sender: TObject); |
| 1815 |
begin |
| 1816 |
if Tree.IsEditing then |
| 1817 |
Tree.Selected.EndEdit(False) |
| 1818 |
else |
| 1819 |
if btApply.Enabled then begin |
| 1820 |
btApplyClick(Sender); |
| 1821 |
ModalResult := mrOk; |
| 1822 |
end else |
| 1823 |
if (btApply.Tag = 1) then |
| 1824 |
ModalResult := mrOk |
| 1825 |
else |
| 1826 |
ModalResult := mrCancel; |
| 1827 |
ForceClose := True; |
| 1828 |
end; |
| 1829 |
|
| 1830 |
procedure TfmDesigner.btCancelClick(Sender: TObject); |
| 1831 |
begin |
| 1832 |
ModalResult := mrCancel; |
| 1833 |
ForceClose := True; |
| 1834 |
end; |
| 1835 |
|
| 1836 |
procedure TfmDesigner.btApplyClick(Sender: TObject); |
| 1837 |
var |
| 1838 |
Stream: TMemoryStream; |
| 1839 |
begin |
| 1840 |
Stream := TMemoryStream.Create; |
| 1841 |
SynUniSyn.SaveToStream(Stream); |
| 1842 |
Stream.Position := 0; |
| 1843 |
OriginalSyn.LoadFromStream(Stream); |
| 1844 |
OriginalSyn.Info.Sample.Text := SampleMemo.Text; |
| 1845 |
Modified(False); |
| 1846 |
btApply.Tag := 1; |
| 1847 |
end; |
| 1848 |
|
| 1849 |
//=== Work with schemes ====================================================== |
| 1850 |
{procedure TfmDesigner.btNewSchemeClick(Sender: TObject); |
| 1851 |
var |
| 1852 |
Name: string; |
| 1853 |
begin |
| 1854 |
if InputQuery(_EnterName, _EnterName, Name) then begin |
| 1855 |
SynUniSyn.AddNewScheme(Name); |
| 1856 |
SynUniSyn.MainRules.Attribs.ParentForeground := False; |
| 1857 |
SynUniSyn.MainRules.Attribs.ParentBackground := False; |
| 1858 |
cbScheme.ItemIndex := cbScheme.Items.Add(Name); |
| 1859 |
SetControlAttributes(Tree.Selected); |
| 1860 |
TotalUpdate; |
| 1861 |
Modified(); |
| 1862 |
end; |
| 1863 |
end; |
| 1864 |
|
| 1865 |
procedure TfmDesigner.btDelSchemeClick(Sender: TObject); |
| 1866 |
var |
| 1867 |
Index: integer; |
| 1868 |
begin |
| 1869 |
if cbScheme.Items.Count > 1 then |
| 1870 |
if Application.MessageBox(PChar(_DeleteScheme),PChar(_Confirm),MB_YESNOCANCEL+MB_ICONQUESTION) = ID_YES then begin |
| 1871 |
Index := cbScheme.ItemIndex; |
| 1872 |
cbScheme.Items.Delete(Index); |
| 1873 |
SynUniSyn.DeleteScheme(Index); |
| 1874 |
if cbScheme.Items.Count = Index then |
| 1875 |
cbScheme.ItemIndex := Index-1 |
| 1876 |
else |
| 1877 |
cbScheme.ItemIndex := Index; |
| 1878 |
SetControlAttributes(Tree.Selected); |
| 1879 |
TotalUpdate; |
| 1880 |
Modified(); |
| 1881 |
end; |
| 1882 |
end; |
| 1883 |
|
| 1884 |
procedure TfmDesigner.cbSchemeSelect(Sender: TObject); |
| 1885 |
begin |
| 1886 |
SynUniSyn.SetSchemeIndex(cbScheme.ItemIndex); |
| 1887 |
SetControlAttributes(Tree.Selected); |
| 1888 |
TotalUpdate; |
| 1889 |
Modified(); |
| 1890 |
end; |
| 1891 |
|
| 1892 |
procedure TfmDesigner.cbSchemeChange(Sender: TObject); |
| 1893 |
var |
| 1894 |
SelStart, SelLength: integer; |
| 1895 |
begin |
| 1896 |
if cbScheme.ItemIndex > -1 then |
| 1897 |
cbScheme.Tag := cbScheme.ItemIndex; |
| 1898 |
SelStart := cbScheme.SelStart; |
| 1899 |
SelLength := cbScheme.SelLength; |
| 1900 |
cbScheme.Items[cbScheme.Tag] := cbScheme.Text; |
| 1901 |
cbScheme.ItemIndex := cbScheme.Tag; |
| 1902 |
SynUniSyn.SchemesList.Strings[cbScheme.Tag] := cbScheme.Text; |
| 1903 |
cbScheme.SelStart := SelStart; |
| 1904 |
cbScheme.SelLength := SelLength; |
| 1905 |
Modified(); |
| 1906 |
end;} |
| 1907 |
|
| 1908 |
//=== Rules changed ========================================================== |
| 1909 |
procedure TfmDesigner.RootChange(Sender: TObject); |
| 1910 |
var |
| 1911 |
i: integer; |
| 1912 |
begin |
| 1913 |
if UpdatingControls then Exit; |
| 1914 |
with SynUniSyn do begin |
| 1915 |
SchemeFileName := edStylesFile.Text; |
| 1916 |
if Styles <> nil then begin |
| 1917 |
Styles.Free; |
| 1918 |
Styles := nil; |
| 1919 |
end; |
| 1920 |
if FileExists(SchemeFileName) then begin |
| 1921 |
Styles := TSynUniStyles.Create; |
| 1922 |
Styles.FileName := SchemeFileName; |
| 1923 |
Styles.Load; |
| 1924 |
end; |
| 1925 |
end; |
| 1926 |
with TSynRange(Tree.Selected.Data) do begin |
| 1927 |
if GetNodeType(Tree.Selected) in [ntRoot] then begin |
| 1928 |
CaseSensitive := chCaseRoot.Checked; |
| 1929 |
Enabled := chEnabledRoot.Checked; |
| 1930 |
end; |
| 1931 |
TermSymbols := []; |
| 1932 |
{ the apparently useless typecast to char is for CLX compatibility } |
| 1933 |
for i := 1 to length(edDelimitersRoot.Text) do |
| 1934 |
TermSymbols := TermSymbols + [char(edDelimitersRoot.Text[i])]; |
| 1935 |
TotalUpdate; |
| 1936 |
end; |
| 1937 |
Modified(); |
| 1938 |
end; |
| 1939 |
|
| 1940 |
procedure TfmDesigner.RangeChange(Sender: TObject); |
| 1941 |
var |
| 1942 |
i: integer; |
| 1943 |
null: string; |
| 1944 |
Range: TSynRange; |
| 1945 |
begin |
| 1946 |
if UpdatingControls then Exit; |
| 1947 |
if GetNodeType(Tree.Selected) in [ntRange, ntRangeLink] then begin |
| 1948 |
if TObject(Tree.Selected.Data) is TSynRange then |
| 1949 |
Range := TSynRange(Tree.Selected.Data) |
| 1950 |
else if TObject(Tree.Selected.Data) is TSynRangeLink then |
| 1951 |
Range := TSynRangeLink(Tree.Selected.Data).Range |
| 1952 |
else |
| 1953 |
Exit; |
| 1954 |
with Range do begin |
| 1955 |
if chFromEOL.Checked then null := #0 else null := ''; |
| 1956 |
fRule.fOpenSymbol.Symbol := edFrom.Text + null; |
| 1957 |
if chToEOL.Checked then null := #0 else null := ''; |
| 1958 |
fRule.fCloseSymbol.Symbol := edTo.Text + null; |
| 1959 |
Enabled := chEnabledRange.Checked; |
| 1960 |
fRule.fCloseOnTerm := chCloseOnWord.Checked; |
| 1961 |
fRule.fCloseOnEol := chCloseOnEOL.Checked; |
| 1962 |
fRule.fAllowPredClose := chCloseParent.Checked; |
| 1963 |
CaseSensitive := chCaseRange.Checked; |
| 1964 |
TermSymbols := StrToSet(edDelimitersRange.Text); |
| 1965 |
{ the apparently useless typecast to char is for CLX compatibility } |
| 1966 |
for i := 1 to Length(edDelimitersRange.Text) do |
| 1967 |
TermSymbols := TermSymbols + [Char(edDelimitersRange.Text[i])]; |
| 1968 |
|
| 1969 |
if popOpenTagMenu.Items.Items[2].Checked then |
| 1970 |
fRule.fOpenSymbol.StartLine := slFirst |
| 1971 |
else |
| 1972 |
if popOpenTagMenu.Items.Items[3].Checked then |
| 1973 |
fRule.fOpenSymbol.StartLine := slFirstNonSpace |
| 1974 |
else |
| 1975 |
fRule.fOpenSymbol.StartLine := slNotFirst; |
| 1976 |
|
| 1977 |
if popCloseTagMenu.Items.Items[2].Checked then |
| 1978 |
fRule.fCloseSymbol.StartLine := slFirst |
| 1979 |
else |
| 1980 |
if popCloseTagMenu.Items.Items[3].Checked then |
| 1981 |
fRule.fCloseSymbol.StartLine := slFirstNonSpace |
| 1982 |
else |
| 1983 |
fRule.fCloseSymbol.StartLine := slNotFirst; |
| 1984 |
|
| 1985 |
if popOpenTagMenu.Items.Items[5].Checked then begin |
| 1986 |
fRule.fOpenSymbol.StartType := stAny; |
| 1987 |
fRule.fOpenSymbol.BrakeType := btAny; |
| 1988 |
end else |
| 1989 |
if popOpenTagMenu.Items.Items[6].Checked then begin |
| 1990 |
fRule.fOpenSymbol.StartType := stTerm; |
| 1991 |
fRule.fOpenSymbol.BrakeType := btAny; |
| 1992 |
end else |
| 1993 |
if popOpenTagMenu.Items.Items[7].Checked then begin |
| 1994 |
fRule.fOpenSymbol.StartType := stAny; |
| 1995 |
fRule.fOpenSymbol.BrakeType := btTerm; |
| 1996 |
end else |
| 1997 |
if popOpenTagMenu.Items.Items[8].Checked then begin |
| 1998 |
fRule.fOpenSymbol.StartType := stTerm; |
| 1999 |
fRule.fOpenSymbol.BrakeType := btTerm; |
| 2000 |
end; |
| 2001 |
|
| 2002 |
if popCloseTagMenu.Items.Items[5].Checked then begin |
| 2003 |
fRule.fCloseSymbol.StartType := stAny; |
| 2004 |
fRule.fCloseSymbol.BrakeType := btAny; |
| 2005 |
end else |
| 2006 |
if popCloseTagMenu.Items.Items[6].Checked then begin |
| 2007 |
fRule.fCloseSymbol.StartType := stTerm; |
| 2008 |
fRule.fCloseSymbol.BrakeType := btAny; |
| 2009 |
end else |
| 2010 |
if popCloseTagMenu.Items.Items[7].Checked then begin |
| 2011 |
fRule.fCloseSymbol.StartType := stAny; |
| 2012 |
fRule.fCloseSymbol.BrakeType := btTerm; |
| 2013 |
end else |
| 2014 |
if popCloseTagMenu.Items.Items[8].Checked then begin |
| 2015 |
fRule.fCloseSymbol.StartType := stTerm; |
| 2016 |
fRule.fCloseSymbol.BrakeType := btTerm; |
| 2017 |
end; |
| 2018 |
end; |
| 2019 |
end; |
| 2020 |
TotalUpdate; |
| 2021 |
Modified(); |
| 2022 |
end; |
| 2023 |
|
| 2024 |
procedure TfmDesigner.KeywordsChange(Sender: TObject); |
| 2025 |
begin |
| 2026 |
lbKeywordCount.Caption := Format(_Lines, [Memo.Lines.Count]); |
| 2027 |
if UpdatingControls then Exit; |
| 2028 |
TSynKeyList(Tree.Selected.Data).Enabled := chEnabledKeyList.Checked; |
| 2029 |
TSynKeyList(Tree.Selected.Data).KeyList.Text := Memo.Lines.Text; |
| 2030 |
TotalUpdate; |
| 2031 |
Modified(); |
| 2032 |
end; |
| 2033 |
|
| 2034 |
procedure TfmDesigner.SetChange(Sender: TObject); |
| 2035 |
begin |
| 2036 |
if UpdatingControls then Exit; |
| 2037 |
TSynSet(Tree.Selected.Data).Enabled := chEnabledSet.Checked; |
| 2038 |
TSynSet(Tree.Selected.Data).SymbSet := StrToSet(edSymbSet.Text); |
| 2039 |
TotalUpdate; |
| 2040 |
Modified(); |
| 2041 |
end; |
| 2042 |
|
| 2043 |
//=== Wotk with Attributes =================================================== |
| 2044 |
procedure TfmDesigner.AttributesChanged(Sender: TObject); |
| 2045 |
begin |
| 2046 |
SetAttributes(Tree.Selected); |
| 2047 |
end; |
| 2048 |
|
| 2049 |
procedure TfmDesigner.SetDefaultAttributes(Node: TTreeNode); |
| 2050 |
begin |
| 2051 |
if TObject(Node.Data) is TSynRule then |
| 2052 |
with TSynRule(Node.Data).Attribs do begin |
| 2053 |
ParentForeground := True; |
| 2054 |
ParentBackground := True; |
| 2055 |
Foreground := TSynRange(Node.Parent.Data).Attribs.Foreground; |
| 2056 |
Background := TSynRange(Node.Parent.Data).Attribs.Background; |
| 2057 |
OldColorForeground := Foreground; |
| 2058 |
OldColorBackground := Background; |
| 2059 |
Style := []; |
| 2060 |
end |
| 2061 |
end; |
| 2062 |
|
| 2063 |
procedure TfmDesigner.SetControlAttributes(Node: TTreeNode; |
| 2064 |
AlreadyUpdate: boolean); |
| 2065 |
var |
| 2066 |
Rule: TSynRule; |
| 2067 |
isCustom: boolean; |
| 2068 |
i: integer; |
| 2069 |
begin |
| 2070 |
UpdatingControls := True; |
| 2071 |
if GetNodeType(Node) in [ntRoot] then begin |
| 2072 |
chForeground.Enabled := False; |
| 2073 |
chBackground.Enabled := False; |
| 2074 |
end |
| 2075 |
else begin |
| 2076 |
chForeground.Enabled := True; |
| 2077 |
chBackground.Enabled := True; |
| 2078 |
end; |
| 2079 |
if TObject(Node.Data) is TSynRule then |
| 2080 |
Rule := TSynRule(Node.Data) |
| 2081 |
else if TObject(Node.Data) is TSynRangeLink then |
| 2082 |
Rule := TSynRangeLink(Node.Data).Range |
| 2083 |
else |
| 2084 |
raise Exception.Create(ClassName + '.SetControlAttributes - Wrong Node data!'); |
| 2085 |
with Rule do begin |
| 2086 |
isCustom := True; |
| 2087 |
for i := 0 to cbStyle.Items.Count-2 do |
| 2088 |
if cbStyle.Items.Strings[i] = Style then begin |
| 2089 |
cbStyle.ItemIndex := i; |
| 2090 |
isCustom := False; |
| 2091 |
continue; |
| 2092 |
end; |
| 2093 |
if isCustom then begin |
| 2094 |
cbStyle.ItemIndex := cbStyle.Items.Count-2; |
| 2095 |
//cbStyle.Text := Style; |
| 2096 |
end; |
| 2097 |
if GetNodeType(Node) in [ntRoot] then begin |
| 2098 |
Attribs.ParentForeground := False; //Need to fix this problem another way... !!! |
| 2099 |
Attribs.ParentBackground := False; |
| 2100 |
end; |
| 2101 |
chForeground.Checked := Attribs.ParentForeground; |
| 2102 |
chBackground.Checked := Attribs.ParentBackground; |
| 2103 |
if Attribs.ParentForeground then |
| 2104 |
pForeColor.Color := TSynRange(Node.Parent.Data).Attribs.Foreground |
| 2105 |
else |
| 2106 |
pForeColor.Color := Attribs.Foreground; |
| 2107 |
if Attribs.ParentBackground then |
| 2108 |
pBackColor.Color := TSynRange(Node.Parent.Data).Attribs.Background |
| 2109 |
else |
| 2110 |
pBackColor.Color := Attribs.Background; |
| 2111 |
chBold.checked := fsBold in Attribs.Style; |
| 2112 |
chItalic.checked := fsItalic in Attribs.Style; |
| 2113 |
chUnderline.checked := fsUnderline in Attribs.Style; |
| 2114 |
chStrikeOut.checked := fsStrikeOut in Attribs.Style; |
| 2115 |
end; |
| 2116 |
if not AlreadyUpdate then UpdatingControls := False; |
| 2117 |
end; |
| 2118 |
|
| 2119 |
procedure TfmDesigner.SetAttributes(Node: TTreeNode); |
| 2120 |
var |
| 2121 |
Rule: TSynRule; |
| 2122 |
begin |
| 2123 |
if UpdatingControls then Exit; |
| 2124 |
if (Node <> nil) then begin |
| 2125 |
if (TObject(Node.Data) is TSynRule) then |
| 2126 |
Rule := TSynRule(Node.Data) |
| 2127 |
else if (TObject(Node.Data) is TSynRangeLink) then |
| 2128 |
Rule := TSynRangeLink(Node.Data).Range |
| 2129 |
else |
| 2130 |
Exit; |
| 2131 |
with Rule.Attribs, Rule do begin |
| 2132 |
Style := cbStyle.Text; |
| 2133 |
if (ParentForeground and not chForeground.Checked) then begin |
| 2134 |
if pForeColor.Color = Foreground then |
| 2135 |
pForeColor.Color := OldColorForeground; |
| 2136 |
end |
| 2137 |
else if (not ParentForeground and chForeground.Checked) then begin |
| 2138 |
OldColorForeground := pForeColor.Color; |
| 2139 |
pForeColor.Color := TSynRange(Node.Parent.Data).Attribs.Foreground |
| 2140 |
end |
| 2141 |
else if chForeground.Checked then |
| 2142 |
if pForeColor.Color <> Foreground then |
| 2143 |
chForeground.Checked := False; |
| 2144 |
|
| 2145 |
if (ParentBackground and not chBackground.Checked) then begin |
| 2146 |
if pBackColor.Color = Background then |
| 2147 |
pBackColor.Color := OldColorBackground; |
| 2148 |
end |
| 2149 |
else if (not ParentBackground and chBackground.Checked) then begin |
| 2150 |
OldColorBackground := pBackColor.Color; |
| 2151 |
pBackColor.Color := TSynRange(Node.Parent.Data).Attribs.Background |
| 2152 |
end |
| 2153 |
else if chBackground.Checked then |
| 2154 |
if pBackColor.Color <> Background then |
| 2155 |
chBackground.Checked := False; |
| 2156 |
|
| 2157 |
ParentForeground := chForeground.Checked; |
| 2158 |
ParentBackground := chBackground.Checked; |
| 2159 |
Foreground := pForeColor.Color; |
| 2160 |
Background := pBackColor.Color; |
| 2161 |
Attribs.Style := GetFontStyle(chBold.checked, chItalic.checked, chUnderline.checked, chStrikeOut.checked); |
| 2162 |
|
| 2163 |
if Styles <> nil then begin |
| 2164 |
Attribs := Styles.GetStyleDef(Style, Attribs); |
| 2165 |
SetControlAttributes(Node); |
| 2166 |
end; |
| 2167 |
|
| 2168 |
if TObject(Node.data) is TSynRange then |
| 2169 |
TSynRange(Node.data).SetColorForChilds; |
| 2170 |
TotalUpdate; |
| 2171 |
end; |
| 2172 |
end; |
| 2173 |
Modified(); |
| 2174 |
end; |
| 2175 |
|
| 2176 |
//============================ D E S I G N =================================== |
| 2177 |
//=== Splitter CanResize ===================================================== |
| 2178 |
procedure TfmDesigner.SplitterBottomCanResize(Sender: TObject; |
| 2179 |
var NewSize: Integer; var Accept: Boolean); |
| 2180 |
begin |
| 2181 |
if pTop.Tag <> -1 then begin |
| 2182 |
Accept := False; |
| 2183 |
Exit; |
| 2184 |
end; |
| 2185 |
if pBottom.Height <= pBottom.Constraints.MinHeight then |
| 2186 |
lbSampMin.Enabled := False |
| 2187 |
else |
| 2188 |
lbSampMin.Enabled := True; |
| 2189 |
|
| 2190 |
if pTop.Height = 0 then lbSampMax.Enabled := False |
| 2191 |
else lbSampMax.Enabled := True; |
| 2192 |
if (0 <= NewSize) and (NewSize < 19) then |
| 2193 |
NewSize := 0 |
| 2194 |
else |
| 2195 |
if (19 <= NewSize) and (NewSize <= 19+10) then |
| 2196 |
NewSize := 19 |
| 2197 |
else |
| 2198 |
if (_pTopHeight-10 <= NewSize) and (NewSize <= _pTopHeight+10) then |
| 2199 |
NewSize := _pTopHeight |
| 2200 |
end; |
| 2201 |
|
| 2202 |
procedure TfmDesigner.SplitterCannotResize(Sender: TObject; |
| 2203 |
var NewSize: Integer; var Accept: Boolean); |
| 2204 |
begin |
| 2205 |
Accept := False; |
| 2206 |
end; |
| 2207 |
|
| 2208 |
//=== Label Mouse Leave/Enter ================================================ |
| 2209 |
procedure TfmDesigner.LabelMouseLeave(Sender: TObject); |
| 2210 |
begin |
| 2211 |
(Sender as TLabel).Font.Color := clBtnFace; |
| 2212 |
end; |
| 2213 |
|
| 2214 |
procedure TfmDesigner.LabelMouseEnter(Sender: TObject); |
| 2215 |
begin |
| 2216 |
(Sender as TLabel).Font.Color := clRed; |
| 2217 |
end; |
| 2218 |
|
| 2219 |
procedure TfmDesigner.LabelContextPopup(Sender: TObject; |
| 2220 |
MousePos: TPoint; var Handled: Boolean); |
| 2221 |
begin |
| 2222 |
LabelMouseLeave(Sender); |
| 2223 |
end; |
| 2224 |
|
| 2225 |
//=== CheckBox =============================================================== |
| 2226 |
procedure TfmDesigner.CheckBoxMouseDown(Sender: TObject; |
| 2227 |
Button: TMouseButton; Shift: TShiftState; X, Y: Integer); |
| 2228 |
begin |
| 2229 |
if Button = mbRight then |
| 2230 |
with (Sender as TCheckBox) do |
| 2231 |
Checked := not Checked; |
| 2232 |
end; |
| 2233 |
|
| 2234 |
procedure TfmDesigner.DontNeedContextPopup(Sender: TObject; |
| 2235 |
MousePos: TPoint; var Handled: Boolean); |
| 2236 |
begin |
| 2237 |
Handled := True; |
| 2238 |
end; |
| 2239 |
|
| 2240 |
//=== Show/Hide panels ======================================================= |
| 2241 |
procedure TfmDesigner.ShowHideTree(Sender: TObject); |
| 2242 |
begin |
| 2243 |
if pLeft.Visible then begin |
| 2244 |
pLeft.Hide; |
| 2245 |
SplitterLeft.Hide; |
| 2246 |
end |
| 2247 |
else begin |
| 2248 |
SplitterLeft.Show; |
| 2249 |
pLeft.Show; |
| 2250 |
end; |
| 2251 |
end; |
| 2252 |
|
| 2253 |
procedure TfmDesigner.ShowHideProp(Sender: TObject); |
| 2254 |
begin |
| 2255 |
if pMiddle.Visible then begin |
| 2256 |
pMiddle.Hide; |
| 2257 |
SplitterLeft.Hide; |
| 2258 |
pLeft.Tag := pLeft.Width; |
| 2259 |
pLeft.Align := alClient; |
| 2260 |
end |
| 2261 |
else begin |
| 2262 |
pLeft.Align := alLeft; |
| 2263 |
pLeft.Width := pLeft.Tag; |
| 2264 |
SplitterLeft.Show; |
| 2265 |
pMiddle.Show; |
| 2266 |
end; |
| 2267 |
end; |
| 2268 |
|
| 2269 |
procedure TfmDesigner.ShowHideAttr(Sender: TObject); |
| 2270 |
begin |
| 2271 |
if pRight.Visible then begin |
| 2272 |
pRight.Hide; |
| 2273 |
SplitterRight.Hide; |
| 2274 |
end |
| 2275 |
else begin |
| 2276 |
pRight.Show; |
| 2277 |
SplitterRight.Show; |
| 2278 |
end; |
| 2279 |
end; |
| 2280 |
|
| 2281 |
procedure TfmDesigner.ShowHideSamp(Sender: TObject); |
| 2282 |
begin |
| 2283 |
if pBottom.Visible then begin |
| 2284 |
pBottom.Hide; |
| 2285 |
SplitterBottom.Hide; |
| 2286 |
pTop.Tag := pTop.Height; |
| 2287 |
pTop.Align := alClient; |
| 2288 |
end |
| 2289 |
else begin |
| 2290 |
pTop.Align := alTop; |
| 2291 |
pTop.Height := pTop.Tag; |
| 2292 |
SplitterBottom.Show; |
| 2293 |
pBottom.Show; |
| 2294 |
end; |
| 2295 |
end; |
| 2296 |
|
| 2297 |
procedure TfmDesigner.PanelDblClick(Sender: TObject); |
| 2298 |
begin |
| 2299 |
if (Sender as TPanel).Name = 'pBottomCapt' then begin |
| 2300 |
if pTop.Height = _pTopHeight then |
| 2301 |
lbSampMaxClick(Sender) |
| 2302 |
else begin |
| 2303 |
pTop.Height := _pTopHeight; |
| 2304 |
lbSampMin.Enabled := True; |
| 2305 |
if pTop.Tag <> -1 then |
| 2306 |
lbSampMinClick(Sender); |
| 2307 |
if not pTop.Visible then |
| 2308 |
lbSampMaxClick(Sender); |
| 2309 |
end; |
| 2310 |
end; |
| 2311 |
end; |
| 2312 |
|
| 2313 |
//=== Middle panel Resize ==================================================== |
| 2314 |
procedure TfmDesigner.pMiddleResize(Sender: TObject); |
| 2315 |
begin |
| 2316 |
if tabRoot.Width <> pRootButtons.Width then begin |
| 2317 |
pRootButtons.ScaleBy(tabRoot.Width, pRootButtons.Width); |
| 2318 |
pRootButtons.Height := 24; |
| 2319 |
btAddRangeRoot.Height := 24; |
| 2320 |
btAddKeywordsRoot.Height := 24; |
| 2321 |
btAddSetRoot.Height := 24; |
| 2322 |
end; |
| 2323 |
if tabRange.Width <> pRangeButtons.Width then begin |
| 2324 |
pRangeButtons.ScaleBy(tabRange.Width, pRangeButtons.Width); |
| 2325 |
pRangeButtons.Height := 24; |
| 2326 |
btAddRange.Height := 24; |
| 2327 |
btAddKeywords.Height := 24; |
| 2328 |
btAddSet.Height := 24; |
| 2329 |
end; |
| 2330 |
end; |
| 2331 |
|
| 2332 |
//=== Push label clicks ====================================================== |
| 2333 |
procedure TfmDesigner.lbPropBackClick(Sender: TObject); |
| 2334 |
begin |
| 2335 |
if (Tree.Selected <> Tree.Items[0]) and (Tree.Selected <> nil) then |
| 2336 |
Tree.Selected.Parent.Selected := True; |
| 2337 |
end; |
| 2338 |
|
| 2339 |
procedure TfmDesigner.lbRootMenuClick(Sender: TObject); |
| 2340 |
begin |
| 2341 |
popRootMenu.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y); |
| 2342 |
LabelMouseLeave(Sender); |
| 2343 |
end; |
| 2344 |
|
| 2345 |
procedure TfmDesigner.lbRuleMenuClick(Sender: TObject); |
| 2346 |
begin |
| 2347 |
popPropMenu.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y); |
| 2348 |
LabelMouseLeave(Sender); |
| 2349 |
end; |
| 2350 |
|
| 2351 |
procedure TfmDesigner.lbSampMaxClick(Sender: TObject); |
| 2352 |
begin |
| 2353 |
if pTop.Visible then begin //: Not maximized (Maximize) |
| 2354 |
pTop.Hide; |
| 2355 |
lbSampMax.Caption := '2'; |
| 2356 |
if pTop.Tag <> -1 then //: Minimized (Restore) |
| 2357 |
lbSampMinClick(Sender); |
| 2358 |
end |
| 2359 |
else begin //: Maximized (Restore) |
| 2360 |
pTop.Show; |
| 2361 |
lbSampMax.Caption := '1'; |
| 2362 |
end; |
| 2363 |
end; |
| 2364 |
(* |
| 2365 |
procedure TfmDesigner.lbSampRestoreClick(Sender: TObject); |
| 2366 |
begin |
| 2367 |
pTop.Height := _pTopHeight; |
| 2368 |
end; |
| 2369 |
*) |
| 2370 |
procedure TfmDesigner.lbSampMinClick(Sender: TObject); |
| 2371 |
begin |
| 2372 |
if pTop.Tag = -1 then begin //: Not minimized (Minimize) |
| 2373 |
pTop.Tag := pTop.Height; |
| 2374 |
pTop.Height := ClientHeight - pBottom.Constraints.MinHeight - SplitterBottom.Height - pButtons.ClientHeight - StatusBar.ClientHeight - SplitterButtons.ClientHeight; |
| 2375 |
lbSampMin.Caption := '2'; |
| 2376 |
if not pTop.Visible then //: Miximized (Restore) |
| 2377 |
lbSampMaxClick(Sender); |
| 2378 |
end |
| 2379 |
else begin //: Minimized (Restore) |
| 2380 |
pTop.Height := pTop.Tag; |
| 2381 |
PTop.Tag := -1; |
| 2382 |
lbSampMin.Caption := '0'; |
| 2383 |
end; |
| 2384 |
end; |
| 2385 |
|
| 2386 |
//============================ P O P U P S =================================== |
| 2387 |
//=== Standard PopupMenu ===================================================== |
| 2388 |
procedure TfmDesigner.SetPopupMenuEnables(Edit: TCustomEdit; popMenu: TPopupMenu); |
| 2389 |
begin |
| 2390 |
with popMenu, Edit do begin |
| 2391 |
Items[0].Enabled := CanUndo; |
| 2392 |
Items[2].Enabled := SelLength <> 0; |
| 2393 |
Items[3].Enabled := SelLength <> 0; |
| 2394 |
Items[4].Enabled := Clipboard.AsText <> ''; |
| 2395 |
Items[5].Enabled := Length(Edit.Text) <> 0;//SelLength <> 0; |
| 2396 |
Items[7].Enabled := Text <> SelText; |
| 2397 |
end; |
| 2398 |
end; |
| 2399 |
|
| 2400 |
procedure TfmDesigner.EditKeyDown(Sender: TObject; var Key: Word; |
| 2401 |
Shift: TShiftState); |
| 2402 |
begin |
| 2403 |
SetPopupMenuEnables((Sender as TCustomEdit), popStandard); |
| 2404 |
end; |
| 2405 |
|
| 2406 |
procedure TfmDesigner.EditContextPopup(Sender: TObject; |
| 2407 |
MousePos: TPoint; var Handled: Boolean); |
| 2408 |
begin |
| 2409 |
SetPopupMenuEnables((Sender as TCustomEdit), popStandard); |
| 2410 |
end; |
| 2411 |
|
| 2412 |
procedure TfmDesigner.popUndoClick(Sender: TObject); |
| 2413 |
begin |
| 2414 |
(ActiveControl as TCustomEdit).Undo; |
| 2415 |
SetPopupMenuEnables((ActiveControl as TCustomEdit), popStandard); |
| 2416 |
end; |
| 2417 |
|
| 2418 |
procedure TfmDesigner.popCutClick(Sender: TObject); |
| 2419 |
begin |
| 2420 |
(ActiveControl as TCustomEdit).CutToClipboard; |
| 2421 |
SetPopupMenuEnables((ActiveControl as TCustomEdit), popStandard); |
| 2422 |
end; |
| 2423 |
|
| 2424 |
procedure TfmDesigner.popCopyClick(Sender: TObject); |
| 2425 |
begin |
| 2426 |
(ActiveControl as TCustomEdit).CopyToClipboard; |
| 2427 |
SetPopupMenuEnables((ActiveControl as TCustomEdit), popStandard); |
| 2428 |
end; |
| 2429 |
|
| 2430 |
procedure TfmDesigner.popPasteClick(Sender: TObject); |
| 2431 |
begin |
| 2432 |
(ActiveControl as TCustomEdit).PasteFromClipboard; |
| 2433 |
SetPopupMenuEnables((ActiveControl as TCustomEdit), popStandard); |
| 2434 |
end; |
| 2435 |
|
| 2436 |
procedure TfmDesigner.popDeleteClick(Sender: TObject); |
| 2437 |
begin |
| 2438 |
if (ActiveControl as TCustomEdit).SelLength = 0 then |
| 2439 |
(ActiveControl as TCustomEdit).SelLength := 1; |
| 2440 |
(ActiveControl as TCustomEdit).ClearSelection; |
| 2441 |
SetPopupMenuEnables((ActiveControl as TCustomEdit), popStandard); |
| 2442 |
end; |
| 2443 |
|
| 2444 |
procedure TfmDesigner.popSelectAllClick(Sender: TObject); |
| 2445 |
begin |
| 2446 |
(ActiveControl as TCustomEdit).SelectAll; |
| 2447 |
SetPopupMenuEnables((ActiveControl as TCustomEdit), popStandard); |
| 2448 |
end; |
| 2449 |
|
| 2450 |
//=== Sample Memo PopupMenu ================================================== |
| 2451 |
procedure TfmDesigner.SetPopupMenuEnables2(Edit: TCustomSynEdit; popMenu: TPopupMenu); |
| 2452 |
begin |
| 2453 |
with popMenu, Edit do begin |
| 2454 |
Items[0].Enabled := (Edit.SelEnd - Edit.SelStart) <> 0; |
| 2455 |
Items[2].Enabled := CanUndo; |
| 2456 |
Items[4].Enabled := (Edit.SelEnd - Edit.SelStart) <> 0; |
| 2457 |
Items[5].Enabled := (Edit.SelEnd - Edit.SelStart) <> 0; |
| 2458 |
Items[6].Enabled := Clipboard.AsText <> ''; |
| 2459 |
Items[7].Enabled := (Edit.SelEnd - Edit.SelStart) <> 0; |
| 2460 |
Items[8].Enabled := Text <> SelText; |
| 2461 |
end; |
| 2462 |
end; |
| 2463 |
|
| 2464 |
procedure TfmDesigner.SampleMemoKeyDown(Sender: TObject; var Key: Word; |
| 2465 |
Shift: TShiftState); |
| 2466 |
begin |
| 2467 |
SetPopupMenuEnables2(SampleMemo, popSampleMemoMenu); |
| 2468 |
end; |
| 2469 |
|
| 2470 |
procedure TfmDesigner.SampleMemoMouseDown(Sender: TObject; |
| 2471 |
Button: TMouseButton; Shift: TShiftState; X, Y: Integer); |
| 2472 |
begin |
| 2473 |
SetPopupMenuEnables2(SampleMemo, popSampleMemoMenu); |
| 2474 |
end; |
| 2475 |
|
| 2476 |
procedure TfmDesigner.Undo1Click(Sender: TObject); |
| 2477 |
begin |
| 2478 |
SampleMemo.Undo; |
| 2479 |
end; |
| 2480 |
|
| 2481 |
procedure TfmDesigner.Cut1Click(Sender: TObject); |
| 2482 |
begin |
| 2483 |
SampleMemo.CutToClipboard; |
| 2484 |
end; |
| 2485 |
|
| 2486 |
procedure TfmDesigner.Copy1Click(Sender: TObject); |
| 2487 |
begin |
| 2488 |
SampleMemo.CopyToClipboard; |
| 2489 |
end; |
| 2490 |
|
| 2491 |
procedure TfmDesigner.Paste1Click(Sender: TObject); |
| 2492 |
begin |
| 2493 |
SampleMemo.PasteFromClipboard; |
| 2494 |
end; |
| 2495 |
|
| 2496 |
procedure TfmDesigner.Delete1Click(Sender: TObject); |
| 2497 |
begin |
| 2498 |
SampleMemo.ClearSelection; |
| 2499 |
end; |
| 2500 |
|
| 2501 |
procedure TfmDesigner.SelectAll1Click(Sender: TObject); |
| 2502 |
begin |
| 2503 |
SampleMemo.SelectAll; |
| 2504 |
end; |
| 2505 |
|
| 2506 |
procedure TfmDesigner.AddselectedtoKeywords1Click(Sender: TObject); |
| 2507 |
begin |
| 2508 |
if PageControl.ActivePage = tabKeyWords then begin |
| 2509 |
Memo.Lines.Add(SampleMemo.SelText); |
| 2510 |
TotalUpdate; |
| 2511 |
end; |
| 2512 |
end; |
| 2513 |
|
| 2514 |
procedure TfmDesigner.popSampleMemoMenuPopup(Sender: TObject); |
| 2515 |
begin |
| 2516 |
popSampleMemoMenu.Items[0].Visible := PageControl.ActivePage = tabKeyWords; |
| 2517 |
popSampleMemoMenu.Items[1].Visible := PageControl.ActivePage = tabKeyWords; |
| 2518 |
end; |
| 2519 |
|
| 2520 |
//=== Tag Menu Clicks... ===================================================== |
| 2521 |
procedure TfmDesigner.btTagMenuClick(Sender: TObject); |
| 2522 |
var P: TPoint; |
| 2523 |
begin |
| 2524 |
// popTagMenu.Tag := Mouse.CursorPos.X + Mouse.CursorPos.Y shl 16; |
| 2525 |
P := (Sender as TButton).ClientToScreen(Point(0, 0)); |
| 2526 |
if (Sender as TButton).Name = 'btFromMenu' then |
| 2527 |
popOpenTagMenu.Popup(P.x, P.y) |
| 2528 |
else if (Sender as TButton).Name = 'btToMenu' then |
| 2529 |
popCloseTagMenu.Popup(P.x, P.y) |
| 2530 |
// popTagMenu.Popup(popTagMenu.Tag and $FFFF, |
| 2531 |
// popTagMenu.Tag shr 16); |
| 2532 |
end; |
| 2533 |
|
| 2534 |
procedure TfmDesigner.miTagMenuClick(Sender: TObject); |
| 2535 |
begin |
| 2536 |
if not (Sender as TMenuItem).Checked then |
| 2537 |
(Sender as TMenuItem).Checked := True; |
| 2538 |
RangeChange(Sender); |
| 2539 |
end; |
| 2540 |
|
| 2541 |
procedure TfmDesigner.miOpenTagMenuClick(Sender: TObject); |
| 2542 |
var i: integer; |
| 2543 |
begin |
| 2544 |
i := popOpenTagMenu.Items.IndexOf(Sender as TMenuItem); |
| 2545 |
if popOpenTagMenu.Items.Items[5-i].Checked then |
| 2546 |
popOpenTagMenu.Items.Items[5-i].Checked := False; |
| 2547 |
RangeChange(Sender); |
| 2548 |
end; |
| 2549 |
|
| 2550 |
procedure TfmDesigner.miCloseTagMenuClick(Sender: TObject); |
| 2551 |
var i: integer; |
| 2552 |
begin |
| 2553 |
i := popCloseTagMenu.Items.IndexOf(Sender as TMenuItem); |
| 2554 |
if popCloseTagMenu.Items.Items[5-i].Checked then |
| 2555 |
popCloseTagMenu.Items.Items[5-i].Checked := False; |
| 2556 |
RangeChange(Sender); |
| 2557 |
end; |
| 2558 |
|
| 2559 |
//=== ColorBox Clicks... ===================================================== |
| 2560 |
procedure TfmDesigner.PanelColorChange(Sender: TObject); |
| 2561 |
//: Handle clicking on Color panel (Show ColorBox to choose color) |
| 2562 |
begin |
| 2563 |
with TColorDialog.Create(nil) do |
| 2564 |
try |
| 2565 |
CustomColors.Text := 'ColorA='+inttohex((Sender as TPanel).Color,6)+#13#10+'ColorB=FFFFEE'+#13#10+'ColorC=EEFFFF'+#13#10+'ColorD=EEFFEE'+#13#10+'ColorE=EEEEFF'+#13#10+'ColorF=FFEEEE'+#13#10+'ColorG=EEEEEE'+#13#10+'ColorH=FFEEAA'+#13#10+'ColorJ=FFAAEE'+#13#10+'ColorK=AAFFEE'+#13#10+'ColorI=AAEEFF'+#13#10+'ColorL=EEFFAA'+#13#10+'ColorM=EEAAFF'+#13#10+'ColorN=AAAAAA'+#13#10+'ColorO=DDDDDD'+#13#10+'ColorP=999999'; |
| 2566 |
Color := (Sender as TPanel).Color; |
| 2567 |
{$IFNDEF SYN_CLX} |
| 2568 |
{$IFNDEF FPC} |
| 2569 |
Options := [cdFullOpen]; |
| 2570 |
{$ENDIF} |
| 2571 |
{$ENDIF} |
| 2572 |
if Execute then |
| 2573 |
begin |
| 2574 |
(Sender as TPanel).Color := Color; |
| 2575 |
SetAttributes(Tree.Selected); |
| 2576 |
end; |
| 2577 |
finally |
| 2578 |
Free; |
| 2579 |
end; |
| 2580 |
end; |
| 2581 |
|
| 2582 |
procedure TfmDesigner.miColor16Click(Sender: TObject); |
| 2583 |
begin |
| 2584 |
if popColorStd.Tag = 1 then |
| 2585 |
pForeColor.Color := Colors16[(Sender as TMenuItem).ImageIndex] |
| 2586 |
else |
| 2587 |
if popColorStd.Tag = 2 then |
| 2588 |
pBackColor.Color := Colors16[(Sender as TMenuItem).ImageIndex]; |
| 2589 |
SetAttributes(Tree.Selected); |
| 2590 |
end; |
| 2591 |
|
| 2592 |
procedure TfmDesigner.miColorSysClick(Sender: TObject); |
| 2593 |
begin |
| 2594 |
if popColorStd.Tag = 1 then |
| 2595 |
pForeColor.Color := ColorsSys[(Sender as TMenuItem).ImageIndex] |
| 2596 |
else |
| 2597 |
if popColorStd.Tag = 2 then |
| 2598 |
pBackColor.Color := ColorsSys[(Sender as TMenuItem).ImageIndex]; |
| 2599 |
SetAttributes(Tree.Selected); |
| 2600 |
end; |
| 2601 |
|
| 2602 |
procedure TfmDesigner.miColor40Click(Sender: TObject); |
| 2603 |
begin |
| 2604 |
if popColorStd.Tag = 1 then |
| 2605 |
pForeColor.Color := Colors40[(Sender as TMenuItem).ImageIndex] |
| 2606 |
else if popColorStd.Tag = 2 then |
| 2607 |
pBackColor.Color := Colors40[(Sender as TMenuItem).ImageIndex]; |
| 2608 |
SetAttributes(Tree.Selected); |
| 2609 |
end; |
| 2610 |
|
| 2611 |
{$IFNDEF FPC} |
| 2612 |
procedure TfmDesigner.Color40MeasureItem(Sender: TObject; ACanvas: TCanvas; |
| 2613 |
var Width, Height: Integer); |
| 2614 |
begin |
| 2615 |
Width := 6; |
| 2616 |
end; |
| 2617 |
{$ELSE} |
| 2618 |
procedure TfmDesigner.Color40MeasureItem(Sender: TObject; ACanvas: TCanvas; |
| 2619 |
var AWidth, AHeight: Integer); |
| 2620 |
begin |
| 2621 |
AWidth := 6; |
| 2622 |
end; |
| 2623 |
{$ENDIF} |
| 2624 |
|
| 2625 |
procedure TfmDesigner.pColorMouseUp(Sender: TObject; Button: TMouseButton; |
| 2626 |
Shift: TShiftState; X, Y: Integer); |
| 2627 |
//var P: TPoint; |
| 2628 |
begin |
| 2629 |
// if (Button = mbRight) or (Button = mbMiddle) then |
| 2630 |
if ((Sender as TPanel).Name = 'pForeColor') or ((Sender as TPanel).Name = 'pForeColorArrow') then |
| 2631 |
popColorStd.Tag := 1 |
| 2632 |
else |
| 2633 |
if ((Sender as TPanel).Name = 'pBackColor') or ((Sender as TPanel).Name = 'pBackColorArrow') then |
| 2634 |
popColorStd.Tag := 2; |
| 2635 |
|
| 2636 |
// P := ((Sender as TPanel).Parent as TPanel).ClientToScreen(Point(-1, ((Sender as TPanel).Parent as TPanel).Height-1)); |
| 2637 |
|
| 2638 |
if (Button = mbMiddle) then |
| 2639 |
popColorSys.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y) |
| 2640 |
else if ((Button = mbRight) and (ssLeft in Shift)) then |
| 2641 |
popColorAdv.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y) |
| 2642 |
else |
| 2643 |
if Button = mbRight then |
| 2644 |
if ssShift in Shift then |
| 2645 |
popColorAdv.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y) |
| 2646 |
else |
| 2647 |
popColorStd.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y); |
| 2648 |
end; |
| 2649 |
|
| 2650 |
procedure TfmDesigner.pColorArrowMouseUp(Sender: TObject; Button: TMouseButton; |
| 2651 |
Shift: TShiftState; X, Y: Integer); |
| 2652 |
//var P: TPoint; |
| 2653 |
begin |
| 2654 |
// if (Button = mbRight) or (Button = mbMiddle) then |
| 2655 |
if ((Sender as TPanel).Name = 'pForeColor') or ((Sender as TPanel).Name = 'pForeColorArrow') then |
| 2656 |
popColorStd.Tag := 1 |
| 2657 |
else |
| 2658 |
if ((Sender as TPanel).Name = 'pBackColor') or ((Sender as TPanel).Name = 'pBackColorArrow') then |
| 2659 |
popColorStd.Tag := 2; |
| 2660 |
|
| 2661 |
// P := ((Sender as TPanel).Parent as TPanel).ClientToScreen(Point(-1, ((Sender as TPanel).Parent as TPanel).Height-1)); |
| 2662 |
if ((Sender as TPanel).Name = 'pForeColorArrow') or ((Sender as TPanel).Name = 'pBackColorArrow') then |
| 2663 |
(Sender as TPanel).BevelInner := bvLowered; |
| 2664 |
|
| 2665 |
if (Button = mbLeft) then |
| 2666 |
popColorStd.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y); |
| 2667 |
if (Button = mbMiddle) then |
| 2668 |
popColorAdv.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y) |
| 2669 |
else if ((Button = mbRight) and (ssLeft in Shift)) then |
| 2670 |
popColorAdv.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y) |
| 2671 |
else |
| 2672 |
if Button = mbRight then |
| 2673 |
if ssShift in Shift then |
| 2674 |
popColorAdv.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y) |
| 2675 |
else |
| 2676 |
popColorSys.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y); |
| 2677 |
|
| 2678 |
if ((Sender as TPanel).Name = 'pForeColorArrow') or ((Sender as TPanel).Name = 'pBackColorArrow') then |
| 2679 |
(Sender as TPanel).BevelInner := bvNone; |
| 2680 |
end; |
| 2681 |
|
| 2682 |
//=== TabSheet showing ======================================================= |
| 2683 |
procedure TfmDesigner.tabRootShow(Sender: TObject); |
| 2684 |
begin |
| 2685 |
popPropMenu := popRootMenu; |
| 2686 |
end; |
| 2687 |
|
| 2688 |
procedure TfmDesigner.tabRangeShow(Sender: TObject); |
| 2689 |
begin |
| 2690 |
popPropMenu := popRangeMenu; |
| 2691 |
end; |
| 2692 |
|
| 2693 |
procedure TfmDesigner.tabKeywordsShow(Sender: TObject); |
| 2694 |
begin |
| 2695 |
popPropMenu := popKeywordsMenu; |
| 2696 |
end; |
| 2697 |
|
| 2698 |
procedure TfmDesigner.tabSetShow(Sender: TObject); |
| 2699 |
begin |
| 2700 |
popPropMenu := popSetMenu; |
| 2701 |
end; |
| 2702 |
|
| 2703 |
|
| 2704 |
///////////////////////////////////////////////////////////////////////////////// |
| 2705 |
// RESORTING RESORTING RESORTING RESORTING RESORTING RESORTING RESORTING // |
| 2706 |
// RESORTING RESORTING RESORTING RESORTING RESORTING RESORTING RESORTING // |
| 2707 |
// RESORTING RESORTING RESORTING RESORTING RESORTING RESORTING RESORTING // |
| 2708 |
// RESORTING RESORTING RESORTING RESORTING RESORTING RESORTING RESORTING // |
| 2709 |
// RESORTING RESORTING RESORTING RESORTING RESORTING RESORTING RESORTING // |
| 2710 |
// RESORTING RESORTING RESORTING RESORTING RESORTING RESORTING RESORTING // |
| 2711 |
///////////////////////////////////////////////////////////////////////////////// |
| 2712 |
|
| 2713 |
//=== Work with files ======================================================== |
| 2714 |
//procedure TfmDesigner.LoadFromFileClick(Sender: TObject); |
| 2715 |
//resourcestring |
| 2716 |
// sUniFileDescription = 'UniHighlighter Syntax'; |
| 2717 |
//var |
| 2718 |
// iDlg: TOpenDialog; |
| 2719 |
// iFile: TFileStream; |
| 2720 |
// iNode: TTreeNode; |
| 2721 |
// iRange: TSynRange; |
| 2722 |
// cSub: integer; |
| 2723 |
//begin |
| 2724 |
// { TreeMenuPopup should handle this } |
| 2725 |
// Assert( TObject(Tree.Selected.Data) is TSynRange ); |
| 2726 |
// iNode := Tree.Selected; |
| 2727 |
// iRange := TSynRange(iNode.Data); |
| 2728 |
// iDlg := TOpenDialog.Create( nil ); |
| 2729 |
// try |
| 2730 |
// iDlg.DefaultExt := '.hgl'; |
| 2731 |
// iDlg.Filter := sUniFileDescription + ' (*.hgl)|*.hgl'; |
| 2732 |
// if not iDlg.Execute then |
| 2733 |
// Exit; |
| 2734 |
// iFile := TFileStream.Create( iDlg.FileName, fmOpenRead or fmShareDenyWrite ); |
| 2735 |
// try |
| 2736 |
// if iRange = SynUniSyn.MainRules then |
| 2737 |
// begin |
| 2738 |
// SynUniSyn.LoadFromStream( iFile ); |
| 2739 |
// Tree.Items.Clear; |
| 2740 |
// FillTree; |
| 2741 |
// SampleMemo.Lines.Text := SynUniSyn.SampleSource; |
| 2742 |
// iNode := Tree.Items[0]; |
| 2743 |
// end |
| 2744 |
// else begin |
| 2745 |
// iRange.LoadFromStream( iFile ); |
| 2746 |
// iNode.DeleteChildren; |
| 2747 |
// for cSub := 0 to iRange.KeyListCount - 1 do |
| 2748 |
// TreeAddKeyList( iNode, iRange.KeyLists[cSub] ); |
| 2749 |
// for cSub := 0 to iRange.RangeCount - 1 do |
| 2750 |
// TreeAddRange( iNode, iRange.Ranges[cSub] ); |
| 2751 |
// end; |
| 2752 |
// iNode.Expand( False ); |
| 2753 |
// TotalUpdate; |
| 2754 |
// finally |
| 2755 |
// iFile.Free; |
| 2756 |
// end; |
| 2757 |
// finally |
| 2758 |
// iDlg.Free; |
| 2759 |
// end; |
| 2760 |
// Modified(); |
| 2761 |
//end; |
| 2762 |
|
| 2763 |
procedure TfmDesigner.rootSaveToFileClick(Sender: TObject); |
| 2764 |
begin |
| 2765 |
if SaveDialog.Execute then |
| 2766 |
SynUniSyn.SaveToFile(SaveDialog.FileName); |
| 2767 |
end; |
| 2768 |
|
| 2769 |
procedure TfmDesigner.rootLoadFromFileClick(Sender: TObject); |
| 2770 |
var |
| 2771 |
Ext: string; |
| 2772 |
EditPlus: TSynUniImportEditPlus; |
| 2773 |
UltraEdit: TSynUniImportUltraEdit; |
| 2774 |
begin |
| 2775 |
if OpenDialog.Execute then begin |
| 2776 |
Ext := ExtractFileExt(OpenDialog.FileName); |
| 2777 |
try |
| 2778 |
if SameText(Ext, '.hgl') or SameText(Ext, '.hlr') then |
| 2779 |
SynUniSyn.{LoadHglFromFile}LoadFromFile(OpenDialog.FileName) |
| 2780 |
else |
| 2781 |
if SameText(Ext, '.stx') then begin |
| 2782 |
EditPlus := TSynUniImportEditPlus.Create(); |
| 2783 |
EditPlus.LoadFromFile(OpenDialog.FileName); |
| 2784 |
EditPlus.Import(SynUniSyn.MainRules, SynUniSyn.Info); |
| 2785 |
EditPlus.Free; |
| 2786 |
end else |
| 2787 |
if SameText(Ext, '.txt') then begin |
| 2788 |
UltraEdit := TSynUniImportUltraEdit.Create(); |
| 2789 |
UltraEdit.LoadFromFile(OpenDialog.FileName); |
| 2790 |
UltraEdit.Import(SynUniSyn.MainRules, SynUniSyn.Info); |
| 2791 |
UltraEdit.Free; |
| 2792 |
{ else // '.hlr' |
| 2793 |
SynUniSyn.LoadFromFile(OpenDialog.FileName);} |
| 2794 |
end else |
| 2795 |
raise Exception.Create(ClassName + '.rootLoadFromFile - Bad file extension!'); |
| 2796 |
finally |
| 2797 |
Tree.Items.Clear; |
| 2798 |
FillTree; |
| 2799 |
SampleMemo.Lines.Text := SynUniSyn.SampleSource; |
| 2800 |
Tree.Items[0].Expand(False); |
| 2801 |
TotalUpdate; |
| 2802 |
Modified(); |
| 2803 |
end; |
| 2804 |
end; |
| 2805 |
end; |
| 2806 |
|
| 2807 |
procedure TfmDesigner.rangeLoadFromFileClick(Sender: TObject); |
| 2808 |
begin |
| 2809 |
if OpenDialog.Execute then begin |
| 2810 |
if Application.MessageBox('It will delete current rule. Continue?', PChar(_Confirm), MB_OKCANCEL+MB_ICONQUESTION) = ID_OK then begin |
| 2811 |
DeleteNode(Tree.Selected, True); |
| 2812 |
TSynRule(Tree.Selected.Data).LoadFromFile(OpenDialog.FileName); //Сделать, что можно загрузить Keywords в Ranges и т.д... |
| 2813 |
TreeAddRange(Tree.Selected, TSynRange(Tree.Selected.Data), akReplace); |
| 2814 |
TreeChange(Sender, Tree.Selected); |
| 2815 |
Tree.Selected.Text := TSynRule(Tree.Selected.Data).Name; |
| 2816 |
Tree.Items[0].Expand(False); |
| 2817 |
TotalUpdate; |
| 2818 |
Modified(); |
| 2819 |
end; |
| 2820 |
end; |
| 2821 |
end; |
| 2822 |
|
| 2823 |
procedure TfmDesigner.rangeSaveToFileClick(Sender: TObject); |
| 2824 |
begin |
| 2825 |
if SaveDialog.Execute then |
| 2826 |
SynUniSyn.SaveToFile(SaveDialog.FileName, TSynRule(Tree.Selected.Data)); |
| 2827 |
end; |
| 2828 |
|
| 2829 |
//=== Clipboard ============================================================== |
| 2830 |
procedure TfmDesigner.StreamToClipboard(Stream: TStream); |
| 2831 |
var |
| 2832 |
Buf: PChar; |
| 2833 |
BufSize: Integer; |
| 2834 |
begin |
| 2835 |
buf := nil; // Чтобы убрать Warning компилятора |
| 2836 |
try |
| 2837 |
BufSize := Stream.Size; |
| 2838 |
GetMem(Buf, BufSize+1); |
| 2839 |
Stream.Position := 0; |
| 2840 |
Stream.ReadBuffer(Buf^, BufSize); |
| 2841 |
Buf[BufSize] := #0; |
| 2842 |
Clipboard.SetTextBuf(Buf); |
| 2843 |
finally |
| 2844 |
FreeMem(Buf); |
| 2845 |
Stream.Free; |
| 2846 |
end; |
| 2847 |
end; |
| 2848 |
|
| 2849 |
function TfmDesigner.GetClipboardAsStream: TMemoryStream; |
| 2850 |
var |
| 2851 |
hClipbrd: THandle; |
| 2852 |
Buf: PChar; |
| 2853 |
begin |
| 2854 |
{$note Error 2} |
| 2855 |
{$IFNDEF FPC} |
| 2856 |
Result := TMemoryStream.Create; |
| 2857 |
ClipBoard.Open; |
| 2858 |
try |
| 2859 |
hClipbrd := Clipboard.GetAsHandle(CF_TEXT); |
| 2860 |
Buf := GlobalLock(hClipbrd); |
| 2861 |
Result.WriteBuffer(Buf^, StrLen(Buf)); |
| 2862 |
Result.Position := 0; |
| 2863 |
GlobalUnlock(hClipbrd); |
| 2864 |
finally |
| 2865 |
Clipboard.Close; |
| 2866 |
end; |
| 2867 |
{$ENDIF} |
| 2868 |
end; |
| 2869 |
|
| 2870 |
//=== Root range ============================================================= |
| 2871 |
procedure TfmDesigner.rootCutClick(Sender: TObject); |
| 2872 |
begin |
| 2873 |
rootCopyClick(Sender); |
| 2874 |
ShowDialog := False; |
| 2875 |
DoDeleteNode(Sender); |
| 2876 |
end; |
| 2877 |
|
| 2878 |
procedure TfmDesigner.rootCopyClick(Sender: TObject); |
| 2879 |
begin |
| 2880 |
StreamToClipboard(SynUniSyn.GetAsStream()); |
| 2881 |
end; |
| 2882 |
|
| 2883 |
procedure TfmDesigner.rootPasteInsideClick(Sender: TObject); |
| 2884 |
begin |
| 2885 |
Tree.Selected.Selected := False; |
| 2886 |
Tree.Selected := Tree.Items[0]; |
| 2887 |
rangePasteInsideClick(Sender); |
| 2888 |
end; |
| 2889 |
|
| 2890 |
procedure TfmDesigner.rootPasteAndReplaceClick(Sender: TObject); |
| 2891 |
begin |
| 2892 |
Tree.Selected := Tree.Items[0]; |
| 2893 |
DeleteNode(Tree.Selected, True); |
| 2894 |
SynUniSyn.LoadFromStream(GetClipboardAsStream); |
| 2895 |
TreeAddRange(Tree.Selected, SynUniSyn.MainRules, akReplace); |
| 2896 |
TreeChange(nil, Tree.Selected); |
| 2897 |
Tree.Selected.Text := TSynRule(Tree.Selected.Data).Name; |
| 2898 |
SampleMemo.Text := SynUniSyn.Info.Sample.Text; |
| 2899 |
TotalUpdate; |
| 2900 |
Modified(); |
| 2901 |
end; |
| 2902 |
|
| 2903 |
//=== Other rules ============================================================ |
| 2904 |
procedure TfmDesigner.rangeCutClick(Sender: TObject); |
| 2905 |
begin |
| 2906 |
rangeCopyClick(Sender); |
| 2907 |
ShowDialog := False; |
| 2908 |
DoDeleteNode(Sender); |
| 2909 |
end; |
| 2910 |
|
| 2911 |
procedure TfmDesigner.rangeCopyClick(Sender: TObject); |
| 2912 |
begin |
| 2913 |
StreamToClipboard(TSynRule(Tree.Selected.Data).GetAsStream); |
| 2914 |
end; |
| 2915 |
|
| 2916 |
procedure TfmDesigner.rangePasteInsideClick(Sender: TObject); |
| 2917 |
var |
| 2918 |
Rule: TSynRule; |
| 2919 |
begin |
| 2920 |
if (copy(Clipboard.AsText, 1, Length('<UniHighlighter')) = '<UniHighlighter') or (copy(Clipboard.AsText, 1, Length('<Range')) = '<Range') then |
| 2921 |
Rule := TSynRange.Create else |
| 2922 |
if (copy(Clipboard.AsText, 1, Length('<Keywords')) = '<Keywords') then |
| 2923 |
Rule := TSynKeyList.Create else |
| 2924 |
if (copy(Clipboard.AsText, 1, Length('<Set')) = '<Set') then |
| 2925 |
Rule := TSynSet.Create |
| 2926 |
else |
| 2927 |
Exit; |
| 2928 |
Rule.LoadFromStream(GetClipboardAsStream); |
| 2929 |
TSynRange(Tree.Selected.Data).AddRule(Rule); |
| 2930 |
// Tree.MultiSelect := False; |
| 2931 |
with TreeAddRule(Tree.Selected, Rule) do Selected := True; |
| 2932 |
TotalUpdate; |
| 2933 |
// Tree.MultiSelect := True; |
| 2934 |
Modified(); |
| 2935 |
end; |
| 2936 |
|
| 2937 |
procedure TfmDesigner.rangePasteAndReplaceClick(Sender: TObject); |
| 2938 |
begin |
| 2939 |
if Application.MessageBox('It will delete current rule. Continue?', PChar(_Confirm), MB_OKCANCEL+MB_ICONQUESTION) = ID_OK then begin |
| 2940 |
DeleteNode(Tree.Selected, True); |
| 2941 |
TSynRule(Tree.Selected.Data).LoadFromStream(GetClipboardAsStream); |
| 2942 |
TreeAddRange(Tree.Selected, TSynRange(Tree.Selected.Data), akReplace); |
| 2943 |
TreeChange(Sender, Tree.Selected); |
| 2944 |
Tree.Selected.Text := TSynRule(Tree.Selected.Data).Name; |
| 2945 |
TotalUpdate; |
| 2946 |
Modified(); |
| 2947 |
end; |
| 2948 |
end; |
| 2949 |
|
| 2950 |
procedure TfmDesigner.rangePasteNextToClick(Sender: TObject); |
| 2951 |
var |
| 2952 |
Rule: TSynRule; |
| 2953 |
begin |
| 2954 |
if (copy(Clipboard.AsText, 1, Length('<UniHighlighter')) = '<UniHighlighter') or (copy(Clipboard.AsText, 1, Length('<Range')) = '<Range') then |
| 2955 |
Rule := TSynRange.Create else |
| 2956 |
if (copy(Clipboard.AsText, 1, Length('<Keywords')) = '<Keywords') then |
| 2957 |
Rule := TSynKeyList.Create else |
| 2958 |
if (copy(Clipboard.AsText, 1, Length('<Set')) = '<Set') then |
| 2959 |
Rule := TSynSet.Create |
| 2960 |
else |
| 2961 |
Exit; |
| 2962 |
Rule.LoadFromStream(GetClipboardAsStream); |
| 2963 |
TSynRange(Tree.Selected.Parent.Data).AddRule(Rule); |
| 2964 |
with TreeAddRule(Tree.Selected, Rule, akInsert) do Selected := True; |
| 2965 |
TotalUpdate; |
| 2966 |
Modified(); |
| 2967 |
end; |
| 2968 |
|
| 2969 |
//=== UNSORTED =============================================================== |
| 2970 |
procedure TfmDesigner.rootInfoClick(Sender: TObject); |
| 2971 |
var InfoText: string; |
| 2972 |
begin |
| 2973 |
with SynUniSyn.Info do begin |
| 2974 |
if General.Name <> '' then InfoText := InfoText + Format(_Name, [General.Name]) + #13#10 |
| 2975 |
else InfoText := InfoText + Format(_Name, ['<Noname>']) + #13#10; |
| 2976 |
if General.Extensions <> '' then InfoText := InfoText + Format(_Extensions, [General.Extensions]) + #13#10; |
| 2977 |
InfoText := InfoText + Format(_Version, [IntToStr(Version.Version) + '.' + IntToStr(Version.Revision)]) + #13#10; |
| 2978 |
InfoText := InfoText + Format(_Date, [DateTimeToStr(Version.ReleaseDate)]) + #13#10; |
| 2979 |
if Author.Name <> '' then InfoText := InfoText + Format(_Author, [Author.Name]) + #13#10; |
| 2980 |
if Author.Email <> '' then InfoText := InfoText + Format(_Mail, [Author.Email]) + #13#10; |
| 2981 |
if Author.Web <> '' then InfoText := InfoText + Format(_Web, [Author.Web]) + #13#10; |
| 2982 |
if Author.Copyright <> '' then InfoText := InfoText + Format(_Copyright, [Author.Copyright]) + #13#10; |
| 2983 |
if Author.Company <> '' then InfoText := InfoText + Format(_Company, [Author.Company]) + #13#10; |
| 2984 |
if Author.Remark <> '' then InfoText := InfoText + Format(_Remark, [Author.Remark]) + #13#10; |
| 2985 |
Application.MessageBox(PChar(InfoText),'About highlighter...', MB_ICONINFORMATION); |
| 2986 |
end; |
| 2987 |
end; |
| 2988 |
|
| 2989 |
procedure TfmDesigner.btStylesFileClick(Sender: TObject); |
| 2990 |
//var |
| 2991 |
// xml: TXMLParser; ++++++++++++ |
| 2992 |
begin |
| 2993 |
{ |
| 2994 |
if OpenDialog2.Execute then begin |
| 2995 |
edStylesFile.Text := OpenDialog2.FileName; |
| 2996 |
ComboBox2.Clear; |
| 2997 |
xml := TXMLParser.Create; |
| 2998 |
try |
| 2999 |
if xml.LoadFromFile(edStylesFile.Text) then begin |
| 3000 |
xml.StartScan; |
| 3001 |
while xml.Scan do |
| 3002 |
if (xml.CurPartType = ptStartTag) and SameText(xml.CurName, 'Scheme') then |
| 3003 |
ComboBox2.Items.Add(xml.CurAttr.Value('Name')); |
| 3004 |
end; |
| 3005 |
finally |
| 3006 |
xml.Free; |
| 3007 |
end; |
| 3008 |
ComboBox2.ItemIndex := 0; |
| 3009 |
end; |
| 3010 |
} |
| 3011 |
end; |
| 3012 |
|
| 3013 |
//============================================================================ |
| 3014 |
end. |
| 3015 |
|