CEdit: clipping text, small changes

git-svn-id: svn://kolibrios.org@9892 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Anton Krotov 2023-01-21 12:10:00 +00:00
parent 2919153f32
commit bd24d8a01e
7 changed files with 46 additions and 40 deletions

View File

@ -1,3 +1,3 @@
#SHS #SHS
/kolibrios/develop/oberon07/compiler.kex ./src/cedit.ob07 kosexe -out /tmp0/1/cedit.kex -stk 1 -nochk a /kolibrios/develop/oberon07/compiler.kex ./src/cedit.ob07 kosexe -out /tmp0/1/cedit -stk 1 -nochk a
exit exit

Binary file not shown.

View File

@ -1,3 +1,3 @@
#SHS #SHS
/tmp0/1/cedit.kex /tmp0/1/cedit
exit exit

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 (13-jan-2023)"; HEADER = "CEdit (21-jan-2023)";
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";
@ -65,7 +65,7 @@ CONST
toolbarTop = Menu.MainMenuHeight + 3; toolbarTop = Menu.MainMenuHeight + 3;
TOP = toolbarTop + Toolbar.BtnSize + 10 + Tabs.tabHeight; TOP = toolbarTop + Toolbar.BtnSize + 9 + Tabs.tabHeight;
minWinWidth = 635; minWinHeight = 550; minWinWidth = 635; minWinHeight = 550;
@ -169,6 +169,8 @@ CONST
SHIFT = Menu.SHIFT; SHIFT = Menu.SHIFT;
CTRL = Menu.CTRL; CTRL = Menu.CTRL;
ClippingArea = 50;
VAR VAR
header: RW.tFileName; header: RW.tFileName;
@ -446,7 +448,8 @@ BEGIN
END; END;
BOTTOM := SB.height() + scrollWidth - 1; BOTTOM := SB.height() + scrollWidth - 1;
G.destroy(canvas); G.destroy(canvas);
canvas := G.CreateCanvas(cliWidth - (LEFT + RIGHT + 2 + RIGHT_PADDING), cliHeight - (TOP + BOTTOM + 1)); canvas := G.CreateCanvas(cliWidth - (LEFT + RIGHT + 2 + RIGHT_PADDING), cliHeight - (TOP + BOTTOM + 1 - ClippingArea));
DEC(canvas.height, ClippingArea);
Tabs.setArea(tabs, LEFT, TOP - Tabs.tabHeight, cliWidth - (LEFT + RIGHT + 2 + RIGHT_PADDING), Tabs.tabHeight); Tabs.setArea(tabs, LEFT, TOP - Tabs.tabHeight, cliWidth - (LEFT + RIGHT + 2 + RIGHT_PADDING), Tabs.tabHeight);
G.SetFont(canvas, font); G.SetFont(canvas, font);
T.setCanvas(canvas); T.setCanvas(canvas);
@ -2099,7 +2102,8 @@ BEGIN
RIGHT := scrollWidth - 2; RIGHT := scrollWidth - 2;
BOTTOM := SB.height() + scrollWidth - 1; BOTTOM := SB.height() + scrollWidth - 1;
SkinHeight := K.SkinHeight(); SkinHeight := K.SkinHeight();
canvas := G.CreateCanvas(winWidth - (LEFT + RIGHT + 11 + RIGHT_PADDING), winHeight - (TOP + BOTTOM + 5) - SkinHeight); canvas := G.CreateCanvas(winWidth - (LEFT + RIGHT + 11 + RIGHT_PADDING), winHeight - (TOP + BOTTOM + 5 - ClippingArea) - SkinHeight);
DEC(canvas.height, ClippingArea);
tabs := Tabs.create(); tabs := Tabs.create();
Tabs.setArea(tabs, LEFT, TOP - Tabs.tabHeight, canvas.width, Tabs.tabHeight); Tabs.setArea(tabs, LEFT, TOP - Tabs.tabHeight, canvas.width, Tabs.tabHeight);
font := G.fonts[Ini.font]; font := G.fonts[Ini.font];

