Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 9179 → Rev 9180

/programs/develop/cedit/CEDIT
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/programs/develop/cedit/SRC/CEdit.ob07
28,7 → 28,7
RW, Ini, box_lib, Icons, Tabs, Timer;
 
CONST
header = "CEdit (03-sep-2021)";
header = "CEdit (06-sep-2021)";
 
ShellFilter = "";
EditFilter = "SH|ASM|TXT|INC|OB07|C|CPP|H|PAS|PP|LUA|INI|JSON";
62,10 → 62,11
btnEdit = 71;
btnMenuSearch = 72;
btnEncoding = 73;
btnView = 74;
btnSyntax = 75;
btnProgram = 76;
btnTools = 77;
btnEOL = 74;
btnView = 75;
btnSyntax = 76;
btnProgram = 77;
btnTools = 78;
 
MainMenuHeight = fontHeight + 7;
 
91,7 → 92,8
menuEditX = menuFileX + 4*fontWidth + 2 + 7;
menuSearchX = menuEditX + 4*fontWidth + 2 + 7;
menuEncodingX = menuSearchX + 6*fontWidth + 2 + 7;
menuViewX = menuEncodingX + 8*fontWidth + 2 + 7;
menuEOLX = menuEncodingX + 8*fontWidth + 2 + 7;
menuViewX = menuEOLX + 3*fontWidth + 2 + 7;
menuSyntaxX = menuViewX + 4*fontWidth + 2 + 7;
menuProgramX = menuSyntaxX + 6*fontWidth + 2 + 7;
menuToolsX = menuProgramX + 7*fontWidth + 2 + 7;
169,6 → 171,10
menuNextBookmark = 132;
menuPrevBookmark = 133;
 
menuLF = 140;
menuCRLF = 141;
menuCR = 142;
 
maxTexts = 32;
scrollDelay = 40;
 
203,7 → 209,7
mainTID, delay: INTEGER;
 
context, menuFile, menuEdit, menuSearch, menuEncoding,
menuView, menuSyntax, menuProgram, menuTools,
menuEOL, menuView, menuSyntax, menuProgram, menuTools,
subCurLine, subIndent, subCase, subBookmark: Menu.tMenu;
 
menuActive: BOOLEAN;
414,11 → 420,16
 
