Subversion Repositories Kolibri OS

Rev

Rev 9599 | Rev 9668 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9599 Rev 9659
Line 171... Line 171...
171
BEGIN
171
BEGIN
172
	drawCursor := FALSE
172
	drawCursor := FALSE
173
END hideCursor;
173
END hideCursor;
Line 174... Line -...
174
 
-
 
175
 
-
 
176
PROCEDURE getChar (line: tLine; i: INTEGER): WCHAR;
-
 
177
VAR
-
 
178
    res: WCHAR;
-
 
179
BEGIN
-
 
180
    IF i >= line.length THEN
-
 
181
        res := 0X
-
 
182
    ELSE
-
 
183
        res := Lines.getChar(line, i)
-
 
184
    END
-
 
185
    RETURN res
-
 
186
END getChar;
-
 
187
 
174
 
188
 
175
 
189
PROCEDURE getString (src: tLine; pos, cnt: INTEGER; VAR dst: ARRAY OF WCHAR): INTEGER;
176
PROCEDURE getString (src: tLine; pos, cnt: INTEGER; VAR dst: ARRAY OF WCHAR): INTEGER;
190
VAR
177
VAR
191
    i: INTEGER;
178
    i: INTEGER;
192
BEGIN
179
BEGIN
193
    i := 0;
180
    i := 0;
194
    WHILE (pos < src.length) & (cnt > 0) DO
181
    WHILE (pos < src.length) & (cnt > 0) DO
195
        IF i < LEN(dst) - 1 THEN
182
        IF i < LEN(dst) - 1 THEN
196
            dst[i] := getChar(src, pos);
183
            dst[i] := Lines.getChar(src, pos);
197
            INC(i)
184
            INC(i)
198
        END;
185
        END;
199
        INC(pos);
186
        INC(pos);
Line 320... Line 307...
320
        c: WCHAR;
307
        c: WCHAR;
321
        lexLen: INTEGER;
308
        lexLen: INTEGER;
322
        s: ARRAY 32 OF WCHAR;
309
        s: ARRAY 32 OF WCHAR;
323
        color: INTEGER;
310
        color: INTEGER;
324
    BEGIN
311
    BEGIN
325
        c := getChar(line, i);
312
        c := Lines.getChar(line, i);
326
        WHILE U.isLetter(c) OR (c = "_") OR U.isDigit(c) DO
313
        WHILE U.isLetter(c) OR (c = "_") OR U.isDigit(c) DO
327
            INC(i);
314
            INC(i);
328
            c := getChar(line, i);
315
            c := Lines.getChar(line, i);
329
        END;
316
        END;
330
        DEC(i);
317
        DEC(i);
331
        lexLen := getString(line, first, i - first + 1, s);
318
        lexLen := getString(line, first, i - first + 1, s);
332
        IF ~cs THEN
319
        IF ~cs THEN
333
            U.upcase16(s)
320
            U.upcase16(s)
Line 358... Line 345...
358
        IF text.lang IN Lang.escLang THEN
345
        IF text.lang IN Lang.escLang THEN
359
	        Start := k + 1;
346
	        Start := k + 1;
360
	        End := i - 1;
347
	        End := i - 1;
361
	        k := Start;
348
	        k := Start;
362
	        WHILE k <= End DO
349
	        WHILE k <= End DO
363
	        	c := getChar(line, k);
350
	        	c := Lines.getChar(line, k);
364
	        	IF c = "\" THEN
351
	        	IF c = "\" THEN
365
	        		j := k;
352
	        		j := k;
366
	        		Lang.SkipEsc(line, k, line.length - 1, text.lang);
353
	        		Lang.SkipEsc(line, k, line.length - 1, text.lang);
367
	        		PrintLex(text, line, j, k, y, colors.escape, backColor)
354
	        		PrintLex(text, line, j, k, y, colors.escape, backColor)
368
	        	END;
355
	        	END;
Line 379... Line 366...
379
    IF (depth > 0) & (n >= 0) THEN
366
    IF (depth > 0) & (n >= 0) THEN
380
        PrintComment(text, line, depth, i, 2, y, backColor)
367
        PrintComment(text, line, depth, i, 2, y, backColor)
381
    END;
368
    END;
382
    cond := 0;
369
    cond := 0;
383
    WHILE i <= n DO
370
    WHILE i <= n DO
384
        c := getChar(line, i);
371
        c := Lines.getChar(line, i);
Line 385... Line 372...
385
 
372
 
Line 386... Line 373...
386
        IF lang = Lang.langFasm THEN
373
        IF lang = Lang.langFasm THEN
387
 
374
 
Line 394... Line 381...
394
                ident(text, i, i, y, line, backColor, Lang.isCS(lang))
381
                ident(text, i, i, y, line, backColor, Lang.isCS(lang))
395
            ELSIF U.isDigit(c) THEN
382
            ELSIF U.isDigit(c) THEN
396
                hex := FALSE;
383
                hex := FALSE;
397
                k := i;
384
                k := i;
398
                INC(i);
385
                INC(i);
399
                c := getChar(line, i);
386
                c := Lines.getChar(line, i);
400
                IF (cap(c) = "X") & (getChar(line, i - 1) = "0") THEN
