mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-11-23 09:21:23 +03:00
compile/run/debug with fasm without script; support docpack; convert cp866 <=> cp1251
git-svn-id: svn://kolibrios.org@9674 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
8fdd480786
commit
2edd1b82f9
Binary file not shown.
@ -101,7 +101,7 @@ delim = =
|
||||
KW1 =
|
||||
KW2 =
|
||||
KW3 =
|
||||
delim = {}[]<>:,()&*/|+-\#
|
||||
delim = {}[]<>=:,()&*/|+-\#
|
||||
|
||||
[lang_JSON]
|
||||
KW1 =
|
||||
|
@ -40,6 +40,7 @@
|
||||
|
||||
ctrl+F9 компилировать
|
||||
F9 выполнить
|
||||
ctrl+F8 отладка
|
||||
|
||||
перемещение по тексту:
|
||||
(ctrl+)Home, (ctrl+)End, (ctrl+)PageUp, (ctrl+)PageDown
|
||||
|
@ -24,11 +24,11 @@ IMPORT
|
||||
U := Utils, Lines, Menu, List,
|
||||
G := Graph, T := Text, E := Encodings,
|
||||
CB := Clipboard, Languages,
|
||||
ChangeLog, Scroll, CheckBox,
|
||||
ChangeLog, Scroll, CheckBox, KOSAPI, SYSTEM,
|
||||
RW, Ini, EB := EditBox, Tabs, Toolbar, SB := StatusBar;
|
||||
|
||||
CONST
|
||||
HEADER = "CEdit (26-jan-2022)";
|
||||
HEADER = "CEdit (28-jan-2022)";
|
||||
|
||||
ShellFilter = "";
|
||||
EditFilter = "SH|INC|TXT|ASM|OB07|C|CPP|H|PAS|PP|LUA|INI|JSON";
|
||||
@ -119,12 +119,15 @@ CONST
|
||||
menuRunScript = 53;
|
||||
menuDebug = 54;
|
||||
menuDebugScript = 55;
|
||||
menuFASM = 56;
|
||||
|
||||
menuUTF8BOM = 60;
|
||||
menuUTF8 = 61;
|
||||
menuCP866 = 62;
|
||||
menuWin1251 = 63;
|
||||
menuEOL = 140;
|
||||
menuConv1251_866 = 64;
|
||||
menuConv866_1251 = 65;
|
||||
|
||||
menuPipet = 70;
|
||||
menuMagnify = 71;
|
||||
@ -413,8 +416,8 @@ BEGIN
|
||||
Toolbar.enable(toolbar, btnRedo, ~ChangeLog.isLastGuard(text.edition));
|
||||
Toolbar.enable(toolbar, btnUpper, T.selected(text));
|
||||
Toolbar.enable(toolbar, btnLower, T.selected(text));
|
||||
Toolbar.enable(toolbar, btnBuild, buildScript # "");
|
||||
Toolbar.enable(toolbar, btnRun, runScript # "");
|
||||
Toolbar.enable(toolbar, btnBuild, (buildScript # "") OR text.fasm);
|
||||
Toolbar.enable(toolbar, btnRun, (runScript # "") OR text.fasm);
|
||||
Toolbar.drawIcons(toolbar)
|
||||
END
|
||||
END repaint;
|
||||
@ -795,7 +798,7 @@ BEGIN
|
||||
IF fileName # "" THEN
|
||||
n := getFileNum(fileName);
|
||||
IF n = -1 THEN
|
||||
nov := T.open(fileName, err);
|
||||
nov := T.open(fileName, 0, 0, err);
|
||||
IF nov = NIL THEN
|
||||
error("error opening file");
|
||||
SwitchTab(curText);
|
||||
@ -1060,9 +1063,13 @@ BEGIN
|
||||
Menu.option(menu, menuOberon, text.lang = Languages.langOberon);
|
||||
Menu.option(menu, menuPascal, text.lang = Languages.langPascal);
|
||||
ELSIF menu = menuProgram THEN
|
||||
Menu.setEnabled(menu, menuBuild, buildScript # "");
|
||||
Menu.setEnabled(menu, menuDebug, debugScript # "");
|
||||
Menu.setEnabled(menu, menuRun, runScript # "")
|
||||
Menu.setEnabled(menu, menuBuild, (buildScript # "") OR text.fasm);
|
||||
Menu.setEnabled(menu, menuDebug, (debugScript # "") OR text.fasm);
|
||||
Menu.setEnabled(menu, menuRun, (runScript # "") OR text.fasm);
|
||||
Menu.setEnabled(menu, menuBuildScript, ~text.fasm);
|
||||
Menu.setEnabled(menu, menuDebugScript, ~text.fasm);
|
||||
Menu.setEnabled(menu, menuRunScript, ~text.fasm);
|
||||
Menu.check(menu, menuFASM, text.fasm)
|
||||
ELSIF menu = menuOptions THEN
|
||||
Menu.check(menu, menuLineNumbers, T.lineNumbers);
|
||||
Menu.check(menu, menuAutoIndents, T.autoIndents);
|
||||
@ -1106,6 +1113,64 @@ BEGIN
|
||||
END setScript;
|
||||
|
||||
|
||||
PROCEDURE FasmCompile (run, debug: BOOLEAN);
|
||||
VAR
|
||||
curFileName, ext, outfile, path, param: RW.tFileName;
|
||||
BEGIN
|
||||
curFileName := texts[curText].fileName;
|
||||
U.getFileName(curFileName, param, U.SLASH);
|
||||
U.getFileName(curFileName, ext, ".");
|
||||
U.getPath(curFileName, path);
|
||||
outfile := param;
|
||||
IF (ext # "") & ((LENGTH(ext) + 1) < LENGTH(outfile)) THEN
|
||||
outfile[LENGTH(outfile) - LENGTH(ext) - 1] := 0X
|
||||
ELSE
|
||||
U.append8(outfile, ".kex")
|
||||
END;
|
||||
U.append8(param, ",");
|
||||
U.append8(param, outfile);
|
||||
U.append8(param, ",");
|
||||
U.append8(param, path);
|
||||
U.append8(param, U.SLASH);
|
||||
IF run THEN
|
||||
U.append8(param, ",run")
|
||||
ELSIF debug THEN
|
||||
U.append8(param, ",dbg")
|
||||
END;
|
||||
K.Run("/sys/develop/fasm", param)
|
||||
END FasmCompile;
|
||||
|
||||
|
||||
PROCEDURE ProgramBuild;
|
||||
BEGIN
|
||||
IF ~text.fasm THEN
|
||||
Script(buildScript)
|
||||
ELSE
|
||||
FasmCompile(FALSE, FALSE)
|
||||
END
|
||||
END ProgramBuild;
|
||||
|
||||
|
||||
PROCEDURE ProgramRun;
|
||||
BEGIN
|
||||
IF ~text.fasm THEN
|
||||
Script(runScript)
|
||||
ELSE
|
||||
FasmCompile(TRUE, FALSE)
|
||||
END
|
||||
END ProgramRun;
|
||||
|
||||
|
||||
PROCEDURE ProgramDebug;
|
||||
BEGIN
|
||||
IF ~text.fasm THEN
|
||||
Script(debugScript)
|
||||
ELSE
|
||||
FasmCompile(FALSE, TRUE)
|
||||
END
|
||||
END ProgramDebug;
|
||||
|
||||
|
||||
PROCEDURE ClickMenu;
|
||||
VAR
|
||||
item: List.tItem;
|
||||
@ -1187,17 +1252,19 @@ BEGIN
|
||||
|menuPascal:
|
||||
T.setLang(text, Languages.langPascal)
|
||||
|menuBuild:
|
||||
Script(buildScript)
|
||||
ProgramBuild
|
||||
|menuBuildScript:
|
||||
setScript(buildScript)
|
||||
|menuRun:
|
||||
Script(runScript)
|
||||
ProgramRun
|
||||
|menuRunScript:
|
||||
setScript(runScript)
|
||||
|menuDebug:
|
||||
Script(debugScript)
|
||||
ProgramDebug
|
||||
|menuDebugScript:
|
||||
setScript(debugScript)
|
||||
|menuFASM:
|
||||
text.fasm := ~text.fasm
|
||||
|menuUTF8BOM:
|
||||
T.setEnc(text, E.UTF8BOM)
|
||||
|menuUTF8:
|
||||
@ -1212,6 +1279,10 @@ BEGIN
|
||||
T.setEol(text, E.EOL_CRLF)
|
||||
|menuCR:
|
||||
T.setEol(text, E.EOL_CR)
|
||||
|menuConv1251_866:
|
||||
T.convert(text, E.cp866, E.W1251)
|
||||
|menuConv866_1251:
|
||||
T.convert(text, E.cp1251, E.CP866)
|
||||
|menuPipet:
|
||||
K.Run("/sys/develop/pipet", "")
|
||||
|menuMagnify:
|
||||
@ -1346,6 +1417,9 @@ BEGIN
|
||||
Menu.delimiter(menu);
|
||||
Menu.AddMenuItem(menu, menuEOL, "EOL");
|
||||
Menu.child(menu, subEOL);
|
||||
Menu.delimiter(menu);
|
||||
Menu.AddMenuItem(menu, menuConv1251_866, "convert 1251 >> 866");
|
||||
Menu.AddMenuItem(menu, menuConv866_1251, "convert 866 >> 1251");
|
||||
RETURN Menu.create(menu)
|
||||
END CreateMenuEncoding;
|
||||
|
||||
@ -1415,8 +1489,10 @@ BEGIN
|
||||
Menu.AddMenuItem(menu, menuRun, "run F9");
|
||||
Menu.AddMenuItem(menu, menuRunScript, "script");
|
||||
Menu.delimiter(menu);
|
||||
Menu.AddMenuItem(menu, menuDebug, "debug");
|
||||
Menu.AddMenuItem(menu, menuDebug, "debug ctrl-F8");
|
||||
Menu.AddMenuItem(menu, menuDebugScript, "script");
|
||||
Menu.delimiter(menu);
|
||||
Menu.AddMenuItem(menu, menuFASM, "Fasm");
|
||||
RETURN Menu.create(menu)
|
||||
END CreateMenuProgram;
|
||||
|
||||
@ -1511,6 +1587,7 @@ BEGIN
|
||||
Menu.AddShortcut(31 + CTRL, menuSave);
|
||||
Menu.AddShortcut(49 + CTRL, menuNew);
|
||||
Menu.AddShortcut(67 + CTRL, menuBuild);
|
||||
Menu.AddShortcut(66 + CTRL, menuDebug);
|
||||
Menu.AddShortcut(83 + CTRL, menuRemove);
|
||||
Menu.AddShortcut(22 + CTRL, menuUpper);
|
||||
Menu.AddShortcut(38 + CTRL, menuLower);
|
||||
@ -1570,12 +1647,17 @@ BEGIN
|
||||
ELSE
|
||||
T.gotoLabel(text, ~shift)
|
||||
END
|
||||
ELSIF keyCode = 66 THEN (* F8 *)
|
||||
key := -1;
|
||||
IF ctrl THEN
|
||||
ProgramDebug
|
||||
END
|
||||
ELSIF keyCode = 67 THEN (* F9 *)
|
||||
key := -1;
|
||||
IF ctrl THEN
|
||||
Script(buildScript)
|
||||
ProgramBuild
|
||||
ELSE
|
||||
Script(runScript)
|
||||
ProgramRun
|
||||
END
|
||||
ELSIF keyCode = 68 THEN (* F10 *)
|
||||
IF shift THEN
|
||||
@ -1767,9 +1849,9 @@ BEGIN
|
||||
|btnLower:
|
||||
T.chCase(text, FALSE)
|
||||
|btnBuild:
|
||||
Script(buildScript)
|
||||
ProgramBuild
|
||||
|btnRun:
|
||||
Script(runScript)
|
||||
ProgramRun
|
||||
|btnFindNext:
|
||||
IF searchText # "" THEN
|
||||
notFound := ~T.findNext(text, BKW.value);
|
||||
@ -1940,6 +2022,47 @@ BEGIN
|
||||
END ScrollChange;
|
||||
|
||||
|
||||
PROCEDURE docpack (VAR param: RW.tFileName);
|
||||
VAR
|
||||
i, size, errno: INTEGER;
|
||||
ptr, ptr2: INTEGER;
|
||||
s: ARRAY 32 OF WCHAR;
|
||||
BEGIN
|
||||
U.reverse8(param);
|
||||
param[LENGTH(param) - 1] := 0X;
|
||||
U.reverse8(param);
|
||||
i := 0;
|
||||
WHILE param[i] # 0X DO
|
||||
s[i] := WCHR(ORD(param[i]));
|
||||
INC(i)
|
||||
END;
|
||||
IF U.str2int(s, size) THEN
|
||||
INC(size, 20);
|
||||
ptr := KOSAPI.malloc(size);
|
||||
IF ptr # 0 THEN
|
||||
SYSTEM.PUT32(ptr, 0);
|
||||
SYSTEM.PUT32(ptr + 4, 8);
|
||||
KOSAPI.sysfunc4(60, 1, ptr, size);
|
||||
K.SetEventsMask({6});
|
||||
IF K.EventTimeout(200) = 7 THEN
|
||||
SYSTEM.PUT32(ptr, 1);
|
||||
SYSTEM.GET(ptr + 12, size);
|
||||
ptr2 := KOSAPI.malloc(size);
|
||||
IF ptr2 # 0 THEN
|
||||
SYSTEM.MOVE(ptr + 16, ptr2, size);
|
||||
text := T.open("", ptr2, size, errno);
|
||||
IF text # NIL THEN
|
||||
insert(0, text);
|
||||
T.SetPos(text, 0, 0)
|
||||
END
|
||||
END
|
||||
END;
|
||||
ptr := KOSAPI.free(ptr)
|
||||
END
|
||||
END
|
||||
END docpack;
|
||||
|
||||
|
||||
PROCEDURE main;
|
||||
VAR
|
||||
fileName, filePath: RW.tFileName;
|
||||
@ -2042,8 +2165,12 @@ BEGIN
|
||||
END;
|
||||
FOR i := 1 TO Args.argc - 1 DO
|
||||
Args.GetArg(i, fileName);
|
||||
IF open(fileName) THEN
|
||||
U.getPath(fileName, filePath)
|
||||
IF fileName[0] # "*" THEN
|
||||
IF open(fileName) THEN
|
||||
U.getPath(fileName, filePath)
|
||||
END
|
||||
ELSE
|
||||
docpack(fileName)
|
||||
END
|
||||
END;
|
||||
IF textsCount = 0 THEN
|
||||
|
@ -1,5 +1,5 @@
|
||||
(*
|
||||
Copyright 2021 Anton Krotov
|
||||
Copyright 2021, 2022 Anton Krotov
|
||||
|
||||
This file is part of CEdit.
|
||||
|
||||
|
@ -28,12 +28,12 @@ CONST
|
||||
CR = 0DX; LF = 0AX;
|
||||
|
||||
TYPE
|
||||
CP = ARRAY 256 OF INTEGER;
|
||||
CP* = ARRAY 256 OF INTEGER;
|
||||
|
||||
tEOL* = ARRAY 3 OF WCHAR;
|
||||
|
||||
VAR
|
||||
cpW1251*, cp866*: CP;
|
||||
cp1251*, cp866*: CP;
|
||||
names*: ARRAY 4, 16 OF WCHAR;
|
||||
UNI*: ARRAY 65536, 2 OF INTEGER;
|
||||
|
||||
@ -117,8 +117,8 @@ BEGIN
|
||||
UNI[i, W1251] := UNDEF
|
||||
END;
|
||||
FOR i := 0 TO 255 DO
|
||||
IF cpW1251[i] # UNDEF THEN
|
||||
UNI[cpW1251[i], W1251] := i
|
||||
IF cp1251[i] # UNDEF THEN
|
||||
UNI[cp1251[i], W1251] := i
|
||||
END;
|
||||
IF cp866[i] # UNDEF THEN
|
||||
UNI[cp866[i], CP866] := i
|
||||
@ -138,7 +138,7 @@ BEGIN
|
||||
names[W1251] := "Windows-1251";
|
||||
names[UTF8] := "UTF-8";
|
||||
names[UTF8BOM] := "UTF-8-BOM";
|
||||
InitW1251(cpW1251);
|
||||
InitW1251(cp1251);
|
||||
InitCP866(cp866);
|
||||
setUNI
|
||||
END Encodings.
|
@ -51,6 +51,8 @@ TYPE
|
||||
|
||||
tVectorItem = tLine;
|
||||
|
||||
fConvert* = PROCEDURE (VAR c: WCHAR): BOOLEAN;
|
||||
|
||||
|
||||
VAR
|
||||
|
||||
@ -497,19 +499,14 @@ BEGIN
|
||||
END copy;
|
||||
|
||||
|
||||
PROCEDURE chCase* (line: tLine; pos1, pos2: INTEGER; upper: BOOLEAN): BOOLEAN;
|
||||
PROCEDURE convert* (line: tLine; pos1, pos2: INTEGER; func: fConvert): BOOLEAN;
|
||||
VAR
|
||||
i: INTEGER;
|
||||
modified: BOOLEAN;
|
||||
c: WCHAR;
|
||||
func: PROCEDURE (VAR c: WCHAR): BOOLEAN;
|
||||
BEGIN
|
||||
ASSERT(func # NIL);
|
||||
modified := FALSE;
|
||||
IF upper THEN
|
||||
func := Utils.cap
|
||||
ELSE
|
||||
func := Utils.low
|
||||
END;
|
||||
i := pos2;
|
||||
WHILE i >= pos1 DO
|
||||
c := getChar(line, i);
|
||||
@ -532,7 +529,7 @@ BEGIN
|
||||
modify(line)
|
||||
END
|
||||
RETURN modified
|
||||
END chCase;
|
||||
END convert;
|
||||
|
||||
|
||||
PROCEDURE init* (movInt: PmovInt; movPtr: PmovPtr; movBool, movBool2: PmovBool; typedPtr: PTypedPtr; untypedPtr: PUntypedPtr);
|
||||
|
@ -144,7 +144,7 @@ END getCharUTF8;
|
||||
|
||||
|
||||
PROCEDURE getCharW1251 (file: tInput): INTEGER;
|
||||
RETURN E.cpW1251[getByte(file)]
|
||||
RETURN E.cp1251[getByte(file)]
|
||||
END getCharW1251;
|
||||
|
||||
|
||||
@ -344,23 +344,17 @@ BEGIN
|
||||
END createStrBuf;
|
||||
|
||||
|
||||
PROCEDURE load* (name: tFileName; VAR enc, eol: INTEGER): tInput;
|
||||
PROCEDURE _loadFromMem (ptr, size: INTEGER; cp866: BOOLEAN; VAR enc, eol: INTEGER): tInput;
|
||||
VAR
|
||||
res: tInput;
|
||||
fsize: INTEGER;
|
||||
BEGIN
|
||||
NEW(res);
|
||||
res.pos := 0;
|
||||
res.CR := FALSE;
|
||||
res.getChar := NIL;
|
||||
res.clipbrd := FALSE;
|
||||
fsize := File.FileSize(name);
|
||||
IF fsize = 0 THEN
|
||||
res.buffer := KOSAPI.malloc(4096);
|
||||
res.cnt := 0
|
||||
ELSE
|
||||
res.buffer := File.Load(name, res.cnt)
|
||||
END;
|
||||
res.buffer := ptr;
|
||||
res.cnt := size;
|
||||
IF res.buffer = 0 THEN
|
||||
DISPOSE(res)
|
||||
ELSE
|
||||
@ -370,13 +364,37 @@ BEGIN
|
||||
ELSIF enc = E.CP866 THEN
|
||||
res.getChar := getCharCP866
|
||||
ELSIF enc = E.W1251 THEN
|
||||
res.getChar := getCharW1251
|
||||
IF cp866 THEN
|
||||
enc := E.CP866;
|
||||
res.getChar := getCharCP866
|
||||
ELSE
|
||||
res.getChar := getCharW1251
|
||||
END
|
||||
END;
|
||||
eol := detectEOL(res);
|
||||
createStrBuf(res)
|
||||
END
|
||||
RETURN res
|
||||
END load;
|
||||
END _loadFromMem;
|
||||
|
||||
|
||||
PROCEDURE loadFromMem* (ptr, size: INTEGER; VAR enc, eol: INTEGER): tInput;
|
||||
RETURN _loadFromMem(ptr, size, TRUE, enc, eol)
|
||||
END loadFromMem;
|
||||
|
||||
|
||||
PROCEDURE loadFromFile* (name: tFileName; VAR enc, eol: INTEGER): tInput;
|
||||
VAR
|
||||
ptr, size: INTEGER;
|
||||
BEGIN
|
||||
size := File.FileSize(name);
|
||||
IF size = 0 THEN
|
||||
ptr := KOSAPI.malloc(4096)
|
||||
ELSE
|
||||
ptr := File.Load(name, size)
|
||||
END
|
||||
RETURN _loadFromMem(ptr, size, FALSE, enc, eol)
|
||||
END loadFromFile;
|
||||
|
||||
|
||||
PROCEDURE clipboard* (): tInput;
|
||||
|
@ -67,13 +67,12 @@ TYPE
|
||||
CurX: INTEGER;
|
||||
smallChange: INTEGER;
|
||||
modified*, smallMove,
|
||||
comments, guard,
|
||||
comments, guard, fasm*,
|
||||
search, cs, whole: BOOLEAN;
|
||||
edition*: tGuard;
|
||||
curLine: tLine;
|
||||
lang*: INTEGER;
|
||||
enc, eol: INTEGER;
|
||||
table: Search.IdxTable;
|
||||
foundList: List.tList;
|
||||
foundSel: INTEGER;
|
||||
searchText: tString;
|
||||
@ -101,11 +100,15 @@ VAR
|
||||
size, textsize: tPoint;
|
||||
charWidth, charHeight: INTEGER;
|
||||
autoIndents*, lineNumbers*, autoBrackets*, trimSpace*: BOOLEAN;
|
||||
idxTable: Search.IdxTable;
|
||||
|
||||
|
||||
PROCEDURE setLang* (text: tText; lang: INTEGER);
|
||||
BEGIN
|
||||
text.lang := lang;
|
||||
IF text.lang # lang THEN
|
||||
text.fasm := lang = Lang.langFasm;
|
||||
text.lang := lang
|
||||
END;
|
||||
text.comments := TRUE;
|
||||
Lang.setCurLang(text.lang)
|
||||
END setLang;
|
||||
@ -298,6 +301,18 @@ BEGIN
|
||||
END Comments;
|
||||
|
||||
|
||||
PROCEDURE leadingSpaces (line: tLine): INTEGER;
|
||||
VAR
|
||||
i: INTEGER;
|
||||
BEGIN
|
||||
i := 0;
|
||||
WHILE Lines.isSpace(Lines.getChar(line, i)) DO
|
||||
INC(i)
|
||||
END
|
||||
RETURN i
|
||||
END leadingSpaces;
|
||||
|
||||
|
||||
PROCEDURE parse (text: tText; line: tLine; y: INTEGER; backColor: INTEGER; lang: INTEGER);
|
||||
VAR
|
||||
c: WCHAR;
|
||||
@ -813,7 +828,7 @@ BEGIN
|
||||
ELSIF lang = Lang.langIni THEN
|
||||
|
||||
IF depth = 0 THEN
|
||||
IF (c = ";") OR (c = "#") THEN
|
||||
IF ((c = ";") OR (c = "#")) & (leadingSpaces(line) = i) THEN
|
||||
PrintLex(text, line, i, n, y, colors.comment, backColor);
|
||||
i := n
|
||||
ELSIF c = '"' THEN
|
||||
@ -844,18 +859,6 @@ BEGIN
|
||||
END parse;
|
||||
|
||||
|
||||
PROCEDURE leadingSpaces (line: tLine): INTEGER;
|
||||
VAR
|
||||
i: INTEGER;
|
||||
BEGIN
|
||||
i := 0;
|
||||
WHILE Lines.isSpace(Lines.getChar(line, i)) DO
|
||||
INC(i)
|
||||
END
|
||||
RETURN i
|
||||
END leadingSpaces;
|
||||
|
||||
|
||||
PROCEDURE plain (text: tText): CB.tBuffer;
|
||||
VAR
|
||||
buf: CB.tBuffer;
|
||||
@ -908,8 +911,8 @@ BEGIN
|
||||
END;
|
||||
IF text.searchText # "" THEN
|
||||
plainText := plain(text);
|
||||
idxData := Search.index(plainText, text.table, cs);
|
||||
Search.find(plainText, text.table, text.searchText, whole, text.foundList);
|
||||
idxData := Search.index(plainText, idxTable, cs);
|
||||
Search.find(plainText, idxTable, text.searchText, whole, text.foundList);
|
||||
res := text.foundList.count > 0
|
||||
END;
|
||||
CB.destroy(plainText);
|
||||
@ -1771,6 +1774,7 @@ PROCEDURE changeCase (text: tText; upper: BOOLEAN);
|
||||
VAR
|
||||
i: INTEGER;
|
||||
line: tLine;
|
||||
func: Lines.fConvert;
|
||||
BEGIN
|
||||
line := text.curLine;
|
||||
i := text.cursor.X - 1;
|
||||
@ -1779,7 +1783,13 @@ BEGIN
|
||||
DEC(i)
|
||||
END;
|
||||
|
||||
IF Lines.chCase(line, i + 1, text.cursor.X - 1, upper) THEN
|
||||
IF upper THEN
|
||||
func := U.cap
|
||||
ELSE
|
||||
func := U.low
|
||||
END;
|
||||
|
||||
IF Lines.convert(line, i + 1, text.cursor.X - 1, func) THEN
|
||||
INC(text.smallChange);
|
||||
modify(text)
|
||||
END
|
||||
@ -1791,6 +1801,7 @@ VAR
|
||||
selBeg, selEnd: tPoint;
|
||||
first, line: Lines.tLine;
|
||||
cnt: INTEGER;
|
||||
func: Lines.fConvert;
|
||||
modified: BOOLEAN;
|
||||
BEGIN
|
||||
modified := FALSE;
|
||||
@ -1799,23 +1810,30 @@ BEGIN
|
||||
first := getLine2(text, selBeg.Y);
|
||||
line := first;
|
||||
cnt := selEnd.Y - selBeg.Y;
|
||||
|
||||
IF upper THEN
|
||||
func := U.cap
|
||||
ELSE
|
||||
func := U.low
|
||||
END;
|
||||
|
||||
IF cnt = 0 THEN
|
||||
IF Lines.chCase(line, selBeg.X, selEnd.X - 1, upper) THEN
|
||||
IF Lines.convert(line, selBeg.X, selEnd.X - 1, func) THEN
|
||||
modified := TRUE
|
||||
END
|
||||
ELSE
|
||||
IF Lines.chCase(line, selBeg.X, line.length - 1, upper) THEN
|
||||
IF Lines.convert(line, selBeg.X, line.length - 1, func) THEN
|
||||
modified := TRUE
|
||||
END;
|
||||
WHILE cnt > 1 DO
|
||||
NextLine(line);
|
||||
IF Lines.chCase(line, 0, line.length - 1, upper) THEN
|
||||
IF Lines.convert(line, 0, line.length - 1, func) THEN
|
||||
modified := TRUE
|
||||
END;
|
||||
DEC(cnt)
|
||||
END;
|
||||
NextLine(line);
|
||||
IF Lines.chCase(line, 0, selEnd.X - 1, upper) THEN
|
||||
IF Lines.convert(line, 0, selEnd.X - 1, func) THEN
|
||||
modified := TRUE
|
||||
END
|
||||
END
|
||||
@ -2536,7 +2554,7 @@ BEGIN
|
||||
END destroy;
|
||||
|
||||
|
||||
PROCEDURE open* (name: RW.tFileName; VAR errno: INTEGER): tText;
|
||||
PROCEDURE open* (name: RW.tFileName; ptr, size: INTEGER; VAR errno: INTEGER): tText;
|
||||
VAR
|
||||
text: tText;
|
||||
file: RW.tInput;
|
||||
@ -2547,7 +2565,11 @@ BEGIN
|
||||
errno := 0;
|
||||
text := create(name);
|
||||
IF text # NIL THEN
|
||||
file := RW.load(name, enc, eol);
|
||||
IF ptr = 0 THEN
|
||||
file := RW.loadFromFile(name, enc, eol)
|
||||
ELSE
|
||||
file := RW.loadFromMem(ptr, size, enc, eol)
|
||||
END;
|
||||
IF file = NIL THEN
|
||||
destroy(text)
|
||||
END
|
||||
@ -2699,6 +2721,65 @@ BEGIN
|
||||
END replaceAll;
|
||||
|
||||
|
||||
PROCEDURE conv (VAR c: WCHAR; cp: E.CP; enc: INTEGER): BOOLEAN;
|
||||
VAR
|
||||
code: INTEGER;
|
||||
res: BOOLEAN;
|
||||
BEGIN
|
||||
res := FALSE;
|
||||
IF (c # 0X) & (c # Lines.NUL) & (c # Lines.TAB1) THEN
|
||||
code := E.UNI[ORD(c), enc];
|
||||
IF (0 <= code) & (code <= 255) THEN
|
||||
code := cp[code]
|
||||
ELSE
|
||||
code := ORD(c)
|
||||
END;
|
||||
res := WCHR(code) # c;
|
||||
c := WCHR(code)
|
||||
END
|
||||
RETURN res
|
||||
END conv;
|
||||
|
||||
|
||||
PROCEDURE conv1251to866 (VAR c: WCHAR): BOOLEAN;
|
||||
RETURN conv(c, E.cp866, E.W1251)
|
||||
END conv1251to866;
|
||||
|
||||
|
||||
PROCEDURE conv866to1251 (VAR c: WCHAR): BOOLEAN;
|
||||
RETURN conv(c, E.cp1251, E.CP866)
|
||||
END conv866to1251;
|
||||
|
||||
|
||||
PROCEDURE convert* (text: tText; cp: E.CP; enc: INTEGER);
|
||||
VAR
|
||||
line: tLine;
|
||||
func: Lines.fConvert;
|
||||
modified: BOOLEAN;
|
||||
BEGIN
|
||||
modified := FALSE;
|
||||
line := text.first(tLine);
|
||||
IF enc = E.CP866 THEN
|
||||
func := conv866to1251
|
||||
ELSIF enc = E.W1251 THEN
|
||||
func := conv1251to866
|
||||
ELSE
|
||||
line := NIL
|
||||
END;
|
||||
|
||||
WHILE line # NIL DO
|
||||
IF Lines.convert(line, 0, line.length - 1, func) THEN
|
||||
modified := TRUE
|
||||
END;
|
||||
NextLine(line)
|
||||
END;
|
||||
|
||||
IF modified THEN
|
||||
modify(text)
|
||||
END
|
||||
END convert;
|
||||
|
||||
|
||||
PROCEDURE New* (): tText;
|
||||
VAR
|
||||
text: tText;
|
||||
|
Loading…
Reference in New Issue
Block a user