View File

@ -45,7 +45,7 @@ TYPE
tCanvas* = POINTER TO RECORD tCanvas* = POINTER TO RECORD
bitmap: INTEGER; bitmap: INTEGER;
width*, height*: INTEGER; width*, height*, sizeY: INTEGER;
color, backColor, textColor: INTEGER; color, backColor, textColor: INTEGER;
font*: tFont; font*: tFont;
mode: INTEGER mode: INTEGER
@ -166,22 +166,18 @@ END VLine;
PROCEDURE notVLine* (canvas: tCanvas; x, y1, y2: INTEGER); PROCEDURE notVLine* (canvas: tCanvas; x, y1, y2: INTEGER);
BEGIN BEGIN
IF (0 <= y1) & (y1 < canvas.height) & (0 <= y2) & (y2 < canvas.height) THEN canvas.mode := modeNOT;
canvas.mode := modeNOT; VLine(canvas, x, y1, y2);
VLine(canvas, x, y1, y2); canvas.mode := modeCOPY
canvas.mode := modeCOPY
END
END notVLine; END notVLine;
PROCEDURE xorVLine* (canvas: tCanvas; x, y1, y2: INTEGER); PROCEDURE xorVLine* (canvas: tCanvas; x, y1, y2: INTEGER);
BEGIN BEGIN
IF (0 <= y1) & (y1 < canvas.height) & (0 <= y2) & (y2 < canvas.height) THEN canvas.mode := modeXOR;
canvas.mode := modeXOR; SetColor(canvas, 0FF0000H);
SetColor(canvas, 0FF0000H); VLine(canvas, x, y1, y2);
VLine(canvas, x, y1, y2); canvas.mode := modeCOPY
canvas.mode := modeCOPY
END
END xorVLine; END xorVLine;
@ -259,7 +255,7 @@ BEGIN
w := canvas.width*4; w := canvas.width*4;
ptr := canvas.bitmap; ptr := canvas.bitmap;
ptr2 := ptr; ptr2 := ptr;
i := canvas.height - 1; i := canvas.sizeY - 1;
WHILE i > 0 DO WHILE i > 0 DO
INC(ptr2, w); INC(ptr2, w);
SYSTEM.MOVE(ptr, ptr2, w); SYSTEM.MOVE(ptr, ptr2, w);
@ -277,7 +273,7 @@ VAR
c: WCHAR; c: WCHAR;
BEGIN BEGIN
font := canvas.font; font := canvas.font;
IF (0 <= y) & (y <= canvas.height - font.height - 1) THEN IF (0 <= y) & (y <= canvas.sizeY - font.height - 1) THEN
IF x < 0 THEN IF x < 0 THEN
i := -(x DIV font.width); i := -(x DIV font.width);
INC(x, i*font.width); INC(x, i*font.width);
@ -339,6 +335,7 @@ BEGIN
INC(canvas.bitmap, 8); INC(canvas.bitmap, 8);
canvas.width := width; canvas.width := width;
canvas.height := height; canvas.height := height;
canvas.sizeY := height;
canvas.mode := modeCOPY canvas.mode := modeCOPY
RETURN canvas RETURN canvas
END CreateCanvas; END CreateCanvas;

View File

