forked from KolibriOS/kolibrios
CEdit: show number of selected characters
git-svn-id: svn://kolibrios.org@9462 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
784428d4f3
commit
086f5f8132
Binary file not shown.
@ -28,7 +28,7 @@ IMPORT
|
|||||||
RW, Ini, EB := EditBox, Tabs, Toolbar;
|
RW, Ini, EB := EditBox, Tabs, Toolbar;
|
||||||
|
|
||||||
CONST
|
CONST
|
||||||
HEADER = "CEdit (22-dec-2021)";
|
HEADER = "CEdit (23-dec-2021)";
|
||||||
|
|
||||||
ShellFilter = "";
|
ShellFilter = "";
|
||||||
EditFilter = "SH|INC|TXT|ASM|OB07|C|CPP|H|PAS|PP|LUA|INI|JSON";
|
EditFilter = "SH|INC|TXT|ASM|OB07|C|CPP|H|PAS|PP|LUA|INI|JSON";
|
||||||
@ -218,15 +218,28 @@ VAR
|
|||||||
|
|
||||||
PROCEDURE WritePos (y: INTEGER);
|
PROCEDURE WritePos (y: INTEGER);
|
||||||
VAR
|
VAR
|
||||||
s1, s2: ARRAY 32 OF WCHAR;
|
s1, s2, s3: ARRAY 32 OF WCHAR;
|
||||||
line, col: INTEGER;
|
line, col, chars, lines: INTEGER;
|
||||||
BEGIN
|
BEGIN
|
||||||
T.getPos(text, col, line);
|
T.getPos(text, col, line);
|
||||||
U.int2str(line, s1);
|
U.int2str(line, s1);
|
||||||
U.int2str(col, s2);
|
U.int2str(col, s2);
|
||||||
U.append(s1, ": ");
|
U.append(s1, ": ");
|
||||||
U.append(s1, s2);
|
U.append(s1, s2);
|
||||||
K.DrawText(LEFT, y, K.textColor, s1)
|
IF T.selected(text) THEN
|
||||||
|
T.getSelCnt(text, chars, lines);
|
||||||
|
s3 := "sel: ";
|
||||||
|
U.int2str(chars, s2);
|
||||||
|
U.append(s3, s2);
|
||||||
|
U.append(s3, " | ");
|
||||||
|
U.int2str(lines, s2);
|
||||||
|
U.append(s3, s2)
|
||||||
|
ELSE
|
||||||
|
s3 := ""
|
||||||
|
END;
|
||||||
|
K.DrawRect(LEFT, TOP + canvas.height + scrollWidth, (16+24)*fontWidth, BOTTOM - scrollWidth + 1, K.winColor);
|
||||||
|
K.DrawText(LEFT, y, K.textColor, s1);
|
||||||
|
K.DrawText(LEFT + 16*fontWidth, y, K.textColor, s3)
|
||||||
END WritePos;
|
END WritePos;
|
||||||
|
|
||||||
|
|
||||||
@ -284,7 +297,6 @@ PROCEDURE Message (s: ARRAY OF WCHAR);
|
|||||||
CONST
|
CONST
|
||||||
minWidth = 30;
|
minWidth = 30;
|
||||||
height = 40;
|
height = 40;
|
||||||
borderColor = 808080H;
|
|
||||||
VAR
|
VAR
|
||||||
top, left, right, bottom, x, y, width: INTEGER;
|
top, left, right, bottom, x, y, width: INTEGER;
|
||||||
BEGIN
|
BEGIN
|
||||||
@ -298,7 +310,7 @@ BEGIN
|
|||||||
x := minWidth DIV 2 + left;
|
x := minWidth DIV 2 + left;
|
||||||
y := (height - fontHeight) DIV 2 + top;
|
y := (height - fontHeight) DIV 2 + top;
|
||||||
K.DrawRect(left, top, width, height, K.winColor);
|
K.DrawRect(left, top, width, height, K.winColor);
|
||||||
Rect(left, top, right, bottom, borderColor);
|
Rect(left, top, right, bottom, K.borderColor);
|
||||||
K.DrawText(x, y, K.textColor, s);
|
K.DrawText(x, y, K.textColor, s);
|
||||||
END Message;
|
END Message;
|
||||||
|
|
||||||
@ -376,7 +388,7 @@ BEGIN
|
|||||||
U.append(s, 20X + 20X);
|
U.append(s, 20X + 20X);
|
||||||
U.append(s, E.names[enc]);
|
U.append(s, E.names[enc]);
|
||||||
SetCaption(text.fileName);
|
SetCaption(text.fileName);
|
||||||
K.DrawRect(LEFT + 16*fontWidth, TOP + canvas.height + scrollWidth, width - (LEFT + 16*fontWidth), BOTTOM - scrollWidth + 1, K.winColor);
|
K.DrawRect(LEFT + (16+24)*fontWidth, TOP + canvas.height + scrollWidth, width - (LEFT + (16+24)*fontWidth), BOTTOM - scrollWidth + 1, K.winColor);
|
||||||
y := height - (BOTTOM - scrollWidth) + (BOTTOM - scrollWidth - 16) DIV 2;
|
y := height - (BOTTOM - scrollWidth) + (BOTTOM - scrollWidth - 16) DIV 2;
|
||||||
K.DrawText(width - LENGTH(s)*fontWidth - (RIGHT_PADDING + 1), y, K.textColor, s);
|
K.DrawText(width - LENGTH(s)*fontWidth - (RIGHT_PADDING + 1), y, K.textColor, s);
|
||||||
MarkModified
|
MarkModified
|
||||||
@ -395,7 +407,7 @@ END DrawScroll;
|
|||||||
|
|
||||||
PROCEDURE repaint;
|
PROCEDURE repaint;
|
||||||
VAR
|
VAR
|
||||||
width, height, scrollX, scrollY, y: INTEGER;
|
width, height, scrollX, scrollY: INTEGER;
|
||||||
BEGIN
|
BEGIN
|
||||||
IF (text # NIL) & ~K.RolledUp() THEN
|
IF (text # NIL) & ~K.RolledUp() THEN
|
||||||
IF confirm THEN
|
IF confirm THEN
|
||||||
@ -416,9 +428,7 @@ BEGIN
|
|||||||
switch := FALSE
|
switch := FALSE
|
||||||
END;
|
END;
|
||||||
T.draw(text);
|
T.draw(text);
|
||||||
y := height - (BOTTOM - scrollWidth) + (BOTTOM - scrollWidth - 16) DIV 2;
|
WritePos(height - (BOTTOM - scrollWidth) + (BOTTOM - scrollWidth - 16) DIV 2);
|
||||||
K.DrawRect(LEFT, TOP + canvas.height + scrollWidth, 16*fontWidth, BOTTOM - scrollWidth + 1, K.winColor);
|
|
||||||
WritePos(y);
|
|
||||||
|
|
||||||
IF (enc # T.getEnc(text)) OR (eol # T.getEol(text)) THEN
|
IF (enc # T.getEnc(text)) OR (eol # T.getEol(text)) THEN
|
||||||
DrawState(text, width, height)
|
DrawState(text, width, height)
|
||||||
|
@ -1472,6 +1472,50 @@ BEGIN
|
|||||||
END redo;
|
END redo;
|
||||||
|
|
||||||
|
|
||||||
|
PROCEDURE getSelCnt* (text: tText; VAR chars, lines: INTEGER);
|
||||||
|
VAR
|
||||||
|
selBeg, selEnd: tPoint;
|
||||||
|
first, last, line: tLine;
|
||||||
|
|
||||||
|
PROCEDURE charCnt (line: tLine; first, last: INTEGER): INTEGER;
|
||||||
|
VAR
|
||||||
|
i, res: INTEGER;
|
||||||
|
BEGIN
|
||||||
|
res := 0;
|
||||||
|
FOR i := first TO last DO
|
||||||
|
IF getChar(line, i) # TAB1 THEN
|
||||||
|
INC(res)
|
||||||
|
END
|
||||||
|
END
|
||||||
|
RETURN res
|
||||||
|
END charCnt;
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
IF selected(text) THEN
|
||||||
|
getSelect(text, selBeg, selEnd);
|
||||||
|
first := getLine(text, selBeg.Y);
|
||||||
|
last := getLine(text, selEnd.Y);
|
||||||
|
lines := selEnd.Y - selBeg.Y + 1;
|
||||||
|
|
||||||
|
IF lines > 1 THEN
|
||||||
|
chars := charCnt(first, selBeg.X, first.length - 1) + charCnt(last, 0, selEnd.X - 1) + lenEOL;
|
||||||
|
line := first.next(tLine)
|
||||||
|
ELSE
|
||||||
|
chars := charCnt(first, selBeg.X, selEnd.X - 1);
|
||||||
|
line := last
|
||||||
|
END;
|
||||||
|
|
||||||
|
WHILE line # last DO
|
||||||
|
INC(chars, charCnt(line, 0, line.length - 1) + lenEOL);
|
||||||
|
NextLine(line)
|
||||||
|
END
|
||||||
|
ELSE
|
||||||
|
chars := 0;
|
||||||
|
lines := 0
|
||||||
|
END
|
||||||
|
END getSelCnt;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE copy (text: tText);
|
PROCEDURE copy (text: tText);
|
||||||
VAR
|
VAR
|
||||||
selBeg, selEnd: tPoint;
|
selBeg, selEnd: tPoint;
|
||||||
|
Loading…
Reference in New Issue
Block a user