CEdit: minor changes

git-svn-id: svn://kolibrios.org@9708 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Anton Krotov 2022-02-08 21:57:18 +00:00
parent 44bef28048
commit 1fdbd55957
6 changed files with 87 additions and 80 deletions

Binary file not shown.

View File

@ -24,11 +24,11 @@ IMPORT
U := Utils, Lines, Menu, List, U := Utils, Lines, Menu, List,
G := Graph, T := Text, E := Encodings, G := Graph, T := Text, E := Encodings,
CB := Clipboard, Languages, CB := Clipboard, Languages,
ChangeLog, Scroll, CheckBox, KOSAPI, SYSTEM, ChangeLog, Scroll, CheckBox,
RW, Ini, EB := EditBox, Tabs, Toolbar, SB := StatusBar; RW, Ini, EB := EditBox, Tabs, Toolbar, SB := StatusBar;
CONST CONST
HEADER = "CEdit (28-jan-2022)"; HEADER = "CEdit (09-feb-2022)";
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";
@ -124,7 +124,7 @@ CONST
menuUTF8BOM = 60; menuUTF8BOM = 60;
menuUTF8 = 61; menuUTF8 = 61;
menuCP866 = 62; menuCP866 = 62;
menuWin1251 = 63; menuCP1251 = 63;
menuEOL = 140; menuEOL = 140;
menuConv1251_866 = 64; menuConv1251_866 = 64;
menuConv866_1251 = 65; menuConv866_1251 = 65;
@ -1045,7 +1045,7 @@ BEGIN
Menu.option(menu, menuUTF8BOM, T.getEnc(text) = E.UTF8BOM); Menu.option(menu, menuUTF8BOM, T.getEnc(text) = E.UTF8BOM);
Menu.option(menu, menuUTF8, T.getEnc(text) = E.UTF8); Menu.option(menu, menuUTF8, T.getEnc(text) = E.UTF8);
Menu.option(menu, menuCP866, T.getEnc(text) = E.CP866); Menu.option(menu, menuCP866, T.getEnc(text) = E.CP866);
Menu.option(menu, menuWin1251, T.getEnc(text) = E.W1251) Menu.option(menu, menuCP1251, T.getEnc(text) = E.CP1251)
ELSIF menu = menuView THEN ELSIF menu = menuView THEN
Menu.option(menu, menuFontSmall, font = G.fonts[0]); Menu.option(menu, menuFontSmall, font = G.fonts[0]);
Menu.option(menu, menuFontMedium, font = G.fonts[1]); Menu.option(menu, menuFontMedium, font = G.fonts[1]);
@ -1271,8 +1271,8 @@ BEGIN
T.setEnc(text, E.UTF8) T.setEnc(text, E.UTF8)
|menuCP866: |menuCP866:
T.setEnc(text, E.CP866) T.setEnc(text, E.CP866)
|menuWin1251: |menuCP1251:
T.setEnc(text, E.W1251) T.setEnc(text, E.CP1251)
|menuLF: |menuLF:
T.setEol(text, E.EOL_LF) T.setEol(text, E.EOL_LF)
|menuCRLF: |menuCRLF:
@ -1280,9 +1280,9 @@ BEGIN
|menuCR: |menuCR:
T.setEol(text, E.EOL_CR) T.setEol(text, E.EOL_CR)
|menuConv1251_866: |menuConv1251_866:
T.convert(text, E.cp866, E.W1251) T.convert(text, (*E.cp866,*) E.CP1251)
|menuConv866_1251: |menuConv866_1251:
T.convert(text, E.cp1251, E.CP866) T.convert(text, (*E.cp1251,*) E.CP866)
|menuPipet: |menuPipet:
K.Run("/sys/develop/pipet", "") K.Run("/sys/develop/pipet", "")
|menuMagnify: |menuMagnify:
@ -1413,7 +1413,7 @@ BEGIN
Menu.AddMenuItem(menu, menuUTF8BOM, E.names[E.UTF8BOM]); Menu.AddMenuItem(menu, menuUTF8BOM, E.names[E.UTF8BOM]);
Menu.AddMenuItem(menu, menuUTF8, E.names[E.UTF8]); Menu.AddMenuItem(menu, menuUTF8, E.names[E.UTF8]);
Menu.AddMenuItem(menu, menuCP866, E.names[E.CP866]); Menu.AddMenuItem(menu, menuCP866, E.names[E.CP866]);
Menu.AddMenuItem(menu, menuWin1251, E.names[E.W1251]); Menu.AddMenuItem(menu, menuCP1251, E.names[E.CP1251]);
Menu.delimiter(menu); Menu.delimiter(menu);
Menu.AddMenuItem(menu, menuEOL, "EOL"); Menu.AddMenuItem(menu, menuEOL, "EOL");
Menu.child(menu, subEOL); Menu.child(menu, subEOL);
@ -2022,47 +2022,6 @@ BEGIN
END ScrollChange; 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; PROCEDURE main;
VAR VAR
fileName, filePath: RW.tFileName; fileName, filePath: RW.tFileName;
@ -2070,6 +2029,7 @@ VAR
resized: BOOLEAN; resized: BOOLEAN;
firstClickX, firstClickY, time, blink, i: INTEGER; firstClickX, firstClickY, time, blink, i: INTEGER;
key, scr: INTEGER; key, scr: INTEGER;
text_ptr, text_size, errno: INTEGER;
BEGIN BEGIN
header := ""; header := "";
K.GetSystemColors; K.GetSystemColors;
@ -2170,7 +2130,14 @@ BEGIN
U.getPath(fileName, filePath) U.getPath(fileName, filePath)
END END
ELSE ELSE
docpack(fileName) K.docpack(fileName, text_ptr, text_size);
IF text_ptr # 0 THEN
text := T.open("", text_ptr, text_size, errno);
IF text # NIL THEN
insert(0, text);
T.SetPos(text, 0, 0)
END
END
END END
END; END;
IF textsCount = 0 THEN IF textsCount = 0 THEN

