[CEdit, FB2 Reader]: minor fixes

git-svn-id: svn://kolibrios.org@9599 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Anton Krotov 2022-01-08 21:10:10 +00:00
parent eb8c7e7663
commit ef33c606ec
7 changed files with 49 additions and 52 deletions

Binary file not shown.

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 (05-jan-2022)"; HEADER = "CEdit (08-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";
@ -404,6 +404,8 @@ BEGIN
CheckBox.paint(WH); CheckBox.paint(WH);
END; END;
G.SetColor(canvas, K.borderColor);
G.VLine(canvas, 0, 0, canvas.height - 1);
G.DrawCanvas(canvas, LEFT, TOP); G.DrawCanvas(canvas, LEFT, TOP);
NotFound; NotFound;
Replaced; Replaced;
@ -1952,7 +1954,7 @@ VAR
fileName, filePath: RW.tFileName; fileName, filePath: RW.tFileName;
width, height, cliWidth, cliHeight: INTEGER; width, height, cliWidth, cliHeight: INTEGER;
resized: BOOLEAN; resized: BOOLEAN;
firstClickX, firstClickY, time: INTEGER; firstClickX, firstClickY, time, blink: INTEGER;
BEGIN BEGIN
header := ""; header := "";
K.GetSystemColors; K.GetSystemColors;
@ -2066,11 +2068,17 @@ BEGIN
K.SetEventsMask({0, 1, 2, 5, 6, 31}); K.SetEventsMask({0, 1, 2, 5, 6, 31});
Menu.init(resetTimer); Menu.init(resetTimer);
draw_window; draw_window;
blink := Ini.blink;
IF blink <= 0 THEN
blink := 0
ELSIF blink < 30 THEN
blink := 30
END;
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 > Ini.blink) & timerEnabled THEN IF (CurrentTime - CursorTime > blink) & (blink > 0) & timerEnabled THEN
CursorTime := CurrentTime; CursorTime := CurrentTime;
T.toggleCursor; T.toggleCursor;
repaint repaint

View File

