Subversion Repositories Kolibri OS

Rev

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

Rev 9902 Rev 9903
Line 117... Line 117...
117
VAR
117
VAR
118
    ext: RW.tFileName;
118
    ext: RW.tFileName;
119
BEGIN
119
BEGIN
120
    text.fileName := name;
120
    text.fileName := name;
121
    U.getFileName(name, ext, ".");
121
    U.getFileName(name, ext, ".");
122
    U.upcase(ext);
122
    U.lowcase8(ext);
123
    setLang(text, Lang.getLang(ext))
123
    setLang(text, Lang.getLang(ext))
124
END setName;
124
END setName;
Line 125... Line 125...
125
 
125
 
Line 350... Line 350...
350
        ProcessComments(line, depth, i, 0, line.length - 1, text.lang);
350
        ProcessComments(line, depth, i, 0, line.length - 1, text.lang);
351
        PrintLex(text, line, lexStart, i, y, color, backColor)
351
        PrintLex(text, line, lexStart, i, y, color, backColor)
352
    END PrintComment;
352
    END PrintComment;
Line 353... Line 353...
353
 
353
 
354
 
354
 
355
    PROCEDURE cap (c: WCHAR): WCHAR;
355
    PROCEDURE upper (c: WCHAR): WCHAR;
356
    BEGIN
356
    BEGIN
357
        IF U.cap(c) THEN END
357
        IF U.upper(c) THEN END
Line 358... Line 358...
358
        RETURN c
358
        RETURN c
359
    END cap;
359
    END upper;
360
 
360
 
Line 361... Line 361...
361
 
361
 
362
    PROCEDURE UL (c: WCHAR): BOOLEAN;
362
    PROCEDURE UL (c: WCHAR): BOOLEAN;
363
        RETURN (cap(c) = "U") OR (cap(c) = "L")
363
        RETURN (upper(c) = "U") OR (upper(c) = "L")
Line 364... Line 364...
364
    END UL;
364
    END UL;
365
 
365
 
Line 382... Line 382...
382
            c := Lines.getChar(line, i);
382
            c := Lines.getChar(line, i);
383
        END;
383
        END;
384
        DEC(i);
384
        DEC(i);
385
        lexLen := getString(line, first, i - first + 1, s);
385
        lexLen := getString(line, first, i - first + 1, s);
386
        IF ~cs THEN
386
        IF ~cs THEN
387
            U.upcase16(s)
387
            U.lowcase(s)
388
        END;
388
        END;
389
        IF Lang.isKey(s, text.lang, 1) THEN
389
        IF Lang.isKey(s, text.lang, 1) THEN
390
            color := colors.key1
390
            color := colors.key1
391
        ELSIF Lang.isKey(s, text.lang, 2) THEN
391
        ELSIF Lang.isKey(s, text.lang, 2) THEN
392
            color := colors.key2
392
            color := colors.key2
Line 449... Line 449...
449
            ELSIF U.isDigit(c) THEN
449
            ELSIF U.isDigit(c) THEN
450
                hex := FALSE;
450
                hex := FALSE;
451
                k := i;
451
                k := i;
452
                INC(i);
452
                INC(i);
453
                c := Lines.getChar(line, i);
453
                c := Lines.getChar(line, i);
454
                IF (cap(c) = "X") & (Lines.getChar(line, i - 1) = "0") THEN
454
                IF (upper(c) = "X") & (Lines.getChar(line, i - 1) = "0") THEN
455
                    INC(i);
455
                    INC(i);
456
                    hex := TRUE
456
                    hex := TRUE
457
                END;
457
                END;
Line 458... Line 458...
458
 
458
 
459
                WHILE U.isHex(cap(Lines.getChar(line, i))) DO
459
                WHILE U.isHex(upper(Lines.getChar(line, i))) DO
460
                    INC(i)
460
                    INC(i)
Line 461... Line 461...
461
                END;
461
                END;
462
 
462
 
463
                IF (cap(Lines.getChar(line, i)) = "H") & ~hex THEN
463
                IF (upper(Lines.getChar(line, i)) = "H") & ~hex THEN
Line 464... Line 464...
464
                    INC(i)