View File

@ -20,7 +20,7 @@
MODULE Encodings; MODULE Encodings;
CONST CONST
CP866* = 0; W1251* = 1; UTF8* = 2; UTF8BOM* = 3; (*UTF16LE* = 4;*) CP866* = 0; CP1251* = 1; UTF8* = 2; UTF8BOM* = 3; (*UTF16LE* = 4;*)
UNDEF* = -1; UNDEF* = -1;
@ -64,7 +64,7 @@ BEGIN
END Init8; END Init8;
PROCEDURE InitW1251 (VAR cp: CP); PROCEDURE InitCP1251 (VAR cp: CP);
VAR VAR
n, i: INTEGER; n, i: INTEGER;
BEGIN BEGIN
@ -81,7 +81,7 @@ BEGIN
Init8(cp, n, 0401H, 00A9H, 0404H, 00ABH, 00ACH, 00ADH, 00AEH, 0407H); Init8(cp, n, 0401H, 00A9H, 0404H, 00ABH, 00ACH, 00ADH, 00AEH, 0407H);
Init8(cp, n, 00B0H, 00B1H, 0406H, 0456H, 0491H, 00B5H, 00B6H, 00B7H); Init8(cp, n, 00B0H, 00B1H, 0406H, 0456H, 0491H, 00B5H, 00B6H, 00B7H);
Init8(cp, n, 0451H, 2116H, 0454H, 00BBH, 0458H, 0405H, 0455H, 0457H); Init8(cp, n, 0451H, 2116H, 0454H, 00BBH, 0458H, 0405H, 0455H, 0457H);
END InitW1251; END InitCP1251;
PROCEDURE InitCP866 (VAR cp: CP); PROCEDURE InitCP866 (VAR cp: CP);
@ -113,12 +113,12 @@ VAR
i: INTEGER; i: INTEGER;
BEGIN BEGIN
FOR i := 0 TO 65535 DO FOR i := 0 TO 65535 DO
UNI[i, CP866] := UNDEF; UNI[i, CP866] := UNDEF;
UNI[i, W1251] := UNDEF UNI[i, CP1251] := UNDEF
END; END;
FOR i := 0 TO 255 DO FOR i := 0 TO 255 DO
IF cp1251[i] # UNDEF THEN IF cp1251[i] # UNDEF THEN
UNI[cp1251[i], W1251] := i UNI[cp1251[i], CP1251] := i
END; END;
IF cp866[i] # UNDEF THEN IF cp866[i] # UNDEF THEN
UNI[cp866[i], CP866] := i UNI[cp866[i], CP866] := i
@ -135,10 +135,10 @@ BEGIN
eolNames[EOL_LF] := "LF"; eolNames[EOL_LF] := "LF";
eolNames[EOL_CR] := "CR"; eolNames[EOL_CR] := "CR";
names[CP866] := "CP866"; names[CP866] := "CP866";
names[W1251] := "Windows-1251"; names[CP1251] := "CP1251";
names[UTF8] := "UTF-8"; names[UTF8] := "UTF-8";
names[UTF8BOM] := "UTF-8-BOM"; names[UTF8BOM] := "UTF-8-BOM";
InitW1251(cp1251); InitCP1251(cp1251);
InitCP866(cp866); InitCP866(cp866);
setUNI setUNI
END Encodings. END Encodings.

