CEdit: ctrl+left/right moves the cursor to the next or previous word; small changes

git-svn-id: svn://kolibrios.org@9336 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Anton Krotov 2021-11-27 17:19:15 +00:00
parent f71ae8ed96
commit 63f51aa53b
6 changed files with 148 additions and 58 deletions

Binary file not shown.

View File

@ -6,7 +6,8 @@
ctrl+X вырезать
ctrl+L преобразовать в нижний регистр
ctrl+U преобразовать в верхний регистр
ctrl+F показать панель поиска
ctrl+F,
ctrl+H показать панель поиска/замены
Esc закрыть панель поиска; закрыть меню
shift+Esc скрыть (свернуть) панель поиска
F10 открыть главное меню
@ -40,3 +41,4 @@
перемещение по тексту:
(ctrl+)Home, (ctrl+)End, (ctrl+)PageUp, (ctrl+)PageDown
ctrl+Left, ctrl+Right

View File

@ -28,7 +28,7 @@ IMPORT
RW, Ini, EB := EditBox, Icons, Tabs, Timer;
CONST
HEADER = "CEdit (21-nov-2021)";
HEADER = "CEdit (27-nov-2021)";
ShellFilter = "";
EditFilter = "SH|INC|TXT|ASM|OB07|C|CPP|H|PAS|PP|LUA|INI|JSON";
@ -181,6 +181,7 @@ VAR
AppPath, runScript, buildScript, debugScript: RW.tFileName;
OD: OpenDlg.Dialog;
confirm, notFound, menuFindClicked, search, searchOpened, modified: BOOLEAN;
eol, enc: INTEGER;
switch, closing: BOOLEAN;
leftButton: BOOLEAN;
@ -408,10 +409,12 @@ VAR
s: ARRAY 24 OF WCHAR;
header: RW.tFileName;
BEGIN
eol := T.getEol(text);
enc := T.getEnc(text);
s := "";
U.append(s, RW.eolNames[text.eol]);
U.append(s, RW.eolNames[eol]);
U.append(s, 20X + 20X);
U.append(s, E.names[text.enc]);
U.append(s, E.names[enc]);
header := HEADER;
IF text.fileName # "" THEN
U.append8(header, " - ");
@ -462,7 +465,9 @@ BEGIN
K.DrawRect(LEFT, TOP + canvas.height + scrollWidth, 16*fontWidth, BOTTOM - scrollWidth + 1, K.winColor);
WritePos(y);
IF modified # text.modified THEN
IF (enc # T.getEnc(text)) OR (eol # T.getEol(text)) THEN
DrawState(text, width, height)
ELSIF modified # text.modified THEN
WriteModified(width - 8*fontWidth, y)
END;
@ -1137,10 +1142,10 @@ BEGIN
CanvasToScreen(x, y)
END
ELSIF menu = menuEncoding THEN
Menu.option(menu, menuUTF8BOM, text.enc = E.UTF8BOM);
Menu.option(menu, menuUTF8, text.enc = E.UTF8);
Menu.option(menu, menuCP866, text.enc = E.CP866);
Menu.option(menu, menuWin1251, text.enc = E.W1251);
Menu.option(menu, menuUTF8BOM, T.getEnc(text) = E.UTF8BOM);
Menu.option(menu, menuUTF8, T.getEnc(text) = E.UTF8);
Menu.option(menu, menuCP866, T.getEnc(text) = E.CP866);
Menu.option(menu, menuWin1251, T.getEnc(text) = E.W1251);
INC(x, menuEncodingX)
ELSIF menu = menuView THEN
Menu.check(menu, menuNumbers, text.numbers);
@ -1180,9 +1185,9 @@ BEGIN
Menu.setEnabled(subCase, menuUpper, selected);
Menu.setEnabled(subCase, menuLower, selected);
Menu.option(subEOL, menuCRLF, text.eol = RW.EOL_CRLF);
Menu.option(subEOL, menuLF, text.eol = RW.EOL_LF);
Menu.option(subEOL, menuCR, text.eol = RW.EOL_CR);
Menu.option(subEOL, menuCRLF, T.getEol(text) = RW.EOL_CRLF);
Menu.option(subEOL, menuLF, T.getEol(text) = RW.EOL_LF);
Menu.option(subEOL, menuCR, T.getEol(text) = RW.EOL_CR);
IF menu # NIL THEN
Timer.kill;
@ -1326,19 +1331,19 @@ BEGIN
|menuDebugScript:
setScript(debugScript)
|menuUTF8BOM:
text.enc := E.UTF8BOM
T.setEnc(text, E.UTF8BOM)
|menuUTF8:
text.enc := E.UTF8
T.setEnc(text, E.UTF8)
|menuCP866:
text.enc := E.CP866
T.setEnc(text, E.CP866)
|menuWin1251:
text.enc := E.W1251
T.setEnc(text, E.W1251)
|menuLF:
text.eol := RW.EOL_LF
T.setEol(text, RW.EOL_LF)
|menuCRLF:
text.eol := RW.EOL_CRLF
T.setEol(text, RW.EOL_CRLF)
|menuCR:
text.eol := RW.EOL_CR
T.setEol(text, RW.EOL_CR)
|menuPipet:
K.Run("/rd/1/develop/pipet", "")
|menuBoard:
@ -1383,7 +1388,8 @@ BEGIN
|21: menuItem := menuRedo
|30: menuItem := menuSelectAll
|32: menuItem := menuDuplicate
|33: menuItem := menuFind
|33,
35: menuItem := menuFind
|34: menuItem := menuGoto
|44: menuItem := menuUndo
|45: menuItem := menuCut
@ -1725,28 +1731,40 @@ BEGIN
ELSIF (keyCode = 15) & ctrl THEN (* ctrl+Tab *)
key := -1;
SwitchTab((curText + 1) MOD textsCount)
ELSIF (keyCode = 33) & ctrl THEN
ELSIF ((keyCode = 33) OR (keyCode = 35)) & ctrl THEN (* ctrl+F, ctrl+H*)
key := -1;
ShowSearchPanel(FALSE)
ELSIF (keyCode = 34) & ctrl THEN
ELSIF (keyCode = 34) & ctrl THEN (* ctrl+G *)
key := -1;
ShowSearchPanel(TRUE)
ELSE
IF EditBox_Focus(FindEdit) THEN
EB.key(FindEdit, key);
EditBox_GetValue(FindEdit, new_searchText);
IF new_searchText # searchText THEN
searchText := new_searchText;
notFound := ~T.search(text, searchText, cs, whole)
IF keyCode = 15 THEN (* Tab *)
SetFocus(ReplaceEdit, TRUE)
ELSE
EB.key(FindEdit, key);
EditBox_GetValue(FindEdit, new_searchText);
IF new_searchText # searchText THEN
searchText := new_searchText;
notFound := ~T.search(text, searchText, cs, whole)
END
END
ELSIF EditBox_Focus(ReplaceEdit) THEN
EB.key(ReplaceEdit, key);
EditBox_GetValue(ReplaceEdit, replaceText)
IF keyCode = 15 THEN (* Tab *)
SetFocus(GotoEdit, TRUE)
ELSE
EB.key(ReplaceEdit, key);
EditBox_GetValue(ReplaceEdit, replaceText)
END
ELSIF EditBox_Focus(GotoEdit) THEN
IF (key DIV 256) MOD 256 = 13 THEN
goto
ELSE
EB.key(GotoEdit, key)
IF keyCode = 15 THEN (* Tab *)
SetFocus(FindEdit, TRUE)
ELSE
IF (key DIV 256) MOD 256 = 13 THEN
goto
ELSE
EB.key(GotoEdit, key)
END
END
ELSE
CASE keyCode OF
@ -2129,8 +2147,8 @@ BEGIN
OD := OpenDlg.Create(draw_window, OpenDlg.topen, filePath, "");
insert(0, text);
Scroll.init(ScrollChange);
Scroll.create(FALSE, canvas.width + 1, scrollWidth, scrollWidth, scrollWidth, hScroll);
Scroll.create(TRUE, scrollWidth, canvas.height + 1, scrollWidth, scrollWidth, vScroll);
Scroll.create(FALSE, canvas.width + 1, scrollWidth, scrollWidth, scrollWidth*3 DIV 2, hScroll);
Scroll.create(TRUE, scrollWidth, canvas.height + 1, scrollWidth, scrollWidth*3 DIV 2, vScroll);
T.resize(canvas.width, canvas.height);
T.SetPos(text, 0, 0);
confirm := FALSE;

View File

@ -242,7 +242,7 @@ BEGIN
END changeBool2;
PROCEDURE changeInt (VAR v: INTEGER; x: INTEGER);
PROCEDURE changeInt* (VAR v: INTEGER; x: INTEGER);
BEGIN
changeWord(SYSTEM.ADR(v), SYSTEM.ADR(x))
END changeInt;

View File

@ -80,25 +80,25 @@ PROCEDURE InitCP866 (VAR cp: CP);
VAR
n, i: INTEGER;
BEGIN
FOR i := 0410H TO 043FH DO
cp[i - 0410H + 80H] := i
END;
FOR i := 0440H TO 044FH DO
cp[i - 0440H + 0E0H] := i
END;
n := 0B0H;
Init8(cp, n, 2591H, 2592H, 2593H, 2502H, 2524H, 2561H, 2562H, 2556H);
Init8(cp, n, 2555H, 2563H, 2551H, 2557H, 255DH, 255CH, 255BH, 2510H);
Init8(cp, n, 2514H, 2534H, 252CH, 251CH, 2500H, 253CH, 255EH, 255FH);
Init8(cp, n, 255AH, 2554H, 2569H, 2566H, 2560H, 2550H, 256CH, 2567H);
Init8(cp, n, 2568H, 2564H, 2565H, 2559H, 2558H, 2552H, 2553H, 256BH);
Init8(cp, n, 256AH, 2518H, 250CH, 2588H, 2584H, 258CH, 2590H, 2580H);
FOR i := 0410H TO 043FH DO
cp[i - 0410H + 80H] := i
END;
FOR i := 0440H TO 044FH DO
cp[i - 0440H + 0E0H] := i
END;
n := 0B0H;
Init8(cp, n, 2591H, 2592H, 2593H, 2502H, 2524H, 2561H, 2562H, 2556H);
Init8(cp, n, 2555H, 2563H, 2551H, 2557H, 255DH, 255CH, 255BH, 2510H);
Init8(cp, n, 2514H, 2534H, 252CH, 251CH, 2500H, 253CH, 255EH, 255FH);
Init8(cp, n, 255AH, 2554H, 2569H, 2566H, 2560H, 2550H, 256CH, 2567H);
Init8(cp, n, 2568H, 2564H, 2565H, 2559H, 2558H, 2552H, 2553H, 256BH);
Init8(cp, n, 256AH, 2518H, 250CH, 2588H, 2584H, 258CH, 2590H, 2580H);
n := 0F0H;
Init8(cp, n, 0401H, 0451H, 0404H, 0454H, 0407H, 0457H, 040EH, 045EH);
Init8(cp, n, 00B0H, 2219H, 00B7H, 221AH, 2116H, 00A4H, 25A0H, 00A0H);
n := 0F0H;
Init8(cp, n, 0401H, 0451H, 0404H, 0454H, 0407H, 0457H, 040EH, 045EH);
Init8(cp, n, 00B0H, 2219H, 00B7H, 221AH, 2116H, 00A4H, 25A0H, 00A0H);
InitCP(cp)
InitCP(cp)
END InitCP866;

View File

@ -72,7 +72,7 @@ TYPE
search, cs, whole: BOOLEAN;
curLine: tLine;
lang*: INTEGER;
enc*, eol*: INTEGER;
enc, eol: INTEGER;
table: Search.IdxTable;
foundList: List.tList;
idxData: Search.tBuffer;
@ -883,6 +883,36 @@ BEGIN
END modify;
PROCEDURE setEnc* (text: tText; enc: INTEGER);
BEGIN
IF text.enc # enc THEN
ChangeLog.changeInt(text.enc, enc);
text.enc := enc;
modify(text)
END
END setEnc;
PROCEDURE setEol* (text: tText; eol: INTEGER);
BEGIN
IF text.eol # eol THEN
ChangeLog.changeInt(text.eol, eol);
text.eol := eol;
modify(text)
END
END setEol;
PROCEDURE getEnc* (text: tText): INTEGER;
RETURN text.enc
END getEnc;
PROCEDURE getEol* (text: tText): INTEGER;
RETURN text.eol
END getEol;
PROCEDURE DelLine (text: tText; line: tLine);
BEGIN
List._delete(text, line);
@ -1801,9 +1831,32 @@ BEGIN
END wordSel;
PROCEDURE getWordPos (line: tLine; pos: INTEGER): INTEGER;
VAR
c: WCHAR;
BEGIN
c := getChar(line, pos);
IF isWordChar(c) THEN
WHILE (pos < line.length) & isWordChar(getChar(line, pos)) DO
INC(pos)
END
ELSIF Lines.isSpace(c) THEN
WHILE (pos < line.length) & Lines.isSpace(getChar(line, pos)) DO
INC(pos)
END
ELSE
WHILE (pos < line.length) & ~Lines.isSpace(getChar(line, pos)) & ~isWordChar(getChar(line, pos)) DO
INC(pos)
END
END
RETURN pos
END getWordPos;
PROCEDURE key* (text: tText; code: INTEGER; shift, ctrl: BOOLEAN);
VAR
n: INTEGER;
n, wPos: INTEGER;
BEGIN
IF shift THEN
setSelect(text)
@ -1849,7 +1902,16 @@ BEGIN
IF (text.cursor.X = 0) & (text.curLine.prev # NIL) THEN
SetPos(text, text.curLine.prev(tLine).length, text.cursor.Y - 1)
ELSE
move(text, -1)
IF ctrl THEN
wPos := 0;
REPEAT
n := wPos;
wPos := getWordPos(text.curLine, wPos)
UNTIL wPos >= text.cursor.X;
move(text, n - text.cursor.X)
ELSE
move(text, -1)
END
END
|38:
IF ctrl THEN
@ -1861,7 +1923,11 @@ BEGIN
IF (text.cursor.X = text.curLine.length) & (text.curLine.next # NIL) THEN
SetPos(text, 0, text.cursor.Y + 1)
ELSE
move(text, 1)
IF ctrl THEN
move(text, getWordPos(text.curLine, text.cursor.X) - text.cursor.X)
ELSE
move(text, 1)
END
END
|40:
IF ctrl THEN
@ -1940,7 +2006,7 @@ BEGIN
cursorX := text.cursor.X;
line := text.curLine;
x1 := cursorX - 1;
IF (cursorX < line.length) & isWordChar(getChar(line,cursorX)) THEN
IF (cursorX < line.length) & isWordChar(getChar(line, cursorX)) THEN
x2 := cursorX;
WHILE (x2 < line.length) & isWordChar(getChar(line, x2)) DO
INC(x2)
@ -2292,6 +2358,8 @@ BEGIN
file := RW.load(name, enc, eol);
IF file # NIL THEN
text := create(name);
ChangeLog.changeInt(text.enc, enc);
ChangeLog.changeInt(text.eol, eol);
text.enc := enc;
text.eol := eol;
line := Lines.create(FALSE);
@ -2451,6 +2519,8 @@ BEGIN
text := create("");
List._append(text, Lines.create(FALSE));
text.curLine := text.first(tLine);
ChangeLog.changeInt(text.enc, E.CP866);
ChangeLog.changeInt(text.eol, RW.EOL_CRLF);
text.enc := E.CP866;
text.eol := RW.EOL_CRLF;
SetPos(text, 0, 0);