Rev 9060 | Rev 9174 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 9060 | Rev 9073 | ||
---|---|---|---|
Line 25... | Line 25... | ||
25 | U := Utils, |
25 | U := Utils, |
26 | RW, Search, |
26 | RW, Search, |
27 | E := Encodings, |
27 | E := Encodings, |
28 | CB := Clipboard, |
28 | CB := Clipboard, |
29 | K := KolibriOS, |
29 | K := KolibriOS, |
30 | ChangeLog, |
30 | ChangeLog, File, |
31 | Lang := Languages; |
31 | Lang := Languages; |
Line 32... | Line 32... | ||
32 | 32 | ||
Line 33... | Line 33... | ||
33 | 33 | ||
34 | CONST |
34 | CONST |
35 | 35 | ||
Line 36... | Line -... | ||
36 | SPACE = 20X; |
- | |
37 | TAB = RW.TAB_SIZE; |
- | |
38 | lenEOL = CB.lenEOL; |
36 | SPACE = 20X; |
39 | 37 | TAB = RW.TAB_SIZE; |
|
40 | SHIFT* = 0; CTRL* = 1; |
38 | lenEOL = CB.lenEOL; |
41 | 39 | ||
Line 1185... | Line 1183... | ||
1185 | text.scroll.Y := MIN(MAX(text.scroll.Y, 0), text.count - 1) |
1183 | text.scroll.Y := MIN(MAX(text.scroll.Y, 0), text.count - 1) |
1186 | END scroll; |
1184 | END scroll; |
Line 1187... | Line 1185... | ||
1187 | 1185 | ||
- | 1186 | ||
- | 1187 | PROCEDURE save* (text: tText; name: RW.tFileName; enc, nl: INTEGER): BOOLEAN; |
|
1188 | 1188 | CONST |
|
1189 | PROCEDURE save* (text: tText; name: RW.tFileName; enc, nl: INTEGER): BOOLEAN; |
1189 | tempFile = "/tmp0/1/cedit~.tmp"; |
1190 | VAR |
1190 | VAR |
1191 | line: tLine; |
1191 | line: tLine; |
1192 | file: RW.tOutput; |
1192 | file: RW.tOutput; |
1193 | res: BOOLEAN; |
- | |
1194 | Len: INTEGER; |
1193 | res: BOOLEAN; |
- | 1194 | Len: INTEGER; |
|
1195 | (* item: List.tItem;*) |
1195 | BEGIN |
1196 | BEGIN |
1196 | ChangeLog.setGuard(text.edition); |
1197 | res := TRUE; |
1197 | res := TRUE; |
1198 | file := RW.create(name, enc, nl); |
- | |
1199 | IF file # NIL THEN |
- | |
1200 | (* IF ChangeLog.Log.last IS ChangeLog.tGuard THEN |
1198 | file := RW.create(tempFile, enc, nl); |
1201 | item := List.pop(ChangeLog.Log); |
- | |
1202 | DISPOSE(item) |
1199 | IF file # NIL THEN |
1203 | END;*) |
1200 | ChangeLog.delSaved; |
1204 | line := text.first(tLine); |
1201 | line := text.first(tLine); |
1205 | WHILE (line # NIL) & res DO |
1202 | WHILE (line # NIL) & res DO |
1206 | Len := Lines.trimLength(line); |
1203 | Len := Lines.trimLength(line); |
Line 1217... | Line 1214... | ||
1217 | END |
1214 | END |
1218 | END |
1215 | END |
1219 | END; |
1216 | END; |
1220 | IF ~RW.close(file) THEN |
1217 | IF ~RW.close(file) THEN |
1221 | res := FALSE |
1218 | res := FALSE |
1222 | END; |
- | |
1223 | IF res THEN |
- | |
1224 | text.modified := FALSE |
- | |
1225 | END |
1219 | END |
1226 | ELSE |
1220 | ELSE |
1227 | res := FALSE |
1221 | res := FALSE |
1228 | END; |
1222 | END; |
- | 1223 | IF res THEN |
|
- | 1224 | res := File.Copy(tempFile, name); |
|
- | 1225 | IF res THEN |
|
1229 | text.guard := TRUE |
1226 | text.modified := FALSE; |
- | 1227 | ChangeLog.save(text.edition); |
|
- | 1228 | IF File.Delete(tempFile) THEN END |
|
- | 1229 | END |
|
- | 1230 | END; |
|
- | 1231 | IF ~res THEN |
|
- | 1232 | ChangeLog.delCurSaved |
|
- | 1233 | END |
|
1230 | RETURN res |
1234 | RETURN res |
1231 | END save; |
1235 | END save; |
Line 1232... | Line 1236... | ||
1232 | 1236 | ||
Line 1260... | Line 1264... | ||
1260 | item := item.prev |
1264 | item := item.prev |
1261 | END; |
1265 | END; |
Line 1262... | Line 1266... | ||
1262 | 1266 | ||
1263 | IF item # NIL THEN |
1267 | IF item # NIL THEN |
1264 | guard := item(tGuard); |
1268 | guard := item(tGuard); |
1265 | text.edition := guard; |
- | |
1266 | text.modified := TRUE |
1269 | text.edition := guard |
Line 1267... | Line 1270... | ||
1267 | END; |
1270 | END; |
1268 | 1271 | ||
1269 | item := ChangeLog.CL.Log.first; |
1272 | item := ChangeLog.CL.Log.first; |
1270 | WHILE item # guard DO |
1273 | WHILE item # guard DO |
1271 | ChangeLog.redo(item); |
1274 | ChangeLog.redo(item); |
1272 | item := item.next |
1275 | item := item.next |
1273 | END; |
1276 | END; |
- | 1277 | redoGuard(text, guard); |
|
1274 | redoGuard(text, guard); |
1278 | ChangeLog.setGuard(guard); |
Line 1275... | Line 1279... | ||
1275 | ChangeLog.setGuard(guard) |
1279 | text.modified := ~guard.saved |
1276 | END undo; |
1280 | END undo; |
Line 1289... | Line 1293... | ||
1289 | END; |
1293 | END; |
1290 | IF item # NIL THEN |
1294 | IF item # NIL THEN |
1291 | guard := item(tGuard); |
1295 | guard := item(tGuard); |
1292 | redoGuard(text, guard) |
1296 | redoGuard(text, guard) |
1293 | END; |
1297 | END; |
1294 | ChangeLog.setGuard(guard) |
1298 | ChangeLog.setGuard(guard); |
- | 1299 | text.modified := ~guard.saved |
|
1295 | END redo; |
1300 | END redo; |
Line 1296... | Line 1301... | ||
1296 | 1301 | ||
1297 | 1302 | ||
Line 1430... | Line 1435... | ||
1430 | 1435 | ||
1431 | PROCEDURE gotoLabel* (text: tText; frw: BOOLEAN); |
1436 | PROCEDURE gotoLabel* (text: tText; frw: BOOLEAN); |
1432 | VAR |
1437 | VAR |
1433 | line: tLine; |
1438 | line: tLine; |
- | 1439 | n: INTEGER; |
|
- | 1440 | ||
- | 1441 | PROCEDURE search (VAR line: tLine; VAR n: INTEGER; frw: BOOLEAN); |
|
- | 1442 | BEGIN |
|
- | 1443 | IF frw THEN |
|
- | 1444 | WHILE (line # NIL) & ~line.label DO |
|
- | 1445 | NextLine(line); |
|
- | 1446 | INC(n) |
|
- | 1447 | END |
|
- | 1448 | ELSE |
|
- | 1449 | WHILE (line # NIL) & ~line.label DO |
|
- | 1450 | PrevLine(line); |
|
- | 1451 | DEC(n) |
|
- | 1452 | END |
|
- | 1453 | END |
|
- | 1454 | END search; |
|
1434 | n: INTEGER; |
1455 | |
1435 | BEGIN |
1456 | BEGIN |
1436 | n := text.cursor.Y; |
1457 | n := text.cursor.Y; |
1437 | line := text.curLine; |
1458 | line := text.curLine; |
1438 | IF frw THEN |
- | |
1439 | REPEAT |
1459 | IF frw THEN |
1440 | line := line.next(tLine); |
1460 | NextLine(line); |
1441 | INC(n) |
- | |
1442 | UNTIL (line = NIL) OR line.label |
1461 | INC(n) |
1443 | ELSE |
- | |
1444 | REPEAT |
1462 | ELSE |
1445 | line := line.prev(tLine); |
1463 | PrevLine(line); |
- | 1464 | DEC(n) |
|
- | 1465 | END; |
|
- | 1466 | search(line, n, frw); |
|
- | 1467 | IF line = NIL THEN |
|
- | 1468 | IF frw THEN |
|
1446 | DEC(n) |
1469 | n := 0; |
- | 1470 | line := text.first(tLine) |
|
- | 1471 | ELSE |
|
- | 1472 | n := text.count - 1; |
|
- | 1473 | line := text.last(tLine) |
|
- | 1474 | END; |
|
1447 | UNTIL (line = NIL) OR line.label |
1475 | search(line, n, frw) |
1448 | END; |
1476 | END; |
1449 | IF line # NIL THEN |
1477 | IF line # NIL THEN |
1450 | IF goto(text, n + 1) THEN END |
1478 | IF goto(text, n + 1) THEN END |
1451 | END |
1479 | END |
Line 1613... | Line 1641... | ||
1613 | END; |
1641 | END; |
1614 | IF search(text, str, Lang.isCS(text.lang), TRUE) THEN END |
1642 | IF search(text, str, Lang.isCS(text.lang), TRUE) THEN END |
1615 | END wordSel; |
1643 | END wordSel; |
Line 1616... | Line 1644... | ||
1616 | 1644 | ||
1617 | 1645 | ||
1618 | PROCEDURE key* (text: tText; code: INTEGER; shift: SET); |
1646 | PROCEDURE key* (text: tText; code: INTEGER; shift, ctrl: BOOLEAN); |
1619 | BEGIN |
1647 | BEGIN |
1620 | IF SHIFT IN shift THEN |
1648 | IF shift THEN |
1621 | setSelect(text) |
1649 | setSelect(text) |
1622 | ELSE |
1650 | ELSE |
1623 | IF (33 <= code) & (code <= 40) THEN |
1651 | IF (33 <= code) & (code <= 40) THEN |
1624 | resetSelect(text) |
1652 | resetSelect(text) |
Line 1625... | Line 1653... | ||
1625 | END |
1653 | END |
1626 | END; |
1654 | END; |
1627 | 1655 | ||
1628 | CASE code OF |
1656 | CASE code OF |
1629 | |33: |
1657 | |33: |
1630 | IF CTRL IN shift THEN |
1658 | IF ctrl THEN |
1631 | UpDown(text, text.scroll.Y - text.cursor.Y) |
1659 | UpDown(text, text.scroll.Y - text.cursor.Y) |
1632 | ELSE |
1660 | ELSE |
1633 | text.scroll.Y := MAX(text.scroll.Y - textsize.Y, 0); |
1661 | text.scroll.Y := MAX(text.scroll.Y - textsize.Y, 0); |
1634 | UpDown(text, -textsize.Y) |
1662 | UpDown(text, -textsize.Y) |
1635 | END |
1663 | END |
1636 | |34: |
1664 | |34: |
1637 | IF CTRL IN shift THEN |
1665 | IF ctrl THEN |
1638 | UpDown(text, MIN(text.scroll.Y + textsize.Y - 1, text.count - 1) - text.cursor.Y) |
1666 | UpDown(text, MIN(text.scroll.Y + textsize.Y - 1, text.count - 1) - text.cursor.Y) |
1639 | ELSE |
1667 | ELSE |
1640 | text.scroll.Y := MIN(text.scroll.Y + textsize.Y, text.count - 1); |
1668 | text.scroll.Y := MIN(text.scroll.Y + textsize.Y, text.count - 1); |
1641 | UpDown(text, textsize.Y) |
1669 | UpDown(text, textsize.Y) |
1642 | END |
1670 | END |
1643 | |35: |
1671 | |35: |
1644 | IF CTRL IN shift THEN |
1672 | IF ctrl THEN |
1645 | SetPos(text, text.last(tLine).length, text.count - 1) |
1673 | SetPos(text, text.last(tLine).length, text.count - 1) |
1646 | ELSE |
1674 | ELSE |
1647 | SetPos(text, text.curLine.length, text.cursor.Y) |
1675 | SetPos(text, text.curLine.length, text.cursor.Y) |
1648 | END |
1676 | END |
1649 | |36: |
1677 | |36: |
1650 | IF CTRL IN shift THEN |
1678 | IF ctrl THEN |
1651 | SetPos(text, 0, 0) |
1679 | SetPos(text, 0, 0) |
1652 | ELSE |
1680 | ELSE |
Line 1657... | Line 1685... | ||
1657 | SetPos(text, text.curLine.prev(tLine).length, text.cursor.Y - 1) |
1685 | SetPos(text, text.curLine.prev(tLine).length, text.cursor.Y - 1) |
1658 | ELSE |
1686 | ELSE |
1659 | SetPos(text, text.cursor.X - 1, text.cursor.Y) |
1687 | SetPos(text, text.cursor.X - 1, text.cursor.Y) |
1660 | END |
1688 | END |
1661 | |38: |
1689 | |38: |
1662 | IF CTRL IN shift THEN |
1690 | IF ctrl THEN |
1663 | upLine(text) |
1691 | upLine(text) |
1664 | ELSE |
1692 | ELSE |
1665 | UpDown(text, -1) |
1693 | UpDown(text, -1) |
1666 | END |
1694 | END |
1667 | |39: |
1695 | |39: |
Line 1669... | Line 1697... | ||
1669 | SetPos(text, 0, text.cursor.Y + 1) |
1697 | SetPos(text, 0, text.cursor.Y + 1) |
1670 | ELSE |
1698 | ELSE |
1671 | SetPos(text, text.cursor.X + 1, text.cursor.Y) |
1699 | SetPos(text, text.cursor.X + 1, text.cursor.Y) |
1672 | END |
1700 | END |
1673 | |40: |
1701 | |40: |
1674 | IF CTRL IN shift THEN |
1702 | IF ctrl THEN |
1675 | downLine(text) |
1703 | downLine(text) |
1676 | ELSE |
1704 | ELSE |
1677 | UpDown(text, 1) |
1705 | UpDown(text, 1) |
1678 | END |
1706 | END |
1679 | |46: |
1707 | |46: |
1680 | IF CTRL IN shift THEN |
1708 | IF ctrl THEN |
1681 | delLine(text) |
1709 | delLine(text) |
1682 | ELSE |
1710 | ELSE |
1683 | delete(text); ShowCursor; drawCursor := TRUE |
1711 | delete(text); ShowCursor; drawCursor := TRUE |
1684 | END |
1712 | END |
1685 | |ORD("C"): |
1713 | |ORD("C"): |
1686 | IF CTRL IN shift THEN |
1714 | IF ctrl THEN |
1687 | IF selected(text) THEN |
1715 | IF selected(text) THEN |
1688 | copy(text) |
1716 | copy(text) |
1689 | END |
1717 | END |
1690 | END |
1718 | END |
1691 | |ORD("X"): |
1719 | |ORD("X"): |
1692 | IF CTRL IN shift THEN |
1720 | IF ctrl THEN |
1693 | IF selected(text) THEN |
1721 | IF selected(text) THEN |
1694 | copy(text); |
1722 | copy(text); |
1695 | delSelect(text) |
1723 | delSelect(text) |
1696 | END |
1724 | END |
1697 | END |
1725 | END |
1698 | |ORD("V"): |
1726 | |ORD("V"): |
1699 | IF CTRL IN shift THEN |
1727 | IF ctrl THEN |
1700 | IF CB.available() THEN |
1728 | IF CB.available() THEN |
1701 | paste(text) |
1729 | paste(text) |
1702 | END |
1730 | END |
1703 | END |
1731 | END |
1704 | |ORD("A"): |
1732 | |ORD("A"): |
1705 | IF CTRL IN shift THEN |
1733 | IF ctrl THEN |
1706 | text.select2.X := 0; |
1734 | text.select2.X := 0; |
1707 | text.select2.Y := 0; |
1735 | text.select2.Y := 0; |
1708 | text.select := text.select2; |
1736 | text.select := text.select2; |
1709 | SetPos(text, text.last(tLine).length, text.count - 1) |
1737 | SetPos(text, text.last(tLine).length, text.count - 1) |
1710 | END |
1738 | END |
1711 | |ORD("L"), ORD("U"): |
1739 | |ORD("L"), ORD("U"): |
1712 | IF CTRL IN shift THEN |
1740 | IF ctrl THEN |
1713 | changeCase(text, code = ORD("U")) |
1741 | changeCase(text, code = ORD("U")) |
1714 | END |
1742 | END |
1715 | |ORD("D"): |
1743 | |ORD("D"): |
1716 | IF CTRL IN shift THEN |
1744 | IF ctrl THEN |
1717 | dupLine(text) |
1745 | dupLine(text) |
1718 | END |
1746 | END |
1719 | ELSE |
1747 | ELSE |
1720 | END |
1748 | END |
1721 | END key; |
1749 | END key; |
Line 1840... | Line 1868... | ||
1840 | Comments(text) |
1868 | Comments(text) |
1841 | END; |
1869 | END; |
1842 | IF text.guard THEN |
1870 | IF text.guard THEN |
1843 | NEW(guard); |
1871 | NEW(guard); |
1844 | List.append(ChangeLog.CL.Log, guard); |
1872 | List.append(ChangeLog.CL.Log, guard); |
- | 1873 | guard.saved := ChangeLog.isFirstGuard(guard); |
|
1845 | text.edition := guard; |
1874 | text.edition := guard; |
1846 | text.guard := FALSE; |
1875 | text.guard := FALSE |
1847 | ELSE |
1876 | ELSE |
1848 | guard := text.edition |
1877 | guard := text.edition |
1849 | END; |
1878 | END; |
Line 1850... | Line 1879... | ||
1850 | 1879 |