387
                IF (cap(c) = "X") & (Lines.getChar(line, i - 1) = "0") THEN
401
                    INC(i);
388
                    INC(i);
402
                    hex := TRUE
389
                    hex := TRUE
403
                END;
390
                END;
Line 404... Line 391...
404
 
391
 
405
                WHILE U.isHex(cap(getChar(line, i))) DO
392
                WHILE U.isHex(cap(Lines.getChar(line, i))) DO
406
                    INC(i)
393
                    INC(i)
Line 407... Line 394...
407
                END;
394
                END;
408
 
395
 
409
                IF (cap(getChar(line, i)) = "H") & ~hex THEN
396
                IF (cap(Lines.getChar(line, i)) = "H") & ~hex THEN
Line 410... Line 397...
410
                    INC(i)
397
                    INC(i)
411
                END;
398
                END;
Line 433... Line 420...
433
	            ELSIF U.isLetter(c) OR (c = "_") OR (c = "'") OR (c = '"') THEN
420
	            ELSIF U.isLetter(c) OR (c = "_") OR (c = "'") OR (c = '"') THEN
434
	            	k := i;
421
	            	k := i;
435
	            	IF (c = "'") OR (c = '"') THEN
422
	            	IF (c = "'") OR (c = '"') THEN
436
	            		String(text, line, i, y, backColor);
423
	            		String(text, line, i, y, backColor);
437
	            	ELSE
424
	            	ELSE
438
	            		ident(text, i, i - ORD((lang = Lang.langC) & (i > 0) & (getChar(line, i - 1) = "#")), y, line, backColor, Lang.isCS(lang))
425
	            		ident(text, i, i - ORD((lang = Lang.langC) & (i > 0) & (Lines.getChar(line, i - 1) = "#")), y, line, backColor, Lang.isCS(lang))
439
	            	END;
426
	            	END;
440
	                IF lang = Lang.langJSON THEN
427
	                IF lang = Lang.langJSON THEN
441
		                WHILE Lines.isSpace(getChar(line, i + 1)) DO
428
		                WHILE Lines.isSpace(Lines.getChar(line, i + 1)) DO
442
		                	INC(i)
429
		                	INC(i)
443
		                END;
430
		                END;
444
		                IF getChar(line, i + 1) = ":" THEN
431
		                IF Lines.getChar(line, i + 1) = ":" THEN
445
		                	PrintLex(text, line, k, i, y, colors.key1, backColor)
432
		                	PrintLex(text, line, k, i, y, colors.key1, backColor)
446
		                END
433
		                END
447
	                END;
434
	                END;
448
	                cond := 0
435
	                cond := 0
449
	            ELSIF U.isDigit(c) THEN
436
	            ELSIF U.isDigit(c) THEN
450
	                k := i;
437
	                k := i;
451
	                INC(i);
438
	                INC(i);
452
	                c := getChar(line, i);
439
	                c := Lines.getChar(line, i);
453
	                IF c = "." THEN
440
	                IF c = "." THEN
454
	                    DEC(i);
441
	                    DEC(i);
455
	                    c := getChar(line, i)
442
	                    c := Lines.getChar(line, i)
456
	                END;
443
	                END;
457
	                IF (cap(c) = "X") & (getChar(line, i - 1) = "0") THEN
444
	                IF (cap(c) = "X") & (Lines.getChar(line, i - 1) = "0") THEN
458
	                    REPEAT
445
	                    REPEAT
459
	                        INC(i);
446
	                        INC(i);
460
	                        c := getChar(line, i)
447
	                        c := Lines.getChar(line, i)
461
	                    UNTIL ~U.isHex(cap(c));
448
	                    UNTIL ~U.isHex(cap(c));
462
	                    IF UL(c) THEN
449
	                    IF UL(c) THEN
463
	                        INC(i)
450
	                        INC(i)
464
	                    END
451
	                    END
465
	                ELSIF UL(c) THEN
452
	                ELSIF UL(c) THEN
466
	                    INC(i)
453
	                    INC(i)
467
	                ELSIF U.isDigit(c) THEN
454
	                ELSIF U.isDigit(c) THEN
468
	                    REPEAT
455
	                    REPEAT
469
	                        INC(i)
456
	                        INC(i)
470
	                    UNTIL ~U.isDigit(getChar(line, i));
457
	                    UNTIL ~U.isDigit(Lines.getChar(line, i));
471
	                    c := getChar(line, i);
458
	                    c := Lines.getChar(line, i);
472
	                    IF UL(c) THEN
459
	                    IF UL(c) THEN
473
	                        INC(i)
460
	                        INC(i)
474
	                    ELSIF c = "." THEN
461
	                    ELSIF c = "." THEN
475
	                        INC(i);
462
	                        INC(i);
476
	                        WHILE U.isDigit(getChar(line, i)) DO
463
	                        WHILE U.isDigit(Lines.getChar(line, i)) DO
477
	                            INC(i)
464
	                            INC(i)
478
	                        END;
465
	                        END;
479
	                        c := getChar(line, i);
466
	                        c := Lines.getChar(line, i);
480
	                        IF cap(c) = "E" THEN
467
	                        IF cap(c) = "E" THEN
481
	                            INC(i);
468
	                            INC(i);
482
	                            c := getChar(line, i);
