CEdit: refactoring, minor fixes

git-svn-id: svn://kolibrios.org@9659 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Anton Krotov 2022-01-20 17:15:39 +00:00
parent 23e31695bd
commit c327661fd8
15 changed files with 374 additions and 486 deletions

Binary file not shown.

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 (18-jan-2022)"; HEADER = "CEdit (20-jan-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";
@ -354,7 +354,7 @@ BEGIN
SB.setWidth(canvas.width + scrollWidth); SB.setWidth(canvas.width + scrollWidth);
SB.setPos(line, col); SB.setPos(line, col);
SB.setSel(chars, lines); SB.setSel(chars, lines);
SB.setEnc(RW.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)
END Status; END Status;
@ -833,19 +833,19 @@ BEGIN
END createSearchForm; END createSearchForm;
PROCEDURE EditBox_GetValue (edit: EB.tEditBox; VAR s: ARRAY OF WCHAR); PROCEDURE EditBox_Get (edit: EB.tEditBox; VAR s: ARRAY OF WCHAR);
VAR VAR
str: ARRAY EDITBOX_MAXCHARS + 1 OF CHAR; str: ARRAY EDITBOX_MAXCHARS + 1 OF CHAR;
i: INTEGER; i: INTEGER;
BEGIN BEGIN
EB.getValue(edit, str); EB.get(edit, str);
i := 0; i := 0;
WHILE str[i] # 0X DO WHILE str[i] # 0X DO
s[i] := WCHR(E.cp866[ORD(str[i])]); s[i] := WCHR(E.cp866[ORD(str[i])]);
INC(i) INC(i)
END; END;
s[i] := 0X s[i] := 0X
END EditBox_GetValue; END EditBox_Get;
PROCEDURE Search; PROCEDURE Search;
@ -927,7 +927,7 @@ PROCEDURE goto;
VAR VAR
gotoVal: INTEGER; gotoVal: INTEGER;
BEGIN BEGIN
EditBox_GetValue(GotoEdit, gotoText); EditBox_Get(GotoEdit, gotoText);
IF U.str2int(gotoText, gotoVal) & T.goto(text, gotoVal) THEN IF U.str2int(gotoText, gotoVal) & T.goto(text, gotoVal) THEN
SetFocus(GotoEdit, FALSE) SetFocus(GotoEdit, FALSE)
END END
@ -957,7 +957,7 @@ BEGIN
END; END;
IF new_searchText[i] = 0X THEN IF new_searchText[i] = 0X THEN
searchText := new_searchText; searchText := new_searchText;
EB.setValue(FindEdit, searchText); EB.set(FindEdit, searchText);
notFound := ~T.search(text, searchText, cs, whole); notFound := ~T.search(text, searchText, cs, whole);
END END
END END
@ -1077,9 +1077,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, T.getEol(text) = RW.EOL_CRLF); Menu.option(subEOL, menuCRLF, T.getEol(text) = E.EOL_CRLF);
Menu.option(subEOL, menuLF, T.getEol(text) = RW.EOL_LF); Menu.option(subEOL, menuLF, T.getEol(text) = E.EOL_LF);
Menu.option(subEOL, menuCR, T.getEol(text) = RW.EOL_CR); Menu.option(subEOL, menuCR, T.getEol(text) = E.EOL_CR);
IF menu # NIL THEN IF menu # NIL THEN
timerEnabled := FALSE; timerEnabled := FALSE;
@ -1209,11 +1209,11 @@ BEGIN
|menuWin1251: |menuWin1251:
T.setEnc(text, E.W1251) T.setEnc(text, E.W1251)
|menuLF: |menuLF:
T.setEol(text, RW.EOL_LF) T.setEol(text, E.EOL_LF)
|menuCRLF: |menuCRLF:
T.setEol(text, RW.EOL_CRLF) T.setEol(text, E.EOL_CRLF)
|menuCR: |menuCR:
T.setEol(text, RW.EOL_CR) T.setEol(text, E.EOL_CR)
|menuPipet: |menuPipet:
K.Run("/sys/develop/pipet", "") K.Run("/sys/develop/pipet", "")
|menuMagnify: |menuMagnify:
@ -1344,9 +1344,9 @@ VAR
menu: List.tList; menu: List.tList;
BEGIN BEGIN
menu := List.create(NIL); menu := List.create(NIL);
Menu.AddMenuItem(menu, menuCRLF, RW.eolNames[RW.EOL_CRLF]); Menu.AddMenuItem(menu, menuCRLF, E.eolNames[E.EOL_CRLF]);
Menu.AddMenuItem(menu, menuLF, RW.eolNames[RW.EOL_LF]); Menu.AddMenuItem(menu, menuLF, E.eolNames[E.EOL_LF]);
Menu.AddMenuItem(menu, menuCR, RW.eolNames[RW.EOL_CR]); Menu.AddMenuItem(menu, menuCR, E.eolNames[E.EOL_CR]);
RETURN Menu.create(menu) RETURN Menu.create(menu)
END CreateMenuEOL; END CreateMenuEOL;
@ -1591,7 +1591,7 @@ BEGIN
SetFocus(ReplaceEdit, TRUE) SetFocus(ReplaceEdit, TRUE)
ELSE ELSE
EB.key(FindEdit, key); EB.key(FindEdit, key);
EditBox_GetValue(FindEdit, new_searchText); EditBox_Get(FindEdit, new_searchText);
IF new_searchText # searchText THEN IF new_searchText # searchText THEN
searchText := new_searchText; searchText := new_searchText;
notFound := ~T.search(text, searchText, cs, whole) notFound := ~T.search(text, searchText, cs, whole)
@ -1602,7 +1602,7 @@ BEGIN
SetFocus(GotoEdit, TRUE) SetFocus(GotoEdit, TRUE)
ELSE ELSE
EB.key(ReplaceEdit, key); EB.key(ReplaceEdit, key);
EditBox_GetValue(ReplaceEdit, replaceText) EditBox_Get(ReplaceEdit, replaceText)
END END
ELSIF EditBox_Focus(GotoEdit) THEN ELSIF EditBox_Focus(GotoEdit) THEN
IF keyCode = 15 THEN (* Tab *) IF keyCode = 15 THEN (* Tab *)
@ -1886,11 +1886,9 @@ BEGIN
cliHeight := height; cliHeight := height;
resize; resize;
resized := TRUE resized := TRUE
END; END
K.SetEventsMask({0, 1, 2, 5, 31})
ELSE ELSE
SetCaption(text.fileName); SetCaption(text.fileName)
K.SetEventsMask({0, 30, 31})
END; END;
draw_window; draw_window;
IF SkinHeight # K.SkinHeight() THEN IF SkinHeight # K.SkinHeight() THEN
@ -1921,6 +1919,7 @@ VAR
width, height, cliWidth, cliHeight: INTEGER; width, height, cliWidth, cliHeight: INTEGER;
resized: BOOLEAN; resized: BOOLEAN;
firstClickX, firstClickY, time, blink, i: INTEGER; firstClickX, firstClickY, time, blink, i: INTEGER;
key, scr: INTEGER;
BEGIN BEGIN
header := ""; header := "";
K.GetSystemColors; K.GetSystemColors;
@ -2047,8 +2046,9 @@ BEGIN
timerEnabled := TRUE; timerEnabled := TRUE;
CursorTime := K.GetTickCount(); CursorTime := K.GetTickCount();
WHILE TRUE DO WHILE TRUE DO
CurrentTime := K.GetTickCount(); CurrentTime := K.GetTickCount();
IF (CurrentTime - CursorTime > blink) & (blink > 0) & timerEnabled THEN IF (CurrentTime - CursorTime > blink) & (blink > 0) & timerEnabled & ~K.RolledUp() THEN
CursorTime := CurrentTime; CursorTime := CurrentTime;
T.toggleCursor; T.toggleCursor;
repaint repaint
@ -2057,9 +2057,18 @@ BEGIN
CASE K.EventTimeout(10) OF CASE K.EventTimeout(10) OF
|0: |0:
|1: Redraw(resized, width, height, cliWidth, cliHeight) |1: Redraw(resized, width, height, cliWidth, cliHeight)
|2: KeyDown(K.GetKey()) |2:
key := K.GetKey();
IF ~K.RolledUp() THEN
KeyDown(key)
END
|3: BtnClick |3: BtnClick
|6: MouseEvent(resized, firstClickX, firstClickY, time) |6:
IF ~K.RolledUp() THEN
MouseEvent(resized, firstClickX, firstClickY, time)
ELSE
scr := K.Scroll()
END
END END
END END
END main; END main;

View File

