Rev 9906 | Rev 9909 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 9906 | Rev 9907 | ||
---|---|---|---|
Line 856... | Line 856... | ||
856 | INC(i) |
856 | INC(i) |
857 | END |
857 | END |
858 | END parse; |
858 | END parse; |
Line 859... | Line 859... | ||
859 | 859 | ||
860 | 860 | ||
- | 861 | PROCEDURE plain (text: tText; textStart, textEnd: tPoint; _copy: BOOLEAN): CB.tBuffer; |
|
- | 862 | VAR |
|
861 | PROCEDURE plain (text: tText): CB.tBuffer; |
863 | first, line: tLine; |
- | 864 | cnt, n: INTEGER; |
|
- | 865 | buffer: CB.tBuffer; |
|
- | 866 | ||
- | 867 | ||
862 | VAR |
868 | PROCEDURE append (buffer: CB.tBuffer; line: tLine; first, last: INTEGER; _copy: BOOLEAN); |
- | 869 | BEGIN |
|
- | 870 | IF first <= last THEN |
|
- | 871 | CB.append(buffer, line, first, last) |
|
- | 872 | ELSE |
|
- | 873 | IF (U.OS = "KOS") & _copy THEN |
|
- | 874 | CB.appends(buffer, SPACE, 0, 0) |
|
863 | buf: CB.tBuffer; |
875 | END |
- | 876 | END |
|
- | 877 | END append; |
|
864 | size: INTEGER; |
878 | |
865 | line: tLine; |
879 | |
- | 880 | BEGIN |
|
866 | BEGIN |
881 | IF ~_copy THEN |
867 | size := 0; |
882 | cnt := -lenEOL; |
- | 883 | line := text.first(tLine); |
|
868 | line := text.first(tLine); |
884 | WHILE line # NIL DO |
869 | WHILE line # NIL DO |
885 | INC(cnt, lenEOL); |
870 | line.pos := size; |
886 | line.pos := cnt; |
871 | INC(size, line.length); |
- | |
872 | NextLine(line); |
- | |
873 | IF line # NIL THEN |
887 | INC(cnt, line.length); |
874 | INC(size, CB.lenEOL) |
888 | NextLine(line) |
- | 889 | END |
|
875 | END |
890 | END; |
876 | END; |
891 | |
- | 892 | first := getLine2(text, textStart.Y); |
|
- | 893 | line := first; |
|
- | 894 | ||
877 | buf := CB.create(size + 2); |
895 | n := textEnd.Y - textStart.Y; |
- | 896 | cnt := 0; |
|
878 | line := text.first(tLine); |
897 | WHILE n >= 0 DO |
- | 898 | INC(cnt, line.length + lenEOL); |
|
- | 899 | IF (U.OS = "KOS") & _copy & (line.length = 0) THEN |
|
879 | WHILE line # NIL DO |
900 | INC(cnt) |
880 | CB.append(buf, line, 0, line.length - 1); |
- | |
881 | NextLine(line); |
- | |
882 | IF line # NIL THEN |
901 | END; |
883 | CB.eol(buf) |
902 | NextLine(line); |
- | 903 | DEC(n) |
|
- | 904 | END; |
|
- | 905 | ||
884 | END |
906 | buffer := CB.create(cnt + 2); (* +2 wchars EOT *) |
- | 907 | ||
- | 908 | n := textEnd.Y - textStart.Y; |
|
- | 909 | line := first; |
|
- | 910 | IF n = 0 THEN |
|
- | 911 | append(buffer, line, textStart.X, textEnd.X - 1, _copy) |
|
- | 912 | ELSE |
|
- | 913 | append(buffer, line, textStart.X, line.length - 1, _copy); |
|
885 | END; |
914 | REPEAT |
- | 915 | DEC(n); |
|
- | 916 | CB.eol(buffer); |
|
- | 917 | NextLine(line); |
|
- | 918 | IF n > 0 THEN |
|
- | 919 | append(buffer, line, 0, line.length - 1, _copy) |
|
- | 920 | END |
|
- | 921 | UNTIL n = 0; |
|
- | 922 | append(buffer, line, 0, textEnd.X - 1, _copy) |
|
886 | CB.appends(buf, 0X, 0, 0); |
923 | END |
887 | CB.appends(buf, 0X, 0, 0) |
924 | |
Line 888... | Line 925... | ||
888 | RETURN buf |
925 | RETURN buffer |
889 | END plain; |
926 | END plain; |
890 | 927 | ||
891 | 928 | ||
892 | PROCEDURE search* (text: tText; s: ARRAY OF WCHAR; cs, whole: BOOLEAN): BOOLEAN; |
929 | PROCEDURE _search (text: tText; s: ARRAY OF WCHAR; cs, whole: BOOLEAN; textStart, textEnd: tPoint): BOOLEAN; |
- | 930 | VAR |
|
- | 931 | pos: List.tItem; |
|
893 | VAR |
932 | res: BOOLEAN; |
894 | pos: List.tItem; |
933 | plainText, idxData: CB.tBuffer; |
895 | res: BOOLEAN; |
934 | first: tLine; |
896 | plainText, idxData: Search.tBuffer; |
935 | |
897 | BEGIN |
936 | BEGIN |
Line 907... | Line 946... | ||
907 | text.searchText := s; |
946 | text.searchText := s; |
908 | IF ~cs THEN |
947 | IF ~cs THEN |
909 | U.lowcase(text.searchText) |
948 | U.lowcase(text.searchText) |
910 | END; |
949 | END; |
911 | IF text.searchText # "" THEN |
950 | IF text.searchText # "" THEN |
- | 951 | first := getLine2(text, textStart.Y); |
|
912 | plainText := plain(text); |
952 | plainText := plain(text, textStart, textEnd, FALSE); |
- | 953 | CB.appends(plainText, 0X, 0, 0); |
|
- | 954 | CB.appends(plainText, 0X, 0, 0); |
|
913 | idxData := Search.index(plainText, cs); |
955 | idxData := Search.index(plainText, cs); |
914 | Search.find(plainText, text.searchText, whole, text.foundList); |
956 | Search.find(plainText, text.searchText, whole, text.foundList, first.pos + textStart.X); |
915 | res := text.foundList.count > 0 |
957 | res := text.foundList.count > 0 |
916 | ELSE |
958 | ELSE |
917 | Search.close |
959 | Search.close |
918 | END; |
960 | END; |
919 | CB.destroy(plainText); |
961 | CB.destroy(plainText); |
920 | CB.destroy(idxData); |
962 | CB.destroy(idxData); |
921 | text.search := FALSE; |
963 | text.search := FALSE; |
922 | text.foundSel := 0 |
964 | text.foundSel := 0 |
923 | RETURN res |
965 | RETURN res |
- | 966 | END _search; |
|
- | 967 | ||
- | 968 | ||
- | 969 | PROCEDURE search* (text: tText; s: ARRAY OF WCHAR; cs, whole: BOOLEAN): BOOLEAN; |
|
- | 970 | VAR |
|
- | 971 | textStart, textEnd: tPoint; |
|
- | 972 | (* |
|
- | 973 | PROCEDURE _getSelect (text: tText; VAR selBeg, selEnd: tPoint); |
|
- | 974 | BEGIN |
|
- | 975 | selBeg := text.cursor^; |
|
- | 976 | selEnd := text.select^; |
|
- | 977 | IF (selBeg.Y > selEnd.Y) OR (selBeg.Y = selEnd.Y) & (selBeg.X > selEnd.X) THEN |
|
- | 978 | selBeg := text.select^; |
|
- | 979 | selEnd := text.cursor^ |
|
- | 980 | END |
|
- | 981 | END _getSelect;*) |
|
- | 982 | ||
- | 983 | BEGIN |
|
- | 984 | textStart.Y := 0; textStart.X := 0; |
|
- | 985 | textEnd.Y := text.count - 1; textEnd.X := text.last(tLine).length; |
|
- | 986 | //_getSelect(text, textStart, textEnd) |
|
- | 987 | RETURN _search(text, s, cs, whole, textStart, textEnd) |
|
924 | END search; |
988 | END search; |
Line 925... | Line 989... | ||
925 | 989 | ||
926 | 990 | ||
Line 1570... | Line 1634... | ||
1570 | lines := 0 |
1634 | lines := 0 |
1571 | END |
1635 | END |
1572 | END getSelCnt; |
1636 | END getSelCnt; |
Line 1573... | Line 1637... | ||
1573 | 1637 | ||
1574 | 1638 | ||
1575 | PROCEDURE copy (text: tText); |
1639 | PROCEDURE Copy (text: tText); |
1576 | VAR |
- | |
1577 | selBeg, selEnd: tPoint; |
- | |
1578 | first, line: tLine; |
1640 | VAR |
1579 | cnt, n: INTEGER; |
- | |
1580 | buffer: CB.tBuffer; |
- | |
1581 | - | ||
1582 | - | ||
1583 | PROCEDURE append (buffer: CB.tBuffer; line: tLine; first, last: INTEGER); |
- | |
1584 | BEGIN |
- | |
1585 | IF first <= last THEN |
- | |
1586 | CB.append(buffer, line, first, last) |
- | |
1587 | ELSE |
- | |
1588 | IF U.OS = "KOS" THEN |
- | |
1589 | CB.appends(buffer, SPACE, 0, 0) |
- | |
1590 | END |
- | |
1591 | END |
- | |
1592 | END append; |
- | |
1593 | 1641 | selStart, selEnd: tPoint; |
|
1594 | 1642 | buffer: CB.tBuffer; |
|
1595 | BEGIN |
- | |
1596 | getSelect(text, selBeg, selEnd); |
1643 | BEGIN |
1597 | - | ||
1598 | first := getLine2(text, selBeg.Y); |
- | |
1599 | line := first; |
- | |
1600 | - | ||
1601 | n := selEnd.Y - selBeg.Y; |
- | |
1602 | cnt := 0; |
- | |
1603 | WHILE n >= 0 DO |
- | |
1604 | INC(cnt, line.length + (lenEOL + ORD(U.OS = "KOS"))); |
- | |
1605 | NextLine(line); |
- | |
1606 | DEC(n) |
- | |
1607 | END; |
- | |
1608 | - | ||
1609 | buffer := CB.create(cnt + 2); (* +2 wchars EOT *) |
- | |
1610 | - | ||
1611 | n := selEnd.Y - selBeg.Y; |
- | |
1612 | line := first; |
- | |
1613 | IF n = 0 THEN |
- | |
1614 | append(buffer, line, selBeg.X, selEnd.X - 1) |
- | |
1615 | ELSE |
- | |
1616 | append(buffer, line, selBeg.X, line.length - 1); |
- | |
1617 | REPEAT |
- | |
1618 | DEC(n); |
- | |
1619 | CB.eol(buffer); |
- | |
1620 | NextLine(line); |
- | |
1621 | IF n > 0 THEN |
- | |
1622 | append(buffer, line, 0, line.length - 1) |
- | |
1623 | END |
- | |
1624 | UNTIL n = 0; |
- | |
1625 | append(buffer, line, 0, selEnd.X - 1) |
1644 | getSelect(text, selStart, selEnd); |
1626 | END; |
1645 | buffer := plain(text, selStart, selEnd, TRUE); |
1627 | CB.eot(buffer); |
1646 | CB.eot(buffer); |
1628 | CB.put(buffer); |
1647 | CB.put(buffer); |
Line 1629... | Line 1648... | ||
1629 | CB.destroy(buffer) |
1648 | CB.destroy(buffer) |
1630 | END copy; |
1649 | END Copy; |
1631 | 1650 | ||
Line 1967... | Line 1986... | ||
1967 | END |
1986 | END |
1968 | END |
1987 | END |
1969 | END MoveLines; |
1988 | END MoveLines; |
Line 1970... | Line -... | ||
1970 | - | ||
1971 | - | ||
1972 | PROCEDURE isWordChar (c: WCHAR): BOOLEAN; |
- | |
1973 | RETURN U.isLetter(c) OR U.isDigit(c) OR (c = "_") |
- | |
1974 | END isWordChar; |
- | |
1975 | 1989 | ||
1976 | 1990 | ||
1977 | PROCEDURE getSelectedText* (text: tText; VAR s: ARRAY OF WCHAR); |
1991 | PROCEDURE getSelectedText* (text: tText; VAR s: ARRAY OF WCHAR); |
1978 | VAR |
1992 | VAR |
1979 | n: INTEGER; |
1993 | n: INTEGER; |
Line 2004... | Line 2018... | ||
2004 | ELSE |
2018 | ELSE |
2005 | str := "" |
2019 | str := "" |
2006 | END; |
2020 | END; |
2007 | IF str # "" THEN |
2021 | IF str # "" THEN |
2008 | i := 0; |
2022 | i := 0; |
2009 | WHILE (i < n) & isWordChar(str[i]) DO |
2023 | WHILE (i < n) & U.isWordChar(str[i]) DO |
2010 | INC(i) |
2024 | INC(i) |
2011 | END; |
2025 | END; |
2012 | IF (i # n) OR |
2026 | IF (i # n) OR |
2013 | ((x1 > 0) & isWordChar(Lines.getChar(curLine, x1 - 1))) OR |
2027 | ((x1 > 0) & U.isWordChar(Lines.getChar(curLine, x1 - 1))) OR |
2014 | ((x2 < curLine.length) & isWordChar(Lines.getChar(curLine, x2))) THEN |
2028 | ((x2 < curLine.length) & U.isWordChar(Lines.getChar(curLine, x2))) THEN |
2015 | str := "" |
2029 | str := "" |
2016 | END |
2030 | END |
2017 | END; |
2031 | END; |
2018 | IF text.searchText # str THEN |
2032 | IF text.searchText # str THEN |
2019 | text.smallMove := FALSE |
2033 | text.smallMove := FALSE |
Line 2027... | Line 2041... | ||
2027 | PROCEDURE getWordPos (line: tLine; pos: INTEGER): INTEGER; |
2041 | PROCEDURE getWordPos (line: tLine; pos: INTEGER): INTEGER; |
2028 | VAR |
2042 | VAR |
2029 | c: WCHAR; |
2043 | c: WCHAR; |
2030 | BEGIN |
2044 | BEGIN |
2031 | c := Lines.getChar(line, pos); |
2045 | c := Lines.getChar(line, pos); |
2032 | IF isWordChar(c) THEN |
2046 | IF U.isWordChar(c) THEN |
2033 | WHILE (pos < line.length) & isWordChar(Lines.getChar(line, pos)) DO |
2047 | WHILE (pos < line.length) & U.isWordChar(Lines.getChar(line, pos)) DO |
2034 | INC(pos) |
2048 | INC(pos) |
2035 | END |
2049 | END |
2036 | ELSIF Lines.isSpace(c) THEN |
2050 | ELSIF Lines.isSpace(c) THEN |
2037 | WHILE (pos < line.length) & Lines.isSpace(Lines.getChar(line, pos)) DO |
2051 | WHILE (pos < line.length) & Lines.isSpace(Lines.getChar(line, pos)) DO |
2038 | INC(pos) |
2052 | INC(pos) |
2039 | END |
2053 | END |
2040 | ELSE |
2054 | ELSE |
2041 | WHILE (pos < line.length) & ~Lines.isSpace(Lines.getChar(line, pos)) & ~isWordChar(Lines.getChar(line, pos)) DO |
2055 | WHILE (pos < line.length) & ~Lines.isSpace(Lines.getChar(line, pos)) & ~U.isWordChar(Lines.getChar(line, pos)) DO |
2042 | INC(pos) |
2056 | INC(pos) |
2043 | END |
2057 | END |
2044 | END |
2058 | END |
2045 | RETURN pos |
2059 | RETURN pos |
2046 | END getWordPos; |
2060 | END getWordPos; |
Line 2149... | Line 2163... | ||
2149 | ShowCursor |
2163 | ShowCursor |
2150 | END |
2164 | END |
2151 | |ORD("C"), ORD("X"): |
2165 | |ORD("C"), ORD("X"): |
2152 | IF ctrl THEN |
2166 | IF ctrl THEN |
2153 | IF selected(text) THEN |
2167 | IF selected(text) THEN |
2154 | copy(text); |
2168 | Copy(text); |
2155 | IF code = ORD("X") THEN |
2169 | IF code = ORD("X") THEN |
2156 | delSelect(text) |
2170 | delSelect(text) |
2157 | END |
2171 | END |
2158 | END |
2172 | END |
2159 | END |
2173 | END |
Line 2206... | Line 2220... | ||
2206 | BEGIN |
2220 | BEGIN |
2207 | resetSelect(text); |
2221 | resetSelect(text); |
2208 | cursorX := text.cursor.X; |
2222 | cursorX := text.cursor.X; |
2209 | line := text.curLine; |
2223 | line := text.curLine; |
2210 | x1 := cursorX - 1; |
2224 | x1 := cursorX - 1; |
2211 | IF (cursorX < line.length) & isWordChar(Lines.getChar(line, cursorX)) THEN |
2225 | IF (cursorX < line.length) & U.isWordChar(Lines.getChar(line, cursorX)) THEN |
2212 | x2 := cursorX; |
2226 | x2 := cursorX; |
2213 | WHILE (x2 < line.length) & isWordChar(Lines.getChar(line, x2)) DO |
2227 | WHILE (x2 < line.length) & U.isWordChar(Lines.getChar(line, x2)) DO |
2214 | INC(x2) |
2228 | INC(x2) |
2215 | END |
2229 | END |
2216 | ELSE |
2230 | ELSE |
2217 | WHILE (x1 >= 0) & ~isWordChar(Lines.getChar(line, x1)) DO |
2231 | WHILE (x1 >= 0) & ~U.isWordChar(Lines.getChar(line, x1)) DO |
2218 | DEC(x1) |
2232 | DEC(x1) |
2219 | END; |
2233 | END; |
2220 | x2 := x1 + 1 |
2234 | x2 := x1 + 1 |
2221 | END; |
2235 | END; |
2222 | WHILE (x1 >= 0) & isWordChar(Lines.getChar(line, x1)) DO |
2236 | WHILE (x1 >= 0) & U.isWordChar(Lines.getChar(line, x1)) DO |
2223 | DEC(x1) |
2237 | DEC(x1) |
2224 | END; |
2238 | END; |
2225 | INC(x1); |
2239 | INC(x1); |
2226 | IF x1 < x2 THEN |
2240 | IF x1 < x2 THEN |
2227 | SetPos(text, x1, text.cursor.Y); |
2241 | SetPos(text, x1, text.cursor.Y); |