-
Notifications
You must be signed in to change notification settings - Fork 0
/
infinite2.pas
2344 lines (2207 loc) · 68.6 KB
/
infinite2.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit infinite2;
//##############################################################################
//## Name......... Infinite
//## Type......... User Program
//## Desciption... Writing management system
//## Version...... 1.00.850
//## Date......... 02may2023
//## Lines........ 2,253
//## Copyright.... (c) 1997-2023 Blaiz Enterprises and www.BlaizEnterprises.com
//##############################################################################
interface
uses
{$ifdef D3}
Windows, Forms, Controls, SysUtils, Classes, ShellApi, ShlObj, Graphics, Clipbrd,
messages, math, extctrls{tpanel}, filectrl{tdrivetype}, ActiveX, ComObj, registry,
gosscore, gossdat;
{$endif}
{$ifdef D10}
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.surfaces,
system.dateutils, gosscore, gossdat;
{$endif}
var
sysrecent_txt:boolean=false;
type
{tdoceditor}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx//eeeeeeeeeeeeeeeeeeeeeee
tdoceditor=class;
tdoccheck=procedure(xdoc:tdoceditor;xfilename:string) of object;
tdoceditor=class(tbasiccols)
private
itimerAutosave,itimer100:comp;
icansave,iloaded,ibuildingcontrol:boolean;
inav:tbasicnav;
inavtitle:tbasictitle;
ilastfilename,ilastsyncREF,imustsetnavvalue,iextref,isettingsref:string;
ilogbuffer:tstr8;
//.edit support
ilogbase:tbasicscroll;
itexttitle:tbasictitle;
itext,ilog:tbasicbwp;
iimagelist,ilist:tbasicmenu;
iimage:tbasiccontrol;
isplit,irows,ishownav,ishowlog:boolean;
imodifiedid,istyle,iscrollv_px,iscrollh,ipos,ipos2:longint;
ic2pref,ic2pref_mask,inavref,ifilename,isyncref,iinforef:string;
function getcore:pwordcore;
function getcpos:longint;
procedure xtextfont;//30dec2021
procedure nav__showmenuFill(sender:tobject;xstyle:string;xmenudata:tstr8;var ximagealign:longint;var xmenuname:string);
function nav__showmenuClick(sender:tbasiccontrol;xstyle:string;xcode:longint;xcode2:string;xtepcolor:longint):boolean;
function xcmd(sender:tobject;xcode:longint;xcode2:string):boolean;//true=handled
procedure _ontimer(sender:tobject); override;
function getbackup:boolean;
procedure setbackup(x:boolean);
procedure xresetAutosave;
procedure xbackup_viaformatlevel(xfilename:string);
public
//vars
xbutcap:string;//read by host
xbuttep:longint;
ondoccheck:tdoccheck;
host:tobject;//optional
//create
constructor create(xparent:tobject); virtual;
constructor create2(xparent:tobject;xstart:boolean); virtual;
destructor destroy; override;
//information
property split:boolean read isplit write isplit;
property style:longint read istyle write istyle;//0=no wrap, 1=wrap to window, 2=wrap to page, 3=wrap to page + 200% line spacing
property rows:boolean read irows write irows;
property shownav:boolean read ishownav write ishownav;
property showlog:boolean read ishowlog write ishowlog;
property backup:boolean read getbackup write setbackup;
property core:pwordcore read getcore;
property cpos:longint read getcpos;
property _text:tbasicbwp read itext;//use with care
property cansave:boolean read icansave;
//edit support
function popfav:string;
procedure logclear;
procedure logadd(x:string);
function xnavvalue(xportable:boolean):string;
procedure xsetnavvalue(x:string);
function xnavfolder:string;
function xnavfile:string;
procedure xclear;
procedure xsmartsync;
procedure xsync;
procedure xsync2(xinfo_mustload,xinfo_mustsave,xdata_mustload,xdata_mustsave:boolean);
function xnav:tbasicnav;
procedure xclose;
procedure xshowmenu(xname:string);
procedure xreload;
//text support - 19apr2022
function textshowing:boolean;
function canpastetext:boolean;
function pastetext:boolean;
//spell
function xcanspell:boolean;
procedure xspell;
function xcanspelladd:boolean;
procedure xspelladd;
//find
function xcanfind:boolean;
//save support
procedure xsave;
procedure xsaveas;
//last support
function canlast:boolean;
procedure lasttoggle;
//settings
function xloadsettings(xname:string;dvars:tvars8):boolean;//prgsettings -> control -> dvars (allows for filtering of value) - 25mar2021
function xsavesettings(xname:string;dvars:tvars8):boolean;//prgsettings -> control -> dvars (allows for filtering of value) - 25mar2021
function xmustsavesettings:boolean;
//modified
function modified:boolean;
procedure modifiedoff;
//other
procedure xshowhide;
end;
{tprogram}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxx//sssssssssssssssssssssssssssssssssss
tprogram=class(tbasicprg2)
private
idocindex:longint;
idoclist:array[0..9] of tdoceditor;
icols,icols2:tbasiccols;
ishownav,iautoview,ibuildingcontrol,iloaded,ibackup,ishowlog:boolean;
iwritingtime,iwritingwords,iwritingwordsREF,iwritingtime2,istatusref64,iinfotimer,itimer100,itimer250,itimer500,itimerslow:comp;
ibackupfolder,iwritingwordsREF2:string;
//.log support
ilognamelist:array[0..199] of string;
ilognamecount:longint;
//.build support
ifiletime:string;
itexttime,iimgtime,icleantime,iiotime,iiotimeCOPYFILE,iiotimeFROMFILE,iiotimeTOFILE,icodetime:comp;
ircode10:byte;
iruncodeCOUNT,ifilecount,ifilebytes,idepthcount,ierrorcount,iwarncount:longint;
ilastfilecount:array[0..3] of longint;
iparsep:char;// "|"
//.status support
isettingsref,isettingsref2:string;
iinfoid,idownindex,inavindex,ifolderindex,ifileindex:longint;
iisnav,iisfolder,iisfile:boolean;
procedure __onclick(sender:tobject);
procedure __ontimer(sender:tobject); override;
procedure xloadsettings;
procedure xsavesettings;
procedure xautosavesettings(xfull:boolean);
procedure xfillinfo;
procedure xshowmenuFill1(sender:tobject;xstyle:string;xmenudata:tstr8;var ximagealign:longint;var xmenuname:string);
function xshowmenuClick1(sender:tbasiccontrol;xstyle:string;xcode:longint;xcode2:string;xtepcolor:longint):boolean;
procedure xshowpage(x:longint);
//edit support
procedure xclosesamefiles(x:tdoceditor;xfilename:string);
function xdoc:tdoceditor;
function xdocindex:longint;
procedure xsync;
//build support
procedure xshow(xmsg:string);
function xshowinfo(xmsg,xmorechain:string):boolean;
function xshowwarn(xmsg,xmorechain:string):boolean;
function xshowerror(xmsg,xmorechain:string):boolean;
function xfindformat(x:tstr8):string;
//log support
procedure xlognameclear;
procedure xlognameadd(xlogname:string);
procedure xlognamedel;
//backup support
function canbackup:boolean;
procedure backup;
//other
procedure xsplitnameonlastdash(x:string;var v1,v2:string);//07oct2022
procedure xclickcell(sender:tobject);
procedure xwritingreset;
function xonshortcut(sender:tobject):boolean;
procedure xunpackdic(xforce:boolean);
public
//create
constructor create(xminsysver:longint;xhost:tobject;dwidth,dheight:longint); override;
destructor destroy; override;
//support
procedure xcmd(sender:tobject;xcode:longint;xcode2:string);
end;
function low__createprogram(xhost:tobject):tbasicprg1;
//suport procs - 24dec2021
function low__chapterfileOK(xfilename:string):boolean;
function low__lastfoldername(xfolder,xdefaultname:string):string;
//support for Gossamer
procedure program__init;
procedure program__close;
implementation
uses infinite1;
//## low__datestr0 ##
function low__datestr0(x:tdatetime):string;
var
yy,mm,dd,hh,min,ss,ms:word;
begin
try
result:='';
low__decodedate2(x,yy,mm,dd);
low__decodetime2(x,hh,min,ss,ms);
result:=inttostr(yy)+'y-'+inttostr(mm)+'m-'+inttostr(dd)+'d-'+inttostr(hh)+'h-'+inttostr(min)+'m-'+inttostr(ss)+'s-'+inttostr(ms)+'ms';
except;end;
end;
//## low__createprogram ##
function low__createprogram(xhost:tobject):tbasicprg1;
begin
try
result:=tprogram.create(0,xhost,1350,800);
result.createfinish;//perform form and POST create operations like sync main form's help visible state - 30jul2021
except;end;
end;
//## program__init ##
procedure program__init;
begin
//nil
end;
//## program__close ##
procedure program__close;
begin
//nil
end;
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx//eeeeeeeeeeeeeeeeeeeeeee
//## create ##
constructor tdoceditor.create(xparent:tobject);
begin
create2(xparent,true);
end;
//## create ##
constructor tdoceditor.create2(xparent:tobject;xstart:boolean);
begin
inherited create2(xparent,false);
//vars
ibuildingcontrol:=true;
iloaded:=false;
itimer100:=ms64;
itimerAutosave:=ms64;
ilastsyncREF:='';
host:=nil;
ilogbase:=nil;
icansave:=false;
ondoccheck:=nil;
xbutcap:='';
xbuttep:=tepEdit20;
style:=bcVertical;
ishownav:=true;
ishowlog:=true;
isplit:=false;
ilogbuffer:=bnew;
imodifiedid:=0;
ilastfilename:='*';//means none - empty - disabled
//nav
with cols2[0,20,false] do
begin
xcols.style:=bcHorizontal;
//xcols.visible:=false;
with xcols.cols2[1,50,false] do
begin
inavtitle:=ntitle(false,ntranslate('Product Files'),'');
inav:=nnav.makenavlist2;
inav.hisname:='fileeditor';
inav.omasklist:='*.dic;*.txt;*.bwd;*.bwp;*.gif;*.png;*.jpg;*.jpeg;*.bmp;*.ico;*.cur;*.tea;';
inav.oemasklist:='.be.tea;';
inav.oautoheight:=true;
inav.sortstyle:=nlName;//nlSize;
end;
end;
//edit
with cols2[1,70,false].ncols do
begin
makeautoheight;
visible:=true;
style:=bcHorizontal;
//.text editor
with cols2[0,76,false] do
begin
itexttitle:=ntitle(false,'Editor','Editor');
//.editor support
itext:=nbwp4('Edit text document',nil,0,true,true,false,false,false);
itext.omenustyles:=true;
itext.undoenabled:=true;
itext.core.oviewurl:=false;//disable click to view http:// urls
itext.core.onefontname:='$fontname2';//05feb2022
itext.core.onefontsize:=1;//viFontsize2 - system size - 05feb2022
itext.core.odic:=true;//04feb2023
itext.core.obackup:=true;//04feb2023
itext.olivewordcount:=true;//05feb2023
itext.vsmooth:=true;
ilist:=nlist('','',nil,10);
ilist.otab:=tbL250_R100_L300;//tbL120_L120_L300;
iimagelist:=nlist('','',nil,3);
iimagelist.otab:=tbL250_R100_L300;
iimage:=nimageviewer(nil,'');
end;
//.log viewer
ilogbase:=cols2[1,24,false];
with ilogbase do
begin
ntitle(false,'Build Log','Build Log');
ilog:=nbwp4('Build Log',nil,0,true,true,false,false,false);
ilog.oreadonly:=true;
ilog.oshowcursor:=false;
ilog.core.oviewurl:=false;//disable click to view http:// urls
ilog.core.defFontname:='Courier new';
end;
ilogbase.visible:=false;//hide - not yet used - 04feb2023
end;
//events
inav.showmenuFill1:=nav__showmenuFill;
inav.showmenuClick2:=nav__showmenuClick;;
//defaults
xresetAutosave;
modifiedoff;
//finished building
ibuildingcontrol:=false;
//start
if xstart then start;
end;
//## destroy ##
destructor tdoceditor.destroy;
begin
try
//control
bfree(ilogbuffer);
//self
inherited destroy;
except;end;
end;
//## xbackup_viaformatlevel ##
procedure tdoceditor.xbackup_viaformatlevel(xfilename:string);
var
e,dext,aext:string;
a:tstr8;
begin
try
//defaults
a:=nil;
//check
if not itext.visible then exit;
//init
aext:='';
xfilename:=low__extractfilename(xfilename);
dext:=lowercase__readfileext(xfilename);
//get
case low__wordcore__findformatlevel(itext.core^) of
1:if (dext<>'bwd') and (dext<>'bwp') then aext:='bwd';
2:if (dext<>'bwp') then aext:='bwp';
end;
//set
if (aext<>'') then
begin
a:=bnew;
itext.ioget(a,aext);
low__tofile(low__backupfilename(remlastext(xfilename)+'.'+aext),a,e);
low__iroll(systrack_backupcount,1);//12feb2023
end;
except;end;
try;bfree(a);except;end;
end;
//## getbackup ##
function tdoceditor.getbackup:boolean;
begin
try;result:=itext.core.obackup;except;end;
end;
//## setbackup ##
procedure tdoceditor.setbackup(x:boolean);
begin
try;itext.core.obackup:=x;except;end;
end;
//## xshowhide ##
procedure tdoceditor.xshowhide;
begin
try
vis[0]:=ishownav;
except;end;
end;
//## _ontimer ##
procedure tdoceditor._ontimer(sender:tobject);//._ontimer
begin
try
//timer100
if (ms64>=itimer100) and iloaded then
begin
//sync
xshowhide;
//reset
itimer100:=ms64+100;
end;
//itimerAutosave
if (ms64>=itimerAutosave) and iloaded then
begin
xresetAutosave;
if backup and cansave and modified then xsave;
end;
except;end;
end;
//## xresetAutosave ##
procedure tdoceditor.xresetAutosave;//autosave backup every 5 min - 12feb2023
begin
try;itimerAutosave:=low__add64(ms64,300000);except;end;
end;
//## popfav ##
function tdoceditor.popfav:string;
begin
try
result:=inav.popfav;
xsetnavvalue(result);
except;end;
end;
//## nav__showmenuFill##
procedure tdoceditor.nav__showmenuFill(sender:tobject;xstyle:string;xmenudata:tstr8;var ximagealign:longint;var xmenuname:string);
var
xok:boolean;
//## dwords ##
function dwords(x:longint):string;
begin
result:=' ( '+low__64(dic_wordcount(x))+' w )';
end;
begin
try
//check
if zznil(xmenudata,2318) then exit;
//get
//.new document
xok:=(xnavfolder<>'');
low__menutitle(xmenudata,tepnone,'New Document','Select document format');
low__menuitem2(xmenudata,tepTXT20,'Text Document','TXT document','new.txt',100,aknone,xok);
low__menuitem2(xmenudata,tepBWD20,'Enhanced Text Document','BWD document','new.bwd',100,aknone,xok);
low__menuitem2(xmenudata,tepBWP20,'Advanced Text Document','BWP document','new.bwp',100,aknone,xok);
low__menusep(xmenudata);
low__menuitem2(xmenudata,tep__yes(sysrecent_txt),'Automatically maintain ".__recent.txt/html"','Ticked: Stores contents of recently saved document (from cursor line onwards) to ".__recent.txt/html" files.','toggle.recent',100,aknone,true);
//.options
xok:=(xnavfile<>'');
low__menutitle(xmenudata,tepnone,'Options','Display options');
low__menuitem2(xmenudata,tep__yes(rows),'Color Rows','Color rows','toggle.rows',100,aknone,xok);
low__menuitem2(xmenudata,tepRefresh20,'Reset Writing Counter...','Reset writing counter','host.time.reset',100,aknone,true);
//.spelling
low__menutitle(xmenudata,tepnone,'Spelling','Spelling options');
low__menuitem2(xmenudata,tep__yes(sysdic_main_use),'Main'+dwords(0),'Use dictionary: main.dic','toggle.main',100,aknone,true);
low__menuitem2(xmenudata,tep__yes(sysdic_sup1_use),'Supplementary 1'+dwords(1),'Use dictionary: sup1.dic','toggle.sup1',100,aknone,true);
low__menuitem2(xmenudata,tep__yes(sysdic_sup2_use),'Supplementary 2'+dwords(2),'Use dictionary: sup2.dic','toggle.sup2',100,aknone,true);
low__menusep(xmenudata);
low__menuitem2(xmenudata,tepEdit20,'Edit Main','Edit dictionary: main.dic','edit.main',100,aknone,true);
low__menuitem2(xmenudata,tepEdit20,'Edit Supplementary 1','Edit dictionary: sup1.dic','edit.sup1',100,aknone,true);
low__menuitem2(xmenudata,tepEdit20,'Edit Supplementary 2','Edit dictionary: sup2.dic','edit.sup2',100,aknone,true);
low__menusep(xmenudata);
low__menuitem2(xmenudata,tepRefresh20,'Reload Dictionaries','Reload dictionaries','reload.dics',100,aknone,true);
low__menuitem2(xmenudata,tepSave20,'Restore Main Dictionary...','Restore main dictionary to default','host.restore.maindic',100,aknone,true);
//.backup`
low__menutitle(xmenudata,tepnone,'Backup','Backup options');
low__menuitem2(xmenudata,tep__yes(backup),'Make Backups','A backup is written each time the document is significantly changed','host.backup.toggle',100,aknone,true);
low__menuitem2(xmenudata,tepFolder20,'Show Folder','Show the backups storage folder','host.backup.showfolder',100,aknone,true);
except;end;
end;
//## nav__showmenuClick ##
function tdoceditor.nav__showmenuClick(sender:tbasiccontrol;xstyle:string;xcode:longint;xcode2:string;xtepcolor:longint):boolean;
begin
try;result:=xcmd(self,xcode,xcode2);except;end;
end;
//## xcmd ##
function tdoceditor.xcmd(sender:tobject;xcode:longint;xcode2:string):boolean;//true=handled
label
skipend,redonew;
var
e,str1,str2:string;
begin
try
//defaults
result:=false;
//get
if (xcode2='refresh') then xreload
else if (xcode2='toggle.rows') then rows:=not rows
else if low__comparetext(strcopy1(xcode2,1,4),'new.') then
begin
str1:=strcopy1(xcode2,5,length(xcode2));
if (xnavfolder<>'') then
begin
str2:=low__extractfilepath(xnavfolder)+'.'+str1;
redonew:
if sysprogram.rootwin.gui.popsave(str2,str1,'') then
begin
if low__fileexists(str2) then
begin
gui.popquery('File already exists. Use another name.');
goto redonew;
end
else
begin
low__tofilestr(str2,'',e);
xcmd(nil,0,'refresh');
end;
end;
end;
end
else if (xcode2='toggle.recent') then low__toggle(sysrecent_txt)
else if (xcode2='toggle.main') then low__toggle(sysdic_main_use)
else if (xcode2='toggle.sup1') then low__toggle(sysdic_sup1_use)
else if (xcode2='toggle.sup2') then low__toggle(sysdic_sup2_use)
else if (xcode2='edit.main') then dic_edit(0)
else if (xcode2='edit.sup1') then dic_edit(1)
else if (xcode2='edit.sup2') then dic_edit(2)
else if (xcode2='reload.dics') then dic_reload(-1)
else if (strcopy1(xcode2,1,5)='host.') then
begin
if (host<>nil) and (host is tprogram) then (host as tprogram).xcmd(sender,xcode,strcopy1(xcode2,6,length(xcode2)));//pass onto our host
end
else goto skipend;//not handled
//successful
result:=true;
skipend:
except;end;
end;
//## modified ##
function tdoceditor.modified:boolean;
begin
try;result:=(imodifiedid<>itext.core.dataid3);except;end;
end;
//## modifiedoff ##
procedure tdoceditor.modifiedoff;
begin
try;imodifiedid:=itext.core.dataid3;except;end;
end;
//## xreload ##
procedure tdoceditor.xreload;
begin
try;inav.reload;except;end;
end;
//## xtextfont ##
procedure tdoceditor.xtextfont;//30dec2021
begin
try
//text
with itext.core^ do
begin
defFontname :='Default 2';//courier new
defFontsize :=vifontsize__root+low__insint(2,vifontsize__root<=10);//non-zoomed version
defFontcolor :=vinormal.font;
pagecolor :=vinormal.background;
pageselcolor :=vinormal.highlight;
pagefontselcolor:=vinormal.fonthighlight;
viewcolor :=low__dc(pagecolor,50);
cfontname :=defFontname;
cfontsize :=defFontsize;
cbold :=false;
citalic :=false;
cunderline :=false;
cstrikeout :=false;
end;
//log
with ilog.core^ do
begin
cfontname :='Courier New';
cfontsize :=9;
cbold :=false;
citalic :=false;
cunderline :=false;
cstrikeout :=false;
end;
except;end;
end;
//## logclear ##
procedure tdoceditor.logclear;
begin
try
ilogbuffer.clear;
low__wordcore(ilog.core^,'clear',nil);
except;end;
end;
//## logadd ##
procedure tdoceditor.logadd(x:string);
begin
if (ilogbase<>nil) then
begin
xtextfont;
low__wordcore_str(ilog.core^,'ins2',x);//ins2 overrides readonly
end;
end;
//## getcore ##
function tdoceditor.getcore:pwordcore;
begin
try;result:=itext.core;except;end;
end;
//## getcpos ##
function tdoceditor.getcpos:longint;
begin
try;result:=itext.cpos;except;end;
end;
//## xmustsavesettings ##
function tdoceditor.xmustsavesettings:boolean;
begin
try;result:=(not ibuildingcontrol) and low__setstr(isettingsref,bnc(isplit)+'|'+inttostr(inav.sortstyle)+'|'+xnavvalue(false));except;end;
end;
//## xloadsettings ##
function tdoceditor.xloadsettings(xname:string;dvars:tvars8):boolean;//prgsettings -> control -> dvars (allows for filtering of value) - 25mar2021
begin
try
//defaults
result:=false;
//check
if (dvars=nil) then exit;
//get
dvars.b[xname+'.split']:=prgsettings.bdef(xname+'.split',false);
dvars.s[xname+'.value']:=prgsettings.sdef(xname+'.value','');
dvars.s[xname+'.value0']:=prgsettings.sdef(xname+'.value0','');
isplit:=dvars.b[xname+'.split'];
dvars.b[xname+'.split']:=isplit;
xsync;//update for "isplit" immediately - 12jan2022
inav.xfromprg2(xname+'.nav',dvars);//prg -> nav -> a
xsetnavvalue(dvars.s[xname+'.value']);
dvars.s[xname+'.value']:=xnavvalue(true);
//set
iloaded:=true;
result:=true;
except;end;
end;
//## xsavesettings ##
function tdoceditor.xsavesettings(xname:string;dvars:tvars8):boolean;//prgsettings -> control -> dvars (allows for filtering of value) - 25mar2021
begin
try
//defaults
result:=false;
//check
if (dvars=nil) then exit;
//get
dvars.b[xname+'.split']:=isplit;
dvars.s[xname+'.value']:=xnavvalue(true);
inav.xto(inav,dvars,xname+'.nav');
//set
result:=true;
except;end;
end;
//## xnav ##
function tdoceditor.xnav:tbasicnav;
begin
try;result:=inav;except;end;
end;
//## xshowmenu ##
procedure tdoceditor.xshowmenu(xname:string);
begin
try
if (xname='edit') then
begin
if itext.visible then itext.showmenu;
end;
except;end;
end;
//## xcanfind ##
function tdoceditor.xcanfind:boolean;
begin
try;result:=itext.visible and itext.canfind;except;end;
end;
//## xcanspell ##
function tdoceditor.xcanspell:boolean;
begin
try;result:=itext.visible and itext.canspell;except;end;
end;
//## xspell ##
procedure tdoceditor.xspell;
begin
try
if xcanspell then
begin
itext.spell;
itext.setfocus;
end;
except;end;
end;
//## xcanspelladd ##
function tdoceditor.xcanspelladd:boolean;
begin
try;result:=itext.visible and itext.canspell and ( (sysdic_sup1_use and (sysdic_sup1<>nil)) or (sysdic_sup2_use and (sysdic_sup2<>nil)) ) and (itext.core.dic_addword<>'');except;end;
end;
//## xspelladd ##
procedure tdoceditor.xspelladd;
var
i:longint;
begin
try
i:=0;
if xcanspelladd then
begin
//init
if (i<1) and sysdic_sup1_use and (sysdic_sup1<>nil) then i:=1;
if (i<1) and sysdic_sup2_use and (sysdic_sup2<>nil) then i:=2;
//get
if (i>=1) then
begin
if pop_query2('Add word "'+itext.core.dic_addword+'" to supplementary dictionary '+inttostr(i)+' ?','','Add Word') then dic_addword(itext.core.dic_addword,i);
itext.core.dic_addword:='';
end;
xspell;
end;
except;end;
end;
//## xsave ##
procedure tdoceditor.xsave;
begin
try
if (ifilename<>'') then xsync2(false,true,false,true);
except;end;
end;
//## xsaveas ##
procedure tdoceditor.xsaveas;
begin
try
//xxxxxxxxxxxxxxx if (ifilename<>'') then xsync2(false,true,false,true);
except;end;
end;
//## xclose ##
procedure tdoceditor.xclose;
begin
try
inav.xlist.itemindex:=0;
xsync;
except;end;
end;
//## xnavfolder ##
function tdoceditor.xnavfolder:string;
begin
try;result:=inav.folder;except;end;
end;
//## xnavfile ##
function tdoceditor.xnavfile:string;
begin
try
if (inav.valuestyle=nltFile) then result:=inav.value else result:='';
except;end;
end;
//## canlast ##
function tdoceditor.canlast:boolean;
begin
try;result:=(ilastfilename<>'*');except;end;
end;
//## lasttoggle ##
procedure tdoceditor.lasttoggle;
var
str1:string;
begin
try
if canlast then
begin
str1:=xnavfile;
inav.value:=ilastfilename;
ilastfilename:=str1;
end;
except;end;
end;
//## xnavvalue ##
function tdoceditor.xnavvalue(xportable:boolean):string;
begin
try
if (inav.valuestyle=nltFile) then result:=inav.value
else if xportable then result:=low__makeportablefilename(inav.folder)
else result:=inav.folder;
except;end;
end;
//## xsetnavvalue ##
procedure tdoceditor.xsetnavvalue(x:string);
begin
try
if (x='') then inav.folder:=''
else if (strlastx(x)='\') or (strlastx(x)='/') then inav.folder:=low__readportablefilename(asfolderNIL(x))
else inav.value:=x;
except;end;
end;
//## xclear ##
procedure tdoceditor.xclear;
begin
try
imustsetnavvalue:='';
ic2pref:='';
ic2pref_mask:='';
inavref:='';
iinforef:='';
isyncref:='';
ifilename:='';
isplit:=false;
istyle:=0;
irows:=false;
ishowlog:=false;
iscrollv_px:=0;
iscrollh:=0;
ipos:=0;
ipos2:=0;
itext.visible:=false;
ilist.visible:=false;
iimage.visible:=false;
iimagelist.visible:=false;
except;end;
end;
//xxxxxxxxxxxxxxxxxxx//eeeeeeeeeeeeeeeeeeeeeee
//## textshowing ##
function tdoceditor.textshowing:boolean;
begin
try;result:=(itext<>nil) and itext.visible;except;end;
end;
//## canpastetext ##
function tdoceditor.canpastetext:boolean;
begin
try;result:=textshowing and low__canpastetxt;except;end;
end;
//## pastetext ##
function tdoceditor.pastetext:boolean;
var
a,b:tstr8;
int1:longint;
begin
try
//defaults
result:=false;
a:=nil;
b:=nil;
//get
if canpastetext then
begin
a:=bnew;
b:=bnew;
if low__pastetxt(a) then
begin
itext.iogetbwp(b);
itext.revertinit(b,true);
int1:=itext.vpos;
itext.ioset2(a,-1,int1);
result:=true;
end;
end;
except;end;
try
bfree(a);
bfree(b);
except;end;
end;
//##xsmartsync ##
procedure tdoceditor.xsmartsync;
begin
try
//check
if ibuildingcontrol or (not iloaded) then exit;
//smart check -> limit syncing to visible TAB and those tabs that need startup or current sync BUT NO ongoing syncing - 12jan2022
if (not low__setstr(ilastsyncREF,bnc(iloaded)+'|'+inav.folder+'|')) and (not visible) then exit;
//get
xsync;
except;end;
end;
//## xsync ##
procedure tdoceditor.xsync;
begin
try;xsync2(false,false,false,false);except;end;
end;
//## xsync2 ##
procedure tdoceditor.xsync2(xinfo_mustload,xinfo_mustsave,xdata_mustload,xdata_mustsave:boolean);
var
tmpstr,tmpstr2,str2,str1,xnavext,xext,anavfolder,xnavfilename,xfilename,e:string;
xstatus_loadeddata,bol1,xmustpaint,xmustdata,xmustinfo,xsplit,xrows:boolean;
int2,int1,p,xpos,xpos2,xscrollv_px,xscrollh:longint;
xstyle,sbits,sw,sh,scellcount,scellw,scellh,sdelay:longint;
shasai,stransparent:boolean;
xvars:tvars8;
xtmp,xdata:tstr8;
//## xshow ##
procedure xshow(x:tbasiccontrol;xvisible:boolean);
begin
try
if (x<>nil) and (x.visible<>xvisible) then
begin
x.visible:=xvisible;
xmustpaint:=true;
end;
except;end;
end;
//## xsubname ##
function xsubname(xname:string):string;
begin
result:=xname+'.*;'+xname+'-*.*;';
end;
//## xneedtmp ##
function xneedtmp:boolean;
begin
result:=true;
if (xtmp=nil) then xtmp:=bnew else xtmp.clear;
end;
//## xfindwrap ##
function xfindwrap:longint;
begin
case xstyle of
0:result:=wwsNone;
1:result:=wwsWindow;
2:result:=wwsPage;
3:result:=wwsPage;
4:result:=wwsPage2
else result:=wwsNone;
end;//case
end;
//## xfindlinespacing ##
function xfindlinespacing:longint;
begin
case xstyle of
3..4:result:=2;
else result:=1;
end;//case
end;
//## xsentencesep ##
function xsentencesep(x:longint):boolean;
var
v:byte;
begin
v:=low__wordcore_docchar(itext.core^,x);
result:=(v=ssDot) or (v=ssexclaim) or (v=ssquestion) or (v=ss10);
end;
begin
try
//defaults
xdata:=nil;
xtmp:=nil;
xmustpaint:=false;
xstatus_loadeddata:=false;
//disable this, was used for Claude only - xsplit:=isplit;
xsplit:=false;
//check
if ibuildingcontrol or (ilogbase=nil) then exit;
//nav - switch display modes
bol1:=low__setstr(inavref,bnc(xsplit));
inav.ocansort:=not xsplit;
case xsplit of
false:begin
if bol1 or (inav.style<>bnNavlist) then
begin
inavtitle.visible:=false;
//inav.omasklist:='*';
inav.style:=bnNavlist;
xmustpaint:=true;
end;
end;
true:begin
if bol1 or (inav.style=bnNavlist) then
begin
inavtitle.visible:=true;
inav.style:=bnNamelist;
xmustpaint:=true;
end;
//mask
//if (inav.omasklist<>str1) then inav.omasklist:=str1;
if (imustsetnavvalue<>'') then
begin
str1:=imustsetnavvalue;
imustsetnavvalue:='';
xsetnavvalue(str1);
end;
end;
end;
//init
anavfolder:=xnavfolder;
xnavfilename:=xnavfile;
//.special check -> remove all instances of the same file being editing by other tabs - 19dec2021
if (xnavfilename<>'') and assigned(ondoccheck) and visible then ondoccheck(self,xnavfilename);
xfilename:=ifilename;
xstyle:=frcrange(istyle,0,4);
xrows:=irows;