469
	                            c := Lines.getChar(line, i);
483
	                            IF (c = "+") OR (c = "-") THEN
470
	                            IF (c = "+") OR (c = "-") THEN
484
	                                INC(i)
471
	                                INC(i)
485
	                            END;
472
	                            END;
486
	                            IF U.isDigit(getChar(line, i)) THEN
473
	                            IF U.isDigit(Lines.getChar(line, i)) THEN
487
	                                WHILE U.isDigit(getChar(line, i)) DO
474
	                                WHILE U.isDigit(Lines.getChar(line, i)) DO
488
	                                    INC(i)
475
	                                    INC(i)
489
	                                END;
476
	                                END;
490
	                                c := getChar(line, i);
477
	                                c := Lines.getChar(line, i);
491
	                                IF FL(c) THEN
478
	                                IF FL(c) THEN
492
	                                    INC(i)
479
	                                    INC(i)
493
	                                END
480
	                                END
494
	                            END
481
	                            END
495
	                        ELSIF FL(c) THEN
482
	                        ELSIF FL(c) THEN
Line 529... Line 516...
529
	            cond := 0
516
	            cond := 0
530
	        ELSIF (depth = 0) & U.isDigit(c) THEN
517
	        ELSIF (depth = 0) & U.isDigit(c) THEN
531
	            color := colors.num;
518
	            color := colors.num;
532
	            k := i;
519
	            k := i;
533
	            INC(i);
520
	            INC(i);
534
	            WHILE U.isHex(getChar(line, i)) DO
521
	            WHILE U.isHex(Lines.getChar(line, i)) DO
535
	                INC(i)
522
	                INC(i)
536
	            END;
523
	            END;
537
	            IF i <= n THEN
524
	            IF i <= n THEN
538
	                IF getChar(line, i) = "." THEN
525
	                IF Lines.getChar(line, i) = "." THEN
539
	                    INC(i);
526
	                    INC(i);
540
	                    IF getChar(line, i) = "." THEN
527
	                    IF Lines.getChar(line, i) = "." THEN
541
	                        DEC(i)
528
	                        DEC(i)
542
	                    END;
529
	                    END;
543
	                    WHILE U.isDigit(getChar(line, i)) DO
530
	                    WHILE U.isDigit(Lines.getChar(line, i)) DO
544
	                        INC(i)
531
	                        INC(i)
545
	                    END;
532
	                    END;
546
	                    IF getChar(line, i) = "E" THEN
533
	                    IF Lines.getChar(line, i) = "E" THEN
547
	                        INC(i);
534
	                        INC(i);
548
	                        IF (getChar(line, i) = "+") OR (getChar(line, i) = "-") THEN
535
	                        IF (Lines.getChar(line, i) = "+") OR (Lines.getChar(line, i) = "-") THEN
549
	                            INC(i)
536
	                            INC(i)
550
	                        END;
537
	                        END;
551
	                        WHILE U.isDigit(getChar(line, i)) DO
538
	                        WHILE U.isDigit(Lines.getChar(line, i)) DO
552
	                            INC(i)
539
	                            INC(i)
553
	                        END
540
	                        END
554
	                    END
541
	                    END
555
	                ELSIF getChar(line, i) = "H" THEN
542
	                ELSIF Lines.getChar(line, i) = "H" THEN
556
	                    INC(i)
543
	                    INC(i)
557
	                ELSIF getChar(line, i) = "X" THEN
544
	                ELSIF Lines.getChar(line, i) = "X" THEN
558
	                    color := colors.string;
545
	                    color := colors.string;
559
	                    INC(i)
546
	                    INC(i)
560
	                END
547
	                END
561
	            END;
548
	            END;
562
	            DEC(i);
549
	            DEC(i);
Line 616... Line 603...
616
	            ELSIF (c = "'") OR (c = '"') THEN
603
	            ELSIF (c = "'") OR (c = '"') THEN
617
	                String(text, line, i, y, backColor);
604
	                String(text, line, i, y, backColor);
618
	                cond := 0
605
	                cond := 0
619
	            ELSIF U.isDigit(c) THEN
606
	            ELSIF U.isDigit(c) THEN
620
	                k := i;
607
	                k := i;
621
	                IF (c = "0") & (cap(getChar(line, i + 1)) = "X") THEN
608
	                IF (c = "0") & (cap(Lines.getChar(line, i + 1)) = "X") THEN
622
	                    isDgt := U.isHex;
609
	                    isDgt := U.isHex;
623
	                    hex := TRUE;
610
	                    hex := TRUE;
624
	                    INC(i, 2)
611
	                    INC(i, 2)
625
	                ELSE
612
	                ELSE
626
	                    isDgt := U.isDigit;
613
	                    isDgt := U.isDigit;
627
	                    hex := FALSE
614
	                    hex := FALSE
628
	                END;
615
	                END;
629
	                WHILE isDgt(cap(getChar(line, i))) DO
616
	                WHILE isDgt(cap(Lines.getChar(line, i))) DO
630
	                    INC(i)
617
	                    INC(i)
631
	                END;
618
	                END;
632
	                IF getChar(line, i) = "." THEN
619
	                IF Lines.getChar(line, i) = "." THEN
633
	                    INC(i);
620
	                    INC(i);