464
                    INC(i)
465
                END;
465
                END;
Line 506... Line 506...
506
	                c := Lines.getChar(line, i);
506
	                c := Lines.getChar(line, i);
507
	                IF c = "." THEN
507
	                IF c = "." THEN
508
	                    DEC(i);
508
	                    DEC(i);
509
	                    c := Lines.getChar(line, i)
509
	                    c := Lines.getChar(line, i)
510
	                END;
510
	                END;
511
	                IF (cap(c) = "X") & (Lines.getChar(line, i - 1) = "0") THEN
511
	                IF (upper(c) = "X") & (Lines.getChar(line, i - 1) = "0") THEN
512
	                    REPEAT
512
	                    REPEAT
513
	                        INC(i);
513
	                        INC(i);
514
	                        c := Lines.getChar(line, i)
514
	                        c := Lines.getChar(line, i)
515
	                    UNTIL ~U.isHex(cap(c));
515
	                    UNTIL ~U.isHex(upper(c));
516
	                    IF UL(c) THEN
516
	                    IF UL(c) THEN
517
	                        INC(i)
517
	                        INC(i)
518
	                    END
518
	                    END
519
	                ELSIF UL(c) THEN
519
	                ELSIF UL(c) THEN
520
	                    INC(i)
520
	                    INC(i)
Line 529... Line 529...
529
	                        INC(i);
529
	                        INC(i);
530
	                        WHILE U.isDigit(Lines.getChar(line, i)) DO
530
	                        WHILE U.isDigit(Lines.getChar(line, i)) DO
531
	                            INC(i)
531
	                            INC(i)
532
	                        END;
532
	                        END;
533
	                        c := Lines.getChar(line, i);
533
	                        c := Lines.getChar(line, i);
534
	                        IF cap(c) = "E" THEN
534
	                        IF upper(c) = "E" THEN
535
	                            INC(i);
535
	                            INC(i);
536
	                            c := Lines.getChar(line, i);
536
	                            c := Lines.getChar(line, i);
537
	                            IF (c = "+") OR (c = "-") THEN
537
	                            IF (c = "+") OR (c = "-") THEN
538
	                                INC(i)
538
	                                INC(i)
539
	                            END;
539
	                            END;
Line 670... Line 670...
670
	            ELSIF (c = "'") OR (c = '"') THEN
670
	            ELSIF (c = "'") OR (c = '"') THEN
671
	                String(text, line, i, y, backColor);
671
	                String(text, line, i, y, backColor);
672
	                cond := 0
672
	                cond := 0
673
	            ELSIF U.isDigit(c) THEN
673
	            ELSIF U.isDigit(c) THEN
674
	                k := i;
674
	                k := i;
675
	                IF (c = "0") & (cap(Lines.getChar(line, i + 1)) = "X") THEN
675
	                IF (c = "0") & (upper(Lines.getChar(line, i + 1)) = "X") THEN
676
	                    isDgt := U.isHex;
676
	                    isDgt := U.isHex;
677
	                    hex := TRUE;
677
	                    hex := TRUE;
678
	                    INC(i, 2)
678
	                    INC(i, 2)
679
	                ELSE
679
	                ELSE
680
	                    isDgt := U.isDigit;
680
	                    isDgt := U.isDigit;
681
	                    hex := FALSE
681
	                    hex := FALSE
682
	                END;
682
	                END;
683
	                WHILE isDgt(cap(Lines.getChar(line, i))) DO
683
	                WHILE isDgt(upper(Lines.getChar(line, i))) DO
684
	                    INC(i)
684
	                    INC(i)
685
	                END;
685
	                END;
686
	                IF Lines.getChar(line, i) = "." THEN
686
	                IF Lines.getChar(line, i) = "." THEN
687
	                    INC(i);
687
	                    INC(i);
688
	                    IF Lines.getChar(line, i) = "." THEN
688
	                    IF Lines.getChar(line, i) = "." THEN
689
	                        DEC(i)
689
	                        DEC(i)
690
	                    END;
690
	                    END;
691
	                    WHILE isDgt(cap(Lines.getChar(line, i))) DO
691
	                    WHILE isDgt(upper(Lines.getChar(line, i))) DO
