Subversion Repositories Kolibri OS

Rev

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

Rev 9659 Rev 9902
Line 1... Line 1...
1
(*
1
(*
2
    Copyright 2021, 2022 Anton Krotov
2
    Copyright 2021-2023 Anton Krotov
Line 3... Line 3...
3
 
3
 
Line 4... Line 4...
4
    This file is part of CEdit.
4
    This file is part of CEdit.
5
 
5
 
Line 22... Line 22...
22
IMPORT
22
IMPORT
23
    CB := Clipboard, List, Utils, SYSTEM;
23
    CB := Clipboard, List, Utils, SYSTEM;
Line 24... Line 24...
24
 
24
 
25
 
-
 
26
TYPE
25
 
Line 27... Line 26...
27
 
26
TYPE
Line 28... Line 27...
28
    tBuffer* = CB.tBuffer;
27
    tBuffer* = CB.tBuffer;
29
 
28
 
30
    IdxTable* = ARRAY 65536, 2 OF INTEGER;
29
    tIdxTable = ARRAY 65536, 2 OF INTEGER;
Line -... Line 30...
-
 
30
 
-
 
31
    tPos* = POINTER TO RECORD (List.tItem)
-
 
32
        pos*: INTEGER
Line 31... Line 33...
31
 
33
    END;
32
    tPos* = POINTER TO RECORD (List.tItem)
34
 
33
        pos*: INTEGER
35
VAR
34
    END;
36
	table: POINTER TO RECORD data: tIdxTable END;
35
 
37
 
36
 
38
 
Line 78... Line 80...
78
    FOR i := 0 TO 65535 DO
80
    FOR i := 0 TO 65535 DO
79
        DEC(table[i, 0], table[i, 1]*SYSTEM.SIZE(INTEGER))
81
        DEC(table[i, 0], table[i, 1]*SYSTEM.SIZE(INTEGER))
80
    END
82
    END
Line 81... Line 83...
81
 
83
 
-
 
84
    RETURN res
-
 
85
END _index;
-
 
86
 
-
 
87
 
-
 
88
PROCEDURE index* (text: tBuffer; cs: BOOLEAN): tBuffer;
-
 
89
BEGIN
-
 
90
	IF table = NIL THEN
-
 
91
		NEW(table)
-
 
92
	END
82
    RETURN res
93
	RETURN _index(text, cs, table.data)
Line 83... Line 94...
83
END index;
94
END index;
84
 
95
 
85
 
96
 
86
PROCEDURE find* (text: tBuffer; table: IdxTable; s: ARRAY OF WCHAR; whole: BOOLEAN; list: List.tList);
97
PROCEDURE find* (text: tBuffer; s: ARRAY OF WCHAR; whole: BOOLEAN; list: List.tList);
87
VAR
98
VAR
88
    k, pos, n, x, prev_item_pos: INTEGER;
99
    k, pos, n, x, prev_item_pos: INTEGER;
89
    item: tPos;
100
    item: tPos;
-
 
101
    c1, c2: WCHAR;
90
    c1, c2: WCHAR;
102
    flag: BOOLEAN;
91
    flag: BOOLEAN;
103
BEGIN
92
BEGIN
104
	ASSERT(table # NIL);
93
    n := LENGTH(s);
105
    n := LENGTH(s);
94
    k := table[ORD(s[0]), 1];
106
    k := table.data[ORD(s[0]), 1];
95
    pos := table[ORD(s[0]), 0];
107
    pos := table.data[ORD(s[0]), 0];
96
    prev_item_pos := 0;
108
    prev_item_pos := 0;
97
    WHILE k > 0 DO
109
    WHILE k > 0 DO
Line 103... Line 115...
103
                    SYSTEM.GET(text.dataPtr + (x - 1)*SYSTEM.SIZE(WCHAR), c1);
115
                    SYSTEM.GET(text.dataPtr + (x - 1)*SYSTEM.SIZE(WCHAR), c1);
104
                ELSE
116
                ELSE
105
                    c1 := 0X
117
                    c1 := 0X
106
                END;
118
                END;
107
                SYSTEM.GET(text.dataPtr + (x + n)*SYSTEM.SIZE(WCHAR), c2);
119
                SYSTEM.GET(text.dataPtr + (x + n)*SYSTEM.SIZE(WCHAR), c2);
108
                flag := Utils.isLetter(c1) OR Utils.isLetter(c2) OR Utils.isDigit(c1) OR Utils.isDigit(c2) OR (c1 = "_") OR (c2 = "_")
120
                flag := Utils.isLetter(c1) OR Utils.isLetter(c2) OR Utils.isDigit(c1) OR Utils.isDigit(c2) OR
-
 
121
                	(c1 = "_") OR (c2 = "_")
109
            END;
122
            END;
110
            IF ~flag & (x >= prev_item_pos) THEN
123
            IF ~flag & (x >= prev_item_pos) THEN
111
                prev_item_pos := x + n;
124
                prev_item_pos := x + n;
112
                NEW(item);
125
                NEW(item);
113
                item.pos := x;
126
                item.pos := x;
Line 118... Line 131...
118
        DEC(k)
131
        DEC(k)
119
    END
132
    END
120
END find;
133
END find;
Line -... Line 134...
-
 
134
 
-
 
135
 
-
 
136
PROCEDURE close*;
-
 
137
BEGIN
-
 
138
	IF table # NIL THEN
-
 
139
		DISPOSE(table)
-
 
140
	END
-
 
141
END close;
-
 
142
 
-
 
143
 
121
 
144
BEGIN
122
 
145
	table := NIL