634
	                    IF getChar(line, i) = "." THEN
621
	                    IF Lines.getChar(line, i) = "." THEN
635
	                        DEC(i)
622
	                        DEC(i)
636
	                    END;
623
	                    END;
637
	                    WHILE isDgt(cap(getChar(line, i))) DO
624
	                    WHILE isDgt(cap(Lines.getChar(line, i))) DO
638
	                        INC(i)
625
	                        INC(i)
639
	                    END
626
	                    END
640
	                END;
627
	                END;
641
	                IF (cap(getChar(line, i)) = "E") OR hex & (cap(getChar(line, i)) = "P") THEN
628
	                IF (cap(Lines.getChar(line, i)) = "E") OR hex & (cap(Lines.getChar(line, i)) = "P") THEN
642
	                    INC(i);
629
	                    INC(i);
643
	                    IF (getChar(line, i) = "-") OR (getChar(line, i) = "+") THEN
630
	                    IF (Lines.getChar(line, i) = "-") OR (Lines.getChar(line, i) = "+") THEN
644
	                        INC(i)
631
	                        INC(i)
645
	                    END;
632
	                    END;
646
	                    WHILE isDgt(cap(getChar(line, i))) DO
633
	                    WHILE isDgt(cap(Lines.getChar(line, i))) DO
647
	                        INC(i)
634
	                        INC(i)
648
	                    END
635
	                    END
649
	                END;
636
	                END;
650
	                DEC(i);
637
	                DEC(i);
651
	                PrintLex(text, line, k, i, y, colors.num, backColor);
638
	                PrintLex(text, line, k, i, y, colors.num, backColor);
Line 690... Line 677...
690
	                END
677
	                END
691
	            ELSIF c = "'" THEN
678
	            ELSIF c = "'" THEN
692
	                String(text, line, i, y, backColor);
679
	                String(text, line, i, y, backColor);
693
	                cond := 0
680
	                cond := 0
694
	            ELSIF c = "{" THEN
681
	            ELSIF c = "{" THEN
695
	                IF getChar(line, i + 1) = "$" THEN
682
	                IF Lines.getChar(line, i + 1) = "$" THEN
696
	                    depth := 3
683
	                    depth := 3
697
	                ELSE
684
	                ELSE
698
	                    depth := 1
685
	                    depth := 1
699
	                END;
686
	                END;
700
	                INC(i);
687
	                INC(i);
701
	                PrintComment(text, line, depth, i, 1, y, backColor);
688
	                PrintComment(text, line, depth, i, 1, y, backColor);
702
	                cond := 0
689
	                cond := 0
703
	            ELSIF c = "#" THEN
690
	            ELSIF c = "#" THEN
704
	                k := i;
691
	                k := i;
705
	                INC(i);
692
	                INC(i);
706
	                WHILE U.isDigit(getChar(line, i)) DO
693
	                WHILE U.isDigit(Lines.getChar(line, i)) DO
707
	                    INC(i)
694
	                    INC(i)
708
	                END;
695
	                END;
709
	                DEC(i);
696
	                DEC(i);
710
	                PrintLex(text, line, k, i, y, colors.string, backColor);
697
	                PrintLex(text, line, k, i, y, colors.string, backColor);
711
	                cond := 0
698
	                cond := 0
712
	            ELSIF c = "$" THEN
699
	            ELSIF c = "$" THEN
713
	                IF (i > 0 ) & (getChar(line, i - 1) = "#") THEN
700
	                IF (i > 0 ) & (Lines.getChar(line, i - 1) = "#") THEN
714
	                    color := colors.string
701
	                    color := colors.string
715
	                ELSE
702
	                ELSE
716
	                    color := colors.num
703
	                    color := colors.num
717
	                END;
704
	                END;
718
	                k := i;
705
	                k := i;
719
	                INC(i);
706
	                INC(i);
720
	                WHILE U.isHex(cap(getChar(line, i))) DO
707
	                WHILE U.isHex(cap(Lines.getChar(line, i))) DO
721
	                    INC(i)
708
	                    INC(i)
722
	                END;
709
	                END;
723
	                DEC(i);
710
	                DEC(i);
724
	                PrintLex(text, line, k, i, y, color, backColor);
711
	                PrintLex(text, line, k, i, y, color, backColor);
725
	                cond := 0
712
	                cond := 0
726
	            ELSIF U.isDigit(c) THEN
713
	            ELSIF U.isDigit(c) THEN
727
	                k := i;
714
	                k := i;
728
	                WHILE U.isDigit(getChar(line, i)) DO
715
	                WHILE U.isDigit(Lines.getChar(line, i)) DO
729
	                    INC(i)
716
	                    INC(i)
730
	                END;
717
	                END;
731
	                IF getChar(line, i) = "." THEN
718
	                IF Lines.getChar(line, i) = "." THEN
732
	                    INC(i);
719
	                    INC(i);
733
	                    IF getChar(line, i) = "." THEN
720
	                    IF Lines.getChar(line, i) = "." THEN
734
	                        DEC(i)
721
	                        DEC(i)
735
	                    END;
722
	                    END;
736
	                    WHILE U.isDigit(getChar(line, i)) DO
723
	                    WHILE U.isDigit(Lines.getChar(line, i)) DO