@ -34,7 +34,6 @@ TYPE
tCheckBox* = RECORD tCheckBox* = RECORD
left*, top*: INTEGER; left*, top*: INTEGER;
width, height: INTEGER;
value*, mouse: BOOLEAN; value*, mouse: BOOLEAN;
text: ARRAY 32 OF WCHAR; text: ARRAY 32 OF WCHAR;
canvas: G.tCanvas canvas: G.tCanvas
@ -56,14 +55,14 @@ BEGIN
G.Rect(canvas, 0, 0, fontHeight - 1, fontHeight - 1); G.Rect(canvas, 0, 0, fontHeight - 1, fontHeight - 1);
IF chkbox.value THEN IF chkbox.value THEN
G.SetColor(canvas, fColor); G.SetColor(canvas, fColor);
G.DLine(canvas, 2, 6, 6, -1); G.DLine(canvas, 2, 6, 6, -1);
G.DLine(canvas, 2, 6, 7, -1); G.DLine(canvas, 2, 6, 7, -1);
G.DLine(canvas, 7, 13, 9, 1); G.DLine(canvas, 7, 13, 9, 1);
G.DLine(canvas, 7, 13, 10, 1); G.DLine(canvas, 7, 13, 10, 1);
G.DLine(canvas, 2, 6, 8, -1); G.DLine(canvas, 2, 6, 8, -1);
G.DLine(canvas, 7, 13, 11, 1); G.DLine(canvas, 7, 13, 11, 1);
G.DLine(canvas, 2, 6, 5, -1); G.DLine(canvas, 2, 6, 5, -1);
G.DLine(canvas, 7, 13, 8, 1); G.DLine(canvas, 7, 13, 8, 1);
END; END;
G.SetTextColor(canvas, K.colors.work_text); G.SetTextColor(canvas, K.colors.work_text);
G.SetBkColor(canvas, K.colors.work); G.SetBkColor(canvas, K.colors.work);
@ -84,8 +83,6 @@ BEGIN
COPY(text, res.text); COPY(text, res.text);
res.canvas := G.CreateCanvas(fontHeight + padding + LENGTH(res.text)*fontWidth, fontHeight + 1); res.canvas := G.CreateCanvas(fontHeight + padding + LENGTH(res.text)*fontWidth, fontHeight + 1);
G.SetFont(res.canvas, G.CreateFont(1, "", {})); G.SetFont(res.canvas, G.CreateFont(1, "", {}));
res.width := res.canvas.width;
res.height := res.canvas.height;
chkbox := res chkbox := res
END create; END create;
@ -101,8 +98,8 @@ BEGIN
DEC(x, chkbox.left); DEC(x, chkbox.left);
DEC(y, chkbox.top); DEC(y, chkbox.top);
chkbox.mouse := TRUE; chkbox.mouse := TRUE;
IF U.between(0, x, chkbox.width - 1) & U.between(0, y, chkbox.height - 1) THEN IF U.between(0, x, chkbox.canvas.width - 1) & U.between(0, y, chkbox.canvas.height - 1) THEN
chkbox.value := ~chkbox.value; chkbox.value := ~chkbox.value
END; END;
draw(chkbox) draw(chkbox)
END END

View File

@ -51,28 +51,27 @@ TYPE
PROCEDURE [stdcall, "box_lib.obj", "edit_box_draw"] draw* (eb: tEditBox); END; PROCEDURE [stdcall, "box_lib.obj", "edit_box_draw"] draw* (eb: tEditBox); END;
PROCEDURE [stdcall, "box_lib.obj", "edit_box_mouse"] mouse* (eb: tEditBox); END; PROCEDURE [stdcall, "box_lib.obj", "edit_box_mouse"] mouse* (eb: tEditBox); END;
PROCEDURE [stdcall, "box_lib.obj", "edit_box_set_text"] _setValue (eb: tEditBox; text: INTEGER); END; PROCEDURE [stdcall, "box_lib.obj", "edit_box_set_text"] set_text (eb: tEditBox; text: INTEGER); END;
PROCEDURE [stdcall, "box_lib.obj", "edit_box_key_safe"] key* (eb: tEditBox; key: INTEGER); END; PROCEDURE [stdcall, "box_lib.obj", "edit_box_key_safe"] key* (eb: tEditBox; key: INTEGER); END;
PROCEDURE getValue* (text: tEditBox; VAR str: ARRAY OF CHAR); PROCEDURE get* (text: tEditBox; VAR str: ARRAY OF CHAR);
VAR VAR
ptr, max, i: INTEGER; ptr, max, i: INTEGER;
BEGIN BEGIN
ptr := text.text; ptr := text.text;
max := text.max; max := text.max;
ASSERT(max < LEN(str)); ASSERT(max < LEN(str));
i := 0; i := 0;
REPEAT REPEAT
SYSTEM.GET(ptr, str[i]); SYSTEM.GET(ptr, str[i]);
INC(i); INC(i);
INC(ptr) INC(ptr)
UNTIL (str[i - 1] = 0X) OR (i = max); UNTIL (str[i - 1] = 0X) OR (i = max);
str[i] := 0X str[i] := 0X
END getValue; END get;
PROCEDURE setValue* (text: tEditBox; str: ARRAY OF WCHAR); PROCEDURE set* (text: tEditBox; str: ARRAY OF WCHAR);
VAR VAR
i: INTEGER; i: INTEGER;
temp: ARRAY MAX_LENGTH OF CHAR; temp: ARRAY MAX_LENGTH OF CHAR;
@ -83,25 +82,25 @@ BEGIN
temp[i] := CHR(Encodings.UNI[ORD(str[i]), Encodings.CP866] MOD 256); temp[i] := CHR(Encodings.UNI[ORD(str[i]), Encodings.CP866] MOD 256);
INC(i) INC(i)
UNTIL str[i - 1] = 0X; UNTIL str[i - 1] = 0X;
_setValue(text, SYSTEM.ADR(temp[0])) set_text(text, SYSTEM.ADR(temp[0]))
END setValue; END set;
PROCEDURE create* (tlx, tly, width, max_chars: INTEGER; VAR editbox: tEditBox); PROCEDURE create* (x, y, width, max_chars: INTEGER; VAR editbox: tEditBox);
BEGIN BEGIN
editbox.width := width; editbox.width := width;
editbox.left := tlx; editbox.left := x;
editbox.top := tly; editbox.top := y;
editbox.color := 0FFFFFFH; editbox.color := 0FFFFFFH;
editbox.shift_color := 06A9480H; editbox.shift_color := 06A9480H;
editbox.focus_border_color := 0; editbox.focus_border_color := 0;
editbox.blur_border_color := 06A9480H; editbox.blur_border_color := 06A9480H;
editbox.text_color := 30000000H; editbox.text_color := 30000000H;
editbox.max := max_chars; editbox.max := max_chars;
editbox.text := KOSAPI.malloc(max_chars + 2); editbox.text := KOSAPI.malloc(max_chars + 2);
ASSERT(editbox.text # 0); ASSERT(editbox.text # 0);
editbox.mouse_variable := 0; editbox.mouse_variable := 0;
editbox.flags := {14} editbox.flags := {14}
END create; END create;

View File

@ -1,5 +1,5 @@
(* (*
Copyright 2021 Anton Krotov Copyright 2021, 2022 Anton Krotov
This file is part of CEdit. This file is part of CEdit.
@ -20,18 +20,26 @@
MODULE Encodings; MODULE Encodings;
CONST CONST
CP866* = 0; W1251* = 1; UTF8* = 2; UTF8BOM* = 3; UTF16LE* = 4; CP866* = 0; W1251* = 1; UTF8* = 2; UTF8BOM* = 3; (*UTF16LE* = 4;*)
UNDEF* = -1; UNDEF* = -1;
EOL_CRLF* = 0; EOL_LF* = 1; EOL_CR* = 2;
CR = 0DX; LF = 0AX;
TYPE TYPE
CP = ARRAY 256 OF INTEGER; CP = ARRAY 256 OF INTEGER;
tEOL* = ARRAY 3 OF WCHAR;
VAR VAR
cpW1251*, cp866*: CP; cpW1251*, cp866*: CP;
names*: ARRAY 4, 16 OF WCHAR; names*: ARRAY 4, 16 OF WCHAR;
UNI*: ARRAY 65536, 2 OF INTEGER; UNI*: ARRAY 65536, 2 OF INTEGER;
eol*: ARRAY 3 OF tEOL;
eolNames*: ARRAY 3, 16 OF WCHAR;
PROCEDURE InitCP (VAR cp: CP); PROCEDURE InitCP (VAR cp: CP);
VAR VAR
@ -60,6 +68,10 @@ PROCEDURE InitW1251 (VAR cp: CP);
VAR VAR
n, i: INTEGER; n, i: INTEGER;
BEGIN BEGIN
InitCP(cp);
FOR i := 0410H TO 044FH DO
cp[i - 350H] := i
END;
n := 80H; n := 80H;
Init8(cp, n, 0402H, 0403H, 201AH, 0453H, 201EH, 2026H, 2020H, 2021H); Init8(cp, n, 0402H, 0403H, 201AH, 0453H, 201EH, 2026H, 2020H, 2021H);
Init8(cp, n, 20ACH, 2030H, 0409H, 2039H, 040AH, 040CH, 040BH, 040FH); Init8(cp, n, 20ACH, 2030H, 0409H, 2039H, 040AH, 040CH, 040BH, 040FH);
@ -69,10 +81,6 @@ 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);
FOR i := 0410H TO 044FH DO
cp[i - 350H] := i
END;
InitCP(cp)
END InitW1251; END InitW1251;
@ -80,11 +88,12 @@ PROCEDURE InitCP866 (VAR cp: CP);
VAR VAR
n, i: INTEGER; n, i: INTEGER;
BEGIN BEGIN
InitCP(cp);
FOR i := 0410H TO 043FH DO FOR i := 0410H TO 043FH DO
cp[i - 0410H + 80H] := i cp[i - 390H] := i
END; END;
FOR i := 0440H TO 044FH DO FOR i := 0440H TO 044FH DO
cp[i - 0440H + 0E0H] := i cp[i - 360H] := 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);
@ -93,12 +102,9 @@ BEGIN
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)
END InitCP866; END InitCP866;
@ -108,7 +114,7 @@ VAR
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, W1251] := UNDEF
END; END;
FOR i := 0 TO 255 DO FOR i := 0 TO 255 DO
IF cpW1251[i] # UNDEF THEN IF cpW1251[i] # UNDEF THEN
@ -122,6 +128,12 @@ END setUNI;
BEGIN BEGIN
eol[EOL_CRLF] := CR + LF;
eol[EOL_LF] := LF;
eol[EOL_CR] := CR;
eolNames[EOL_CRLF] := "CRLF";
eolNames[EOL_LF] := "LF";
eolNames[EOL_CR] := "CR";
names[CP866] := "CP866"; names[CP866] := "CP866";
names[W1251] := "Windows-1251"; names[W1251] := "Windows-1251";
names[UTF8] := "UTF-8"; names[UTF8] := "UTF-8";

