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

View File

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

View File

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

View File

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