737
	                        INC(i)
724
	                        INC(i)
738
	                    END;
725
	                    END;
739
	                    IF cap(getChar(line, i)) = "E" THEN
726
	                    IF cap(Lines.getChar(line, i)) = "E" THEN
740
	                        INC(i);
727
	                        INC(i);
741
	                        IF (getChar(line, i) = "-") OR (getChar(line, i) = "+") THEN
728
	                        IF (Lines.getChar(line, i) = "-") OR (Lines.getChar(line, i) = "+") THEN
742
	                            INC(i)
729
	                            INC(i)
743
	                        END;
730
	                        END;
744
	                        WHILE U.isDigit(getChar(line, i)) DO
731
	                        WHILE U.isDigit(Lines.getChar(line, i)) DO
745
	                            INC(i)
732
	                            INC(i)
746
	                        END
733
	                        END
747
	                    END
734
	                    END
748
	                END;
735
	                END;
749
	                DEC(i);
736
	                DEC(i);
Line 782... Line 769...
782
	                depth := 1;
769
	                depth := 1;
783
	                INC(i);
770
	                INC(i);
784
	                PrintComment(text, line, depth, i, 1, y, backColor)
771
	                PrintComment(text, line, depth, i, 1, y, backColor)
785
	            ELSIF U.isDigit(c) THEN
772
	            ELSIF U.isDigit(c) THEN
786
	                k := i;
773
	                k := i;
787
	                WHILE U.isDigit(getChar(line, i)) DO
774
	                WHILE U.isDigit(Lines.getChar(line, i)) DO
788
	                    INC(i)
775
	                    INC(i)
789
	                END;
776
	                END;
790
	                DEC(i);
777
	                DEC(i);
791
	                PrintLex(text, line, k, i, y, colors.num, backColor)
778
	                PrintLex(text, line, k, i, y, colors.num, backColor)
792
	            ELSIF (U.isLetter(c) OR (c = "_")) THEN
779
	            ELSIF (U.isLetter(c) OR (c = "_")) THEN
Line 807... Line 794...
807
PROCEDURE leadingSpaces (line: tLine): INTEGER;
794
PROCEDURE leadingSpaces (line: tLine): INTEGER;
808
VAR
795
VAR
809
    i: INTEGER;
796
    i: INTEGER;
810
BEGIN
797
BEGIN
811
    i := 0;
798
    i := 0;
812
    WHILE Lines.isSpace(getChar(line, i)) DO
799
    WHILE Lines.isSpace(Lines.getChar(line, i)) DO
813
        INC(i)
800
        INC(i)
814
    END
801
    END
815
    RETURN i
802
    RETURN i
816
END leadingSpaces;
803
END leadingSpaces;
Line 975... Line 962...
975
        ELSE
962
        ELSE
976
            text.curLine := getLine(text, y)
963
            text.curLine := getLine(text, y)
977
        END
964
        END
978
    END;
965
    END;
979
    cursor.X := MIN(MAX(x, 0), text.curLine.length);
966
    cursor.X := MIN(MAX(x, 0), text.curLine.length);
980
    c := getChar(text.curLine, cursor.X);
967
    c := Lines.getChar(text.curLine, cursor.X);
981
    IF c = TAB1 THEN
968
    IF c = TAB1 THEN
982
        n := cursor.X;
969
        n := cursor.X;
983
        WHILE getChar(text.curLine, n) = TAB1 DO
970
        WHILE Lines.getChar(text.curLine, n) = TAB1 DO
984
            INC(n)
971
            INC(n)
985
        END;
972
        END;
986
        R := n - cursor.X;
973
        R := n - cursor.X;
987
        n := cursor.X;
974
        n := cursor.X;
988
        WHILE getChar(text.curLine, n) # TAB DO
975
        WHILE Lines.getChar(text.curLine, n) # TAB DO
989
            DEC(n)
976
            DEC(n)
990
        END;
977
        END;
991
        L := cursor.X - n;
978
        L := cursor.X - n;
992
        IF L < R THEN
979
        IF L < R THEN
993
            DEC(cursor.X, L)
980
            DEC(cursor.X, L)
Line 1076... Line 1063...
1076
        i := text.cursor.X;
1063
        i := text.cursor.X;
1077
        curLine := text.curLine;
1064
        curLine := text.curLine;
1078
        IF i < curLine.length THEN
1065
        IF i < curLine.length THEN
1079
            n := i;
1066
            n := i;
1080
            INC(i);
1067
            INC(i);
1081
            IF getChar(curLine, i - 1) = TAB THEN
1068
            IF Lines.getChar(curLine, i - 1) = TAB THEN
1082
                WHILE getChar(curLine, i) = TAB1 DO
1069
                WHILE Lines.getChar(curLine, i) = TAB1 DO
1083
                    INC(i)
1070
                    INC(i)
1084
                END
1071
                END
1085
            END;
1072
            END;
1086
            Lines.delCharN(curLine, n, i - n);
1073
            Lines.delCharN(curLine, n, i - n);
1087
            Lines.modify(curLine);
1074
            Lines.modify(curLine);
Line 1103... Line 1090...
1103
PROCEDURE move (text: tText; d: INTEGER);
1090
PROCEDURE move (text: tText; d: INTEGER);
1104
VAR
1091
VAR
1105
    pos: INTEGER;
