diff --git a/programs/develop/cedit/CEDIT b/programs/develop/cedit/CEDIT index 8722fe8fa3..0ef59a7338 100644 Binary files a/programs/develop/cedit/CEDIT and b/programs/develop/cedit/CEDIT differ diff --git a/programs/develop/cedit/SRC/CEdit.ob07 b/programs/develop/cedit/SRC/CEdit.ob07 index 695d176757..65f4e2e52e 100644 --- a/programs/develop/cedit/SRC/CEdit.ob07 +++ b/programs/develop/cedit/SRC/CEdit.ob07 @@ -28,14 +28,13 @@ IMPORT RW, Ini, EB := EditBox, Tabs, Toolbar, SB := StatusBar; CONST - HEADER = "CEdit (20-jan-2022)"; + HEADER = "CEdit (25-jan-2022)"; ShellFilter = ""; EditFilter = "SH|INC|TXT|ASM|OB07|C|CPP|H|PAS|PP|LUA|INI|JSON"; fontWidth = K.fontWidth; fontHeight = K.fontHeight; - scrollWidth = 22; btnClose = 1; @@ -67,8 +66,6 @@ CONST toolbarTop = Menu.MainMenuHeight + 3; TOP = toolbarTop + Toolbar.BtnSize + 10 + Tabs.tabHeight; - RIGHT = scrollWidth - 2; - BOTTOM = scrollWidth + 18; minWinWidth = 635; minWinHeight = 550; @@ -111,7 +108,9 @@ CONST menuExit = 17; menuNumbers = 20; - menuFontSize = 21; + menuFontSmall = 21; + menuFontMedium = 22; + menuFontBig = 23; menuColors = 1000; menuMaxColors = menuColors + Ini.MAX_SECTIONS - 1; @@ -176,7 +175,7 @@ CONST VAR header: RW.tFileName; canvas: G.tCanvas; - font, font1, font2: G.tFont; + font: G.tFont; tabs: Tabs.tTabs; text: T.tText; @@ -184,14 +183,14 @@ VAR textsCount, curText: INTEGER; winWidth, winHeight: INTEGER; - SkinHeight: INTEGER; + SkinHeight, scrollWidth: INTEGER; AppPath, runScript, buildScript, debugScript, CurFolder: RW.tFileName; OD: OpenDlg.Dialog; confirm, notFound, menuFindClicked, search, searchOpened: BOOLEAN; switch, closing: BOOLEAN; leftButton: BOOLEAN; - LEFT: INTEGER; + LEFT, RIGHT, BOTTOM: INTEGER; FindEdit, ReplaceEdit, GotoEdit: EB.tEditBox; hScroll, vScroll: Scroll.tScroll; @@ -370,6 +369,14 @@ BEGIN END DrawScroll; +PROCEDURE drawText; +BEGIN + G.SetColor(canvas, K.colors.line); + G.VLine(canvas, 0, 0, canvas.height - 1); + G.DrawCanvas(canvas, LEFT, TOP) +END drawText; + + PROCEDURE repaint; VAR width, height, scrollX, scrollY: INTEGER; @@ -403,10 +410,7 @@ BEGIN CheckBox.draw(CS); CheckBox.draw(WH); END; - - G.SetColor(canvas, K.colors.line); - G.VLine(canvas, 0, 0, canvas.height - 1); - G.DrawCanvas(canvas, LEFT, TOP); + drawText; NotFound; Replaced; Toolbar.enable(toolbar, btnSave, text.modified); @@ -435,6 +439,12 @@ BEGIN K.SetWinSize(winWidth, winHeight); K.WinSize(winWidth, winHeight); K.ClientSize(cliWidth, cliHeight); + IF font # G.font2 THEN + SB.SetFont(font) + ELSE + SB.SetFont(G.font1) + END; + BOTTOM := SB.height() + scrollWidth - 1; G.destroy(canvas); canvas := G.CreateCanvas(cliWidth - (LEFT + RIGHT + 2 + RIGHT_PADDING), cliHeight - (TOP + BOTTOM + 1)); Tabs.setArea(tabs, LEFT, TOP - Tabs.tabHeight, cliWidth - (LEFT + RIGHT + 2 + RIGHT_PADDING), Tabs.tabHeight); @@ -1040,8 +1050,10 @@ BEGIN Menu.option(menu, menuWin1251, T.getEnc(text) = E.W1251); INC(x, menuEncodingX) ELSIF menu = menuView THEN - Menu.check(menu, menuNumbers, text.numbers); - Menu.check(menu, menuFontSize, font = font2); + Menu.check(menu, menuNumbers, text.numbers); + Menu.option(menu, menuFontSmall, font = G.font0); + Menu.option(menu, menuFontMedium, font = G.font1); + Menu.option(menu, menuFontBig, font = G.font2); FOR i := 0 TO Ini.sections.count - 1 DO Menu.option(menu, menuColors + i, Ini.curSectionNum = i) END; @@ -1165,13 +1177,15 @@ BEGIN T.gotoLabel(text, FALSE) |menuNumbers: T.toggleNumbers(text) - |menuFontSize: - IF font = font1 THEN - font := font2 - ELSE - font := font1 - END; - resize + |menuFontSmall: + font := G.font0; + resize + |menuFontMedium: + font := G.font1; + resize + |menuFontBig: + font := G.font2; + resize |menuText: T.setLang(text, Languages.langText) |menuC: @@ -1359,7 +1373,10 @@ VAR BEGIN menu := List.create(NIL); Menu.AddMenuItem(menu, menuNumbers, "line numbers"); - Menu.AddMenuItem(menu, menuFontSize, "x2"); + Menu.delimiter(menu); + Menu.AddMenuItem(menu, menuFontSmall, "small"); + Menu.AddMenuItem(menu, menuFontMedium, "medium"); + Menu.AddMenuItem(menu, menuFontBig, "big"); Menu.delimiter(menu); colors := Ini.sections.first(Ini.tSection); @@ -1763,10 +1780,12 @@ BEGIN goto END; - IF exit THEN - Close - ELSE - repaint + IF ~middle THEN + IF exit THEN + Close + ELSE + repaint + END END END BtnClick; @@ -1921,6 +1940,7 @@ VAR firstClickX, firstClickY, time, blink, i: INTEGER; key, scr: INTEGER; BEGIN + font := G.font1; header := ""; K.GetSystemColors; switch := FALSE; @@ -1932,20 +1952,21 @@ BEGIN leftButton := FALSE; resized := FALSE; K.ScreenSize(winWidth, winHeight); + scrollWidth := winHeight DIV 35; winWidth := (winWidth*80) DIV 100 - (128 + 30); winHeight := winHeight - (128 + 30); winWidth := MAX(winWidth, minWinWidth); winHeight := MAX(winHeight, minWinHeight); cliWidth := winWidth; cliHeight := winHeight; + LEFT := LEFT_PADDING; + RIGHT := scrollWidth - 2; + BOTTOM := SB.height() + scrollWidth - 1; SkinHeight := K.SkinHeight(); canvas := G.CreateCanvas(winWidth - (LEFT + RIGHT + 11 + RIGHT_PADDING), winHeight - (TOP + BOTTOM + 5) - SkinHeight); tabs := Tabs.create(); Tabs.setArea(tabs, LEFT, TOP - Tabs.tabHeight, canvas.width, Tabs.tabHeight); - font1 := G.CreateFont(1, "", {}); - font2 := G.CreateFont(2, "", {}); - font := font1; G.SetFont(canvas, font); T.init(resetTimer); T.setCanvas(canvas); @@ -2050,8 +2071,8 @@ BEGIN CurrentTime := K.GetTickCount(); IF (CurrentTime - CursorTime > blink) & (blink > 0) & timerEnabled & ~K.RolledUp() THEN CursorTime := CurrentTime; - T.toggleCursor; - repaint + T.cursor(text); + drawText END; CASE K.EventTimeout(10) OF diff --git a/programs/develop/cedit/SRC/ChangeLog.ob07 b/programs/develop/cedit/SRC/ChangeLog.ob07 index 02d7c3cd5a..55f46ef701 100644 --- a/programs/develop/cedit/SRC/ChangeLog.ob07 +++ b/programs/develop/cedit/SRC/ChangeLog.ob07 @@ -46,7 +46,7 @@ TYPE tLog* = POINTER TO RECORD Log*, Pointers*: List.tList; - guard: tGuard; + guard, first: tGuard; isLast: BOOLEAN END; @@ -73,16 +73,25 @@ BEGIN END isLastGuard; -PROCEDURE isFirstGuard* (guard: tGuard): BOOLEAN; +PROCEDURE getFirstGuard (): tGuard; VAR - item: List.tItem; + item: List.tItem; BEGIN - ASSERT(guard # NIL); - item := CL.Log.first; - WHILE ~(item IS tGuard) DO - item := item.next - END - RETURN guard = item + item := CL.Log.first; + WHILE ~(item IS tGuard) DO + item := item.next + END + RETURN item(tGuard) +END getFirstGuard; + + +PROCEDURE isFirstGuard* (guard: tGuard): BOOLEAN; +BEGIN + ASSERT(guard # NIL); + IF CL.first = NIL THEN + CL.first := getFirstGuard() + END + RETURN guard = CL.first END isFirstGuard; @@ -285,6 +294,7 @@ VAR BEGIN NEW(newLog); newLog.guard := NIL; + newLog.first := NIL; newLog.isLast := TRUE; newLog.Log := List.create(NIL); newLog.Pointers := List.create(NIL); diff --git a/programs/develop/cedit/SRC/CheckBox.ob07 b/programs/develop/cedit/SRC/CheckBox.ob07 index f7486bc389..84f884cd6a 100644 --- a/programs/develop/cedit/SRC/CheckBox.ob07 +++ b/programs/develop/cedit/SRC/CheckBox.ob07 @@ -82,7 +82,7 @@ BEGIN res.mouse := FALSE; COPY(text, res.text); res.canvas := G.CreateCanvas(fontHeight + padding + LENGTH(res.text)*fontWidth, fontHeight + 1); - G.SetFont(res.canvas, G.CreateFont(1, "", {})); + G.SetFont(res.canvas, G.font1); chkbox := res END create; diff --git a/programs/develop/cedit/SRC/Graph.ob07 b/programs/develop/cedit/SRC/Graph.ob07 index 27d32123e9..1e71740c63 100644 --- a/programs/develop/cedit/SRC/Graph.ob07 +++ b/programs/develop/cedit/SRC/Graph.ob07 @@ -19,7 +19,7 @@ MODULE Graph; -IMPORT SYSTEM, KOSAPI, Lines, Languages; +IMPORT SYSTEM, KOSAPI, Lines, Languages, E := Encodings; CONST @@ -39,6 +39,7 @@ TYPE height*: INTEGER; width*: INTEGER; size: INTEGER; + flags: INTEGER; name*: ARRAY 256 OF WCHAR END; @@ -50,6 +51,10 @@ TYPE mode: INTEGER END; +VAR + + font0*, font1*, font2*: tFont; + PROCEDURE getRGB* (color: INTEGER; VAR r, g, b: BYTE); BEGIN @@ -83,15 +88,26 @@ BEGIN END SetBkColor; -PROCEDURE CreateFont* (height: INTEGER; name: ARRAY OF WCHAR; attr: SET): tFont; +PROCEDURE CreateFont (size: INTEGER; name: ARRAY OF WCHAR; attr: SET): tFont; VAR font: tFont; BEGIN + ASSERT(size IN {0, 1, 2}); NEW(font); - font.size := MAX(MIN(height, 8), 1); - font.width := font.size*8; - font.height := font.size*16; - DEC(font.size); + font.size := size; + IF size = 0 THEN + font.width := 6; + font.height := 9; + font.flags := 08000000H + ELSE + font.width := size*8; + font.height := size*16; + IF size = 1 THEN + font.flags := 28000000H + ELSIF size = 2 THEN + font.flags := 29000000H + END + END; font.name := name RETURN font END CreateFont; @@ -256,24 +272,25 @@ PROCEDURE TextOut* (canvas: tCanvas; x, y: INTEGER; text: INTEGER; n: INTEGER; d CONST WCHAR_SIZE = 2; VAR - color, i, font: INTEGER; + color, i, ch: INTEGER; + font: tFont; c: WCHAR; BEGIN - IF (0 <= y) & (y <= canvas.height - canvas.font.height - 1) THEN + font := canvas.font; + IF (0 <= y) & (y <= canvas.height - font.height - 1) THEN IF x < 0 THEN - i := -(x DIV canvas.font.width); - INC(x, i*canvas.font.width); + i := -(x DIV font.width); + INC(x, i*font.width); DEC(n, i) ELSE i := 0 END; IF n > 0 THEN - n := MAX(MIN(n, (canvas.width - x) DIV canvas.font.width), 0); + n := MAX(MIN(n, (canvas.width - x) DIV font.width), 0); color := canvas.color; canvas.color := canvas.backColor; - FillRect(canvas, x, y, x + n*canvas.font.width, y + canvas.font.height); + FillRect(canvas, x, y, x + n*font.width, y + font.height); canvas.color := color; - font := LSL(28H + canvas.font.size, 24); WHILE n > 0 DO SYSTEM.GET(text + i*WCHAR_SIZE, c); IF ~Lines.isSpace(c) THEN @@ -285,9 +302,17 @@ BEGIN IF c = Lines.NUL THEN c := 0X END; - KOSAPI.sysfunc6(4, x*65536 + y, font + color, SYSTEM.ADR(c), 1, canvas.bitmap - 8) + IF font = font0 THEN + ch := E.UNI[ORD(c), E.CP866]; + IF ch = E.UNDEF THEN + c := "?" + ELSE + c := WCHR(ch) + END + END; + KOSAPI.sysfunc6(4, x*65536 + y, font.flags + color, SYSTEM.ADR(c), 1, canvas.bitmap - 8) END; - INC(x, canvas.font.width); + INC(x, font.width); INC(i); DEC(n) END @@ -322,10 +347,14 @@ END CreateCanvas; PROCEDURE destroy* (VAR canvas: tCanvas); BEGIN IF canvas # NIL THEN - canvas.bitmap := KOSAPI.free(canvas.bitmap); + canvas.bitmap := KOSAPI.free(canvas.bitmap - 8); DISPOSE(canvas) END END destroy; +BEGIN + font0 := CreateFont(0, "", {}); + font1 := CreateFont(1, "", {}); + font2 := CreateFont(2, "", {}); END Graph. \ No newline at end of file diff --git a/programs/develop/cedit/SRC/Icons.ob07 b/programs/develop/cedit/SRC/Icons.ob07 index ee051afdb4..a53a1e42ce 100644 --- a/programs/develop/cedit/SRC/Icons.ob07 +++ b/programs/develop/cedit/SRC/Icons.ob07 @@ -56,7 +56,7 @@ BEGIN END GetInf; -PROCEDURE GetImg* (ptr, size: INTEGER): INTEGER; +PROCEDURE GetImg (ptr, size: INTEGER): INTEGER; VAR image_data, dst, x, type: INTEGER; BEGIN @@ -133,7 +133,7 @@ BEGIN (*ELSE copy(source, icons); copy(source, grayIcons)*) - END; + END END get; diff --git a/programs/develop/cedit/SRC/Lines.ob07 b/programs/develop/cedit/SRC/Lines.ob07 index 2bf203dfee..33d6f325c2 100644 --- a/programs/develop/cedit/SRC/Lines.ob07 +++ b/programs/develop/cedit/SRC/Lines.ob07 @@ -45,6 +45,12 @@ TYPE PTypedPtr = PROCEDURE (p: List.tItem); PUntypedPtr = PROCEDURE (p: INTEGER); + tVector* = POINTER TO RECORD + size, data: INTEGER + END; + + tVectorItem = tLine; + VAR @@ -58,6 +64,57 @@ VAR tabs*: BOOLEAN; +PROCEDURE createVector* (size: INTEGER): tVector; +VAR + res: tVector; +BEGIN + IF size > 0 THEN + NEW(res); + res.size := size; + IF size < 4096 THEN + size := 4096 + END; + res.data := API._NEW(size*SYSTEM.SIZE(tVectorItem)); + IF res.data = 0 THEN + DISPOSE(res) + END + ELSE + res := NIL + END + RETURN res +END createVector; + + +PROCEDURE destroyVector* (VAR vector: tVector); +BEGIN + IF vector # NIL THEN + IF vector.data # 0 THEN + vector.data := API._DISPOSE(vector.data) + END; + DISPOSE(vector) + END +END destroyVector; + + +PROCEDURE setVectorItem* (vector: tVector; idx: INTEGER; item: tVectorItem); +BEGIN + ASSERT(vector # NIL); + ASSERT((0 <= idx) & (idx < vector.size)); + SYSTEM.PUT(vector.data + idx*SYSTEM.SIZE(tVectorItem), item) +END setVectorItem; + + +PROCEDURE getVectorItem* (vector: tVector; idx: INTEGER): tVectorItem; +VAR + res: tVectorItem; +BEGIN + ASSERT(vector # NIL); + ASSERT((0 <= idx) & (idx < vector.size)); + SYSTEM.GET(vector.data + idx*SYSTEM.SIZE(tVectorItem), res) + RETURN res +END getVectorItem; + + PROCEDURE movInt (VAR v: INTEGER; x: INTEGER); BEGIN _movInt(v, x) @@ -173,8 +230,8 @@ BEGIN ASSERT(line.temp); IF size > 0 THEN line.ptr := API._DISPOSE(line.ptr); - size := size*WCHAR_SIZE + 4; - INC(size, (-size) MOD 32); + size := size*WCHAR_SIZE + 4; + INC(size, (-size) MOD 32); line.ptr := API._NEW(size) ELSE destroy(line) diff --git a/programs/develop/cedit/SRC/List.ob07 b/programs/develop/cedit/SRC/List.ob07 index 849215c86c..b2cc1922e0 100644 --- a/programs/develop/cedit/SRC/List.ob07 +++ b/programs/develop/cedit/SRC/List.ob07 @@ -22,7 +22,7 @@ MODULE List; TYPE tItem* = POINTER TO RECORD - prev*, next*: tItem + next*, prev*: tItem END; tList* = POINTER TO RECORD @@ -54,18 +54,27 @@ END create; PROCEDURE getItem* (list: tList; idx: INTEGER): tItem; VAR - item: tItem; + item: tItem; BEGIN - IF idx < 0 THEN - item := NIL - ELSE - item := list.first; - WHILE (idx > 0) & (item # NIL) DO - item := item.next; - DEC(idx) - END - END - RETURN item + IF (idx < 0) OR (idx >= list.count) THEN + item := NIL + ELSE + IF list.count DIV 2 < idx THEN + item := list.last; + idx := list.count - idx - 1; + WHILE idx > 0 DO + item := item.prev; + DEC(idx) + END + ELSE + item := list.first; + WHILE idx > 0 DO + item := item.next; + DEC(idx) + END + END + END + RETURN item END getItem; diff --git a/programs/develop/cedit/SRC/Menu.ob07 b/programs/develop/cedit/SRC/Menu.ob07 index 1b72a1f491..1ce3c3a911 100644 --- a/programs/develop/cedit/SRC/Menu.ob07 +++ b/programs/develop/cedit/SRC/Menu.ob07 @@ -641,7 +641,7 @@ BEGIN END; m.width := maxLength*fontWidth + LEFT + RIGHT; m.height := items.count*fontHeight - 2; - m.font := G.CreateFont(1, "", {}); + m.font := G.font1; m.canvas := G.CreateCanvas(m.width + 1, m.height + 1); G.SetFont(m.canvas, m.font); RETURN m diff --git a/programs/develop/cedit/SRC/StatusBar.ob07 b/programs/develop/cedit/SRC/StatusBar.ob07 index efbba64b47..b2f52478db 100644 --- a/programs/develop/cedit/SRC/StatusBar.ob07 +++ b/programs/develop/cedit/SRC/StatusBar.ob07 @@ -76,12 +76,17 @@ BEGIN END setEnc; +PROCEDURE height* (): INTEGER; + RETURN font.height + 3 +END height; + + PROCEDURE setWidth* (width: INTEGER); BEGIN ASSERT(width > 0); - IF (SB.canvas = NIL) OR (SB.canvas.width # width) THEN + IF (SB.canvas = NIL) OR (SB.canvas.width # width) OR (SB.canvas.height # height()) THEN G.destroy(SB.canvas); - SB.canvas := G.CreateCanvas(width, 19); + SB.canvas := G.CreateCanvas(width, height()); G.SetFont(SB.canvas, font) END END setWidth; @@ -100,13 +105,22 @@ BEGIN G.SetTextColor(SB.canvas, K.colors.work_text); G.clear(SB.canvas); TextOut(1, SB.pos); - TextOut(16*K.fontWidth, SB.sel); - TextOut(SB.canvas.width - LENGTH(SB.enc)*K.fontWidth - 1, SB.enc); + TextOut(16*font.width, SB.sel); + TextOut(SB.canvas.width - LENGTH(SB.enc)*font.width - 1, SB.enc); G.DrawCanvas(SB.canvas, left, top) END draw; +PROCEDURE SetFont* (_font: G.tFont); +BEGIN + font := _font; + IF SB.canvas # NIL THEN + setWidth(SB.canvas.width) + END +END SetFont; + + BEGIN SB.canvas := NIL; - font := G.CreateFont(1, "", {}) + font := G.font1 END StatusBar. \ No newline at end of file diff --git a/programs/develop/cedit/SRC/Text.ob07 b/programs/develop/cedit/SRC/Text.ob07 index 17f1dae785..7eed922539 100644 --- a/programs/develop/cedit/SRC/Text.ob07 +++ b/programs/develop/cedit/SRC/Text.ob07 @@ -65,7 +65,8 @@ TYPE cursor, select, select2: pPoint; scroll: tPoint; CurX: INTEGER; - modified*: BOOLEAN; + smallChange: INTEGER; + modified*, smallMove: BOOLEAN; edition*: tGuard; comments, numbers*, guard, search, cs, whole: BOOLEAN; @@ -76,6 +77,7 @@ TYPE foundList: List.tList; foundSel: INTEGER; searchText: tString; + LinesVector: Lines.tVector; chLog*: ChangeLog.tLog; maxLength*: INTEGER; fileName*: RW.tFileName @@ -155,12 +157,6 @@ BEGIN END toggleNumbers; -PROCEDURE toggleCursor*; -BEGIN - drawCursor := ~drawCursor -END toggleCursor; - - PROCEDURE showCursor*; BEGIN drawCursor := TRUE @@ -223,25 +219,63 @@ BEGIN END ProcessComments; +PROCEDURE getLine2 (text: tText; n: INTEGER): tLine; +VAR + item: tLine; +BEGIN + IF (0 <= n) & (n < text.count) THEN + item := Lines.getVectorItem(text.LinesVector, n) + ELSE + item := NIL + END + RETURN item +END getLine2; + + PROCEDURE Comments (text: tText); VAR - line: tLine; - i: INTEGER; + line: tLine; + i, k, cout: INTEGER; BEGIN - line := text.first(tLine); - line.cin := 0; - line.cout := 0; - i := 0; - ProcessComments(line, line.cout, i, -1, line.length - 1, text.lang); - NextLine(line); - WHILE line # NIL DO - line.cin := line.prev(tLine).cout; - line.cout := line.cin; - i := 0; - ProcessComments(line, line.cout, i, -1, line.length - 1, text.lang); - NextLine(line) - END; - text.comments := FALSE + IF text.smallChange = 1 THEN + line := getLine2(text, text.cursor.Y); + IF line.prev # NIL THEN + line.cin := line.prev(tLine).cout + ELSE + line.cin := 0 + END; + cout := line.cout; + line.cout := line.cin; + i := 0; + ProcessComments(line, line.cout, i, -1, line.length - 1, text.lang); + IF line.cout # cout THEN + text.smallChange := 0; + Comments(text) + END + ELSE + Lines.destroyVector(text.LinesVector); + text.LinesVector := Lines.createVector(text.count); + k := 0; + line := text.first(tLine); + Lines.setVectorItem(text.LinesVector, k, line); + INC(k); + line.cin := 0; + line.cout := 0; + i := 0; + ProcessComments(line, line.cout, i, -1, line.length - 1, text.lang); + NextLine(line); + WHILE line # NIL DO + Lines.setVectorItem(text.LinesVector, k, line); + INC(k); + line.cin := line.prev(tLine).cout; + line.cout := line.cin; + i := 0; + ProcessComments(line, line.cout, i, -1, line.length - 1, text.lang); + NextLine(line) + END + END; + text.smallChange := 0; + text.comments := FALSE END Comments; @@ -931,10 +965,10 @@ END resetSelect; PROCEDURE getLine (text: tText; n: INTEGER): tLine; VAR - item: List.tItem; + item: List.tItem; BEGIN - item := List.getItem(text, n); - RETURN item(tLine) + item := List.getItem(text, n) + RETURN item(tLine) END getLine; @@ -1110,6 +1144,7 @@ BEGIN resetSelect(text); curLine := text.curLine; IF text.cursor.X > 0 THEN + INC(text.smallChange); i := text.cursor.X; n := leadingSpaces(curLine); modify(text); @@ -1236,7 +1271,7 @@ VAR BEGIN getSelect(text, selBeg, selEnd); i := selEnd.Y - selBeg.Y + 1; - line := getLine(text, selBeg.Y); + line := getLine2(text, selBeg.Y); modified := incr; WHILE i > 0 DO IF incr THEN @@ -1247,11 +1282,12 @@ BEGIN NextLine(line); DEC(i) END; - line := getLine(text, selEnd.Y); + line := getLine2(text, selEnd.Y); text.select^ := selBeg; text.select.X := 0; SetPos(text, line.length, selEnd.Y); IF modified THEN + INC(text.smallChange); modify(text) END END Indent; @@ -1293,6 +1329,9 @@ VAR BEGIN IF (code >= ORD(SPACE)) & (code # 127) THEN + IF ~selected(text) THEN + INC(text.smallChange) + END; delSelect(text); curLine := text.curLine; Lines.insert(curLine, text.cursor.X, WCHR(code)); @@ -1309,6 +1348,7 @@ BEGIN IF selected(text) THEN Indent(text, TRUE) ELSE + INC(text.smallChange); tab(text) END ELSIF code = 13 THEN @@ -1461,8 +1501,8 @@ VAR BEGIN IF selected(text) THEN getSelect(text, selBeg, selEnd); - first := getLine(text, selBeg.Y); - last := getLine(text, selEnd.Y); + first := getLine2(text, selBeg.Y); + last := getLine2(text, selEnd.Y); lines := selEnd.Y - selBeg.Y + 1; IF lines > 1 THEN @@ -1505,7 +1545,7 @@ VAR BEGIN getSelect(text, selBeg, selEnd); - first := getLine(text, selBeg.Y); + first := getLine2(text, selBeg.Y); line := first; n := selEnd.Y - selBeg.Y; @@ -1697,6 +1737,7 @@ BEGIN END; IF Lines.chCase(line, i + 1, text.cursor.X - 1, upper) THEN + INC(text.smallChange); modify(text) END END changeCase; @@ -1712,7 +1753,7 @@ BEGIN modified := FALSE; IF selected(text) THEN getSelect(text, selBeg, selEnd); - first := getLine(text, selBeg.Y); + first := getLine2(text, selBeg.Y); line := first; cnt := selEnd.Y - selBeg.Y; IF cnt = 0 THEN @@ -1737,6 +1778,7 @@ BEGIN END END; IF modified THEN + INC(text.smallChange); modify(text) END END chCase; @@ -1757,6 +1799,7 @@ END UpDown; PROCEDURE delLine* (text: tText); BEGIN + text.smallChange := 2; resetSelect(text); IF text.curLine.length > 0 THEN Lines.delCharN(text.curLine, 0, text.curLine.length) @@ -1905,6 +1948,9 @@ BEGIN str := "" END END; + IF text.searchText # str THEN + text.smallMove := FALSE + END; IF search(text, str, Lang.isCS(text.lang), TRUE) THEN END END wordSel; @@ -1934,12 +1980,16 @@ END getWordPos; PROCEDURE key* (text: tText; code: INTEGER; shift, ctrl: BOOLEAN); VAR n, wPos: INTEGER; + scrX, scrY: INTEGER; + resSel: BOOLEAN; BEGIN + resSel := FALSE; IF shift THEN setSelect(text) ELSE IF (33 <= code) & (code <= 40) THEN IF ~(((code = 38) OR (code = 40)) & ctrl) THEN + resSel := selected(text); resetSelect(text) END END @@ -1980,6 +2030,8 @@ BEGIN IF (text.cursor.X = 0) & (text.curLine.prev # NIL) THEN SetPos(text, text.curLine.prev(tLine).length, text.cursor.Y - 1) ELSE + scrX := text.scroll.X; + scrY := text.scroll.Y; IF ctrl THEN wPos := 0; REPEAT @@ -1989,7 +2041,8 @@ BEGIN move(text, n - text.cursor.X) ELSE move(text, -1) - END + END; + text.smallMove := (scrX = text.scroll.X) & (scrY = text.scroll.Y) & ~resSel END |38: IF ctrl THEN @@ -2001,11 +2054,14 @@ BEGIN IF (text.cursor.X = text.curLine.length) & (text.curLine.next # NIL) THEN SetPos(text, 0, text.cursor.Y + 1) ELSE + scrX := text.scroll.X; + scrY := text.scroll.Y; IF ctrl THEN move(text, getWordPos(text.curLine, text.cursor.X) - text.cursor.X) ELSE move(text, 1) - END + END; + text.smallMove := (scrX = text.scroll.X) & (scrY = text.scroll.Y) & ~resSel END |40: IF ctrl THEN @@ -2017,6 +2073,9 @@ BEGIN IF ctrl THEN delLine(text) ELSE + IF ~selected(text) & (text.cursor.X < text.curLine.length) THEN + INC(text.smallChange) + END; delete(text); ShowCursor END @@ -2103,21 +2162,23 @@ BEGIN END selectWord; -PROCEDURE cursor (text: tText); +PROCEDURE cursor* (text: tText); VAR x, y1, y2, scrollX, scrollY: INTEGER; cursor: pPoint; BEGIN - cursor := text.cursor; - scrollX := text.scroll.X; - scrollY := text.scroll.Y; - IF ~((scrollY > cursor.Y) OR (scrollY + textsize.Y <= cursor.Y) OR - (scrollX > cursor.X) OR (scrollX + textsize.X <= cursor.X)) THEN - x := (cursor.X - scrollX)*charWidth + padding.left; - y1 := (cursor.Y - scrollY)*charHeight + padding.top + (inter DIV 2 + 1); - y2 := y1 + charHeight - (inter + 2); - G.notVLine(canvas, x, y1, y2); - G.notVLine(canvas, x - 1, y1, y2) + IF drawCursor THEN + cursor := text.cursor; + scrollX := text.scroll.X; + scrollY := text.scroll.Y; + IF ~((scrollY > cursor.Y) OR (scrollY + textsize.Y <= cursor.Y) OR + (scrollX > cursor.X) OR (scrollX + textsize.X <= cursor.X)) THEN + x := (cursor.X - scrollX)*charWidth + padding.left; + y1 := (cursor.Y - scrollY)*charHeight + padding.top + (inter DIV 2 + 1); + y2 := y1 + charHeight - (inter + 2); + G.notVLine(canvas, x, y1, y2); + G.notVLine(canvas, x - 1, y1, y2) + END END END cursor; @@ -2168,7 +2229,7 @@ END setPadding; PROCEDURE draw* (text: tText); VAR - y, n, Len, cnt, i, x: INTEGER; + y, n, cnt, i, x: INTEGER; line, firstLine, lastLine: tLine; selBeg, selEnd: tPoint; s: ARRAY 12 OF WCHAR; @@ -2176,10 +2237,10 @@ VAR p: Search.tPos; guard: tGuard; BEGIN - IF text.search & search(text, text.searchText, text.cs, text.whole) THEN END; - IF (text.lang # Lang.langText) & text.comments THEN + IF text.comments THEN Comments(text) END; + IF text.search & search(text, text.searchText, text.cs, text.whole) THEN END; IF text.guard THEN NEW(guard); List.append(ChangeLog.CL.Log, guard); @@ -2197,7 +2258,9 @@ BEGIN guard.selected := text.select = text.select2; G.SetColor(canvas, colors.back); - G.clear(canvas); + IF ~text.smallMove THEN + G.clear(canvas) + END; wNum := charWidth; IF text.numbers THEN numWidth := U.lg10(text.count) + 2; @@ -2209,9 +2272,19 @@ BEGIN getSelect(text, selBeg, selEnd); y := padding.top + inter DIV 2; n := text.scroll.Y; - line := getLine(text, n); - firstLine := line; - cnt := 0; + firstLine := getLine2(text, n); + IF text.smallMove THEN + line := text.curLine; + cnt := textsize.Y - 1; + y := y + charHeight*(text.cursor.Y - text.scroll.Y); + G.SetColor(canvas, colors.back); + G.FillRect(canvas, padding.left - 2, y - inter DIV 2, size.X - 1, y - inter DIV 2 + charHeight); + n := text.cursor.Y + ELSE + line := firstLine; + cnt := 0 + END; + WHILE (line # NIL) & (cnt < textsize.Y) DO backColor := colors.back; IF (line = text.curLine) & ~selected(text) THEN @@ -2220,26 +2293,28 @@ BEGIN backColor := colors.curline END; SetColor(colors.text, backColor); - Len := MAX(line.length - text.scroll.X, 0); - G.TextOut(canvas, padding.left, y, Lines.getPChar(line, text.scroll.X), MIN(Len, textsize.X + 1), colors.delim); - IF text.lang # Lang.langText THEN - parse(text, line, y, backColor, text.lang) - END; - mark(line, y - inter DIV 2); - IF (selBeg.Y < n) & (n < selEnd.Y) THEN - drawSelect(text, line, 0, line.length, y) - ELSIF (selBeg.Y = n) & (selEnd.Y = n) & (selBeg.X # selEnd.X) THEN + IF (selBeg.Y < n) & (n < selEnd.Y) THEN + drawSelect(text, line, 0, line.length, y) + ELSE + G.TextOut(canvas, padding.left, y, Lines.getPChar(line, text.scroll.X), MIN(MAX(line.length - text.scroll.X, 0), textsize.X + 1), colors.delim); + IF text.lang # Lang.langText THEN + parse(text, line, y, backColor, text.lang) + END + END; + IF (selBeg.Y = n) & (selEnd.Y = n) & (selBeg.X # selEnd.X) THEN drawSelect(text, line, selBeg.X, selEnd.X, y) ELSIF (selBeg.Y = n) & (selEnd.Y # n) THEN drawSelect(text, line, selBeg.X, line.length, y) ELSIF (selBeg.Y # n) & (selEnd.Y = n) THEN drawSelect(text, line, 0, selEnd.X, y) END; + mark(line, y - inter DIV 2); NextLine(line); INC(y, charHeight); INC(n); INC(cnt) END; + G.SetColor(canvas, colors.numback); G.FillRect(canvas, 0, 0, padding.left - pad_left (*+ 1*), size.Y - 1); line := firstLine; @@ -2267,17 +2342,18 @@ BEGIN END; IF text.searchText # "" THEN - cnt := 0; - line := firstLine; - lastLine := line; - WHILE (line # NIL) & (cnt < textsize.Y) DO - lastLine := line; - NextLine(line); - INC(cnt) + IF text.smallMove THEN + firstLine := text.curLine; + lastLine := firstLine + ELSE + lastLine := getLine2(text, text.scroll.Y + textsize.Y - 1) END; p := text.foundList.first(Search.tPos); WHILE p # NIL DO - y := padding.top + inter DIV 2; + y := padding.top + inter DIV 2; + IF text.smallMove THEN + y := y + charHeight*(text.cursor.Y - text.scroll.Y) + END; IF (firstLine.pos <= p.pos) & (p.pos <= lastLine.pos + lastLine.length) THEN line := firstLine; WHILE (line.pos <= p.pos) & (line # lastLine) DO @@ -2296,12 +2372,14 @@ BEGIN END; INC(x); DEC(n) - END; + END END; p := p.next(Search.tPos) END END; + text.smallMove := FALSE; + IF text.foundSel > 0 THEN x := (text.cursor.X - text.scroll.X)*charWidth + padding.left; y := (text.cursor.Y - text.scroll.Y)*charHeight + padding.top + inter DIV 2; @@ -2314,10 +2392,7 @@ BEGIN DEC(n) END END; - - IF drawCursor THEN - cursor(text) - END + cursor(text) END draw; @@ -2346,6 +2421,7 @@ BEGIN setPadding(padding.left, padding.top); text.curLine := NIL; text.modified := FALSE; + text.smallMove := FALSE; text.comments := TRUE; text.search := TRUE; text.cs := FALSE; @@ -2357,7 +2433,9 @@ BEGIN text.searchText := ""; text.foundSel := 0; text.CurX := -1; + text.smallChange := 0; text.lang := Lang.langText; + text.LinesVector := NIL; Lang.setCurLang(Lang.langText); setName(text, fileName); ASSERT(text = List.create(text)) @@ -2408,6 +2486,7 @@ PROCEDURE destroy* (VAR text: tText); BEGIN IF search(text, "", FALSE, FALSE) THEN END; ChangeLog.destroy(text.chLog); + Lines.destroyVector(text.LinesVector); DISPOSE(text.foundList); DISPOSE(text.cursor); DISPOSE(text.select2); @@ -2450,12 +2529,10 @@ BEGIN RW.destroy(file); text.curLine := text.first(tLine); SetPos(text, 0, 0); - resetSelect(text) + resetSelect(text); + Comments(text) ELSE errno := 1 - END; - IF (text # NIL) & (text.lang # Lang.langText) THEN - Comments(text) END RETURN text END open;