PROCEDURE DrawState (text: T.tText; width, height: INTEGER);
VAR
y: INTEGER;
y, w, x: INTEGER;
BEGIN
y := (btnHeight - fontHeight) DIV 2 + btnTop;
K.DrawRect(width - 16*fontWidth, y, 16*fontWidth, fontHeight, K.winColor);
K.DrawText(width - LENGTH(E.names[text.enc])*fontWidth, y, K.textColor, E.names[text.enc]);
K.DrawRect(width - 32*fontWidth, y, 32*fontWidth, fontHeight, K.winColor);
w := LENGTH(E.names[text.enc])*fontWidth;
x := width - w;
K.DrawText(x, y, K.textColor, E.names[text.enc]);
w := LENGTH(RW.eolNames[text.eol])*fontWidth;
DEC(x, w + 10);
K.DrawText(x, y, K.textColor, RW.eolNames[text.eol]);
y := height - (BOTTOM - scrollWidth) + (BOTTOM - scrollWidth - 16) DIV 2;
K.DrawRect(LEFT + 16*fontWidth, TOP + canvas.height + scrollWidth - 1, width - LEFT - 24*fontWidth, BOTTOM - scrollWidth + 1, K.winColor);
K.DrawText866(LEFT + 16*fontWidth, y, K.textColor, text.fileName);
606,6 → 617,7
drawMainMenu(menuEdit, menuEditX, btnEdit, "edit");
drawMainMenu(menuSearch, menuSearchX, btnMenuSearch, "search");
drawMainMenu(menuEncoding, menuEncodingX, btnEncoding, "encoding");
drawMainMenu(menuEOL, menuEOLX, btnEOL, "eol");
drawMainMenu(menuView, menuViewX, btnView, "view");
drawMainMenu(menuSyntax, menuSyntaxX, btnSyntax, "syntax");
drawMainMenu(menuProgram, menuProgramX, btnProgram, "program");
749,7 → 761,7
END;
OpenFile(fileName, EditFilter);
IF fileName # "" THEN
IF T.save(text, fileName, text.enc, RW.EOL_CRLF) THEN
IF T.save(text, fileName) THEN
T.setName(text, fileName);
U.getFileName(fileName, name, U.SLASH);
Tabs.rename(tabs, curText, name)
785,7 → 797,7
BEGIN
IF text.modified THEN
IF text.fileName # "" THEN
IF ~T.save(text, text.fileName, text.enc, RW.EOL_CRLF) THEN
IF ~T.save(text, text.fileName) THEN
saveError(text.fileName)
END
ELSE
1089,6 → 1101,7
Menu.close(menuEdit);
Menu.close(menuSearch);
Menu.close(menuEncoding);
Menu.close(menuEOL);
Menu.close(menuView);
Menu.close(menuSyntax);
Menu.close(menuProgram);
1201,6 → 1214,11
Menu.setCheck(menu, menuCP866, ORD(text.enc = E.CP866)*2);
Menu.setCheck(menu, menuWin1251, ORD(text.enc = E.W1251)*2);
INC(x, menuEncodingX)
ELSIF menu = menuEOL THEN
Menu.setCheck(menu, menuCRLF, ORD(text.eol = RW.EOL_CRLF)*2);
Menu.setCheck(menu, menuLF, ORD(text.eol = RW.EOL_LF)*2);
Menu.setCheck(menu, menuCR, ORD(text.eol = RW.EOL_CR)*2);
INC(x, menuEOLX)
ELSIF menu = menuView THEN
Menu.setCheck(menu, menuNumbers, ORD(text.numbers));
Menu.setCheck(menu, menuFontSize, ORD(font = font2));
1400,6 → 1418,12
text.enc := E.CP866
|menuWin1251:
text.enc := E.W1251
|menuLF:
text.eol := RW.EOL_LF
|menuCRLF:
text.eol := RW.EOL_CRLF
|menuCR:
text.eol := RW.EOL_CR
|menuPipet:
K.Run("/rd/1/develop/pipet", "")
|menuBoard:
1565,6 → 1589,18
END CreateMenuEncoding;
 
 
PROCEDURE CreateMenuEOL (): Menu.tMenu;
VAR
menu: List.tList;
BEGIN
menu := List.create(NIL);
Menu.AddMenuItem(menu, menuCRLF, RW.eolNames[RW.EOL_CRLF]);
Menu.AddMenuItem(menu, menuLF, RW.eolNames[RW.EOL_LF]);
Menu.AddMenuItem(menu, menuCR, RW.eolNames[RW.EOL_CR]);
RETURN Menu.create(menu, MenuItemClick, MenuKeyDown)
END CreateMenuEOL;
 
 
PROCEDURE CreateMenuView (): Menu.tMenu;
VAR
menu: List.tList;
1851,6 → 1887,8
ShowMenu(menuSearch)
|btnEncoding:
ShowMenu(menuEncoding)
|btnEOL:
ShowMenu(menuEOL)
|btnView:
ShowMenu(menuView)
|btnSyntax:
2100,6 → 2138,7
T.init(resetTimer);
T.setCanvas(canvas);
U.ptr2str(K.GetCommandLine(), fileName);
 
context := CreateContextMenu();
menuFile := CreateMenuFile();
subCurLine := CreateMenuCurLine();
2113,6 → 2152,7
menuSearch := CreateMenuSearch();
subBookmark.parent := menuSearch;
menuEncoding := CreateMenuEncoding();
menuEOL := CreateMenuEOL();
menuView := CreateMenuView();
menuSyntax := CreateMenuSyntax();
menuProgram := CreateMenuProgram();
/programs/develop/cedit/SRC/Menu.ob07
124,7 → 124,7
canvas := m.canvas;
G.SetColor(canvas, backColor);
G.clear(canvas);
G.SetColor(canvas, ORD((-BITS(backColor))*{0..23}) );
G.SetColor(canvas, foreColor);
G.Rect(canvas, 0, 0, m.width, m.height);
y := TOP;
i := 0;
172,7 → 172,7
 
INC(y, fontHeight);
IF item.delim THEN
G.SetColor(canvas, ORD((-BITS(backColor))*{0..23}));
G.SetColor(canvas, foreColor);
G.HLine(canvas, y - 2, 1, m.width - 1)
END;
INC(i);
/programs/develop/cedit/SRC/RW.ob07
33,7 → 33,7
 
NAME_LEN = 1024;
 
EOL_LF* = 0; EOL_CRLF* = 1; EOL_CR* = 2;
EOL_CRLF* = 0; EOL_LF* = 1; EOL_CR* = 2;
 
 
TYPE
45,7 → 45,6
tInput* = POINTER TO RECORD
buffer: INTEGER;
pos, cnt: INTEGER;
enc: INTEGER;
CR: BOOLEAN;
clipbrd: BOOLEAN;
getChar: PROCEDURE (file: tInput): INTEGER
63,6 → 62,7
VAR
 