692
	                        INC(i)
692
	                        INC(i)
693
	                    END
693
	                    END
694
	                END;
694
	                END;
695
	                IF (cap(Lines.getChar(line, i)) = "E") OR hex & (cap(Lines.getChar(line, i)) = "P") THEN
695
	                IF (upper(Lines.getChar(line, i)) = "E") OR hex & (upper(Lines.getChar(line, i)) = "P") THEN
696
	                    INC(i);
696
	                    INC(i);
697
	                    IF (Lines.getChar(line, i) = "-") OR (Lines.getChar(line, i) = "+") THEN
697
	                    IF (Lines.getChar(line, i) = "-") OR (Lines.getChar(line, i) = "+") THEN
698
	                        INC(i)
698
	                        INC(i)
699
	                    END;
699
	                    END;
700
	                    WHILE isDgt(cap(Lines.getChar(line, i))) DO
700
	                    WHILE isDgt(upper(Lines.getChar(line, i))) DO
701
	                        INC(i)
701
	                        INC(i)
702
	                    END
702
	                    END
703
	                END;
703
	                END;
704
	                DEC(i);
704
	                DEC(i);
705
	                PrintLex(text, line, k, i, y, colors.num, backColor);
705
	                PrintLex(text, line, k, i, y, colors.num, backColor);
Line 769... Line 769...
769
	                ELSE
769
	                ELSE
770
	                    color := colors.num
770
	                    color := colors.num
771
	                END;
771
	                END;
772
	                k := i;
772
	                k := i;
773
	                INC(i);
773
	                INC(i);
774
	                WHILE U.isHex(cap(Lines.getChar(line, i))) DO
774
	                WHILE U.isHex(upper(Lines.getChar(line, i))) DO
775
	                    INC(i)
775
	                    INC(i)
776
	                END;
776
	                END;
777
	                DEC(i);
777
	                DEC(i);
778
	                PrintLex(text, line, k, i, y, color, backColor);
778
	                PrintLex(text, line, k, i, y, color, backColor);
779
	                cond := 0
779
	                cond := 0
Line 788... Line 788...
788
	                        DEC(i)
788
	                        DEC(i)
789
	                    END;
789
	                    END;
790
	                    WHILE U.isDigit(Lines.getChar(line, i)) DO
790
	                    WHILE U.isDigit(Lines.getChar(line, i)) DO
791
	                        INC(i)
791
	                        INC(i)
792
	                    END;
792
	                    END;
793
	                    IF cap(Lines.getChar(line, i)) = "E" THEN
793
	                    IF upper(Lines.getChar(line, i)) = "E" THEN
794
	                        INC(i);
794
	                        INC(i);
795
	                        IF (Lines.getChar(line, i) = "-") OR (Lines.getChar(line, i) = "+") THEN
795
	                        IF (Lines.getChar(line, i) = "-") OR (Lines.getChar(line, i) = "+") THEN
796
	                            INC(i)
796
	                            INC(i)
797
	                        END;
797
	                        END;
798
	                        WHILE U.isDigit(Lines.getChar(line, i)) DO
798
	                        WHILE U.isDigit(Lines.getChar(line, i)) DO
Line 904... Line 904...
904
	END;
904
	END;
905
	text.whole := whole;
905
	text.whole := whole;
906
	text.cs := cs;
906
	text.cs := cs;
907
	text.searchText := s;
907
	text.searchText := s;
908
	IF ~cs THEN
908
	IF ~cs THEN
909
		U.upcase16(text.searchText)
909
		U.lowcase(text.searchText)
910
	END;
910
	END;
911
	IF text.searchText # "" THEN
911
	IF text.searchText # "" THEN
912
		plainText := plain(text);
912
		plainText := plain(text);
913
		idxData := Search.index(plainText, cs);
913
		idxData := Search.index(plainText, cs);
914
		Search.find(plainText, text.searchText, whole, text.foundList);
914
		Search.find(plainText, text.searchText, whole, text.foundList);
Line 1785... Line 1785...
1785
    WHILE (i >= 0) & U.isLetter(Lines.getChar(line, i)) DO
1785
    WHILE (i >= 0) & U.isLetter(Lines.getChar(line, i)) DO
