CEdit: reduced memory usage

git-svn-id: svn://kolibrios.org@9902 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Anton Krotov 2023-02-22 15:56:05 +00:00
parent 6dae04e665
commit 56ed41fae1
13 changed files with 253 additions and 186 deletions

Binary file not shown.

View File

@ -77,7 +77,7 @@ KW2 = ABS,ASR,ASSERT,BITS,BOOLEAN,BYTE,CHAR,CHR,COPY,DEC,DISPOSE,EXCL,FLOOR,FLT,
KW3 =
[lang_Pascal]
KW1 = AND,ARRAY,BEGIN,CASE,CONST,DIV,DO,DOWNTO,ELSE,END,FILE,FOR,FUNCTION,GOTO,IF,IMPLEMENTATION,IN,INTERFACE,LABEL,MOD,NIL,NOT,OF,OR,PACKED,PROCEDURE,PROGRAM,RECORD,REPEAT,SET,SHL,SHR,STRING,THEN,TO,TYPE,UNIT,UNTIL,USES,VAR,WHILE,WITH,XOR
KW1 = and,array,begin,case,const,div,do,downto,else,end,file,for,function,goto,if,implementation,in,interface,label,mod,nil,not,of,or,packed,procedure,program,record,repeat,set,shl,shr,string,then,to,type,unit,until,uses,var,while,with,xor
KW2 =
KW3 =

View File

@ -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, Icons,
RW, Ini, EB := EditBox, Tabs, Toolbar, SB := StatusBar;
CONST
HEADER = "CEdit (21-jan-2023)";
HEADER = "CEdit (22-feb-2023)";
ShellFilter = "";
EditFilter = "SH|INC|TXT|ASM|OB07|C|CPP|H|PAS|PP|LUA|INI|JSON";
@ -2149,20 +2149,20 @@ BEGIN
Shortcuts;
Toolbar.create(toolbar, LEFT_PADDING + 5, toolbarTop);
Toolbar.add(toolbar, btnNew, 2, "");
Toolbar.add(toolbar, btnOpen, 0, "");
Toolbar.add(toolbar, btnSave, 5, "");
Toolbar.add(toolbar, btnNew, Icons.icoNew, "");
Toolbar.add(toolbar, btnOpen, Icons.icoOpen, "");
Toolbar.add(toolbar, btnSave, Icons.icoSave, "");
Toolbar.delimiter(toolbar);
Toolbar.add(toolbar, btnSearch, 49, "");
Toolbar.add(toolbar, btnSearch, Icons.icoSearch, "");
Toolbar.delimiter(toolbar);
Toolbar.add(toolbar, btnUndo, 37, "");
Toolbar.add(toolbar, btnRedo, 36, "");
Toolbar.add(toolbar, btnUndo, Icons.icoUndo, "");
Toolbar.add(toolbar, btnRedo, Icons.icoRedo, "");
Toolbar.delimiter(toolbar);
Toolbar.add(toolbar, btnUpper, -1, "AB");
Toolbar.add(toolbar, btnLower, -1, "ab");
Toolbar.delimiter(toolbar);
Toolbar.add(toolbar, btnBuild, 54, "");
Toolbar.add(toolbar, btnRun, 53, "");
Toolbar.add(toolbar, btnBuild, Icons.icoBuild, "");
Toolbar.add(toolbar, btnRun, Icons.icoRun, "");
filePath := "/sys";
IF Args.argc = 1 THEN

View File