View File

@ -20,7 +20,7 @@
MODULE KolibriOS; MODULE KolibriOS;
IMPORT IMPORT
KOSAPI, SYSTEM; KOSAPI, SYSTEM, U := Utils;
CONST CONST
fontWidth* = 8; fontWidth* = 8;
@ -393,6 +393,44 @@ BEGIN
END PutPixel; END PutPixel;
PROCEDURE docpack* (VAR param: ARRAY OF CHAR; VAR text_ptr, text_size: INTEGER);
VAR
i, size, ptr, ptr2: INTEGER;
s: ARRAY 32 OF WCHAR;
BEGIN
ptr2 := 0;
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);
SetEventsMask({6});
IF 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)
END
END;
ptr := KOSAPI.free(ptr)
END
END;
text_ptr := ptr2;
text_size := size
END docpack;
BEGIN BEGIN
GetSystemColors GetSystemColors
END KolibriOS. END KolibriOS.

View File

@ -143,9 +143,9 @@ BEGIN
END getCharUTF8; END getCharUTF8;
PROCEDURE getCharW1251 (file: tInput): INTEGER; PROCEDURE getCharCP1251 (file: tInput): INTEGER;
RETURN E.cp1251[getByte(file)] RETURN E.cp1251[getByte(file)]
END getCharW1251; END getCharCP1251;
PROCEDURE getCharCP866 (file: tInput): INTEGER; PROCEDURE getCharCP866 (file: tInput): INTEGER;
@ -224,7 +224,7 @@ VAR
pos, cnt, res: INTEGER; pos, cnt, res: INTEGER;
continue, bom: BOOLEAN; continue, bom: BOOLEAN;
b: BYTE; b: BYTE;
cp866, w1251: INTEGER; cp866, cp1251: INTEGER;
BEGIN BEGIN
pos := text.pos; pos := text.pos;
cnt := text.cnt; cnt := text.cnt;
@ -257,20 +257,20 @@ BEGIN
ELSE ELSE
text.cnt := cnt; text.cnt := cnt;
text.pos := pos; text.pos := pos;
cp866 := 0; cp866 := 0;
w1251 := 0; cp1251 := 0;
WHILE text.cnt > 0 DO WHILE text.cnt > 0 DO
b := getByte(text); b := getByte(text);
IF b > 127 THEN IF b > 127 THEN
IF b >= 192 THEN IF b >= 192 THEN
INC(w1251) INC(cp1251)
ELSE ELSE
INC(cp866) INC(cp866)
END END
END END
END; END;
IF w1251 > cp866 THEN IF cp1251 > cp866 THEN
res := E.W1251 res := E.CP1251
ELSE ELSE
res := E.CP866 res := E.CP866
END END
@ -363,12 +363,12 @@ BEGIN
res.getChar := getCharUTF8 res.getChar := getCharUTF8
ELSIF enc = E.CP866 THEN ELSIF enc = E.CP866 THEN
res.getChar := getCharCP866 res.getChar := getCharCP866
ELSIF enc = E.W1251 THEN ELSIF enc = E.CP1251 THEN
IF cp866 THEN IF cp866 THEN
enc := E.CP866; enc := E.CP866;
res.getChar := getCharCP866 res.getChar := getCharCP866
ELSE ELSE
res.getChar := getCharW1251 res.getChar := getCharCP1251
END END
END; END;
eol := detectEOL(res); eol := detectEOL(res);
@ -488,10 +488,10 @@ BEGIN
END putCharCP; END putCharCP;
PROCEDURE putCharW1251 (file: tOutput; code: INTEGER); PROCEDURE putCharCP1251 (file: tOutput; code: INTEGER);
BEGIN BEGIN
putCharCP(file, code, E.W1251) putCharCP(file, code, E.CP1251)
END putCharW1251; END putCharCP1251;
PROCEDURE putCharCP866 (file: tOutput; code: INTEGER); PROCEDURE putCharCP866 (file: tOutput; code: INTEGER);
@ -544,8 +544,8 @@ BEGIN
res.putChar := putCharUTF8 res.putChar := putCharUTF8
(*ELSIF enc = E.UTF16LE THEN (*ELSIF enc = E.UTF16LE THEN
res.putChar := putCharUTF16LE*) res.putChar := putCharUTF16LE*)
ELSIF enc = E.W1251 THEN ELSIF enc = E.CP1251 THEN
res.putChar := putCharW1251 res.putChar := putCharCP1251
ELSIF enc = E.CP866 THEN ELSIF enc = E.CP866 THEN
res.putChar := putCharCP866 res.putChar := putCharCP866
END; END;