1092
    pos: INTEGER;
1106
BEGIN
1093
BEGIN
1107
    pos := text.cursor.X + d;
1094
    pos := text.cursor.X + d;
1108
    WHILE getChar(text.curLine, pos) = TAB1 DO
1095
    WHILE Lines.getChar(text.curLine, pos) = TAB1 DO
1109
        INC(pos, d)
1096
        INC(pos, d)
1110
    END;
1097
    END;
1111
    SetPos(text, pos, text.cursor.Y)
1098
    SetPos(text, pos, text.cursor.Y)
1112
END move;
1099
END move;
Line 1146... Line 1133...
1146
                END;
1133
                END;
1147
                n := k;
1134
                n := k;
1148
                Lines.delCharN(curLine, 0, i);
1135
                Lines.delCharN(curLine, 0, i);
1149
                Lines.insert3(curLine, 0, k);
1136
                Lines.insert3(curLine, 0, k);
1150
                WHILE k > 0 DO
1137
                WHILE k > 0 DO
1151
                    Lines.setChar(curLine, k - 1, getChar(line2, k - 1));
1138
                    Lines.setChar(curLine, k - 1, Lines.getChar(line2, k - 1));
1152
                    DEC(k)
1139
                    DEC(k)
1153
                END;
1140
                END;
1154
                Lines.modify(curLine);
1141
                Lines.modify(curLine);
1155
                SetPos(text, n, text.cursor.Y)
1142
                SetPos(text, n, text.cursor.Y)
1156
            END
1143
            END
Line 1195... Line 1182...
1195
    END;
1182
    END;
1196
    Lines.insert3(text.curLine, 0, n);
1183
    Lines.insert3(text.curLine, 0, n);
1197
    SetPos(text, n, text.cursor.Y);
1184
    SetPos(text, n, text.cursor.Y);
1198
    resetSelect(text);
1185
    resetSelect(text);
1199
    WHILE n > 0 DO
1186
    WHILE n > 0 DO
1200
        Lines.setChar(text.curLine, n - 1, getChar(line2, n - 1));
1187
        Lines.setChar(text.curLine, n - 1, Lines.getChar(line2, n - 1));
1201
        DEC(n)
1188
        DEC(n)
1202
    END;
1189
    END;
1203
    Lines.modify(newLine)
1190
    Lines.modify(newLine)
1204
END enter;
1191
END enter;
Line 1462... Line 1449...
1462
	VAR
1449
	VAR
1463
		i, res: INTEGER;
1450
		i, res: INTEGER;
1464
	BEGIN
1451
	BEGIN
1465
		res := 0;
1452
		res := 0;
1466
		FOR i := first TO last DO
1453
		FOR i := first TO last DO
1467
			IF getChar(line, i) # TAB1 THEN
1454
			IF Lines.getChar(line, i) # TAB1 THEN
1468
				INC(res)
1455
				INC(res)
1469
			END
1456
			END
1470
		END
1457
		END
1471
		RETURN res
1458
		RETURN res
1472
	END charCnt;
1459
	END charCnt;
Line 1478... Line 1465...
1478
		last  := getLine(text, selEnd.Y);
1465
		last  := getLine(text, selEnd.Y);
1479
		lines := selEnd.Y - selBeg.Y + 1;
1466
		lines := selEnd.Y - selBeg.Y + 1;
Line 1480... Line 1467...
1480
 
1467
 
1481
		IF lines > 1 THEN
1468
		IF lines > 1 THEN
1482
			chars := charCnt(first, selBeg.X, first.length - 1) + charCnt(last, 0, selEnd.X - 1) + lenEOL;
1469
			chars := charCnt(first, selBeg.X, first.length - 1) + charCnt(last, 0, selEnd.X - 1) + lenEOL;
1483
			line := first.next(tLine)
-
 
1484
		ELSE
-
 
1485
			chars := charCnt(first, selBeg.X, selEnd.X - 1);
-
 
1486
			line := last
-
 
1487
		END;
-
 
1488
 
1470
			line := first.next(tLine);
1489
		WHILE line # last DO
1471
			WHILE line # last DO
1490
			INC(chars, charCnt(line, 0, line.length - 1) + lenEOL);
1472
				INC(chars, charCnt(line, 0, line.length - 1) + lenEOL);
1491
			NextLine(line)
1473
				NextLine(line)
1492
		END
1474
			END
-
 
1475
		ELSE
-
 
1476
			chars := charCnt(first, selBeg.X, selEnd.X - 1)
-
 
1477
		END
1493
	ELSE
1478
	ELSE
1494
		chars := 0;
1479
		chars := 0;
1495
		lines := 0
1480
		lines := 0
1496
	END
1481
	END
Line 1570... Line 1555...
1570
    	c: WCHAR;
1555
    	c: WCHAR;
1571
    BEGIN
1556
    BEGIN
1572
    	res := pos;
1557
    	res := pos;
1573
    	i := 0;
1558
    	i := 0;
1574
    	REPEAT
1559
    	REPEAT
1575
	    	c := getChar(line, i);
1560
	    	c := Lines.getChar(line, i);
1576
	    	IF c = TAB THEN
