CEdit: added [shift+mouse wheel] for horizontal scrolling;

search improved.


git-svn-id: svn://kolibrios.org@9915 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Anton Krotov 2023-05-07 17:19:42 +00:00
parent 3dc259f833
commit 653161d498
5 changed files with 353 additions and 304 deletions

Binary file not shown.

View File

@ -42,6 +42,8 @@
F9 выполнить F9 выполнить
ctrl+F8 отладка ctrl+F8 отладка
shift+wheel горизонтальная прокрутка
перемещение по тексту: перемещение по тексту:
(ctrl+)Home, (ctrl+)End, (ctrl+)PageUp, (ctrl+)PageDown (ctrl+)Home, (ctrl+)End, (ctrl+)PageUp, (ctrl+)PageDown
ctrl+Left, ctrl+Right ctrl+Left, ctrl+Right

View File

@ -28,7 +28,7 @@ IMPORT
RW, Ini, EB := EditBox, Tabs, Toolbar, SB := StatusBar; RW, Ini, EB := EditBox, Tabs, Toolbar, SB := StatusBar;
CONST CONST
HEADER = "CEdit (13-apr-2023)"; HEADER = "CEdit (07-may-2023)";
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";
@ -169,7 +169,7 @@ CONST
SHIFT = Menu.SHIFT; SHIFT = Menu.SHIFT;
CTRL = Menu.CTRL; CTRL = Menu.CTRL;
ClippingArea = 50; ClippingArea = 32 + T.LineSpacing;
VAR VAR
@ -354,7 +354,11 @@ BEGIN
T.getSelCnt(text, chars, lines); T.getSelCnt(text, chars, lines);
SB.setWidth(canvas.width + scrollWidth); SB.setWidth(canvas.width + scrollWidth);
SB.setPos(line, col); SB.setPos(line, col);
SB.setSel(chars, lines); IF text.foundSel # 0 THEN
SB.setSel("", text.foundCur, text.foundCnt, " / ")
ELSE
SB.setSel("sel: ", chars, lines, " | ")
END;
SB.setEnc(E.eolNames[T.getEol(text)], E.names[T.getEnc(text)]); SB.setEnc(E.eolNames[T.getEol(text)], E.names[T.getEnc(text)]);
SB.draw(LEFT, height - BOTTOM + scrollWidth - 1); SB.draw(LEFT, height - BOTTOM + scrollWidth - 1);
Tabs.modify(tabs, getIdx(text), text.modified) Tabs.modify(tabs, getIdx(text), text.modified)
@ -1945,6 +1949,7 @@ VAR
msState: SET; msState: SET;
scroll, x, y, scrollX, scrollY: INTEGER; scroll, x, y, scrollX, scrollY: INTEGER;
pos1, pos2: T.tPoint; pos1, pos2: T.tPoint;
shift, ctrl: BOOLEAN;
PROCEDURE EditBox (VAR eb: EB.tEditBox); PROCEDURE EditBox (VAR eb: EB.tEditBox);
@ -1969,7 +1974,12 @@ BEGIN
END; END;
scroll := K.Scroll(); scroll := K.Scroll();
IF scroll # 0 THEN IF scroll # 0 THEN
T.scroll(text, 0, scroll*3); K.getKBState(shift, ctrl);
IF shift THEN
T.scroll(text, scroll*3, 0)
ELSE
T.scroll(text, 0, scroll*3)
END;
repaint repaint
END; END;
IF leftButton THEN IF leftButton THEN

View File