View File

@ -20,106 +20,123 @@
MODULE Icons; MODULE Icons;
IMPORT IMPORT
LibImg, K := KolibriOS, Graph, SYSTEM; Graph, File, SYSTEM, KOSAPI;
CONST CONST
fileName = "/sys/Icons16.png"; fileName = "/sys/Icons16.png";
SIZE* = 18; SIZE* = 18;
VAR VAR
source: INTEGER; source: INTEGER;
(*
PROCEDURE copy (src, dst: INTEGER); PROCEDURE copy (src, dst: INTEGER);
VAR VAR
src_sizeX, src_sizeY, dst_sizeX, dst_sizeY, src_width, src_height,
src_data, dst_data: INTEGER; dst_width, dst_height,
src_data, dst_data: INTEGER;
BEGIN BEGIN
LibImg.GetInf(src, src_sizeX, src_sizeY, src_data); LibImg.GetInf(src, src_width, src_height, src_data);
LibImg.GetInf(dst, dst_sizeX, dst_sizeY, dst_data); LibImg.GetInf(dst, dst_width, dst_height, dst_data);
ASSERT(src_sizeX = dst_sizeX); ASSERT(src_width = dst_width);
ASSERT(src_sizeY = dst_sizeY); ASSERT(src_height = dst_height);
SYSTEM.MOVE(src_data, dst_data, src_sizeX*src_sizeY*3) SYSTEM.MOVE(src_data, dst_data, src_width*src_height*4)
END copy; END copy;
*)
PROCEDURE [stdcall, "libimg.obj", ""] img_decode (data, size, options: INTEGER): INTEGER; END;
PROCEDURE [stdcall, "Libimg.obj", ""] img_convert (src, dst, dst_type, flags, param: INTEGER): INTEGER; END;
PROCEDURE [stdcall, "Libimg.obj", ""] img_destroy (img: INTEGER); END;
PROCEDURE GetInf (img: INTEGER; VAR width, height, data: INTEGER);
BEGIN
SYSTEM.GET(img + 4, width);
SYSTEM.GET(img + 8, height);
SYSTEM.GET(img + 24, data);
END GetInf;
PROCEDURE GetImg* (ptr, size: INTEGER): INTEGER;
VAR
image_data, dst, x, type: INTEGER;
BEGIN
image_data := img_decode(ptr, size, 0);
IF image_data # 0 THEN
SYSTEM.GET(image_data + 4, x);
ASSERT(x = SIZE);
SYSTEM.GET(image_data + 20, type);
IF type # 3 THEN
dst := img_convert(image_data, 0, 3, 0, 0);
img_destroy(image_data);
image_data := dst
END
END
RETURN image_data
END GetImg;
PROCEDURE load (): INTEGER; PROCEDURE load (): INTEGER;
VAR VAR
y: INTEGER; size, res, ptr: INTEGER;
BEGIN BEGIN
RETURN LibImg.LoadFromFile(fileName, SIZE, y) res := 0;
ptr := File.Load(fileName, size);
IF ptr # 0 THEN
res := GetImg(ptr, size);
ptr := KOSAPI.free(ptr)
END
RETURN res
END load; END load;
PROCEDURE draw* (icons, n, x, y: INTEGER); PROCEDURE draw* (icons, n, x, y: INTEGER);
VAR VAR
sizeX, sizeY, data: INTEGER; width, height, data: INTEGER;
BEGIN BEGIN
LibImg.GetInf(icons, sizeX, sizeY, data); GetInf(icons, width, height, data);
K.DrawImage(data + SIZE*SIZE*3*n, SIZE, SIZE, x, y) KOSAPI.sysfunc7(65, data + SIZE*SIZE*4*n, SIZE*65536 + SIZE, x*65536 + y, 32, 0, 0)
END draw; END draw;
PROCEDURE gray (icons: INTEGER);
VAR
sizeX, sizeY, data, x, y: INTEGER;
b, g, r, gr: BYTE;
BEGIN
LibImg.GetInf(icons, sizeX, sizeY, data);
FOR y := 0 TO sizeY - 1 DO
FOR x := 0 TO sizeX - 1 DO
SYSTEM.GET8(data, b);
SYSTEM.GET8(data + 1, g);
SYSTEM.GET8(data + 2, r);
gr := (r + g + b) DIV 3;
SYSTEM.PUT8(data, gr);
SYSTEM.PUT8(data + 1, gr);
SYSTEM.PUT8(data + 2, gr);
INC(data, 3);
END
END
END gray;
PROCEDURE iconsBackColor (icons: INTEGER; BackColor: INTEGER); PROCEDURE iconsBackColor (icons: INTEGER; BackColor: INTEGER);
VAR VAR
sizeX, sizeY, data, x, y: INTEGER; width, height, data, x, y, pix: INTEGER;
b, g, r: BYTE; b, g, r, gr: BYTE;
BEGIN BEGIN
LibImg.GetInf(icons, sizeX, sizeY, data); GetInf(icons, width, height, data);
FOR y := 0 TO sizeY - 1 DO FOR y := 0 TO height - 1 DO
FOR x := 0 TO sizeX - 1 DO FOR x := 0 TO width - 1 DO
SYSTEM.GET8(data, b); SYSTEM.GET32(data, pix);
SYSTEM.GET8(data + 1, g); Graph.getRGB(pix, r, g, b);
SYSTEM.GET8(data + 2, r); gr := (r + g + b) DIV 3;
IF b + g + r = 765 THEN IF BackColor = -1 THEN
Graph.getRGB(BackColor, r, g, b) pix := gr + 256*gr + 65536*gr
END; ELSIF gr = 255 THEN
SYSTEM.PUT8(data, b); pix := BackColor
SYSTEM.PUT8(data + 1, g); END;
SYSTEM.PUT8(data + 2, r); SYSTEM.PUT32(data, pix);
INC(data, 3); INC(data, 4)
END END
END END
END iconsBackColor; END iconsBackColor;
PROCEDURE get* (VAR icons, grayIcons: INTEGER; BackColor: INTEGER); PROCEDURE get* (VAR icons, grayIcons: INTEGER; BackColor: INTEGER);
BEGIN BEGIN
IF source = 0 THEN IF source = 0 THEN
source := load(); source := load();
icons := load(); icons := load();
grayIcons := load() grayIcons := load();
ELSE iconsBackColor(grayIcons, -1);
copy(source, icons); iconsBackColor(grayIcons, BackColor);
copy(source, grayIcons) iconsBackColor(icons, BackColor)
END; (*ELSE
gray(grayIcons); copy(source, icons);
iconsBackColor(icons, BackColor); copy(source, grayIcons)*)
iconsBackColor(grayIcons, BackColor) END;
END get; END get;
BEGIN BEGIN
source := 0 source := 0
END Icons. END Icons.

View File