1561
	    	IF c = TAB THEN
1577
	    		INC(res, Lines.tab - res MOD Lines.tab)
1562
	    		INC(res, Lines.tab - res MOD Lines.tab)
1578
	    	ELSIF c # TAB1 THEN
1563
	    	ELSIF c # TAB1 THEN
1579
	    		INC(res)
1564
	    		INC(res)
1580
	    	END;
1565
	    	END;
Line 1705... Line 1690...
1705
    line: tLine;
1690
    line: tLine;
1706
BEGIN
1691
BEGIN
1707
    line := text.curLine;
1692
    line := text.curLine;
1708
    i := text.cursor.X - 1;
1693
    i := text.cursor.X - 1;
Line 1709... Line 1694...
1709
 
1694
 
1710
    WHILE (i >= 0) & U.isLetter(getChar(line, i)) DO
1695
    WHILE (i >= 0) & U.isLetter(Lines.getChar(line, i)) DO
1711
        DEC(i)
1696
        DEC(i)
Line 1712... Line 1697...
1712
    END;
1697
    END;
1713
 
1698
 
Line 1913... Line 1898...
1913
        i := 0;
1898
        i := 0;
1914
        WHILE (i < n) & isWordChar(str[i]) DO
1899
        WHILE (i < n) & isWordChar(str[i]) DO
1915
            INC(i)
1900
            INC(i)
1916
        END;
1901
        END;