@ -1,5 +1,5 @@
(* (*
Copyright 2021, 2022 Anton Krotov Copyright 2021-2023 Anton Krotov
This file is part of CEdit. This file is part of CEdit.
@ -434,7 +434,8 @@ BEGIN
END EnterKW; END EnterKW;
PROCEDURE loadKW (VAR KW: ARRAY OF tKeyWords; VAR delim: tDelimiters; getStr: procGetStr; lang: ARRAY OF CHAR); PROCEDURE loadKW (lang: INTEGER; VAR KW: ARRAY OF tKeyWords; VAR delim: tDelimiters; getStr: procGetStr;
lang_name: ARRAY OF CHAR);
VAR VAR
s: ARRAY 16*1024 OF CHAR; s: ARRAY 16*1024 OF CHAR;
key: ARRAY 4 OF CHAR; key: ARRAY 4 OF CHAR;
@ -443,7 +444,7 @@ BEGIN
FOR i := 0 TO LEN(delim) - 1 DO FOR i := 0 TO LEN(delim) - 1 DO
delim[i] := FALSE delim[i] := FALSE
END; END;
getStr(lang, "delim", s); getStr(lang_name, "delim", s);
i := 0; i := 0;
WHILE s[i] # 0X DO WHILE s[i] # 0X DO
delim[ORD(s[i])] := TRUE; delim[ORD(s[i])] := TRUE;
@ -453,7 +454,10 @@ BEGIN
FOR i := 0 TO 2 DO FOR i := 0 TO 2 DO
KW[i].cnt := 0; KW[i].cnt := 0;
key[2] := CHR(ORD("1") + i); key[2] := CHR(ORD("1") + i);
getStr(lang, key, s); getStr(lang_name, key, s);
IF ~(lang IN csLang) THEN
Utils.upcase(s)
END;
EnterKW(s, KW[i]) EnterKW(s, KW[i])
END END
END loadKW; END loadKW;
@ -498,14 +502,14 @@ END getExt;
PROCEDURE init* (getStr: procGetStr); PROCEDURE init* (getStr: procGetStr);
BEGIN BEGIN
currentLang := langText; currentLang := langText;
loadKW(KW[langText], Delim[langText], getStr, "lang_Text"); loadKW(langText, KW[langText], Delim[langText], getStr, "lang_Text");
loadKW(KW[langOberon], Delim[langOberon], getStr, "lang_Oberon"); loadKW(langOberon, KW[langOberon], Delim[langOberon], getStr, "lang_Oberon");
loadKW(KW[langC], Delim[langC], getStr, "lang_C"); loadKW(langC, KW[langC], Delim[langC], getStr, "lang_C");
loadKW(KW[langPascal], Delim[langPascal], getStr, "lang_Pascal"); loadKW(langPascal, KW[langPascal], Delim[langPascal], getStr, "lang_Pascal");
loadKW(KW[langLua], Delim[langLua], getStr, "lang_Lua"); loadKW(langLua, KW[langLua], Delim[langLua], getStr, "lang_Lua");
loadKW(KW[langIni], Delim[langIni], getStr, "lang_Ini"); loadKW(langIni, KW[langIni], Delim[langIni], getStr, "lang_Ini");
loadKW(KW[langFasm], Delim[langFasm], getStr, "lang_Fasm"); loadKW(langFasm, KW[langFasm], Delim[langFasm], getStr, "lang_Fasm");
loadKW(KW[langJSON], Delim[langJSON], getStr, "lang_JSON"); loadKW(langJSON, KW[langJSON], Delim[langJSON], getStr, "lang_JSON");
fileExt[ 0].ext := "OB07"; fileExt[ 0].lang := langOberon; fileExt[ 0].ext := "OB07"; fileExt[ 0].lang := langOberon;
fileExt[ 1].ext := "C"; fileExt[ 1].lang := langC; fileExt[ 1].ext := "C"; fileExt[ 1].lang := langC;

View File

@ -39,7 +39,7 @@ CONST
mark_width = 2; mark_width = 2;
pad_left = mark_width + 3; pad_left = mark_width + 3;
pad_top = 0; pad_top = 1;
inter = 2; inter = 2;
@ -2234,7 +2234,7 @@ BEGIN
cursor := text.cursor; cursor := text.cursor;
scrollX := text.scroll.X; scrollX := text.scroll.X;
scrollY := text.scroll.Y; scrollY := text.scroll.Y;
IF ~((scrollY > cursor.Y) OR (scrollY + textsize.Y <= cursor.Y) OR IF ~((scrollY > cursor.Y) OR (scrollY + textsize.Y + 1 <= cursor.Y) OR
(scrollX > cursor.X) OR (scrollX + textsize.X <= cursor.X)) THEN (scrollX > cursor.X) OR (scrollX + textsize.X <= cursor.X)) THEN
x := (cursor.X - scrollX)*charWidth + padding.left; x := (cursor.X - scrollX)*charWidth + padding.left;
y1 := (cursor.Y - scrollY)*charHeight + padding.top + (inter DIV 2 + 1); y1 := (cursor.Y - scrollY)*charHeight + padding.top + (inter DIV 2 + 1);
@ -2336,9 +2336,10 @@ BEGIN
y := padding.top + inter DIV 2; y := padding.top + inter DIV 2;
n := text.scroll.Y; n := text.scroll.Y;
firstLine := getLine2(text, n); firstLine := getLine2(text, n);
IF text.smallMove THEN IF text.smallMove THEN
line := text.curLine; line := text.curLine;
cnt := textsize.Y - 1; cnt := textsize.Y;
y := y + charHeight*(text.cursor.Y - text.scroll.Y); y := y + charHeight*(text.cursor.Y - text.scroll.Y);
G.SetColor(canvas, colors.back); G.SetColor(canvas, colors.back);
G.FillRect(canvas, padding.left - 2, y - inter DIV 2, size.X - 1, y - inter DIV 2 + charHeight); G.FillRect(canvas, padding.left - 2, y - inter DIV 2, size.X - 1, y - inter DIV 2 + charHeight);
@ -2348,7 +2349,7 @@ BEGIN
cnt := 0 cnt := 0
END; END;
WHILE (line # NIL) & (cnt < textsize.Y) DO WHILE (line # NIL) & (cnt <= textsize.Y) DO
backColor := colors.back; backColor := colors.back;
IF (line = text.curLine) & ~selected(text) THEN IF (line = text.curLine) & ~selected(text) THEN
G.SetColor(canvas, colors.curline); G.SetColor(canvas, colors.curline);
@ -2383,7 +2384,7 @@ BEGIN
line := firstLine; line := firstLine;
SetColor(colors.numtext, colors.numback); SetColor(colors.numtext, colors.numback);
y := padding.top + inter DIV 2; y := padding.top + inter DIV 2;
n := MIN(text.scroll.Y + textsize.Y, text.count); n := MIN(text.scroll.Y + textsize.Y + 1, text.count);
FOR i := text.scroll.Y + 1 TO n DO FOR i := text.scroll.Y + 1 TO n DO
IF lineNumbers THEN IF lineNumbers THEN
IF (i MOD 10 = 0) OR (i - 1 = text.cursor.Y) OR line.label THEN IF (i MOD 10 = 0) OR (i - 1 = text.cursor.Y) OR line.label THEN
@ -2396,8 +2397,8 @@ BEGIN
END; END;
IF line.label THEN IF line.label THEN
FOR x := wNum DIV 2 TO (padding.left - pad_left) - wNum DIV 2 DO FOR x := wNum DIV 2 TO (padding.left - pad_left) - wNum DIV 2 DO
G.notVLine(canvas, x, y, y + charHeight - inter); G.notVLine(canvas, x, y, y + charHeight - (inter + 1));
G.xorVLine(canvas, x, y, y + charHeight - inter) G.xorVLine(canvas, x, y, y + charHeight - (inter + 1))
END END
END; END;
NextLine(line); NextLine(line);
@ -2409,7 +2410,7 @@ BEGIN
firstLine := text.curLine; firstLine := text.curLine;
lastLine := firstLine lastLine := firstLine
ELSE ELSE
lastLine := getLine2(text, MIN(text.scroll.Y + textsize.Y, text.count) - 1) lastLine := getLine2(text, MIN(text.scroll.Y + textsize.Y + 1, text.count) - 1)
END; END;
p := text.foundList.first(Search.tPos); p := text.foundList.first(Search.tPos);
WHILE p # NIL DO WHILE p # NIL DO