@ -1,5 +1,5 @@
(*
Copyright 2021, 2022 Anton Krotov
Copyright 2021-2023 Anton Krotov
This file is part of CEdit.
@ -23,7 +23,8 @@ IMPORT List, Lines, API, SYSTEM;
TYPE
tIntItem = POINTER TO RECORD (List.tItem)
adr, val: INTEGER
cnt: INTEGER;
adr, val: ARRAY 8 OF INTEGER
END;
tBoolItem = POINTER TO RECORD (List.tItem)
@ -33,11 +34,13 @@ TYPE
END;
tUntypedPtr = POINTER TO RECORD (List.tItem)
p: INTEGER
cnt: INTEGER;
p: ARRAY 64 OF INTEGER
END;
tTypedPtr = POINTER TO RECORD (List.tItem)
p: List.tItem
cnt: INTEGER;
p: ARRAY 64 OF List.tItem
END;
tGuard* = POINTER TO RECORD (List.tItem)
@ -45,7 +48,7 @@ TYPE
END;
tLog* = POINTER TO RECORD
Log*, Pointers*: List.tList;
Log*, TPointers, UPointers: List.tList;
guard, first: tGuard;
isLast: BOOLEAN
END;
@ -103,12 +106,16 @@ END setGuard;
PROCEDURE redo* (item: List.tItem);
VAR
i: INTEGER;
BEGIN
IF item IS tIntItem THEN
SYSTEM.PUT(item(tIntItem).adr, item(tIntItem).val)
ELSIF item IS tBoolItem THEN
SYSTEM.PUT(item(tBoolItem).adr, item(tBoolItem).val)
END
IF item IS tIntItem THEN
FOR i := 0 TO item(tIntItem).cnt - 1 DO
SYSTEM.PUT(item(tIntItem).adr[i], item(tIntItem).val[i])
END
ELSIF item IS tBoolItem THEN
SYSTEM.PUT(item(tBoolItem).adr, item(tBoolItem).val)
END
END redo;
@ -162,15 +169,26 @@ END save;
PROCEDURE changeWord (adrV, adrX: INTEGER);
VAR
item: tIntItem;
item: tIntItem;
cur: List.tItem;
BEGIN
NEW(item);
item.adr := adrV;
SYSTEM.GET(adrX, item.val);
IF ~CL.isLast THEN
clear(CL.guard)
END;
List.append(CL.Log, item)
IF ~CL.isLast THEN
clear(CL.guard)
END;
cur := CL.Log.last;
WHILE (cur # NIL) & ~(cur IS tGuard) & ~(cur IS tIntItem) DO
cur := cur.prev
END;
IF (cur IS tIntItem) & (cur(tIntItem).cnt < LEN(cur(tIntItem).adr)) THEN
item := cur(tIntItem)
ELSE
NEW(item);
item.cnt := 0;
List.append(CL.Log, item)
END;
item.adr[item.cnt] := adrV;
SYSTEM.GET(adrX, item.val[item.cnt]);
INC(item.cnt)
END changeWord;
@ -264,28 +282,38 @@ END changePtr;
PROCEDURE typedPtr (p: List.tItem);
VAR
item: tTypedPtr;
item: tTypedPtr;
BEGIN
NEW(item);
item.p := p;
List.append(CL.Pointers, item)
item := CL.TPointers.last(tTypedPtr);
IF (item = NIL) OR (item.cnt = LEN(item.p)) THEN
NEW(item);
item.cnt := 0;
List.append(CL.TPointers, item)
END;
item.p[item.cnt] := p;
INC(item.cnt)
END typedPtr;
PROCEDURE untypedPtr (p: INTEGER);
VAR
item: tUntypedPtr;
item: tUntypedPtr;
BEGIN
NEW(item);
item.p := p;
List.append(CL.Pointers, item)
item := CL.UPointers.last(tUntypedPtr);
IF (item = NIL) OR (item.cnt = LEN(item.p)) THEN
NEW(item);
item.cnt := 0;
List.append(CL.UPointers, item)
END;
item.p[item.cnt] := p;
INC(item.cnt)
END untypedPtr;
PROCEDURE set* (_CL: tLog);
PROCEDURE setLog* (_CL: tLog);
BEGIN
CL := _CL
END set;
END setLog;
PROCEDURE create* (VAR maxLength: INTEGER): tLog;
@ -297,7 +325,8 @@ BEGIN
newLog.first := NIL;
newLog.isLast := TRUE;
newLog.Log := List.create(NIL);
newLog.Pointers := List.create(NIL);
newLog.TPointers := List.create(NIL);
newLog.UPointers := List.create(NIL);
CL := newLog;
Lines.setMaxLength(maxLength)
RETURN newLog
@ -307,7 +336,7 @@ END create;
PROCEDURE destroy* (VAR log: tLog);
VAR
item: List.tItem;
res: INTEGER;
res, i: INTEGER;
BEGIN
IF log # NIL THEN
item := List.pop(log.Log);
@ -317,17 +346,25 @@ BEGIN
END;
DISPOSE(log.Log);
item := List.pop(log.Pointers);
item := List.pop(log.TPointers);
WHILE item # NIL DO
IF item IS tUntypedPtr THEN
res := API._DISPOSE(item(tUntypedPtr).p)
ELSIF item IS tTypedPtr THEN
DISPOSE(item(tTypedPtr).p)
END;
FOR i := 0 TO item(tTypedPtr).cnt - 1 DO
DISPOSE(item(tTypedPtr).p[i])
END;
DISPOSE(item);
item := List.pop(log.Pointers)
item := List.pop(log.TPointers)
END;
DISPOSE(log.Pointers);
DISPOSE(log.TPointers);
item := List.pop(log.UPointers);
WHILE item # NIL DO
FOR i := 0 TO item(tUntypedPtr).cnt - 1 DO
res := API._DISPOSE(item(tUntypedPtr).p[i])
END;
DISPOSE(item);
item := List.pop(log.UPointers)
END;
DISPOSE(log.UPointers);
DISPOSE(log)
END

View File

@ -1,5 +1,5 @@
(*
Copyright 2021, 2022 Anton Krotov
Copyright 2021-2023 Anton Krotov
This file is part of CEdit.
@ -22,7 +22,7 @@ MODULE Encodings;
CONST
CP866* = 0; CP1251* = 1; UTF8* = 2; UTF8BOM* = 3; (*UTF16LE* = 4;*)
UNDEF* = -1;
UNDEF* = ORD("?");
EOL_CRLF* = 0; EOL_LF* = 1; EOL_CR* = 2;
CR = 0DX; LF = 0AX;
@ -35,7 +35,7 @@ TYPE
VAR
cp1251*, cp866*: CP;
names*: ARRAY 4, 16 OF WCHAR;
UNI*: ARRAY 65536, 2 OF INTEGER;
UNI*: ARRAY 65536, 2 OF BYTE;
eol*: ARRAY 3 OF tEOL;
eolNames*: ARRAY 3, 16 OF WCHAR;
@ -117,12 +117,8 @@ BEGIN
UNI[i, CP1251] := UNDEF
END;
FOR i := 0 TO 255 DO
IF cp1251[i] # UNDEF THEN
UNI[cp1251[i], CP1251] := i
END;
IF cp866[i] # UNDEF THEN
UNI[cp866[i], CP866] := i
END
UNI[cp1251[i], CP1251] := i;
UNI[cp866[i], CP866] := i
END
END setUNI;

View File

@ -268,7 +268,7 @@ PROCEDURE TextOut* (canvas: tCanvas; x, y: INTEGER; text: INTEGER; n: INTEGER; d
CONST
WCHAR_SIZE = 2;
VAR
color, i, ch: INTEGER;
color, i: INTEGER;
font: tFont;
c: WCHAR;
BEGIN
@ -299,12 +299,7 @@ BEGIN
c := 0X
END;
IF font = fonts[0] THEN
ch := E.UNI[ORD(c), E.CP866];
IF ch = E.UNDEF THEN
c := "?"
ELSE
c := WCHR(ch)
END
c := WCHR(E.UNI[ORD(c), E.CP866])
END;
KOSAPI.sysfunc6(4, x*65536 + y, font.flags + color, SYSTEM.ADR(c), 1, canvas.bitmap - 8)
END;

View File

@ -20,123 +20,125 @@
MODULE Icons;
IMPORT
Graph, File, SYSTEM, KOSAPI;
Graph, File, SYSTEM, KOSAPI;
CONST
fileName = "/sys/Icons16.png";
SIZE* = 18;
fileName = "/sys/Icons16.png";
SIZE* = 18;
VAR
source: INTEGER;
icoNew *= 0;
icoOpen *= 1;
icoSave *= 2;
icoSearch *= 3;
icoUndo *= 4;
icoRedo *= 5;
icoBuild *= 6;
icoRun *= 7;
NumberOfIcons = 8;
(*
PROCEDURE copy (src, dst: INTEGER);
VAR
src_width, src_height,
dst_width, dst_height,
src_data, dst_data: INTEGER;
BEGIN
LibImg.GetInf(src, src_width, src_height, src_data);
LibImg.GetInf(dst, dst_width, dst_height, dst_data);
ASSERT(src_width = dst_width);
ASSERT(src_height = dst_height);
SYSTEM.MOVE(src_data, dst_data, src_width*src_height*4)
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;
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
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;
VAR
size, res, ptr: INTEGER;
size, res, ptr: INTEGER;
BEGIN
res := 0;
ptr := File.Load(fileName, size);
IF ptr # 0 THEN
res := GetImg(ptr, size);
ptr := KOSAPI.free(ptr)
END
RETURN res
res := 0;
ptr := File.Load(fileName, size);
IF ptr # 0 THEN
res := GetImg(ptr, size);
ptr := KOSAPI.free(ptr)
END
RETURN res
END load;
PROCEDURE draw* (icons, n, x, y: INTEGER);
VAR
width, height, data: INTEGER;
BEGIN
GetInf(icons, width, height, data);
KOSAPI.sysfunc7(65, data + SIZE*SIZE*4*n, SIZE*65536 + SIZE, x*65536 + y, 32, 0, 0)
KOSAPI.sysfunc7(65, icons + SIZE*SIZE*4*n, SIZE*65536 + SIZE, x*65536 + y, 32, 0, 0)
END draw;
PROCEDURE copy (img: INTEGER; n: INTEGER; dst: INTEGER; m: INTEGER);
VAR
data: INTEGER;
BEGIN
SYSTEM.GET(img + 24, data);
SYSTEM.MOVE(data + SIZE*SIZE*4*n, dst + SIZE*SIZE*4*m, SIZE*SIZE*4)
END copy;
PROCEDURE iconsBackColor (icons: INTEGER; BackColor: INTEGER);
VAR
width, height, data, x, y, pix: INTEGER;
b, g, r, gr: BYTE;
data, x, y, pix: INTEGER;
b, g, r, gr: BYTE;
BEGIN
GetInf(icons, width, height, data);
FOR y := 0 TO height - 1 DO
FOR x := 0 TO width - 1 DO
SYSTEM.GET32(data, pix);
Graph.getRGB(pix, r, g, b);
gr := (r + g + b) DIV 3;
IF BackColor = -1 THEN
pix := gr + 256*gr + 65536*gr
ELSIF gr = 255 THEN
pix := BackColor
END;
SYSTEM.PUT32(data, pix);
INC(data, 4)
END
END
data := icons;
FOR y := 0 TO SIZE*NumberOfIcons - 1 DO
FOR x := 0 TO SIZE - 1 DO
SYSTEM.GET32(data, pix);
Graph.getRGB(pix, r, g, b);
gr := (r + g + b) DIV 3;
IF BackColor = -1 THEN
pix := gr + 256*gr + 65536*gr
ELSIF gr = 255 THEN
pix := BackColor
END;
SYSTEM.PUT32(data, pix);
INC(data, 4)
END
END
END iconsBackColor;
PROCEDURE get* (VAR icons, grayIcons: INTEGER; BackColor: INTEGER);
VAR
source: INTEGER;
BEGIN
IF source = 0 THEN
source := load();
icons := load();
grayIcons := load();
iconsBackColor(grayIcons, -1);
iconsBackColor(grayIcons, BackColor);
iconsBackColor(icons, BackColor)
(*ELSE
copy(source, icons);
copy(source, grayIcons)*)
END
source := load();
IF source # 0 THEN
icons := KOSAPI.malloc(SIZE*SIZE*4*NumberOfIcons*2);
grayIcons := icons + SIZE*SIZE*4*NumberOfIcons;
copy(source, 2, icons, icoNew);
copy(source, 0, icons, icoOpen);
copy(source, 5, icons, icoSave);
copy(source, 49, icons, icoSearch);
copy(source, 37, icons, icoUndo);
copy(source, 36, icons, icoRedo);
copy(source, 54, icons, icoBuild);
copy(source, 53, icons, icoRun);
img_destroy(source);
source := 0;
SYSTEM.MOVE(icons, grayIcons, SIZE*SIZE*4*NumberOfIcons);
iconsBackColor(grayIcons, -1);
iconsBackColor(grayIcons, BackColor);
iconsBackColor(icons, BackColor)
END
END get;
BEGIN
source := 0
END Icons.

View File

@ -439,7 +439,8 @@ PROCEDURE loadKW (lang: INTEGER; VAR KW: ARRAY OF tKeyWords; VAR delim: tDelimit
VAR
s: ARRAY 16*1024 OF CHAR;
key: ARRAY 4 OF CHAR;
i: INTEGER;
i, j, k: INTEGER;
w: WCHAR;
BEGIN
FOR i := 0 TO LEN(delim) - 1 DO
delim[i] := FALSE
@ -458,6 +459,19 @@ BEGIN
IF ~(lang IN csLang) THEN
Utils.upcase(s)
END;
IF lang = langOberon THEN
k := LENGTH(s);
s[k] := ",";
FOR j := 0 TO k - 1 DO
s[j + k + 1] := s[j];
w := WCHR(ORD(s[j]));
IF Utils.low(w) THEN
s[j + k + 1] := CHR(ORD(w) MOD 256)
END
END;
k := 2*k + 1;
s[k] := 0X
END;
EnterKW(s, KW[i])
END
END loadKW;

View File

@ -1,5 +1,5 @@
(*
Copyright 2021, 2022 Anton Krotov
Copyright 2021-2023 Anton Krotov
This file is part of CEdit.
@ -238,6 +238,7 @@ BEGIN
m.active := FALSE;
resetTimer;
m.tid := 0;
G.destroy(m.canvas);
K.Exit
END exit;
@ -249,6 +250,7 @@ BEGIN
resetTimer
END;
m.tid := 0;
G.destroy(m.canvas);
K.Exit
END escape;
@ -354,6 +356,7 @@ BEGIN
END;
temp := m.tid;
m.tid := 0;
G.destroy(m.canvas);
K.ExitID(temp);
m.active := FALSE
END
@ -509,6 +512,7 @@ BEGIN
IF m.parent # NIL THEN
temp := m.parent.tid;
m.parent.tid := 0;
G.destroy(m.parent.canvas);
K.ExitID(temp)
END;
exit(m)
@ -567,6 +571,10 @@ BEGIN
IF K.GetThreadSlot(TIDs[L]) = 0 THEN
m.winX := x;
m.winY := y;
IF m.canvas = NIL THEN
m.canvas := G.CreateCanvas(m.width + 1, m.height + 1);
G.SetFont(m.canvas, m.font)
END;
SYSTEM.PUT(SYSTEM.ADR(stack[L][LEN(stack[0]) - 1]), m);
m.tid := K.CreateThread(SYSTEM.ADR(window), stack[L]);
TIDs[L] := m.tid
@ -678,8 +686,8 @@ BEGIN
m.width := maxLength*fontWidth + LEFT + RIGHT;
m.height := items.count*itemHeight - 2;
m.font := G.fonts[1];
m.canvas := G.CreateCanvas(m.width + 1, m.height + 1);
G.SetFont(m.canvas, m.font)
(* m.canvas := G.CreateCanvas(m.width + 1, m.height + 1);
G.SetFont(m.canvas, m.font)*)
RETURN m
END create;

View File

@ -1,5 +1,5 @@
(*
Copyright 2021, 2022 Anton Krotov
Copyright 2021-2023 Anton Krotov
This file is part of CEdit.
@ -136,7 +136,7 @@ BEGIN
END;
IF n = -1 THEN
code := E.UNDEF
code := -1
END
RETURN code
@ -244,7 +244,7 @@ BEGIN
text.cnt := cnt;
text.pos := pos;
WHILE (text.cnt > 0) & continue DO
IF getCharUTF8(text) = E.UNDEF THEN
IF getCharUTF8(text) = -1 THEN
continue := FALSE
END
END;
@ -470,40 +470,27 @@ BEGIN
putByte(file, (code DIV 64) MOD 64 + 080H);
putByte(file, code MOD 64 + 080H)
ELSE
putByte(file, ORD("?"))
putByte(file, E.UNDEF)
END
END putCharUTF8;
PROCEDURE putCharCP (file: tOutput; code, cp: INTEGER);
VAR
n: INTEGER;
BEGIN
n := E.UNI[code, cp];
IF n # E.UNDEF THEN
putByte(file, n)
ELSE
putByte(file, ORD("?"))
END
END putCharCP;
PROCEDURE putCharCP1251 (file: tOutput; code: INTEGER);
BEGIN
putCharCP(file, code, E.CP1251)
putByte(file, E.UNI[code, E.CP1251])
END putCharCP1251;
PROCEDURE putCharCP866 (file: tOutput; code: INTEGER);
BEGIN
putCharCP(file, code, E.CP866)
putByte(file, E.UNI[code, E.CP866])
END putCharCP866;
(*
PROCEDURE putCharUTF16LE (file: tOutput; code: INTEGER);
BEGIN
IF ~((0 <= code) & (code <= 65535)) THEN
code := ORD("?")
code := E.UNDEF
END;
putByte(file, code MOD 256);
putByte(file, code DIV 256)

View File

@ -1,5 +1,5 @@
(*
Copyright 2021, 2022 Anton Krotov
Copyright 2021-2023 Anton Krotov
This file is part of CEdit.
@ -24,17 +24,19 @@ IMPORT
TYPE
tBuffer* = CB.tBuffer;
IdxTable* = ARRAY 65536, 2 OF INTEGER;
tIdxTable = ARRAY 65536, 2 OF INTEGER;
tPos* = POINTER TO RECORD (List.tItem)
pos*: INTEGER
END;
VAR
table: POINTER TO RECORD data: tIdxTable END;
PROCEDURE index* (text: tBuffer; VAR table: IdxTable; cs: BOOLEAN): tBuffer;
PROCEDURE _index (text: tBuffer; cs: BOOLEAN; VAR table: tIdxTable): tBuffer;
VAR
pChar, cnt, i: INTEGER;
c: WCHAR;
@ -80,19 +82,29 @@ BEGIN
END
RETURN res
END _index;
PROCEDURE index* (text: tBuffer; cs: BOOLEAN): tBuffer;
BEGIN
IF table = NIL THEN
NEW(table)
END
RETURN _index(text, cs, table.data)
END index;
PROCEDURE find* (text: tBuffer; table: IdxTable; s: ARRAY OF WCHAR; whole: BOOLEAN; list: List.tList);
PROCEDURE find* (text: tBuffer; s: ARRAY OF WCHAR; whole: BOOLEAN; list: List.tList);
VAR
k, pos, n, x, prev_item_pos: INTEGER;
item: tPos;
c1, c2: WCHAR;
flag: BOOLEAN;
BEGIN
ASSERT(table # NIL);
n := LENGTH(s);
k := table[ORD(s[0]), 1];
pos := table[ORD(s[0]), 0];
k := table.data[ORD(s[0]), 1];
pos := table.data[ORD(s[0]), 0];
prev_item_pos := 0;
WHILE k > 0 DO
SYSTEM.GET(pos, x);
@ -105,7 +117,8 @@ BEGIN
c1 := 0X
END;
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;
IF ~flag & (x >= prev_item_pos) THEN
prev_item_pos := x + n;
@ -120,4 +133,14 @@ BEGIN
END find;
PROCEDURE close*;
BEGIN
IF table # NIL THEN
DISPOSE(table)
END
END close;
BEGIN
table := NIL
END Search.

View File

@ -100,7 +100,6 @@ VAR
size, textsize: tPoint;
charWidth, charHeight: INTEGER;
autoIndents*, lineNumbers*, autoBrackets*, trimSpace*: BOOLEAN;
idxTable: Search.IdxTable;
PROCEDURE setLang* (text: tText; lang: INTEGER);
@ -911,9 +910,11 @@ BEGIN
END;
IF text.searchText # "" THEN
plainText := plain(text);
idxData := Search.index(plainText, idxTable, cs);
Search.find(plainText, idxTable, text.searchText, whole, text.foundList);
idxData := Search.index(plainText, cs);
Search.find(plainText, text.searchText, whole, text.foundList);
res := text.foundList.count > 0
ELSE
Search.close
END;
CB.destroy(plainText);
CB.destroy(idxData);
@ -2462,7 +2463,7 @@ END draw;
PROCEDURE switch* (text: tText);
BEGIN
ChangeLog.set(text.chLog);
ChangeLog.setLog(text.chLog);
Lines.setMaxLength(text.maxLength);
Lang.setCurLang(text.lang)
END switch;

View File

@ -1,5 +1,5 @@
(*
Copyright 2021, 2022 Anton Krotov
Copyright 2021-2023 Anton Krotov
This file is part of CEdit.
@ -92,7 +92,9 @@ VAR
button: tButton;
BEGIN
setColors(toolbar);
Icons.get(toolbar.icons, toolbar.grayIcons, toolbar.colors.back);
IF (toolbar.icons = 0) OR (toolbar.grayIcons = 0) THEN
Icons.get(toolbar.icons, toolbar.grayIcons, toolbar.colors.back)
END;
i := 0;
WHILE i < toolbar.cnt DO
button := toolbar.buttons[i];
@ -160,7 +162,9 @@ BEGIN
toolbar.x := x;
toolbar.y := y;
toolbar.cnt := 0;
toolbar.width := 0
toolbar.width := 0;
toolbar.icons := 0;
toolbar.grayIcons := 0;
END create;