@ -1,5 +1,5 @@
(* (*
Copyright 2021, 2022 Anton Krotov Copyright 2021-2023 Anton Krotov
This file is part of CEdit. This file is part of CEdit.
@ -50,16 +50,16 @@ BEGIN
END setPos; END setPos;
PROCEDURE setSel* (chars, lines: INTEGER); PROCEDURE setSel* (text: ARRAY OF WCHAR; first, second: INTEGER; delimiter: ARRAY OF WCHAR);
VAR VAR
s1, s2: tString; s1, s2: tString;
BEGIN BEGIN
IF chars # 0 THEN IF first # 0 THEN
s1 := "sel: "; s1 := text;
U.int2str(chars, s2); U.int2str(first, s2);
U.append(s1, s2); U.append(s1, s2);
U.append(s1, " | "); U.append(s1, delimiter);
U.int2str(lines, s2); U.int2str(second, s2);
U.append(s1, s2); U.append(s1, s2);
SB.sel := s1 SB.sel := s1
ELSE ELSE

View File

@ -40,7 +40,7 @@ CONST
mark_width = 2; mark_width = 2;
pad_left = mark_width + 3; pad_left = mark_width + 3;
pad_top = 1; pad_top = 1;
inter = 2; LineSpacing* = 2;
TYPE TYPE
@ -74,7 +74,7 @@ TYPE
lang*: INTEGER; lang*: INTEGER;
enc, eol: INTEGER; enc, eol: INTEGER;
foundList: List.tList; foundList: List.tList;
foundSel: INTEGER; foundSel*, foundCur*, foundCnt*: INTEGER;
searchText: tString; searchText: tString;
LinesVector: Lines.tVector; LinesVector: Lines.tVector;
chLog*: ChangeLog.tLog; chLog*: ChangeLog.tLog;
@ -2389,8 +2389,8 @@ BEGIN
IF ~((scrollY > cursor.Y) OR (scrollY + textsize.Y + 1 <= cursor.Y) OR IF ~((scrollY > cursor.Y) OR (scrollY + textsize.Y + 1 <= cursor.Y) OR
(scrollX > cursor.X) OR (scrollX + textsize.X <= cursor.X)) THEN (scrollX > cursor.X) OR (scrollX + textsize.X <= cursor.X)) THEN
x := (cursor.X - scrollX)*charWidth + padding.left; x := (cursor.X - scrollX)*charWidth + padding.left;
y1 := (cursor.Y - scrollY)*charHeight + padding.top + (inter DIV 2 + 1); y1 := (cursor.Y - scrollY)*charHeight + padding.top + (LineSpacing DIV 2 + 1);
y2 := y1 + charHeight - (inter + 2); y2 := y1 + charHeight - (LineSpacing + 2);
G.notVLine(canvas, x, y1, y2); G.notVLine(canvas, x, y1, y2);
G.notVLine(canvas, x - 1, y1, y2) G.notVLine(canvas, x - 1, y1, y2)
END END
@ -2409,7 +2409,8 @@ BEGIN
pos := MAX((selBeg - text.scroll.X), 0); pos := MAX((selBeg - text.scroll.X), 0);
x := pos*charWidth + padding.left; x := pos*charWidth + padding.left;
G.SetColor(canvas, colors.selback); G.SetColor(canvas, colors.selback);
G.FillRect(canvas, x - 1, y - inter DIV 2, x + Len*charWidth, y - inter DIV 2 + charHeight); G.FillRect(canvas, x - 1, y - LineSpacing DIV 2,
x + Len*charWidth, y - LineSpacing DIV 2 + charHeight);
G.TextOut(canvas, pos*charWidth + padding.left, y, Lines.getPChar(line, firstCharIdx), Len, colors.seltext) G.TextOut(canvas, pos*charWidth + padding.left, y, Lines.getPChar(line, firstCharIdx), Len, colors.seltext)
END drawSelect; END drawSelect;
@ -2485,7 +2486,7 @@ BEGIN
setPadding(pad_left + wNum*2, padding.top) setPadding(pad_left + wNum*2, padding.top)
END; END;
getSelect(text, selBeg, selEnd); getSelect(text, selBeg, selEnd);
y := padding.top + inter DIV 2; y := padding.top + LineSpacing DIV 2;
n := text.scroll.Y; n := text.scroll.Y;
firstLine := getLine2(text, n); firstLine := getLine2(text, n);
@ -2494,7 +2495,8 @@ BEGIN
cnt := textsize.Y; cnt := textsize.Y;
y := y + charHeight*(text.cursor.Y - text.scroll.Y); y := y + charHeight*(text.cursor.Y - text.scroll.Y);
G.SetColor(canvas, colors.back); G.SetColor(canvas, colors.back);
G.FillRect(canvas, padding.left - 2, y - inter DIV 2, size.X - 1, y - inter DIV 2 + charHeight); G.FillRect(canvas, padding.left - 2, y - LineSpacing DIV 2,
size.X - 1, y - LineSpacing DIV 2 + charHeight);
n := text.cursor.Y n := text.cursor.Y
ELSE ELSE
line := firstLine; line := firstLine;
@ -2505,7 +2507,8 @@ BEGIN
backColor := colors.back; backColor := colors.back;
IF (line = text.curLine) & ~selected(text) THEN IF (line = text.curLine) & ~selected(text) THEN
G.SetColor(canvas, colors.curline); G.SetColor(canvas, colors.curline);
G.FillRect(canvas, padding.left - 2, y - inter DIV 2, size.X - 1, y - inter DIV 2 + charHeight); G.FillRect(canvas, padding.left - 2, y - LineSpacing DIV 2,
size.X - 1, y - LineSpacing DIV 2 + charHeight);
backColor := colors.curline backColor := colors.curline
END; END;
SetColor(colors.text, backColor); SetColor(colors.text, backColor);
@ -2524,7 +2527,7 @@ BEGIN
ELSIF (selBeg.Y # n) & (selEnd.Y = n) THEN ELSIF (selBeg.Y # n) & (selEnd.Y = n) THEN
drawSelect(text, line, 0, selEnd.X, y) drawSelect(text, line, 0, selEnd.X, y)
END; END;
mark(line, y - inter DIV 2); mark(line, y - LineSpacing DIV 2);
NextLine(line); NextLine(line);
INC(y, charHeight); INC(y, charHeight);
INC(n); INC(n);
@ -2535,7 +2538,7 @@ BEGIN
G.FillRect(canvas, 0, 0, padding.left - pad_left (*+ 1*), size.Y - 1); G.FillRect(canvas, 0, 0, padding.left - pad_left (*+ 1*), size.Y - 1);
line := firstLine; line := firstLine;
SetColor(colors.numtext, colors.numback); SetColor(colors.numtext, colors.numback);
y := padding.top + inter DIV 2; y := padding.top + LineSpacing DIV 2;
n := MIN(text.scroll.Y + textsize.Y + 1, text.count); n := MIN(text.scroll.Y + textsize.Y + 1, text.count);
FOR i := text.scroll.Y + 1 TO n DO FOR i := text.scroll.Y + 1 TO n DO
IF lineNumbers THEN IF lineNumbers THEN
@ -2544,13 +2547,14 @@ BEGIN
G.TextOut2(canvas, (numWidth - U.lg10(i) - 1)*wNum - wNum DIV 2, y, s, LENGTH(s)) G.TextOut2(canvas, (numWidth - U.lg10(i) - 1)*wNum - wNum DIV 2, y, s, LENGTH(s))
ELSE ELSE
G.SetColor(canvas, colors.numtext); G.SetColor(canvas, colors.numtext);
G.HLine(canvas, y - inter DIV 2 + charHeight DIV 2, xNum - wNum DIV (1 + ORD(i MOD 5 # 0)), xNum) G.HLine(canvas, y - LineSpacing DIV 2 + charHeight DIV 2,
xNum - wNum DIV (1 + ORD(i MOD 5 # 0)), xNum)
END END
END; END;
IF line.label THEN IF line.label THEN
FOR x := wNum DIV 2 TO (padding.left - pad_left) - wNum DIV 2 DO FOR x := wNum DIV 2 TO (padding.left - pad_left) - wNum DIV 2 DO
G.notVLine(canvas, x, y, y + charHeight - (inter + 1)); G.notVLine(canvas, x, y, y + charHeight - (LineSpacing + 1));
G.xorVLine(canvas, x, y, y + charHeight - (inter + 1)) G.xorVLine(canvas, x, y, y + charHeight - (LineSpacing + 1))
END END
END; END;
NextLine(line); NextLine(line);
@ -2569,7 +2573,7 @@ BEGIN
p := text.foundList.first(Search.tPos); p := text.foundList.first(Search.tPos);
pos := Search.next(p, i); pos := Search.next(p, i);
WHILE pos # -1 DO WHILE pos # -1 DO
y := padding.top + inter DIV 2; y := padding.top + LineSpacing DIV 2;
IF text.smallMove THEN IF text.smallMove THEN
y := y + charHeight*(text.cursor.Y - text.scroll.Y) y := y + charHeight*(text.cursor.Y - text.scroll.Y)
END; END;
@ -2587,7 +2591,7 @@ BEGIN
n := LENGTH(text.searchText)*charWidth; n := LENGTH(text.searchText)*charWidth;
WHILE n > 0 DO WHILE n > 0 DO
IF x >= padding.left THEN IF x >= padding.left THEN
G.notVLine(canvas, x, y, y + charHeight - inter) G.notVLine(canvas, x, y, y + charHeight - LineSpacing)
END; END;
INC(x); INC(x);
DEC(n) DEC(n)
@ -2601,11 +2605,11 @@ BEGIN
IF text.foundSel > 0 THEN IF text.foundSel > 0 THEN
x := (text.cursor.X - text.scroll.X)*charWidth + padding.left; x := (text.cursor.X - text.scroll.X)*charWidth + padding.left;
y := (text.cursor.Y - text.scroll.Y)*charHeight + padding.top + inter DIV 2; y := (text.cursor.Y - text.scroll.Y)*charHeight + padding.top + LineSpacing DIV 2;
n := text.foundSel*charWidth; n := text.foundSel*charWidth;
WHILE n > 0 DO WHILE n > 0 DO
IF x >= padding.left THEN IF x >= padding.left THEN
G.xorVLine(canvas, x, y, y + charHeight - inter) G.xorVLine(canvas, x, y, y + charHeight - LineSpacing)
END; END;
INC(x); INC(x);
DEC(n) DEC(n)
@ -2689,7 +2693,7 @@ PROCEDURE setCanvas* (_canvas: G.tCanvas);
BEGIN BEGIN
canvas := _canvas; canvas := _canvas;
charWidth := _canvas.font.width; charWidth := _canvas.font.width;
charHeight := _canvas.font.height + inter charHeight := _canvas.font.height + LineSpacing
END setCanvas; END setCanvas;
@ -2766,7 +2770,7 @@ VAR
cursorPos, x, y, X, Y, Len: INTEGER; cursorPos, x, y, X, Y, Len: INTEGER;
line: tLine; line: tLine;
res: BOOLEAN; res: BOOLEAN;
pos, i, pos0: INTEGER; pos, i, pos0, first, last, num, cnt: INTEGER;
p: Search.tPos; p: Search.tPos;
BEGIN BEGIN
X := text.cursor.X; X := text.cursor.X;
@ -2774,16 +2778,47 @@ BEGIN
text.cursor.X := MIN(text.cursor.X, text.curLine.length); text.cursor.X := MIN(text.cursor.X, text.curLine.length);
cursorPos := text.curLine.pos + text.cursor.X - ORD(prev) - ORD(~prev & (text.foundSel = 0)); cursorPos := text.curLine.pos + text.cursor.X - ORD(prev) - ORD(~prev & (text.foundSel = 0));
pos0 := -1; pos0 := -1;
cnt := 0;
IF text.foundList.count # 0 THEN
p := text.foundList.first(Search.tPos);
first := p.pos[0];
WHILE p # NIL DO
INC(cnt, p.cnt);
p := p.next(Search.tPos)
END;
p := text.foundList.last(Search.tPos);
last := p.pos[p.cnt - 1]
ELSE
first := -1;
last := -1
END;
text.foundCnt := cnt;
num := 1;
i := 0; i := 0;
p := text.foundList.first(Search.tPos); p := text.foundList.first(Search.tPos);
pos := Search.next(p, i); pos := Search.next(p, i);
WHILE (pos # -1) & (pos <= cursorPos) DO WHILE (pos # -1) & (pos <= cursorPos) DO
pos0 := pos; pos0 := pos;
pos := Search.next(p, i) pos := Search.next(p, i);
INC(num)
END; END;
IF prev THEN IF prev THEN
pos := pos0 pos := pos0;
DEC(num)
END; END;
IF pos = -1 THEN
IF prev THEN
pos := last;
num := cnt
ELSE
pos := first;
num := 1
END
END;
res := pos # -1; res := pos # -1;
IF res THEN IF res THEN
y := 0; y := 0;
@ -2806,9 +2841,11 @@ BEGIN
text.scroll.X := MAX(x - 3, 0) text.scroll.X := MAX(x - 3, 0)
END; END;
SetPos(text, x, y); SetPos(text, x, y);
text.foundSel := Len text.foundSel := Len;
text.foundCur := num
ELSE ELSE
SetPos(text, X, Y) SetPos(text, X, Y);
text.foundCur := 0
END END
RETURN res RETURN res
END findNext; END findNext;