Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 9906 → Rev 9907

/programs/develop/cedit/CEDIT
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/programs/develop/cedit/CEDIT.INI
99,7 → 99,7
 
[lang_Fasm]
KW1 =
KW2 =
KW2 = byte,word,dword,db,dw,dd
KW3 =
delim = {}[]<>=:,()&*/|+-\#
 
/programs/develop/cedit/SRC/CEdit.ob07
28,7 → 28,7
RW, Ini, EB := EditBox, Tabs, Toolbar, SB := StatusBar;
 
CONST
HEADER = "CEdit (06-mar-2023)";
HEADER = "CEdit (18-mar-2023)";
 
ShellFilter = "";
EditFilter = "sh|inc|txt|asm|ob07|c|cpp|h|pas|pp|lua|ini|json";
/programs/develop/cedit/SRC/Search.ob07
26,7 → 26,7
itemSize = 64;
 
TYPE
tBuffer* = CB.tBuffer;
tBuffer = CB.tBuffer;
 
tIdxTable = ARRAY 65536, 2 OF INTEGER;
 
115,9 → 115,9
END next;
 
 
PROCEDURE find* (text: tBuffer; s: ARRAY OF WCHAR; whole: BOOLEAN; list: List.tList);
PROCEDURE find* (text: tBuffer; s: ARRAY OF WCHAR; whole: BOOLEAN; list: List.tList; offset: INTEGER);
VAR
k, pos, n, x, prev_item_pos: INTEGER;
k, pos, n, i, x, prev_item_pos: INTEGER;
item: tPos;
c1, c2: WCHAR;
flag: BOOLEAN;
124,6 → 124,11
BEGIN
ASSERT(table # NIL);
n := LENGTH(s);
i := 0;
WHILE (i < n) & whole DO
whole := Utils.isWordChar(s[i]);
INC(i)
END;
k := table.data[ORD(s[0]), 1];
pos := table.data[ORD(s[0]), 0];
prev_item_pos := 0;
138,8 → 143,7
c1 := 0X
END;
SYSTEM.GET(text.dataPtr + (x + n)*SYSTEM.SIZE(WCHAR), c2);
flag := Utils.isLetter(c1) OR Utils.isLetter(c2) OR Utils.isDigit(c1) OR Utils.isDigit(c2) OR
(c1 = "_") OR (c2 = "_")
flag := Utils.isWordChar(c1) OR Utils.isWordChar(c2)
END;
IF ~flag & (x >= prev_item_pos) THEN
prev_item_pos := x + n;
149,7 → 153,7
item.cnt := 0;
List.append(list, item)
END;
item.pos[item.cnt] := x;
item.pos[item.cnt] := x + offset;
INC(item.cnt)
END
END;
/programs/develop/cedit/SRC/Text.ob07
858,42 → 858,81
END parse;
 
 
PROCEDURE plain (text: tText): CB.tBuffer;
PROCEDURE plain (text: tText; textStart, textEnd: tPoint; _copy: BOOLEAN): CB.tBuffer;
VAR
buf: CB.tBuffer;
size: INTEGER;
line: tLine;
first, line: tLine;
cnt, n: INTEGER;
buffer: CB.tBuffer;
 
 
PROCEDURE append (buffer: CB.tBuffer; line: tLine; first, last: INTEGER; _copy: BOOLEAN);
BEGIN
size := 0;
IF first <= last THEN
CB.append(buffer, line, first, last)
ELSE
IF (U.OS = "KOS") & _copy THEN
CB.appends(buffer, SPACE, 0, 0)
END
END
END append;
 
 
BEGIN
IF ~_copy THEN
cnt := -lenEOL;
line := text.first(tLine);
WHILE line # NIL DO
line.pos := size;
INC(size, line.length);
NextLine(line);
IF line # NIL THEN
INC(size, CB.lenEOL)
INC(cnt, lenEOL);
line.pos := cnt;
INC(cnt, line.length);
NextLine(line)
END
END;
buf := CB.create(size + 2);
line := text.first(tLine);
WHILE line # NIL DO
CB.append(buf, line, 0, line.length - 1);
 
first := getLine2(text, textStart.Y);
line := first;
 
n := textEnd.Y - textStart.Y;
cnt := 0;
WHILE n >= 0 DO
INC(cnt, line.length + lenEOL);
IF (U.OS = "KOS") & _copy & (line.length = 0) THEN
INC(cnt)
END;
NextLine(line);
IF line # NIL THEN
CB.eol(buf)
DEC(n)
END;
 
buffer := CB.create(cnt + 2); (* +2 wchars EOT *)
 
n := textEnd.Y - textStart.Y;
line := first;
IF n = 0 THEN
append(buffer, line, textStart.X, textEnd.X - 1, _copy)
ELSE
append(buffer, line, textStart.X, line.length - 1, _copy);
REPEAT
DEC(n);
CB.eol(buffer);
NextLine(line);
IF n > 0 THEN
append(buffer, line, 0, line.length - 1, _copy)
END
END;
CB.appends(buf, 0X, 0, 0);
CB.appends(buf, 0X, 0, 0)
RETURN buf
UNTIL n = 0;
append(buffer, line, 0, textEnd.X - 1, _copy)
END
 
RETURN buffer
END plain;
 
 
PROCEDURE search* (text: tText; s: ARRAY OF WCHAR; cs, whole: BOOLEAN): BOOLEAN;
PROCEDURE _search (text: tText; s: ARRAY OF WCHAR; cs, whole: BOOLEAN; textStart, textEnd: tPoint): BOOLEAN;
VAR
pos: List.tItem;
res: BOOLEAN;
plainText, idxData: Search.tBuffer;
plainText, idxData: CB.tBuffer;
first: tLine;
 
BEGIN
res := TRUE;
plainText := NIL;
909,9 → 948,12
U.lowcase(text.searchText)
END;
IF text.searchText # "" THEN
plainText := plain(text);
first := getLine2(text, textStart.Y);
plainText := plain(text, textStart, textEnd, FALSE);
CB.appends(plainText, 0X, 0, 0);
CB.appends(plainText, 0X, 0, 0);
idxData := Search.index(plainText, cs);
Search.find(plainText, text.searchText, whole, text.foundList);
Search.find(plainText, text.searchText, whole, text.foundList, first.pos + textStart.X);
res := text.foundList.count > 0
ELSE
Search.close
921,6 → 963,28
text.search := FALSE;
text.foundSel := 0
RETURN res
END _search;
 
 
PROCEDURE search* (text: tText; s: ARRAY OF WCHAR; cs, whole: BOOLEAN): BOOLEAN;
VAR
textStart, textEnd: tPoint;
(*
PROCEDURE _getSelect (text: tText; VAR selBeg, selEnd: tPoint);
BEGIN
selBeg := text.cursor^;
selEnd := text.select^;
IF (selBeg.Y > selEnd.Y) OR (selBeg.Y = selEnd.Y) & (selBeg.X > selEnd.X) THEN
selBeg := text.select^;
selEnd := text.cursor^
END
END _getSelect;*)
 
BEGIN
textStart.Y := 0; textStart.X := 0;
textEnd.Y := text.count - 1; textEnd.X := text.last(tLine).length;
//_getSelect(text, textStart, textEnd)
RETURN _search(text, s, cs, whole, textStart, textEnd)
END search;
 
 
1572,62 → 1636,17
END getSelCnt;
 
 
PROCEDURE copy (text: tText);
PROCEDURE Copy (text: tText);
VAR
selBeg, selEnd: tPoint;
first, line: tLine;
cnt, n: INTEGER;
selStart, selEnd: tPoint;
buffer: CB.tBuffer;
 
 
PROCEDURE append (buffer: CB.tBuffer; line: tLine; first, last: INTEGER);
BEGIN
IF first <= last THEN
CB.append(buffer, line, first, last)
ELSE
IF U.OS = "KOS" THEN
CB.appends(buffer, SPACE, 0, 0)
END
END
END append;
 
 
BEGIN
getSelect(text, selBeg, selEnd);
 
first := getLine2(text, selBeg.Y);
line := first;
 
n := selEnd.Y - selBeg.Y;
cnt := 0;
WHILE n >= 0 DO
INC(cnt, line.length + (lenEOL + ORD(U.OS = "KOS")));
NextLine(line);
DEC(n)
END;
 
buffer := CB.create(cnt + 2); (* +2 wchars EOT *)
 
n := selEnd.Y - selBeg.Y;
line := first;
IF n = 0 THEN
append(buffer, line, selBeg.X, selEnd.X - 1)
ELSE
append(buffer, line, selBeg.X, line.length - 1);
REPEAT
DEC(n);
CB.eol(buffer);
NextLine(line);
IF n > 0 THEN
append(buffer, line, 0, line.length - 1)
END
UNTIL n = 0;
append(buffer, line, 0, selEnd.X - 1)
END;
getSelect(text, selStart, selEnd);
buffer := plain(text, selStart, selEnd, TRUE);
CB.eot(buffer);
CB.put(buffer);
CB.destroy(buffer)
END copy;
END Copy;
 
 
PROCEDURE paste (text: tText);
1969,11 → 1988,6
END MoveLines;
 
 
PROCEDURE isWordChar (c: WCHAR): BOOLEAN;
RETURN U.isLetter(c) OR U.isDigit(c) OR (c = "_")
END isWordChar;
 
 
PROCEDURE getSelectedText* (text: tText; VAR s: ARRAY OF WCHAR);
VAR
n: INTEGER;
2006,12 → 2020,12
END;
IF str # "" THEN
i := 0;
WHILE (i < n) & isWordChar(str[i]) DO
WHILE (i < n) & U.isWordChar(str[i]) DO
INC(i)
END;
IF (i # n) OR
((x1 > 0) & isWordChar(Lines.getChar(curLine, x1 - 1))) OR
((x2 < curLine.length) & isWordChar(Lines.getChar(curLine, x2))) THEN
((x1 > 0) & U.isWordChar(Lines.getChar(curLine, x1 - 1))) OR
((x2 < curLine.length) & U.isWordChar(Lines.getChar(curLine, x2))) THEN
str := ""
END
END;
2029,8 → 2043,8
c: WCHAR;
BEGIN
c := Lines.getChar(line, pos);
IF isWordChar(c) THEN
WHILE (pos < line.length) & isWordChar(Lines.getChar(line, pos)) DO
IF U.isWordChar(c) THEN
WHILE (pos < line.length) & U.isWordChar(Lines.getChar(line, pos)) DO
INC(pos)
END
ELSIF Lines.isSpace(c) THEN
2038,7 → 2052,7
INC(pos)
END
ELSE
WHILE (pos < line.length) & ~Lines.isSpace(Lines.getChar(line, pos)) & ~isWordChar(Lines.getChar(line, pos)) DO
WHILE (pos < line.length) & ~Lines.isSpace(Lines.getChar(line, pos)) & ~U.isWordChar(Lines.getChar(line, pos)) DO
INC(pos)
END
END
2151,7 → 2165,7
|ORD("C"), ORD("X"):
IF ctrl THEN
IF selected(text) THEN
copy(text);
Copy(text);
IF code = ORD("X") THEN
delSelect(text)
END
2208,18 → 2222,18
cursorX := text.cursor.X;
line := text.curLine;
x1 := cursorX - 1;
IF (cursorX < line.length) & isWordChar(Lines.getChar(line, cursorX)) THEN
IF (cursorX < line.length) & U.isWordChar(Lines.getChar(line, cursorX)) THEN
x2 := cursorX;
WHILE (x2 < line.length) & isWordChar(Lines.getChar(line, x2)) DO
WHILE (x2 < line.length) & U.isWordChar(Lines.getChar(line, x2)) DO
INC(x2)
END
ELSE
WHILE (x1 >= 0) & ~isWordChar(Lines.getChar(line, x1)) DO
WHILE (x1 >= 0) & ~U.isWordChar(Lines.getChar(line, x1)) DO
DEC(x1)
END;
x2 := x1 + 1
END;
WHILE (x1 >= 0) & isWordChar(Lines.getChar(line, x1)) DO
WHILE (x1 >= 0) & U.isWordChar(Lines.getChar(line, x1)) DO
DEC(x1)
END;
INC(x1);
/programs/develop/cedit/SRC/Utils.ob07
325,4 → 325,9
END inString;
 
 
PROCEDURE isWordChar* (c: WCHAR): BOOLEAN;
RETURN isLetter(c) OR isDigit(c) OR (c = "_")
END isWordChar;
 
 
END Utils.