View File

@ -2734,15 +2734,17 @@ BEGIN
ELSE ELSE
code := ORD(c) code := ORD(c)
END; END;
res := WCHR(code) # c; IF code # ORD(c) THEN
c := WCHR(code) c := WCHR(code);
res := TRUE
END
END END
RETURN res RETURN res
END conv; END conv;
PROCEDURE conv1251to866 (VAR c: WCHAR): BOOLEAN; PROCEDURE conv1251to866 (VAR c: WCHAR): BOOLEAN;
RETURN conv(c, E.cp866, E.W1251) RETURN conv(c, E.cp866, E.CP1251)
END conv1251to866; END conv1251to866;
@ -2751,7 +2753,7 @@ PROCEDURE conv866to1251 (VAR c: WCHAR): BOOLEAN;
END conv866to1251; END conv866to1251;
PROCEDURE convert* (text: tText; cp: E.CP; enc: INTEGER); PROCEDURE convert* (text: tText; (*cp: E.CP;*) enc: INTEGER);
VAR VAR
line: tLine; line: tLine;
func: Lines.fConvert; func: Lines.fConvert;
@ -2761,7 +2763,7 @@ BEGIN
line := text.first(tLine); line := text.first(tLine);
IF enc = E.CP866 THEN IF enc = E.CP866 THEN
func := conv866to1251 func := conv866to1251
ELSIF enc = E.W1251 THEN ELSIF enc = E.CP1251 THEN
func := conv1251to866 func := conv1251to866
ELSE ELSE
line := NIL line := NIL