1786
        DEC(i)
1786
        DEC(i)
1787
    END;
1787
    END;
Line 1788... Line 1788...
1788
 
1788
 
1789
    IF upper THEN
1789
    IF upper THEN
1790
    	func := U.cap
1790
    	func := U.upper
1791
    ELSE
1791
    ELSE
1792
    	func := U.low
1792
    	func := U.lower
Line 1793... Line 1793...
1793
    END;
1793
    END;
1794
 
1794
 
1795
    IF Lines.convert(line, i + 1, text.cursor.X - 1, func) THEN
1795
    IF Lines.convert(line, i + 1, text.cursor.X - 1, func) THEN
Line 1813... Line 1813...
1813
        first := getLine2(text, selBeg.Y);
1813
        first := getLine2(text, selBeg.Y);
1814
        line := first;
1814
        line := first;
1815
        cnt := selEnd.Y - selBeg.Y;
1815
        cnt := selEnd.Y - selBeg.Y;
Line 1816... Line 1816...
1816
 
1816
 
1817
	    IF upper THEN
1817
	    IF upper THEN
1818
	    	func := U.cap
1818
	    	func := U.upper
1819
	    ELSE
1819
	    ELSE
1820
	    	func := U.low
1820
	    	func := U.lower
Line 1821... Line 1821...
1821
	    END;
1821
	    END;
1822
 
1822
 
1823
        IF cnt = 0 THEN
1823
        IF cnt = 0 THEN
Line 2291... Line 2291...
2291
END setPadding;
2291
END setPadding;
Line 2292... Line 2292...
2292
 
2292
 
2293
 
2293
 
2294
PROCEDURE draw* (text: tText);
2294
PROCEDURE draw* (text: tText);
2295
VAR
2295
VAR
2296
    y, n, cnt, i, x: INTEGER;
2296
    y, n, cnt, i, x, pos: INTEGER;
2297
    line, firstLine, lastLine: tLine;
2297
    line, firstLine, lastLine: tLine;
2298
    selBeg, selEnd: tPoint;
2298
    selBeg, selEnd: tPoint;
2299
    s: ARRAY 12 OF WCHAR;
-
 
2300
    backColor, numWidth, xNum, wNum: INTEGER;
2299
    s: ARRAY 12 OF WCHAR;
-
 
2300
    backColor, numWidth, xNum, wNum: INTEGER;
2301
    p: Search.tPos;
2301
    guard: tGuard;
2302
    guard: tGuard;
2302
    p: Search.tPos;
2303
BEGIN
2303
BEGIN
2304
    IF text.comments THEN
2304
    IF text.comments THEN
2305
        Comments(text)
2305
        Comments(text)
Line 2411... Line 2411...
2411
    		firstLine := text.curLine;
2411
    		firstLine := text.curLine;
2412
    		lastLine := firstLine
2412
    		lastLine := firstLine
2413
    	ELSE
2413
    	ELSE
2414
    	    lastLine := getLine2(text, MIN(text.scroll.Y + textsize.Y + 1, text.count) - 1)
2414
    	    lastLine := getLine2(text, MIN(text.scroll.Y + textsize.Y + 1, text.count) - 1)
2415
        END;
2415
        END;
-
 
2416
 
-
 
2417
        i := 0;
2416
        p := text.foundList.first(Search.tPos);
2418
        p := text.foundList.first(Search.tPos);
-
 
2419
        pos := Search.next(p, i);
2417
        WHILE p # NIL DO
2420
        WHILE pos # -1 DO
2418
        	y := padding.top + inter DIV 2;
2421
        	y := padding.top + inter DIV 2;
2419
        	IF text.smallMove THEN
2422
        	IF text.smallMove THEN
2420
        		y := y + charHeight*(text.cursor.Y - text.scroll.Y)
2423
        		y := y + charHeight*(text.cursor.Y - text.scroll.Y)
2421
            END;
2424
            END;
2422
            IF (firstLine.pos <= p.pos) & (p.pos <= lastLine.pos + lastLine.length) THEN
2425
            IF (firstLine.pos <= pos) & (pos <= lastLine.pos + lastLine.length) THEN