@ -49,7 +49,7 @@ VAR
ptr, pchar: INTEGER; ptr, pchar: INTEGER;
wch: WCHAR; wch: WCHAR;
BEGIN BEGIN
cnt := bufSize(buffer) DIV 2; cnt := bufSize(buffer) DIV SYSTEM.SIZE(WCHAR);
size := cnt + 12; size := cnt + 12;
a := KOSAPI.malloc(size); a := KOSAPI.malloc(size);
ASSERT(a # 0); ASSERT(a # 0);

View File

@ -151,11 +151,6 @@ PROCEDURE getSettings* (VAR build, run, debug: RW.tFileName);
BEGIN BEGIN
Lines.setTabs(get_int(IniFileName, "settings", "tab", 4)); Lines.setTabs(get_int(IniFileName, "settings", "tab", 4));
blink := get_int(IniFileName, "settings", "blink", 70); blink := get_int(IniFileName, "settings", "blink", 70);
IF blink = 0 THEN
blink := -1
ELSE
blink := MIN(MAX(blink, 1), 1000)
END;
getStr("settings", "build", build); getStr("settings", "build", build);
getStr("settings", "run", run); getStr("settings", "run", run);
getStr("settings", "debug", debug) getStr("settings", "debug", debug)

View File

@ -497,7 +497,10 @@ BEGIN
_tab := 4 _tab := 4
END; END;
tabs := _tab > 0; tabs := _tab > 0;
tab := ABS(_tab) tab := ABS(_tab);
IF tab > 32 THEN
tab := 32
END
END setTabs; END setTabs;

View File

@ -26,7 +26,6 @@ IMPORT
RW, Search, RW, Search,
E := Encodings, E := Encodings,
CB := Clipboard, CB := Clipboard,
K := KolibriOS,
ChangeLog, File, ChangeLog, File,
Lang := Languages; Lang := Languages;
@ -75,7 +74,6 @@ TYPE
enc, eol: INTEGER; enc, eol: INTEGER;
table: Search.IdxTable; table: Search.IdxTable;
foundList: List.tList; foundList: List.tList;
idxData: Search.tBuffer;
foundSel: INTEGER; foundSel: INTEGER;
searchText: tString; searchText: tString;
chLog*: ChangeLog.tLog; chLog*: ChangeLog.tLog;
@ -818,7 +816,7 @@ BEGIN
END leadingSpaces; END leadingSpaces;
PROCEDURE plain (text: tText; eot: BOOLEAN): CB.tBuffer; PROCEDURE plain (text: tText): CB.tBuffer;
VAR VAR
buf: CB.tBuffer; buf: CB.tBuffer;
size: INTEGER; size: INTEGER;
@ -834,10 +832,7 @@ BEGIN
INC(size, CB.lenEOL) INC(size, CB.lenEOL)
END END
END; END;
IF eot THEN buf := CB.create(size + 2);
INC(size, 2)
END;
buf := CB.create(size);
line := text.first(tLine); line := text.first(tLine);
WHILE line # NIL DO WHILE line # NIL DO
CB.append(buf, line, 0, line.length - 1); CB.append(buf, line, 0, line.length - 1);
@ -846,9 +841,8 @@ BEGIN
CB.eol(buf) CB.eol(buf)
END END
END; END;
IF eot THEN CB.appends(buf, 0X, 0, 0);
CB.appends(buf, 0X + 0X, 0, 1) CB.appends(buf, 0X, 0, 0)
END
RETURN buf RETURN buf
END plain; END plain;
@ -857,9 +851,11 @@ PROCEDURE search* (text: tText; s: ARRAY OF WCHAR; cs, whole: BOOLEAN): BOOLEAN;
VAR VAR
pos: List.tItem; pos: List.tItem;
res: BOOLEAN; res: BOOLEAN;
plainText: Search.tBuffer; plainText, idxData: Search.tBuffer;
BEGIN BEGIN
res := TRUE;
plainText := NIL; plainText := NIL;
idxData := NIL;
WHILE text.foundList.count # 0 DO WHILE text.foundList.count # 0 DO
pos := List.pop(text.foundList); pos := List.pop(text.foundList);
DISPOSE(pos) DISPOSE(pos)
@ -871,15 +867,13 @@ BEGIN
U.upcase16(text.searchText) U.upcase16(text.searchText)
END; END;
IF text.searchText # "" THEN IF text.searchText # "" THEN
plainText := plain(text, TRUE); plainText := plain(text);
text.idxData := Search.index(plainText, text.table, cs); idxData := Search.index(plainText, text.table, cs);
Search.find(plainText, text.table, text.searchText, whole, text.foundList); Search.find(plainText, text.table, text.searchText, whole, text.foundList);
res := text.foundList.count > 0 res := text.foundList.count > 0
ELSE
res := TRUE
END; END;
CB.destroy(plainText); CB.destroy(plainText);
CB.destroy(text.idxData); CB.destroy(idxData);
text.search := FALSE; text.search := FALSE;
text.foundSel := 0 text.foundSel := 0
RETURN res RETURN res
@ -1537,7 +1531,7 @@ BEGIN
DEC(n) DEC(n)
END; END;
buffer := CB.create(cnt); buffer := CB.create(cnt + 2); (* +2 wchars EOT *)
n := selEnd.Y - selBeg.Y; n := selEnd.Y - selBeg.Y;
line := first; line := first;
@ -2343,9 +2337,7 @@ BEGIN
IF drawCursor THEN IF drawCursor THEN
cursor(text) cursor(text)
END; END
G.SetColor(canvas, K.borderColor);
G.VLine(canvas, 0, 0, size.Y - 1);
END draw; END draw;
@ -2380,7 +2372,6 @@ BEGIN
text.whole := FALSE; text.whole := FALSE;
text.numbers := TRUE; text.numbers := TRUE;
text.guard := TRUE; text.guard := TRUE;
text.idxData := NIL;
text.edition := NIL; text.edition := NIL;
text.foundList := List.create(NIL); text.foundList := List.create(NIL);
text.searchText := ""; text.searchText := "";