eol*: ARRAY 3 OF tEOL;
eolNames*: ARRAY 3, 16 OF WCHAR;
 
 
PROCEDURE getByte (file: tInput): BYTE;
296,8 → 296,36
END detectEncoding;
 
 
PROCEDURE load* (name: tFileName; VAR enc: INTEGER): tInput;
PROCEDURE detectEOL (text: tInput): INTEGER;
VAR
pos, cnt, c, res: INTEGER;
BEGIN
res := -1;
pos := text.pos;
cnt := text.cnt;
WHILE (text.cnt > 0) & (res = -1) DO
c := text.getChar(text);
IF c = 10 THEN
res := EOL_LF
ELSIF c = 13 THEN
IF text.getChar(text) = 10 THEN
res := EOL_CRLF
ELSE
res := EOL_CR
END
END
END;
text.cnt := cnt;
text.pos := pos;
IF res = -1 THEN
res := EOL_CRLF
END
RETURN res
END detectEOL;
 
 
PROCEDURE load* (name: tFileName; VAR enc, eol: INTEGER): tInput;
VAR
res: tInput;
fsize: INTEGER;
BEGIN
325,7 → 353,7
ELSIF enc = E.W1251 THEN
res.getChar := getCharW1251
END;
res.enc := enc
eol := detectEOL(res)
END
RETURN res
END load;
340,7 → 368,6
res.CR := FALSE;
res.clipbrd := TRUE;
res.getChar := NIL;
res.enc := E.CP866;
res.getChar := getCharCP866;
res.buffer := CB.get(res.cnt);
IF res.buffer = 0 THEN
524,7 → 551,10
 
 
BEGIN
eol[EOL_CRLF] := CR + LF;
eol[EOL_LF] := LF;
eol[EOL_CRLF] := CR + LF;
eol[EOL_CR] := CR
eol[EOL_CR] := CR;
eolNames[EOL_CRLF] := "CRLF";
eolNames[EOL_LF] := "LF";
eolNames[EOL_CR] := "CR"
END RW.
/programs/develop/cedit/SRC/Text.ob07
75,6 → 75,7
fileName*: RW.tFileName;
lang*: INTEGER;
enc*: INTEGER;
eol*: INTEGER;
table: Search.IdxTable;
foundList: List.tList;
idxData: Search.tBuffer;
1337,7 → 1338,7
END scroll;
 
 
PROCEDURE save* (text: tText; name: RW.tFileName; enc, nl: INTEGER): BOOLEAN;
PROCEDURE save* (text: tText; name: RW.tFileName): BOOLEAN;
CONST
tempFile = "/tmp0/1/cedit~.tmp";
VAR
1348,7 → 1349,7
BEGIN
ChangeLog.setGuard(text.edition);
res := TRUE;
file := RW.create(tempFile, enc, nl);
file := RW.create(tempFile, text.enc, text.eol);
IF file # NIL THEN
ChangeLog.delSaved;
line := text.first(tLine);
2304,34 → 2305,30
VAR
text: tText;
file: RW.tInput;
n, enc: INTEGER;
eol: BOOLEAN;
n, enc, eol: INTEGER;
_eol: BOOLEAN;
line: tLine;
BEGIN
errno := 0;
text := NIL;
file := RW.load(name, enc);
file := RW.load(name, enc, eol);
IF file # NIL THEN
text := create(name);
text.enc := enc;
text.eol := eol;
line := Lines.create(FALSE);
List._append(text, line);
REPEAT
n := RW.getString(file, line, Lines.tabs, _eol);
IF _eol THEN
line := Lines.create(FALSE);
n := RW.getString(file, line, Lines.tabs, eol);
IF n >= 0 THEN
List._append(text, line)
ELSE
Lines.destroy(line)
END
UNTIL n < 0;
UNTIL ~_eol;
RW.destroy(file);
IF n = -1 THEN
IF text.count = 0 THEN
List._append(text, Lines.create(FALSE))
END;
text.curLine := text.first(tLine);
SetPos(text, 0, 0);
resetSelect(text)
END
ELSE
errno := 1
END;
2477,6 → 2474,7
List._append(text, Lines.create(FALSE));
text.curLine := text.first(tLine);
text.enc := E.CP866;
text.eol := RW.EOL_CRLF;
SetPos(text, 0, 0);
resetSelect(text)
RETURN text
/programs/develop/cedit/SRC/Timer.ob07
61,13 → 61,11
IF ~paused THEN
DEC(cnt, step);
IF cnt <= 0 THEN
cnt := time;
IF time > 0 THEN
K.SendIPC(mainTID, ID)
K.SendIPC(mainTID, ID);
cnt := time
END
END
END
END
END main;
 
 
/programs/develop/cedit/SRC/scroll.ob07
90,7 → 90,7
height := scroll.height;
canvas := scroll.canvas;
G.SetColor(canvas, K.winColor);
G.FillRect(canvas, 0, 0, width - 1, height - 1);
G.clear(canvas);
G.SetColor(canvas, K.borderColor);
G.Rect(canvas, 0, 0, width - 1, height - 1);
IF scroll.vertical THEN