1917
        IF (i # n) OR
1902
        IF (i # n) OR
1918
            ((x1 > 0) & isWordChar(getChar(curLine, x1 - 1))) OR
1903
            ((x1 > 0) & isWordChar(Lines.getChar(curLine, x1 - 1))) OR
1919
            ((x2 < curLine.length) & isWordChar(getChar(curLine, x2))) THEN
1904
            ((x2 < curLine.length) & isWordChar(Lines.getChar(curLine, x2))) THEN
1920
            str := ""
1905
            str := ""
1921
        END
1906
        END
1922
    END;
1907
    END;
1923
    IF search(text, str, Lang.isCS(text.lang), TRUE) THEN END
1908
    IF search(text, str, Lang.isCS(text.lang), TRUE) THEN END
1924
END wordSel;
1909
END wordSel;
Line 1926... Line 1911...
1926
 
1911
 
1927
PROCEDURE getWordPos (line: tLine; pos: INTEGER): INTEGER;
1912
PROCEDURE getWordPos (line: tLine; pos: INTEGER): INTEGER;
1928
VAR
1913
VAR
1929
	c: WCHAR;
1914
	c: WCHAR;
1930
BEGIN
1915
BEGIN
1931
	c := getChar(line, pos);
1916
	c := Lines.getChar(line, pos);
1932
	IF isWordChar(c) THEN
1917
	IF isWordChar(c) THEN
1933
		WHILE (pos < line.length) & isWordChar(getChar(line, pos)) DO
1918
		WHILE (pos < line.length) & isWordChar(Lines.getChar(line, pos)) DO
1934
			INC(pos)
1919
			INC(pos)
1935
		END
1920
		END
1936
	ELSIF Lines.isSpace(c) THEN
1921
	ELSIF Lines.isSpace(c) THEN
1937
		WHILE (pos < line.length) & Lines.isSpace(getChar(line, pos)) DO
1922
		WHILE (pos < line.length) & Lines.isSpace(Lines.getChar(line, pos)) DO
1938
			INC(pos)
1923
			INC(pos)
1939
		END
1924
		END
1940
	ELSE
1925
	ELSE
1941
		WHILE (pos < line.length) & ~Lines.isSpace(getChar(line, pos)) & ~isWordChar(getChar(line, pos)) DO
1926
		WHILE (pos < line.length) & ~Lines.isSpace(Lines.getChar(line, pos)) & ~isWordChar(Lines.getChar(line, pos)) DO
1942
			INC(pos)
1927
			INC(pos)
1943
		END
1928
		END
1944
	END
1929
	END
1945
	RETURN pos
1930
	RETURN pos
Line 1984... Line 1969...
1984
    |36:
1969
    |36:
1985
        IF ctrl THEN
1970
        IF ctrl THEN
1986
            SetPos(text, 0, 0)
1971
            SetPos(text, 0, 0)
1987
        ELSE
1972
        ELSE
1988
        	n := leadingSpaces(text.curLine);
1973
        	n := leadingSpaces(text.curLine);
1989
        	IF text.cursor.X > n THEN
1974
        	IF text.cursor.X <= n THEN
-
 
1975
	            n := 0
-
 
1976
        	END;
1990
	            SetPos(text, n, text.cursor.Y)
1977
        	SetPos(text, n, text.cursor.Y)
1991
        	ELSE
-
 
1992
        		SetPos(text, 0, text.cursor.Y)
-
 
1993
        	END
-
 
1994
        END
1978
        END
1995
    |37:
1979
    |37:
1996
        IF (text.cursor.X = 0) & (text.curLine.prev # NIL) THEN
1980
        IF (text.cursor.X = 0) & (text.curLine.prev # NIL) THEN
1997
            SetPos(text, text.curLine.prev(tLine).length, text.cursor.Y - 1)
1981
            SetPos(text, text.curLine.prev(tLine).length, text.cursor.Y - 1)
1998
        ELSE
1982
        ELSE
Line 2034... Line 2018...
2034
            delLine(text)
2018
            delLine(text)
2035
        ELSE
2019
        ELSE
2036
            delete(text);
2020
            delete(text);
2037
            ShowCursor
2021
            ShowCursor
2038
        END
2022
        END
2039
    |ORD("C"):
2023
    |ORD("C"), ORD("X"):
2040
        IF ctrl THEN
-
 
2041
            IF selected(text) THEN
-
 
2042
                copy(text)
-
 
2043
            END
-
 
2044
        END
-
 
2045
    |ORD("X"):
-
 
2046
        IF ctrl THEN
2024
        IF ctrl THEN
2047
            IF selected(text) THEN
2025
            IF selected(text) THEN
2048
                copy(text);
2026
                copy(text);
-
 
2027
                IF code = ORD("X") THEN
2049
                delSelect(text)
2028
                	delSelect(text)
2050
            END
2029
                END
2051
        END
2030
            END
-
 
2031
        END
2052
    |ORD("V"):
2032
    |ORD("V"):
2053
        IF ctrl THEN
2033
        IF ctrl THEN
2054
            IF CB.available() THEN
2034
            IF CB.available() THEN
2055
                paste(text)
2035
                paste(text)
2056
            END
2036
            END
Line 2098... Line 2078...
2098
BEGIN
2078
BEGIN
2099
    resetSelect(text);
2079
    resetSelect(text);
2100
    cursorX := text.cursor.X;
2080
    cursorX := text.cursor.X;
2101
    line := text.curLine;
2081
    line := text.curLine;
2102
    x1 := cursorX - 1;
2082
    x1 := cursorX - 1;
2103
    IF (cursorX < line.length) & isWordChar(getChar(line, cursorX)) THEN
2083
    IF (cursorX < line.length) & isWordChar(Lines.getChar(line, cursorX)) THEN
2104
        x2 := cursorX;
2084
        x2 := cursorX;
2105
        WHILE (x2 < line.length) & isWordChar(getChar(line, x2)) DO
2085
        WHILE (x2 < line.length) & isWordChar(Lines.getChar(line, x2)) DO
2106
            INC(x2)
2086
            INC(x2)
2107
        END
2087
        END
2108
    ELSE
2088
    ELSE
2109
        WHILE (x1 >= 0) & ~isWordChar(getChar(line, x1)) DO
2089
        WHILE (x1 >= 0) & ~isWordChar(Lines.getChar(line, x1)) DO
2110
            DEC(x1)
2090
            DEC(x1)
2111
        END;
2091
        END;
2112
        x2 := x1 + 1
2092
        x2 := x1 + 1
2113
    END;
2093
    END;
2114
    WHILE (x1 >= 0) & isWordChar(getChar(line, x1)) DO
2094
    WHILE (x1 >= 0) & isWordChar(Lines.getChar(line, x1)) DO
2115
        DEC(x1)
2095
        DEC(x1)
2116
    END;
2096
    END;
2117
    INC(x1);
2097
    INC(x1);
2118
    IF x1 < x2 THEN
2098
    IF x1 < x2 THEN
2119
        SetPos(text, x1, text.cursor.Y);
2099
        SetPos(text, x1, text.cursor.Y);
Line 2406... Line 2386...
2406
    colors.key2 := key2;
2386
    colors.key2 := key2;
2407
    colors.key3 := key3;
2387
    colors.key3 := key3;
2408
END setColors;
2388
END setColors;
Line 2409... Line 2389...
2409
 
2389
 
2410
 
2390
 
2411
PROCEDURE setCanvas* (Canvas: G.tCanvas);
2391
PROCEDURE setCanvas* (_canvas: G.tCanvas);
2412
BEGIN
2392
BEGIN
2413
    canvas := Canvas;
2393
    canvas := _canvas;
2414
    charWidth := canvas.font.width;
2394
    charWidth := _canvas.font.width;
Line 2415... Line 2395...
2415
    charHeight := canvas.font.height + inter
2395
    charHeight := _canvas.font.height + inter
2416
END setCanvas;
2396
END setCanvas;
Line 2606... Line 2586...
2606
BEGIN
2586
BEGIN
2607
    text := create("");
2587
    text := create("");
2608
    List._append(text, Lines.create(FALSE));
2588
    List._append(text, Lines.create(FALSE));
2609
    text.curLine := text.first(tLine);
2589
    text.curLine := text.first(tLine);
2610
    ChangeLog.changeInt(text.enc, E.CP866);
2590
    ChangeLog.changeInt(text.enc, E.CP866);
2611
    ChangeLog.changeInt(text.eol, RW.EOL_CRLF);
2591
    ChangeLog.changeInt(text.eol, E.EOL_CRLF);
2612
    text.enc := E.CP866;
2592
    text.enc := E.CP866;
2613
    text.eol := RW.EOL_CRLF;
2593
    text.eol := E.EOL_CRLF;
2614
    SetPos(text, 0, 0);
2594
    SetPos(text, 0, 0);
2615
    resetSelect(text)
2595
    resetSelect(text)
2616
    RETURN text
2596
    RETURN text
2617
END New;
2597
END New;