2423
                line := firstLine;
2426
                line := firstLine;
2424
                WHILE (line.pos <= p.pos) & (line # lastLine) DO
2427
                WHILE (line.pos <= pos) & (line # lastLine) DO
2425
                    NextLine(line);
2428
                    NextLine(line);
2426
                    INC(y, charHeight)
2429
                    INC(y, charHeight)
2427
                END;
2430
                END;
2428
                IF (line # lastLine) & (line # firstLine) OR (line = lastLine) & (line.pos > p.pos) THEN
2431
                IF (line # lastLine) & (line # firstLine) OR (line = lastLine) & (line.pos > pos) THEN
2429
                    PrevLine(line);
2432
                    PrevLine(line);
2430
                    DEC(y, charHeight)
2433
                    DEC(y, charHeight)
2431
                END;
2434
                END;
2432
                x := (p.pos - line.pos - text.scroll.X)*charWidth + padding.left;
2435
                x := (pos - line.pos - text.scroll.X)*charWidth + padding.left;
2433
                n := LENGTH(text.searchText)*charWidth;
2436
                n := LENGTH(text.searchText)*charWidth;
2434
                WHILE n > 0 DO
2437
                WHILE n > 0 DO
2435
                    IF x >= padding.left THEN
2438
                    IF x >= padding.left THEN
2436
                        G.notVLine(canvas, x, y, y + charHeight - inter)
2439
                        G.notVLine(canvas, x, y, y + charHeight - inter)
2437
                    END;
2440
                    END;
2438
                    INC(x);
2441
                    INC(x);
2439
                    DEC(n)
2442
                    DEC(n)
2440
                END
2443
                END
2441
            END;
2444
            END;
2442
            p := p.next(Search.tPos)
2445
            pos := Search.next(p, i)
2443
        END
2446
        END
2444
    END;
2447
    END;
Line 2445... Line 2448...
2445
 
2448
 
Line 2607... Line 2610...
2607
 
2610
 
2608
 
2611
 
2609
PROCEDURE findNext* (text: tText; prev: BOOLEAN): BOOLEAN;
2612
PROCEDURE findNext* (text: tText; prev: BOOLEAN): BOOLEAN;
2610
VAR
-
 
2611
    cursorPos, x, y, X, Y, Len: INTEGER;
2613
VAR
2612
    p: Search.tPos;
2614
    cursorPos, x, y, X, Y, Len: INTEGER;
-
 
2615
    line: tLine;
-
 
2616
    res: BOOLEAN;
2613
    line: tLine;
2617
    pos, i, pos0: INTEGER;
2614
    res: BOOLEAN;
2618
    p: Search.tPos;
2615
BEGIN
2619
BEGIN
2616
    X := text.cursor.X;
2620
    X := text.cursor.X;
2617
    Y := text.cursor.Y;
2621
    Y := text.cursor.Y;
-
 
2622
    text.cursor.X := MIN(text.cursor.X, text.curLine.length);
-
 
2623
    cursorPos := text.curLine.pos + text.cursor.X - ORD(prev) - ORD(~prev & (text.foundSel = 0));
2618
    text.cursor.X := MIN(text.cursor.X, text.curLine.length);
2624
    pos0 := -1;
-
 
2625
    i := 0;
2619
    cursorPos := text.curLine.pos + text.cursor.X - ORD(prev) - ORD(~prev & (text.foundSel = 0));
2626
    p := text.foundList.first(Search.tPos);
-
 
2627
    pos := Search.next(p, i);
2620
    p := text.foundList.first(Search.tPos);
2628
    WHILE (pos # -1) & (pos <= cursorPos) DO
2621
    WHILE (p # NIL) & (p.pos <= cursorPos) DO
2629
    	pos0 := pos;
2622
        p := p.next(Search.tPos)
2630
    	pos := Search.next(p, i)
2623
    END;
-
 
2624
    IF prev THEN
-
 
2625
        IF p = NIL THEN
2631
    END;
2626
            p := text.foundList.last(Search.tPos)
-
 
2627
        ELSE
-
 
2628
            p := p.prev(Search.tPos)
2632
    IF prev THEN
2629
        END
2633
    	pos := pos0
2630
    END;
2634
    END;
2631
    res := p # NIL;
2635
    res := pos # -1;
2632
    IF res THEN
2636
    IF res THEN
2633
        y := 0;
2637
        y := 0;
2634
        line := text.first(tLine);
2638
        line := text.first(tLine);
2635
        WHILE (line.pos <= p.pos) & (line.next # NIL) DO
2639
        WHILE (line.pos <= pos) & (line.next # NIL) DO
2636
            NextLine(line);
2640
            NextLine(line);
2637
            INC(y)
2641
            INC(y)
2638
        END;
2642
        END;
2639
        IF (line.next # NIL) OR (line.pos > p.pos) THEN
2643
        IF (line.next # NIL) OR (line.pos > pos) THEN
2640
            PrevLine(line);
2644
            PrevLine(line);
2641
            DEC(y)
2645
            DEC(y)
2642
        END;
2646
        END;
2643
        resetSelect(text);
2647
        resetSelect(text);
2644
        searchScroll(text, y);
2648
        searchScroll(text, y);
2645
        x := p.pos - line.pos;
2649
        x := pos - line.pos;
2646
        Len := LENGTH(text.searchText);
2650
        Len := LENGTH(text.searchText);
2647
        IF x + Len > text.scroll.X + textsize.X THEN
2651
        IF x + Len > text.scroll.X + textsize.X THEN
2648
            text.scroll.X := MAX(x + Len - textsize.X + 3, 0)
2652
            text.scroll.X := MAX(x + Len - textsize.X + 3, 0)
Line 2686... Line 2690...
2686
END replace;
2690
END replace;
Line 2687... Line 2691...
2687
 
2691
 
2688
 
2692
 
2689
PROCEDURE replaceAll* (text: tText; s: ARRAY OF WCHAR; n: INTEGER): INTEGER;
-
 
2690
VAR
2693
PROCEDURE replaceAll* (text: tText; s: ARRAY OF WCHAR; n: INTEGER): INTEGER;
2691
    p: Search.tPos;
2694
VAR
-
 
2695
    line: tLine;
2692
    line: tLine;
2696
    y, k, d, pos, y0, i, c: INTEGER;
2693
    y, k, d, pos, y0: INTEGER;
2697
    p: Search.tPos;
2694
BEGIN
2698
BEGIN
2695
    resetSelect(text);
2699
    resetSelect(text);
2696
    SetPos(text, 0, 0);
2700
    SetPos(text, 0, 0);
2697
    line := text.first(tLine);
2701
    line := text.first(tLine);
2698
    y := 0;
2702
    y := 0;
2699
    y0 := -1;
2703
    y0 := -1;
-
 
2704
    k := 0;
-
 
2705
    d := LENGTH(s) - n;
2700
    k := 0;
2706
    c := 0;
2701
    d := LENGTH(s) - n;
2707
    i := 0;
2702
    p := text.foundList.first(Search.tPos);
2708
    p := text.foundList.first(Search.tPos);
2703
    WHILE p # NIL DO
2709
    pos := Search.next(p, i);
2704
        pos := p.pos;
2710
    WHILE pos # -1 DO
2705
        WHILE (line.pos <= pos) & (line.next # NIL) DO
2711
        WHILE (line.pos <= pos) & (line.next # NIL) DO
2706
            NextLine(line);
2712
            NextLine(line);
2707
            INC(y)
2713
            INC(y)
Line 2717... Line 2723...
2717
            y0 := y
2723
            y0 := y
2718
        END;
2724
        END;
2719
        SetPos(text, pos - line.pos + k, y);
2725
        SetPos(text, pos - line.pos + k, y);
2720
        text.foundSel := n;
2726
        text.foundSel := n;
2721
        replace(text, s, n);
2727
        replace(text, s, n);
-
 
2728
        INC(c);
2722
        p := p.next(Search.tPos)
2729
        pos := Search.next(p, i)
2723
    END
2730
    END
2724
    RETURN text.foundList.count
2731
    RETURN c
2725
END replaceAll;
2732
END replaceAll;
Line 2726... Line 2733...
2726
 
2733
 
2727
 
2734