@ -1,5 +1,5 @@
(* (*
Copyright 2021 Anton Krotov Copyright 2021, 2022 Anton Krotov
This file is part of CEdit. This file is part of CEdit.
@ -215,31 +215,18 @@ BEGIN
END C; END C;
PROCEDURE getChar (line: tLine; i: INTEGER): WCHAR;
VAR
res: WCHAR;
BEGIN
IF i >= line.length THEN
res := 0X
ELSE
res := Lines.getChar(line, i)
END
RETURN res
END getChar;
PROCEDURE LuaLong* (line: tLine; pos: INTEGER): INTEGER; PROCEDURE LuaLong* (line: tLine; pos: INTEGER): INTEGER;
VAR VAR
res: INTEGER; res: INTEGER;
BEGIN BEGIN
res := -1; res := -1;
IF getChar(line, pos) = "[" THEN IF Lines.getChar(line, pos) = "[" THEN
INC(pos); INC(pos);
WHILE getChar(line, pos) = "=" DO WHILE Lines.getChar(line, pos) = "=" DO
INC(res); INC(res);
INC(pos) INC(pos)
END; END;
IF getChar(line, pos) = "[" THEN IF Lines.getChar(line, pos) = "[" THEN
INC(res) INC(res)
ELSE ELSE
res := -1 res := -1

View File

@ -184,10 +184,14 @@ END resize;
PROCEDURE getChar* (line: tLine; i: INTEGER): WCHAR; PROCEDURE getChar* (line: tLine; i: INTEGER): WCHAR;
VAR VAR
c: WCHAR; res: WCHAR;
BEGIN BEGIN
SYSTEM.GET(line.ptr + i*WCHAR_SIZE, c) IF i >= line.length THEN
RETURN c res := 0X
ELSE
SYSTEM.GET(line.ptr + i*WCHAR_SIZE, res)
END
RETURN res
END getChar; END getChar;

View File

@ -88,7 +88,6 @@ TYPE
key, MenuItem: INTEGER key, MenuItem: INTEGER
END; END;
tClick = PROCEDURE (menu: tMenu; id: INTEGER);
tProc = PROCEDURE; tProc = PROCEDURE;
VAR VAR

View File

@ -33,15 +33,11 @@ CONST
NAME_LEN = 1024; NAME_LEN = 1024;
EOL_CRLF* = 0; EOL_LF* = 1; EOL_CR* = 2;
TYPE TYPE
tFileName* = ARRAY NAME_LEN OF CHAR; tFileName* = ARRAY NAME_LEN OF CHAR;
tEOL = ARRAY 3 OF WCHAR;
tInput* = POINTER TO RECORD tInput* = POINTER TO RECORD
buffer: INTEGER; buffer: INTEGER;
strBuf: Lines.tLine; strBuf: Lines.tLine;
@ -55,18 +51,12 @@ TYPE
handle: File.FS; handle: File.FS;
buffer: ARRAY BUF_SIZE OF BYTE; buffer: ARRAY BUF_SIZE OF BYTE;
pos: INTEGER; pos: INTEGER;
eol: tEOL; eol: E.tEOL;
putChar: PROCEDURE (file: tOutput; code: INTEGER); putChar: PROCEDURE (file: tOutput; code: INTEGER);
error: BOOLEAN error: BOOLEAN
END; END;
VAR
eol*: ARRAY 3 OF tEOL;
eolNames*: ARRAY 3, 16 OF WCHAR;
PROCEDURE getByte (file: tInput): BYTE; PROCEDURE getByte (file: tInput): BYTE;
VAR VAR
res: BYTE; res: BYTE;
@ -109,7 +99,9 @@ BEGIN
ELSIF (0E0H <= b) & (b <= 0EFH) THEN ELSIF (0E0H <= b) & (b <= 0EFH) THEN
DEC(b, 0E0H); DEC(b, 0E0H);
n := 2 n := 2
ELSIF (0F0H <= b) & (b <= 0F7H) THEN ELSE
n := -1
(* ELSIF (0F0H <= b) & (b <= 0F7H) THEN
DEC(b, 0F0H); DEC(b, 0F0H);
n := 3 n := 3
ELSIF (0F8H <= b) & (b <= 0FBH) THEN ELSIF (0F8H <= b) & (b <= 0FBH) THEN
@ -124,15 +116,15 @@ BEGIN
ELSIF b = 0FFH THEN ELSIF b = 0FFH THEN
n := -1 n := -1
ELSIF (080H <= b) & (b <= 0BFH) THEN ELSIF (080H <= b) & (b <= 0BFH) THEN
n := -1 n := -1*)
END; END;
code := b; code := b;
(*
IF n > 2 THEN IF n > 2 THEN
n := -1 n := -1
END; END;
*)
WHILE n > 0 DO WHILE n > 0 DO
DEC(n); DEC(n);
b := peakByte(file); b := peakByte(file);
@ -160,11 +152,11 @@ PROCEDURE getCharCP866 (file: tInput): INTEGER;
RETURN E.cp866[getByte(file)] RETURN E.cp866[getByte(file)]
END getCharCP866; END getCharCP866;
(*
PROCEDURE getCharUTF16LE (file: tInput): INTEGER; PROCEDURE getCharUTF16LE (file: tInput): INTEGER;
RETURN getByte(file) + getByte(file) * 256 RETURN getByte(file) + getByte(file) * 256
END getCharUTF16LE; END getCharUTF16LE;
*)
PROCEDURE getString* (file: tInput; line: Lines.tLine; tabs: BOOLEAN; VAR eol: BOOLEAN): INTEGER; PROCEDURE getString* (file: tInput; line: Lines.tLine; tabs: BOOLEAN; VAR eol: BOOLEAN): INTEGER;
VAR VAR
@ -299,20 +291,20 @@ BEGIN
cnt := text.cnt; cnt := text.cnt;
WHILE (text.cnt > 0) & (res = -1) DO WHILE (text.cnt > 0) & (res = -1) DO
c := text.getChar(text); c := text.getChar(text);
IF c = 10 THEN IF CHR(c) = LF THEN
res := EOL_LF res := E.EOL_LF
ELSIF c = 13 THEN ELSIF CHR(c) = CR THEN
IF text.getChar(text) = 10 THEN IF CHR(text.getChar(text)) = LF THEN
res := EOL_CRLF res := E.EOL_CRLF
ELSE ELSE
res := EOL_CR res := E.EOL_CR
END END
END END
END; END;
text.cnt := cnt; text.cnt := cnt;
text.pos := pos; text.pos := pos;
IF res = -1 THEN IF res = -1 THEN
res := EOL_CRLF res := E.EOL_CRLF
END END
RETURN res RETURN res
END detectEOL; END detectEOL;
@ -373,7 +365,7 @@ BEGIN
DISPOSE(res) DISPOSE(res)
ELSE ELSE
enc := detectEncoding(res); enc := detectEncoding(res);
IF (enc = E.UTF8BOM) OR (enc = E.UTF8) THEN IF enc IN {E.UTF8BOM, E.UTF8} THEN
res.getChar := getCharUTF8 res.getChar := getCharUTF8
ELSIF enc = E.CP866 THEN ELSIF enc = E.CP866 THEN
res.getChar := getCharCP866 res.getChar := getCharCP866
@ -427,11 +419,9 @@ VAR
BEGIN BEGIN
FOR i := 0 TO n - 1 DO FOR i := 0 TO n - 1 DO
c := Lines.getChar(line, i); c := Lines.getChar(line, i);
IF c = Lines.TAB1 THEN IF c = Lines.NUL THEN
(* nothing to do *)
ELSIF c = Lines.NUL THEN
file.putChar(file, 0) file.putChar(file, 0)
ELSE ELSIF c # Lines.TAB1 THEN
file.putChar(file, ORD(c)) file.putChar(file, ORD(c))
END END
END END
@ -467,32 +457,31 @@ BEGIN
END putCharUTF8; END putCharUTF8;
PROCEDURE putCharW1251 (file: tOutput; code: INTEGER); PROCEDURE putCharCP (file: tOutput; code, cp: INTEGER);
VAR VAR
n: INTEGER; n: INTEGER;
BEGIN BEGIN
n := E.UNI[code, E.W1251]; n := E.UNI[code, cp];
IF n # E.UNDEF THEN IF n # E.UNDEF THEN
putByte(file, n) putByte(file, n)
ELSE ELSE
putByte(file, ORD("?")) putByte(file, ORD("?"))
END END
END putCharCP;
PROCEDURE putCharW1251 (file: tOutput; code: INTEGER);
BEGIN
putCharCP(file, code, E.W1251)
END putCharW1251; END putCharW1251;
PROCEDURE putCharCP866 (file: tOutput; code: INTEGER); PROCEDURE putCharCP866 (file: tOutput; code: INTEGER);
VAR
n: INTEGER;
BEGIN BEGIN
n := E.UNI[code, E.CP866]; putCharCP(file, code, E.CP866)
IF n # E.UNDEF THEN
putByte(file, n)
ELSE
putByte(file, ORD("?"))
END
END putCharCP866; END putCharCP866;
(*
PROCEDURE putCharUTF16LE (file: tOutput; code: INTEGER); PROCEDURE putCharUTF16LE (file: tOutput; code: INTEGER);
BEGIN BEGIN
IF ~((0 <= code) & (code <= 65535)) THEN IF ~((0 <= code) & (code <= 65535)) THEN
@ -500,7 +489,7 @@ BEGIN
END; END;
putByte(file, code MOD 256); putByte(file, code MOD 256);
putByte(file, code DIV 256) putByte(file, code DIV 256)
END putCharUTF16LE; END putCharUTF16LE;*)
PROCEDURE close* (VAR file: tOutput): BOOLEAN; PROCEDURE close* (VAR file: tOutput): BOOLEAN;
@ -528,15 +517,15 @@ VAR
BEGIN BEGIN
NEW(res); NEW(res);
res.pos := 0; res.pos := 0;
res.eol := eol[nl]; res.eol := E.eol[nl];
res.putChar := NIL; res.putChar := NIL;
IF (enc = E.UTF8) OR (enc = E.UTF8BOM) THEN IF enc IN {E.UTF8BOM, E.UTF8} THEN
res.putChar := putCharUTF8;
IF enc = E.UTF8BOM THEN IF enc = E.UTF8BOM THEN
res.putChar(res, ORD(BOM)) putCharUTF8(res, ORD(BOM))
END END;
ELSIF enc = E.UTF16LE THEN res.putChar := putCharUTF8
res.putChar := putCharUTF16LE; (*ELSIF enc = E.UTF16LE THEN
res.putChar := putCharUTF16LE*)
ELSIF enc = E.W1251 THEN ELSIF enc = E.W1251 THEN
res.putChar := putCharW1251 res.putChar := putCharW1251
ELSIF enc = E.CP866 THEN ELSIF enc = E.CP866 THEN
@ -568,11 +557,4 @@ BEGIN
END destroy; END destroy;
BEGIN
eol[EOL_CRLF] := CR + LF;
eol[EOL_LF] := LF;
eol[EOL_CR] := CR;
eolNames[EOL_CRLF] := "CRLF";
eolNames[EOL_LF] := "LF";
eolNames[EOL_CR] := "CR"
END RW. END RW.

View File

@ -1,5 +1,5 @@
(* (*
Copyright 2021 Anton Krotov Copyright 2021, 2022 Anton Krotov
This file is part of CEdit. This file is part of CEdit.
@ -41,7 +41,7 @@ VAR
res: tBuffer; res: tBuffer;
BEGIN BEGIN
pChar := text.dataPtr; pChar := text.dataPtr;
cnt := CB.bufSize(text) DIV 2; cnt := CB.bufSize(text) DIV SYSTEM.SIZE(WCHAR);
FOR i := 0 TO 65535 DO FOR i := 0 TO 65535 DO
table[i, 1] := 0 table[i, 1] := 0
@ -54,15 +54,15 @@ BEGIN
SYSTEM.PUT(pChar, c) SYSTEM.PUT(pChar, c)
END; END;
INC(table[ORD(c), 1]); INC(table[ORD(c), 1]);
INC(pChar, 2); INC(pChar, SYSTEM.SIZE(WCHAR));
DEC(i) DEC(i)
END; END;
res := CB.create(cnt * SYSTEM.SIZE(INTEGER)); res := CB.create(cnt*SYSTEM.SIZE(INTEGER));
table[0, 0] := res.dataPtr; table[0, 0] := res.dataPtr;
FOR i := 1 TO 65535 DO FOR i := 1 TO 65535 DO
table[i, 0] := table[i - 1, 0] + table[i - 1, 1] * SYSTEM.SIZE(INTEGER) table[i, 0] := table[i - 1, 0] + table[i - 1, 1]*SYSTEM.SIZE(INTEGER)
END; END;
pChar := text.dataPtr; pChar := text.dataPtr;
@ -71,12 +71,12 @@ BEGIN
SYSTEM.GET(pChar, c); SYSTEM.GET(pChar, c);
SYSTEM.PUT(table[ORD(c), 0], i); SYSTEM.PUT(table[ORD(c), 0], i);
INC(table[ORD(c), 0], SYSTEM.SIZE(INTEGER)); INC(table[ORD(c), 0], SYSTEM.SIZE(INTEGER));
INC(pChar, 2); INC(pChar, SYSTEM.SIZE(WCHAR));
INC(i) INC(i)
END; END;
FOR i := 0 TO 65535 DO FOR i := 0 TO 65535 DO
DEC(table[i, 0], table[i, 1] * SYSTEM.SIZE(INTEGER)) DEC(table[i, 0], table[i, 1]*SYSTEM.SIZE(INTEGER))
END END
RETURN res RETURN res
@ -96,15 +96,15 @@ BEGIN
prev_item_pos := 0; prev_item_pos := 0;
WHILE k > 0 DO WHILE k > 0 DO
SYSTEM.GET(pos, x); SYSTEM.GET(pos, x);
IF Utils.streq(text.dataPtr + x*2, SYSTEM.ADR(s[0]), n) THEN IF Utils.streq(text.dataPtr + x*SYSTEM.SIZE(WCHAR), SYSTEM.ADR(s[0]), n) THEN
flag := whole; flag := whole;
IF flag THEN IF flag THEN
IF x > 0 THEN IF x > 0 THEN
SYSTEM.GET(text.dataPtr + (x - 1)*2, c1); SYSTEM.GET(text.dataPtr + (x - 1)*SYSTEM.SIZE(WCHAR), c1);
ELSE ELSE
c1 := 0X c1 := 0X
END; END;
SYSTEM.GET(text.dataPtr + (x + n)*2, c2); SYSTEM.GET(text.dataPtr + (x + n)*SYSTEM.SIZE(WCHAR), c2);
flag := Utils.isLetter(c1) OR Utils.isLetter(c2) OR Utils.isDigit(c1) OR Utils.isDigit(c2) OR (c1 = "_") OR (c2 = "_") flag := Utils.isLetter(c1) OR Utils.isLetter(c2) OR Utils.isDigit(c1) OR Utils.isDigit(c2) OR (c1 = "_") OR (c2 = "_")
END; END;
IF ~flag & (x >= prev_item_pos) THEN IF ~flag & (x >= prev_item_pos) THEN

View File

@ -173,19 +173,6 @@ BEGIN
END hideCursor; END hideCursor;
PROCEDURE getChar (line: tLine; i: INTEGER): WCHAR;
VAR
res: WCHAR;
BEGIN
IF i >= line.length THEN
res := 0X
ELSE
res := Lines.getChar(line, i)
END
RETURN res
END getChar;
PROCEDURE getString (src: tLine; pos, cnt: INTEGER; VAR dst: ARRAY OF WCHAR): INTEGER; PROCEDURE getString (src: tLine; pos, cnt: INTEGER; VAR dst: ARRAY OF WCHAR): INTEGER;
VAR VAR
i: INTEGER; i: INTEGER;
@ -193,7 +180,7 @@ BEGIN
i := 0; i := 0;
WHILE (pos < src.length) & (cnt > 0) DO WHILE (pos < src.length) & (cnt > 0) DO
IF i < LEN(dst) - 1 THEN IF i < LEN(dst) - 1 THEN
dst[i] := getChar(src, pos); dst[i] := Lines.getChar(src, pos);
INC(i) INC(i)
END; END;
INC(pos); INC(pos);
@ -322,10 +309,10 @@ VAR
s: ARRAY 32 OF WCHAR; s: ARRAY 32 OF WCHAR;
color: INTEGER; color: INTEGER;
BEGIN BEGIN
c := getChar(line, i); c := Lines.getChar(line, i);
WHILE U.isLetter(c) OR (c = "_") OR U.isDigit(c) DO WHILE U.isLetter(c) OR (c = "_") OR U.isDigit(c) DO
INC(i); INC(i);
c := getChar(line, i); c := Lines.getChar(line, i);
END; END;
DEC(i); DEC(i);
lexLen := getString(line, first, i - first + 1, s); lexLen := getString(line, first, i - first + 1, s);
@ -360,7 +347,7 @@ VAR
End := i - 1; End := i - 1;
k := Start; k := Start;
WHILE k <= End DO WHILE k <= End DO
c := getChar(line, k); c := Lines.getChar(line, k);
IF c = "\" THEN IF c = "\" THEN
j := k; j := k;
Lang.SkipEsc(line, k, line.length - 1, text.lang); Lang.SkipEsc(line, k, line.length - 1, text.lang);
@ -381,7 +368,7 @@ BEGIN
END; END;
cond := 0; cond := 0;
WHILE i <= n DO WHILE i <= n DO
c := getChar(line, i); c := Lines.getChar(line, i);
IF lang = Lang.langFasm THEN IF lang = Lang.langFasm THEN
@ -396,17 +383,17 @@ BEGIN
hex := FALSE; hex := FALSE;
k := i; k := i;
INC(i); INC(i);
c := getChar(line, i); c := Lines.getChar(line, i);
IF (cap(c) = "X") & (getChar(line, i - 1) = "0") THEN IF (cap(c) = "X") & (Lines.getChar(line, i - 1) = "0") THEN
INC(i); INC(i);
hex := TRUE hex := TRUE
END; END;
WHILE U.isHex(cap(getChar(line, i))) DO WHILE U.isHex(cap(Lines.getChar(line, i))) DO
INC(i) INC(i)
END; END;
IF (cap(getChar(line, i)) = "H") & ~hex THEN IF (cap(Lines.getChar(line, i)) = "H") & ~hex THEN
INC(i) INC(i)
END; END;
@ -435,13 +422,13 @@ BEGIN
IF (c = "'") OR (c = '"') THEN IF (c = "'") OR (c = '"') THEN
String(text, line, i, y, backColor); String(text, line, i, y, backColor);
ELSE ELSE
ident(text, i, i - ORD((lang = Lang.langC) & (i > 0) & (getChar(line, i - 1) = "#")), y, line, backColor, Lang.isCS(lang)) ident(text, i, i - ORD((lang = Lang.langC) & (i > 0) & (Lines.getChar(line, i - 1) = "#")), y, line, backColor, Lang.isCS(lang))
END; END;
IF lang = Lang.langJSON THEN IF lang = Lang.langJSON THEN
WHILE Lines.isSpace(getChar(line, i + 1)) DO WHILE Lines.isSpace(Lines.getChar(line, i + 1)) DO
INC(i) INC(i)
END; END;
IF getChar(line, i + 1) = ":" THEN IF Lines.getChar(line, i + 1) = ":" THEN
PrintLex(text, line, k, i, y, colors.key1, backColor) PrintLex(text, line, k, i, y, colors.key1, backColor)
END END
END; END;
@ -449,15 +436,15 @@ BEGIN
ELSIF U.isDigit(c) THEN ELSIF U.isDigit(c) THEN
k := i; k := i;
INC(i); INC(i);
c := getChar(line, i); c := Lines.getChar(line, i);
IF c = "." THEN IF c = "." THEN
DEC(i); DEC(i);
c := getChar(line, i) c := Lines.getChar(line, i)
END; END;
IF (cap(c) = "X") & (getChar(line, i - 1) = "0") THEN IF (cap(c) = "X") & (Lines.getChar(line, i - 1) = "0") THEN
REPEAT REPEAT
INC(i); INC(i);
c := getChar(line, i) c := Lines.getChar(line, i)
UNTIL ~U.isHex(cap(c)); UNTIL ~U.isHex(cap(c));
IF UL(c) THEN IF UL(c) THEN
INC(i) INC(i)
@ -467,27 +454,27 @@ BEGIN
ELSIF U.isDigit(c) THEN ELSIF U.isDigit(c) THEN
REPEAT REPEAT
INC(i) INC(i)
UNTIL ~U.isDigit(getChar(line, i)); UNTIL ~U.isDigit(Lines.getChar(line, i));
c := getChar(line, i); c := Lines.getChar(line, i);
IF UL(c) THEN IF UL(c) THEN
INC(i) INC(i)
ELSIF c = "." THEN ELSIF c = "." THEN
INC(i); INC(i);
WHILE U.isDigit(getChar(line, i)) DO WHILE U.isDigit(Lines.getChar(line, i)) DO
INC(i) INC(i)
END; END;
c := getChar(line, i); c := Lines.getChar(line, i);
IF cap(c) = "E" THEN IF cap(c) = "E" THEN
INC(i); INC(i);
c := getChar(line, i); c := Lines.getChar(line, i);
IF (c = "+") OR (c = "-") THEN IF (c = "+") OR (c = "-") THEN
INC(i) INC(i)
END; END;
IF U.isDigit(getChar(line, i)) THEN IF U.isDigit(Lines.getChar(line, i)) THEN
WHILE U.isDigit(getChar(line, i)) DO WHILE U.isDigit(Lines.getChar(line, i)) DO
INC(i) INC(i)
END; END;
c := getChar(line, i); c := Lines.getChar(line, i);
IF FL(c) THEN IF FL(c) THEN
INC(i) INC(i)
END END
@ -531,30 +518,30 @@ BEGIN
color := colors.num; color := colors.num;
k := i; k := i;
INC(i); INC(i);
WHILE U.isHex(getChar(line, i)) DO WHILE U.isHex(Lines.getChar(line, i)) DO
INC(i) INC(i)
END; END;
IF i <= n THEN IF i <= n THEN
IF getChar(line, i) = "." THEN IF Lines.getChar(line, i) = "." THEN
INC(i); INC(i);
IF getChar(line, i) = "." THEN IF Lines.getChar(line, i) = "." THEN
DEC(i) DEC(i)
END; END;
WHILE U.isDigit(getChar(line, i)) DO WHILE U.isDigit(Lines.getChar(line, i)) DO
INC(i) INC(i)
END; END;
IF getChar(line, i) = "E" THEN IF Lines.getChar(line, i) = "E" THEN
INC(i); INC(i);
IF (getChar(line, i) = "+") OR (getChar(line, i) = "-") THEN IF (Lines.getChar(line, i) = "+") OR (Lines.getChar(line, i) = "-") THEN
INC(i) INC(i)
END; END;
WHILE U.isDigit(getChar(line, i)) DO WHILE U.isDigit(Lines.getChar(line, i)) DO
INC(i) INC(i)
END END
END END
ELSIF getChar(line, i) = "H" THEN ELSIF Lines.getChar(line, i) = "H" THEN
INC(i) INC(i)
ELSIF getChar(line, i) = "X" THEN ELSIF Lines.getChar(line, i) = "X" THEN
color := colors.string; color := colors.string;
INC(i) INC(i)
END END
@ -618,7 +605,7 @@ BEGIN
cond := 0 cond := 0
ELSIF U.isDigit(c) THEN ELSIF U.isDigit(c) THEN
k := i; k := i;
IF (c = "0") & (cap(getChar(line, i + 1)) = "X") THEN IF (c = "0") & (cap(Lines.getChar(line, i + 1)) = "X") THEN
isDgt := U.isHex; isDgt := U.isHex;
hex := TRUE; hex := TRUE;
INC(i, 2) INC(i, 2)
@ -626,24 +613,24 @@ BEGIN
isDgt := U.isDigit; isDgt := U.isDigit;
hex := FALSE hex := FALSE
END; END;
WHILE isDgt(cap(getChar(line, i))) DO WHILE isDgt(cap(Lines.getChar(line, i))) DO
INC(i) INC(i)
END; END;
IF getChar(line, i) = "." THEN IF Lines.getChar(line, i) = "." THEN
INC(i); INC(i);
IF getChar(line, i) = "." THEN IF Lines.getChar(line, i) = "." THEN
DEC(i) DEC(i)
END; END;
WHILE isDgt(cap(getChar(line, i))) DO WHILE isDgt(cap(Lines.getChar(line, i))) DO
INC(i) INC(i)
END END
END; END;
IF (cap(getChar(line, i)) = "E") OR hex & (cap(getChar(line, i)) = "P") THEN IF (cap(Lines.getChar(line, i)) = "E") OR hex & (cap(Lines.getChar(line, i)) = "P") THEN
INC(i); INC(i);
IF (getChar(line, i) = "-") OR (getChar(line, i) = "+") THEN IF (Lines.getChar(line, i) = "-") OR (Lines.getChar(line, i) = "+") THEN
INC(i) INC(i)
END; END;
WHILE isDgt(cap(getChar(line, i))) DO WHILE isDgt(cap(Lines.getChar(line, i))) DO
INC(i) INC(i)
END END
END; END;
@ -692,7 +679,7 @@ BEGIN
String(text, line, i, y, backColor); String(text, line, i, y, backColor);
cond := 0 cond := 0
ELSIF c = "{" THEN ELSIF c = "{" THEN
IF getChar(line, i + 1) = "$" THEN IF Lines.getChar(line, i + 1) = "$" THEN
depth := 3 depth := 3
ELSE ELSE
depth := 1 depth := 1
@ -703,21 +690,21 @@ BEGIN
ELSIF c = "#" THEN ELSIF c = "#" THEN
k := i; k := i;
INC(i); INC(i);
WHILE U.isDigit(getChar(line, i)) DO WHILE U.isDigit(Lines.getChar(line, i)) DO
INC(i) INC(i)
END; END;
DEC(i); DEC(i);
PrintLex(text, line, k, i, y, colors.string, backColor); PrintLex(text, line, k, i, y, colors.string, backColor);
cond := 0 cond := 0
ELSIF c = "$" THEN ELSIF c = "$" THEN
IF (i > 0 ) & (getChar(line, i - 1) = "#") THEN IF (i > 0 ) & (Lines.getChar(line, i - 1) = "#") THEN
color := colors.string color := colors.string
ELSE ELSE
color := colors.num color := colors.num
END; END;
k := i; k := i;
INC(i); INC(i);
WHILE U.isHex(cap(getChar(line, i))) DO WHILE U.isHex(cap(Lines.getChar(line, i))) DO
INC(i) INC(i)
END; END;
DEC(i); DEC(i);
@ -725,23 +712,23 @@ BEGIN
cond := 0 cond := 0
ELSIF U.isDigit(c) THEN ELSIF U.isDigit(c) THEN
k := i; k := i;
WHILE U.isDigit(getChar(line, i)) DO WHILE U.isDigit(Lines.getChar(line, i)) DO
INC(i) INC(i)
END; END;
IF getChar(line, i) = "." THEN IF Lines.getChar(line, i) = "." THEN
INC(i); INC(i);
IF getChar(line, i) = "." THEN IF Lines.getChar(line, i) = "." THEN
DEC(i) DEC(i)
END; END;
WHILE U.isDigit(getChar(line, i)) DO WHILE U.isDigit(Lines.getChar(line, i)) DO
INC(i) INC(i)
END; END;
IF cap(getChar(line, i)) = "E" THEN IF cap(Lines.getChar(line, i)) = "E" THEN
INC(i); INC(i);
IF (getChar(line, i) = "-") OR (getChar(line, i) = "+") THEN IF (Lines.getChar(line, i) = "-") OR (Lines.getChar(line, i) = "+") THEN
INC(i) INC(i)
END; END;
WHILE U.isDigit(getChar(line, i)) DO WHILE U.isDigit(Lines.getChar(line, i)) DO
INC(i) INC(i)
END END
END END
@ -784,7 +771,7 @@ BEGIN
PrintComment(text, line, depth, i, 1, y, backColor) PrintComment(text, line, depth, i, 1, y, backColor)
ELSIF U.isDigit(c) THEN ELSIF U.isDigit(c) THEN
k := i; k := i;
WHILE U.isDigit(getChar(line, i)) DO WHILE U.isDigit(Lines.getChar(line, i)) DO
INC(i) INC(i)
END; END;
DEC(i); DEC(i);
@ -809,7 +796,7 @@ VAR
i: INTEGER; i: INTEGER;
BEGIN BEGIN
i := 0; i := 0;
WHILE Lines.isSpace(getChar(line, i)) DO WHILE Lines.isSpace(Lines.getChar(line, i)) DO
INC(i) INC(i)
END END
RETURN i RETURN i
@ -977,15 +964,15 @@ BEGIN
END END
END; END;
cursor.X := MIN(MAX(x, 0), text.curLine.length); cursor.X := MIN(MAX(x, 0), text.curLine.length);
c := getChar(text.curLine, cursor.X); c := Lines.getChar(text.curLine, cursor.X);
IF c = TAB1 THEN IF c = TAB1 THEN
n := cursor.X; n := cursor.X;
WHILE getChar(text.curLine, n) = TAB1 DO WHILE Lines.getChar(text.curLine, n) = TAB1 DO
INC(n) INC(n)
END; END;
R := n - cursor.X; R := n - cursor.X;
n := cursor.X; n := cursor.X;
WHILE getChar(text.curLine, n) # TAB DO WHILE Lines.getChar(text.curLine, n) # TAB DO
DEC(n) DEC(n)
END; END;
L := cursor.X - n; L := cursor.X - n;
@ -1078,8 +1065,8 @@ BEGIN
IF i < curLine.length THEN IF i < curLine.length THEN
n := i; n := i;
INC(i); INC(i);
IF getChar(curLine, i - 1) = TAB THEN IF Lines.getChar(curLine, i - 1) = TAB THEN
WHILE getChar(curLine, i) = TAB1 DO WHILE Lines.getChar(curLine, i) = TAB1 DO
INC(i) INC(i)
END END
END; END;
@ -1105,7 +1092,7 @@ VAR
pos: INTEGER; pos: INTEGER;
BEGIN BEGIN
pos := text.cursor.X + d; pos := text.cursor.X + d;
WHILE getChar(text.curLine, pos) = TAB1 DO WHILE Lines.getChar(text.curLine, pos) = TAB1 DO
INC(pos, d) INC(pos, d)
END; END;
SetPos(text, pos, text.cursor.Y) SetPos(text, pos, text.cursor.Y)
@ -1148,7 +1135,7 @@ BEGIN
Lines.delCharN(curLine, 0, i); Lines.delCharN(curLine, 0, i);
Lines.insert3(curLine, 0, k); Lines.insert3(curLine, 0, k);
WHILE k > 0 DO WHILE k > 0 DO
Lines.setChar(curLine, k - 1, getChar(line2, k - 1)); Lines.setChar(curLine, k - 1, Lines.getChar(line2, k - 1));
DEC(k) DEC(k)
END; END;
Lines.modify(curLine); Lines.modify(curLine);
@ -1197,7 +1184,7 @@ BEGIN
SetPos(text, n, text.cursor.Y); SetPos(text, n, text.cursor.Y);
resetSelect(text); resetSelect(text);
WHILE n > 0 DO WHILE n > 0 DO
Lines.setChar(text.curLine, n - 1, getChar(line2, n - 1)); Lines.setChar(text.curLine, n - 1, Lines.getChar(line2, n - 1));
DEC(n) DEC(n)
END; END;
Lines.modify(newLine) Lines.modify(newLine)
@ -1464,7 +1451,7 @@ VAR
BEGIN BEGIN
res := 0; res := 0;
FOR i := first TO last DO FOR i := first TO last DO
IF getChar(line, i) # TAB1 THEN IF Lines.getChar(line, i) # TAB1 THEN
INC(res) INC(res)
END END
END END
@ -1480,15 +1467,13 @@ BEGIN
IF lines > 1 THEN IF lines > 1 THEN
chars := charCnt(first, selBeg.X, first.length - 1) + charCnt(last, 0, selEnd.X - 1) + lenEOL; chars := charCnt(first, selBeg.X, first.length - 1) + charCnt(last, 0, selEnd.X - 1) + lenEOL;
line := first.next(tLine) line := first.next(tLine);
WHILE line # last DO
INC(chars, charCnt(line, 0, line.length - 1) + lenEOL);
NextLine(line)
END
ELSE ELSE
chars := charCnt(first, selBeg.X, selEnd.X - 1); chars := charCnt(first, selBeg.X, selEnd.X - 1)
line := last
END;
WHILE line # last DO
INC(chars, charCnt(line, 0, line.length - 1) + lenEOL);
NextLine(line)
END END
ELSE ELSE
chars := 0; chars := 0;
@ -1572,7 +1557,7 @@ VAR
res := pos; res := pos;
i := 0; i := 0;
REPEAT REPEAT
c := getChar(line, i); c := Lines.getChar(line, i);
IF c = TAB THEN IF c = TAB THEN
INC(res, Lines.tab - res MOD Lines.tab) INC(res, Lines.tab - res MOD Lines.tab)
ELSIF c # TAB1 THEN ELSIF c # TAB1 THEN
@ -1707,7 +1692,7 @@ BEGIN
line := text.curLine; line := text.curLine;
i := text.cursor.X - 1; i := text.cursor.X - 1;
WHILE (i >= 0) & U.isLetter(getChar(line, i)) DO WHILE (i >= 0) & U.isLetter(Lines.getChar(line, i)) DO
DEC(i) DEC(i)
END; END;
@ -1915,8 +1900,8 @@ BEGIN
INC(i) INC(i)
END; END;
IF (i # n) OR IF (i # n) OR
((x1 > 0) & isWordChar(getChar(curLine, x1 - 1))) OR ((x1 > 0) & isWordChar(Lines.getChar(curLine, x1 - 1))) OR
((x2 < curLine.length) & isWordChar(getChar(curLine, x2))) THEN ((x2 < curLine.length) & isWordChar(Lines.getChar(curLine, x2))) THEN
str := "" str := ""
END END
END; END;
@ -1928,17 +1913,17 @@ PROCEDURE getWordPos (line: tLine; pos: INTEGER): INTEGER;
VAR VAR
c: WCHAR; c: WCHAR;
BEGIN BEGIN
c := getChar(line, pos); c := Lines.getChar(line, pos);
IF isWordChar(c) THEN IF isWordChar(c) THEN
WHILE (pos < line.length) & isWordChar(getChar(line, pos)) DO WHILE (pos < line.length) & isWordChar(Lines.getChar(line, pos)) DO
INC(pos) INC(pos)
END END
ELSIF Lines.isSpace(c) THEN ELSIF Lines.isSpace(c) THEN
WHILE (pos < line.length) & Lines.isSpace(getChar(line, pos)) DO WHILE (pos < line.length) & Lines.isSpace(Lines.getChar(line, pos)) DO
INC(pos) INC(pos)
END END
ELSE ELSE
WHILE (pos < line.length) & ~Lines.isSpace(getChar(line, pos)) & ~isWordChar(getChar(line, pos)) DO WHILE (pos < line.length) & ~Lines.isSpace(Lines.getChar(line, pos)) & ~isWordChar(Lines.getChar(line, pos)) DO
INC(pos) INC(pos)
END END
END END
@ -1986,11 +1971,10 @@ BEGIN
SetPos(text, 0, 0) SetPos(text, 0, 0)
ELSE ELSE
n := leadingSpaces(text.curLine); n := leadingSpaces(text.curLine);
IF text.cursor.X > n THEN IF text.cursor.X <= n THEN
SetPos(text, n, text.cursor.Y) n := 0
ELSE END;
SetPos(text, 0, text.cursor.Y) SetPos(text, n, text.cursor.Y)
END
END END
|37: |37:
IF (text.cursor.X = 0) & (text.curLine.prev # NIL) THEN IF (text.cursor.X = 0) & (text.curLine.prev # NIL) THEN
@ -2036,17 +2020,13 @@ BEGIN
delete(text); delete(text);
ShowCursor ShowCursor
END END
|ORD("C"): |ORD("C"), ORD("X"):
IF ctrl THEN
IF selected(text) THEN
copy(text)
END
END
|ORD("X"):
IF ctrl THEN IF ctrl THEN
IF selected(text) THEN IF selected(text) THEN
copy(text); copy(text);
delSelect(text) IF code = ORD("X") THEN
delSelect(text)
END
END END
END END
|ORD("V"): |ORD("V"):
@ -2100,18 +2080,18 @@ 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(Lines.getChar(line, cursorX)) THEN
x2 := cursorX; x2 := cursorX;
WHILE (x2 < line.length) & isWordChar(getChar(line, x2)) DO WHILE (x2 < line.length) & isWordChar(Lines.getChar(line, x2)) DO
INC(x2) INC(x2)
END END
ELSE ELSE
WHILE (x1 >= 0) & ~isWordChar(getChar(line, x1)) DO WHILE (x1 >= 0) & ~isWordChar(Lines.getChar(line, x1)) DO
DEC(x1) DEC(x1)
END; END;
x2 := x1 + 1 x2 := x1 + 1
END; END;
WHILE (x1 >= 0) & isWordChar(getChar(line, x1)) DO WHILE (x1 >= 0) & isWordChar(Lines.getChar(line, x1)) DO
DEC(x1) DEC(x1)
END; END;
INC(x1); INC(x1);
@ -2408,11 +2388,11 @@ BEGIN
END setColors; END setColors;
PROCEDURE setCanvas* (Canvas: G.tCanvas); 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 + inter
END setCanvas; END setCanvas;
@ -2608,9 +2588,9 @@ BEGIN
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.enc, E.CP866);
ChangeLog.changeInt(text.eol, RW.EOL_CRLF); ChangeLog.changeInt(text.eol, E.EOL_CRLF);
text.enc := E.CP866; text.enc := E.CP866;
text.eol := RW.EOL_CRLF; text.eol := E.EOL_CRLF;
SetPos(text, 0, 0); SetPos(text, 0, 0);
resetSelect(text) resetSelect(text)
RETURN text RETURN text

View File

@ -32,34 +32,32 @@ CONST
PROCEDURE streq* (s1, s2: INTEGER; n: INTEGER): BOOLEAN; PROCEDURE streq* (s1, s2: INTEGER; n: INTEGER): BOOLEAN;
VAR VAR
c1, c2: WCHAR; c1, c2: WCHAR;
res: BOOLEAN;
BEGIN BEGIN
WHILE n > 0 DO res := TRUE;
WHILE (n > 0) & res DO
SYSTEM.GET(s1, c1); SYSTEM.GET(s1, c1);
SYSTEM.GET(s2, c2); SYSTEM.GET(s2, c2);
INC(s1, 2); res := c1 = c2;
INC(s2, 2); INC(s1, SYSTEM.SIZE(WCHAR));
IF c1 = c2 THEN INC(s2, SYSTEM.SIZE(WCHAR));
DEC(n) DEC(n)
ELSE
n := 0
END
END END
RETURN c1 = c2 RETURN res
END streq; END streq;
PROCEDURE append* (VAR s1: ARRAY OF WCHAR; s2: ARRAY OF WCHAR); PROCEDURE append* (VAR s1: ARRAY OF WCHAR; s2: ARRAY OF WCHAR);
VAR VAR
n1, n2, i, j: INTEGER; n, i, j: INTEGER;
BEGIN BEGIN
n1 := LENGTH(s1); j := LENGTH(s1);
n2 := LENGTH(s2); n := LENGTH(s2);
ASSERT(n1 + n2 < LEN(s1)); ASSERT(j + n < LEN(s1));
i := 0; i := 0;
j := n1; WHILE i < n DO
WHILE i < n2 DO
s1[j] := s2[i]; s1[j] := s2[i];
INC(i); INC(i);
INC(j) INC(j)
@ -71,16 +69,15 @@ END append;
PROCEDURE append8* (VAR s1: ARRAY OF CHAR; s2: ARRAY OF CHAR); PROCEDURE append8* (VAR s1: ARRAY OF CHAR; s2: ARRAY OF CHAR);
VAR VAR
n1, n2, i, j: INTEGER; n, i, j: INTEGER;
BEGIN BEGIN
n1 := LENGTH(s1); j := LENGTH(s1);
n2 := LENGTH(s2); n := LENGTH(s2);
ASSERT(n1 + n2 < LEN(s1)); ASSERT(j + n < LEN(s1));
i := 0; i := 0;
j := n1; WHILE i < n DO
WHILE i < n2 DO
s1[j] := s2[i]; s1[j] := s2[i];
INC(i); INC(i);
INC(j) INC(j)

View File

@ -1,97 +0,0 @@
(*
Copyright 2016, 2021, 2022 Anton Krotov
This file is part of CEdit.
CEdit is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
CEdit is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with CEdit. If not, see <http://www.gnu.org/licenses/>.
*)
MODULE LibImg;
IMPORT SYSTEM, KOSAPI, File;
VAR
file: INTEGER;
PROCEDURE [stdcall, "libimg.obj", ""] img_decode (data, size, options: INTEGER): INTEGER; END;
PROCEDURE [stdcall, "libimg.obj", ""] img_to_rgb2 (data, data_rgb: INTEGER); END;
PROCEDURE [stdcall, "libimg.obj", ""] img_scale (src, crop_x, crop_y, crop_width, crop_height, dst, scale, inter, param1, param2: INTEGER): INTEGER; END;
PROCEDURE [stdcall, "libimg.obj", ""] img_destroy* (img: INTEGER); END;
PROCEDURE GetInf*(img: INTEGER; VAR sizeX, sizeY, data: INTEGER);
BEGIN
SYSTEM.GET(img + 4, sizeX);
SYSTEM.GET(img + 8, sizeY);
SYSTEM.GET(img + 24, data);
END GetInf;
PROCEDURE GetImg*(ptr, n, Width: INTEGER; VAR sizeY: INTEGER): INTEGER;
VAR image_data, dst, x, y, type, rgb, data: INTEGER;
BEGIN
image_data := img_decode(ptr, n, 0);
IF image_data # 0 THEN
SYSTEM.GET(image_data + 4, x);
SYSTEM.GET(image_data + 8, y);
SYSTEM.GET(image_data + 20, type);
IF type # 2 THEN
rgb := KOSAPI.malloc(x * y * 3);
IF rgb # 0 THEN
img_to_rgb2(image_data, rgb);
SYSTEM.GET(image_data + 24, data);
data := KOSAPI.free(data);
SYSTEM.PUT(image_data + 24, rgb);
SYSTEM.PUT(image_data + 20, 2)
ELSE
img_destroy(image_data);
image_data := 0
END
END;
IF (x > Width) & (image_data # 0) THEN
dst := img_scale(image_data, 0, 0, x, y, dst, 3, 1, Width, (y * Width) DIV x);
img_destroy(image_data);
image_data := dst
END;
IF image_data # 0 THEN
SYSTEM.GET(image_data + 8, sizeY)
END
END
RETURN image_data
END GetImg;
PROCEDURE LoadFromFile* (FName: ARRAY OF CHAR; Width: INTEGER; VAR sizeY: INTEGER): INTEGER;
VAR F: File.FS; n, size, res: INTEGER;
BEGIN
res := 0;
F := File.Open(FName);
IF F # NIL THEN
size := File.Seek(F, 0, File.SEEK_END);
n := File.Seek(F, 0, File.SEEK_BEG);
file := KOSAPI.malloc(size + 1024);
IF file # 0 THEN
n := File.Read(F, file, size);
res := GetImg(file, n, Width, sizeY);
n := KOSAPI.free(file)
END;
File.Close(F)
END
RETURN res
END LoadFromFile;
END LibImg.

View File

@ -185,31 +185,32 @@ END resize;
PROCEDURE setValue* (VAR scroll: tScroll; value: INTEGER); PROCEDURE setValue* (VAR scroll: tScroll; value: INTEGER);
VAR VAR
pos, maxPos, n, m: INTEGER; pos, maxPos, maxVal, n, m: INTEGER;
BEGIN BEGIN
maxVal := scroll.maxVal;
IF scroll.vertical THEN IF scroll.vertical THEN
maxPos := scroll.height maxPos := scroll.height
ELSE ELSE
maxPos := scroll.width maxPos := scroll.width
END; END;
maxPos := maxPos - scroll.btnSize*2 - scroll.sliderSize + 1; maxPos := maxPos - scroll.btnSize*2 - scroll.sliderSize + 1;
IF (value < 0) OR (scroll.maxVal <= 0) THEN IF (value < 0) OR (maxVal <= 0) THEN
value := 0; value := 0;
pos := 0 pos := 0
ELSIF value > scroll.maxVal THEN ELSIF value > maxVal THEN
value := scroll.maxVal; value := maxVal;
pos := maxPos pos := maxPos
ELSE ELSE
IF (maxPos + 1) >= scroll.maxVal THEN IF (maxPos + 1) >= maxVal THEN
n := (maxPos + 1) DIV scroll.maxVal; n := (maxPos + 1) DIV maxVal;
m := (maxPos + 1) MOD scroll.maxVal; m := (maxPos + 1) MOD maxVal;
pos := value*n + MIN(value, m) pos := value*n + MIN(value, m)
ELSE ELSE
pos := FLOOR(FLT(value)*FLT(maxPos + 1)/FLT(scroll.maxVal)) pos := FLOOR(FLT(value)*FLT(maxPos + 1)/FLT(maxVal))
END; END;
IF pos > maxPos THEN IF pos > maxPos THEN
pos := maxPos; pos := maxPos;
value := scroll.maxVal value := maxVal
END END
END; END;
scroll.pos := pos; scroll.pos := pos;
@ -224,9 +225,10 @@ END ceil;
PROCEDURE setPos (VAR scroll: tScroll; pos: INTEGER); PROCEDURE setPos (VAR scroll: tScroll; pos: INTEGER);
VAR VAR
maxPos, value, n, m, x, x0, q: INTEGER; maxPos, value, maxVal, n, m, x, x0, q: INTEGER;
BEGIN BEGIN
IF scroll.maxVal > 0 THEN maxVal := scroll.maxVal;
IF maxVal > 0 THEN
IF scroll.vertical THEN IF scroll.vertical THEN
maxPos := scroll.height maxPos := scroll.height
ELSE ELSE
@ -238,11 +240,11 @@ BEGIN
value := 0 value := 0
ELSIF pos >= maxPos THEN ELSIF pos >= maxPos THEN
pos := maxPos; pos := maxPos;
value := scroll.maxVal value := maxVal
ELSE ELSE
IF scroll.maxVal <= maxPos + 1 THEN IF maxVal <= maxPos + 1 THEN
n := (maxPos + 1) DIV scroll.maxVal; n := (maxPos + 1) DIV maxVal;
m := (maxPos + 1) MOD scroll.maxVal; m := (maxPos + 1) MOD maxVal;
q := m*(n + 1); q := m*(n + 1);
IF q < pos THEN IF q < pos THEN
@ -263,16 +265,16 @@ BEGIN
pos := x; pos := x;
IF pos > maxPos THEN IF pos > maxPos THEN
pos := maxPos; pos := maxPos;
value := scroll.maxVal value := maxVal
END END
END END
ELSE ELSE
value := FLOOR(FLT(scroll.maxVal)*FLT(pos)/FLT(maxPos + 1)) value := FLOOR(FLT(maxVal)*FLT(pos)/FLT(maxPos + 1))
END END
END END
ELSE ELSE
pos := 0; pos := 0;
scroll.value := 0 value := 0
END; END;
scroll.pos := pos; scroll.pos := pos;
scroll.value := value scroll.value := value