1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429
|
/***********************************************************************/
/* COMM1.C - Commands A-C */
/* This file contains all commands that can be assigned to function */
/* keys or typed on the command line. */
/***********************************************************************/
/*
* THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
* Copyright (C) 1991-1999 Mark Hessling
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to:
*
* The Free Software Foundation, Inc.
* 675 Mass Ave,
* Cambridge, MA 02139 USA.
*
*
* If you make modifications to this software that you feel increases
* it usefulness for the rest of the community, please email the
* changes, enhancements, bug fixes as well as any and all ideas to me.
* This software is going to be maintained and enhanced as deemed
* necessary by the community.
*
* Mark Hessling, M.Hessling@qut.edu.au http://www.lightlink.com/hessling/
* PO Box 203, Bellara, QLD 4507, AUSTRALIA
* Author of THE, a Free XEDIT/KEDIT editor and, Rexx/SQL
* Maintainer of PDCurses: Public Domain Curses and, Regina Rexx interpreter
* Use Rexx ? join the Rexx Language Association: http://www.rexxla.org
*/
static char RCSid[] = "$Id: comm1.c,v 1.5 2001/04/25 01:13:02 mark Exp $";
#include <the.h>
#include <proto.h>
/*#define DEBUG 1*/
/*man-start*********************************************************************
========================================================================
COMMAND REFERENCE
========================================================================
**man-end**********************************************************************/
/*man-start*********************************************************************
COMMAND
add - add blank line
SYNTAX
Add [n]
DESCRIPTION
The ADD command inserts 'n' blank lines after the <current line>,
if issued from the <command line> or after the <focus line>,
if issued from the <filearea> or <prefix area>.
If <SET NEWLINES> is set to ALIGNED, the cursor is positioned in
the column corresponding to the first column not containing a
space in the line above.
If <SET NEWLINES> is set to LEFT, the cursor is positioned in the
first column.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
DEFAULT
1
SEE ALSO
<SOS ADDLINE>
STATUS
Complete
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Add(CHARTYPE *params)
#else
short Add(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
#define ADD_PARAMS 1
CHARTYPE *word[ADD_PARAMS+1];
CHARTYPE strip[ADD_PARAMS];
unsigned short num_params=0;
LINETYPE num_lines=0L;
/*--------------------------- processing ------------------------------*/
TRACE_FUNCTION("comm1.c: Add");
/*---------------------------------------------------------------------*/
/* Validate the parameters that have been supplied. The one and only */
/* parameter should be a positive integer greater than zero. */
/* If no parameter is supplied, 1 is assumed. */
/*---------------------------------------------------------------------*/
strip[0]=STRIP_BOTH;
num_params = param_split(params,word,ADD_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
if (num_params == 0)
{
num_params = 1;
word[0] = (CHARTYPE *)"1";
}
if (num_params != 1)
{
display_error(1,word[1],FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
if (!valid_positive_integer(word[0]))
{
display_error(4,word[0],FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
num_lines = atol((DEFCHAR *)word[0]);
post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
insert_new_line((CHARTYPE *)"",0,num_lines,get_true_line(TRUE),FALSE,FALSE,TRUE,CURRENT_VIEW->display_low,TRUE,FALSE);
if (curses_started
&& CURRENT_VIEW->current_window == WINDOW_COMMAND)
THEcursor_home(TRUE);
TRACE_RETURN();
return(RC_OK);
}
/*man-start*********************************************************************
COMMAND
alert - display a user configurable dialog box with notification
SYNTAX
ALERT /prompt/ [EDITfield [/val/]] [TITLE /title/] [OK|OKCANCEL|YESNO|YESNOCANCEL] [DEFBUTTON n]
DESCRIPTION
The ALERT command is identical to the <DIALOG> command except that
if <SET BEEP> is on, a beep is played.
On exit from the ALERT command, the following Rexx variables are set:
ALERT.0 - 2
ALERT.1 - value of 'EDITfield'
ALERT.2 - button selected as specified in the call to the command.
The colours for the alert box are the same as for a dialog box, except
the prompt area which uses the colour set by <SET COLOR> ALERT.
COMPATIBILITY
XEDIT: N/A
KEDIT: Compatible. Does not support bitmap icons or font options.
SEE ALSO
<POPUP>, <DIALOG>, <READV>, <SET COLOR>
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Alert(CHARTYPE *params)
#else
short Alert(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short rc=RC_OK;
/*--------------------------- processing ------------------------------*/
TRACE_FUNCTION("comm2.c: Alert");
/*
* If we have a beep() functiond and its ON, ring it..
*/
#ifdef HAVE_BEEP
if ( BEEPx )
beep();
#endif
rc = prepare_dialog( params, TRUE, "ALERT" );
TRACE_RETURN();
return(rc);
}
/*man-start*********************************************************************
COMMAND
all - select and display restricted set of lines
SYNTAX
ALL [rtarget]
DESCRIPTION
The ALL command allows for the selective display, and editting
(subject to <SET SCOPE>) of lines that match the specified target.
This target consists of any number of individual targets
seperated by '&' (logical and) or '|' (logical or).
For example, to display all lines in a file that contain the
strings 'ball' and 'cat' on the same line or the named lines
.fred or .bill, use the following command
ALL /ball/ & /cat/ | .fred | .bill
Logical operators act left to right, with no precedence for &.
ALL without any arguments, is the equivalent of setting the
selection level of all lines in your file to 0 and running
<SET DISPLAY> 0 0.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
SEE ALSO
<SET SCOPE>, <SET DISPLAY>, <SET SELECT>
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short All(CHARTYPE *params)
#else
short All(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short rc=RC_OK;
LINE *curr=NULL;
bool target_found=FALSE;
short status=RC_OK;
short target_type=TARGET_NORMAL;
TARGET target;
LINETYPE line_number=0L;
unsigned short x=0,y=0;
bool save_scope=FALSE;
LINETYPE num_lines=0L;
/*--------------------------- processing ------------------------------*/
TRACE_FUNCTION("comm1.c: All");
if (strlen((DEFCHAR *)params) == 0)
{
if (CURRENT_FILE->number_lines == 0L)
{
TRACE_RETURN();
return(rc);
}
post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
curr = CURRENT_FILE->first_line->next;
while(1)
{
curr->select = 0;
curr = curr->next;
if (curr->next == NULL)
break;
}
CURRENT_VIEW->display_low = 0;
CURRENT_VIEW->display_high = 0;
build_screen(current_screen);
display_screen(current_screen);
TRACE_RETURN();
return(rc);
}
if (CURRENT_FILE->number_lines == 0L)
{
display_error(17,params,FALSE);
TRACE_RETURN();
return(RC_TARGET_NOT_FOUND);
}
/*---------------------------------------------------------------------*/
/* Validate the parameters as valid targets... */
/*---------------------------------------------------------------------*/
initialise_target(&target);
rc = parse_target(params,get_true_line(TRUE),&target,target_type,TRUE,TRUE,FALSE);
if (rc != RC_OK)
{
free_target(&target);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
/*---------------------------------------------------------------------*/
/* Save the select levels for all lines in case no target is found. */
/*---------------------------------------------------------------------*/
curr = CURRENT_FILE->first_line->next;
while(1)
{
curr->save_select = curr->select;
curr = curr->next;
if (curr->next == NULL)
break;
}
/*---------------------------------------------------------------------*/
/* Find all lines for the supplied target... */
/*---------------------------------------------------------------------*/
curr = CURRENT_FILE->first_line;
status = FALSE;
save_scope = CURRENT_VIEW->scope_all;
CURRENT_VIEW->scope_all = TRUE;
for (line_number=0L;curr->next != NULL;line_number++)
{
status = find_rtarget_target(curr,&target,0L,line_number,&num_lines);
if (status == RC_OK) /* target found */
{
target_found = TRUE;
curr->select = 1;
}
else if (status == RC_TARGET_NOT_FOUND) /* target not found */
curr->select = 0;
else /* error */
break;
curr = curr->next;
}
/*---------------------------------------------------------------------*/
/* If at least one line matches the target, set DISPLAY to 1 1, */
/* otherwise reset the select levels as they were before the command. */
/*---------------------------------------------------------------------*/
if (target_found)
{
post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
CURRENT_VIEW->display_low = 1;
CURRENT_VIEW->display_high = 1;
CURRENT_VIEW->scope_all = FALSE;
CURRENT_VIEW->current_line = find_next_in_scope(CURRENT_VIEW,CURRENT_FILE->first_line->next,1L,DIRECTION_FORWARD);
build_screen(current_screen);
display_screen(current_screen);
CURRENT_VIEW->focus_line = calculate_focus_line(CURRENT_VIEW->focus_line,
CURRENT_VIEW->current_line);
pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
if (CURRENT_VIEW->current_window != WINDOW_COMMAND)
{
getyx(CURRENT_WINDOW,y,x);
y = get_row_for_focus_line(current_screen,CURRENT_VIEW->focus_line,
CURRENT_VIEW->current_row);
wmove(CURRENT_WINDOW,y,x);
}
}
else
{
CURRENT_VIEW->scope_all = save_scope;
curr = CURRENT_FILE->first_line->next;
while(1)
{
curr->select = curr->save_select;
curr = curr->next;
if (curr->next == NULL)
break;
}
if (status == RC_TARGET_NOT_FOUND)
{
display_error(17,params,FALSE);
rc = RC_TARGET_NOT_FOUND;
}
else
rc = status;
}
free_target(&target);
TRACE_RETURN();
return(rc);
}
/*man-start*********************************************************************
COMMAND
backward - scroll backwards [n] screens
SYNTAX
BAckward [n|*]
DESCRIPTION
The BACKWARD command scrolls the file contents backwards through
the file 'n' or '*' screens.
If 0 is specified as the number of screens to scroll, the last
line of the file becomes the <current line>.
If the BACKWARD command is issued while the current line is
the <Top-of-File line>, the last line of the file becomes the
<current line>.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Does not support HALF or Lines options.
DEFAULT
1
SEE ALSO
<FORWARD>, <TOP>
STATUS
Complete
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Backward(CHARTYPE *params)
#else
short Backward(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
#define BAC_PARAMS 1
CHARTYPE *word[BAC_PARAMS+1];
CHARTYPE strip[BAC_PARAMS];
unsigned short num_params=0;
LINETYPE num_pages=0L;
short rc=RC_OK;
/*--------------------------- processing ------------------------------*/
TRACE_FUNCTION("comm1.c: Backward");
/*
* Validate parameters...
*/
strip[0]=STRIP_BOTH;
num_params = param_split(params,word,BAC_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
if (num_params == 0)
{
num_params = 1;
word[0] = (CHARTYPE *)"1";
}
if (num_params != 1)
{
display_error(1,(CHARTYPE *)word[1],FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
/*
* If parameter is '*', set current line equal to "Top of File".
*/
if (strcmp((DEFCHAR *)word[0],"*") == 0)
{
rc = Top((CHARTYPE *)"");
TRACE_RETURN();
return(rc);
}
/*
* If the parameter is not a valid integer, error.
*/
if (!valid_integer(word[0]))
{
display_error(1,(CHARTYPE *)word[0],FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
/*
* Number of screens to scroll is set here.
*/
num_pages = atol((DEFCHAR *)word[0]);
/*
* If the number specified is < 0, error...
*/
if (num_pages < 0L)
{
display_error(5,(CHARTYPE *)word[0],FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
/*
* If the current line is already on "Top of File" or the parameter is
* 0, go to the bottom of the file.
*/
if ( num_pages == 0
|| ( CURRENT_TOF && PAGEWRAPx ) )
{
rc = Bottom((CHARTYPE *)"");
TRACE_RETURN();
return(rc);
}
/*
* Scroll the screen num_pages...
*/
rc = scroll_page(DIRECTION_BACKWARD,num_pages,FALSE);
TRACE_RETURN();
return(rc);
}
/*man-start*********************************************************************
COMMAND
bottom - move to the bottom of the file
SYNTAX
Bottom
DESCRIPTION
The BOTTOM command moves to the very end of the current file.
The last line of the file is set to the <current line>.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
SEE ALSO
<FORWARD>, <TOP>
STATUS
Complete
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Bottom(CHARTYPE *params)
#else
short Bottom(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short rc=RC_OK;
unsigned short x=0,y=0;
/*--------------------------- processing ------------------------------*/
TRACE_FUNCTION("comm1.c: Bottom");
/*---------------------------------------------------------------------*/
/* No arguments are allowed; error if any are present. */
/*---------------------------------------------------------------------*/
if (strcmp((DEFCHAR *)params,"") != 0)
{
display_error(1,(CHARTYPE *)params,FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
if (CURRENT_VIEW->scope_all)
CURRENT_VIEW->current_line = CURRENT_FILE->number_lines;
else
CURRENT_VIEW->current_line = find_next_in_scope(CURRENT_VIEW,CURRENT_FILE->last_line->prev,CURRENT_FILE->number_lines,DIRECTION_BACKWARD);
post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
build_screen(current_screen);
if (!line_in_view(current_screen,CURRENT_VIEW->focus_line))
CURRENT_VIEW->focus_line = CURRENT_VIEW->current_line;
pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
if (curses_started)
{
if (CURRENT_VIEW->current_window == WINDOW_COMMAND)
getyx(CURRENT_PREV_WINDOW,y,x);
else
getyx(CURRENT_WINDOW,y,x);
display_screen(current_screen);
y = get_row_for_focus_line(current_screen,CURRENT_VIEW->focus_line,
CURRENT_VIEW->current_row);
if (CURRENT_VIEW->current_window == WINDOW_COMMAND)
wmove(CURRENT_PREV_WINDOW,y,x);
else
wmove(CURRENT_WINDOW,y,x);
}
TRACE_RETURN();
return(rc);
}
/*man-start*********************************************************************
COMMAND
cancel - quit from all unaltered files in the ring
SYNTAX
CANcel
DESCRIPTION
The CANCEL command exits from THE quickly by executing a <QQUIT>
command for every file in the ring that does not have any
outstanding alterations.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
SEE ALSO
<CCANCEL>
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Cancel(CHARTYPE *params)
#else
short Cancel(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
VIEW_DETAILS *save_current_view=(VIEW_DETAILS *)NULL;
LINETYPE save_number_of_files=number_of_files;
register int i=0;
/*--------------------------- processing ------------------------------*/
TRACE_FUNCTION("comm1.c: Cancel");
/*---------------------------------------------------------------------*/
/* No arguments are allowed; error if any are present. */
/*---------------------------------------------------------------------*/
if (strcmp((DEFCHAR *)params,"") != 0)
{
display_error(1,(CHARTYPE *)params,FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
#if 0
CURRENT_VIEW = vd_first;
while (CURRENT_VIEW != (VIEW_DETAILS *)NULL)
{
if (CURRENT_FILE->save_alt == 0)
free_view_memory(TRUE);
else
{
save_current_view = CURRENT_VIEW;
CURRENT_VIEW = CURRENT_VIEW->next;
}
}
#else
for (i=0;i<save_number_of_files;i++)
{
if (CURRENT_FILE->save_alt == 0)
free_view_memory(TRUE,FALSE);
else
{
save_current_view = CURRENT_VIEW;
CURRENT_VIEW = CURRENT_VIEW->next;
if (CURRENT_VIEW == NULL)
CURRENT_VIEW = vd_first;
}
}
#endif
if (save_current_view != (VIEW_DETAILS *)NULL)
{
CURRENT_VIEW = save_current_view;
CURRENT_SCREEN.screen_view = CURRENT_VIEW;
pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
build_screen(current_screen);
display_screen(current_screen);
if (curses_started)
{
if (CURRENT_WINDOW_PREFIX != NULL)
touchwin(CURRENT_WINDOW_PREFIX);
if (CURRENT_WINDOW_COMMAND != NULL)
touchwin(CURRENT_WINDOW_COMMAND);
touchwin(CURRENT_WINDOW_FILEAREA);
touchwin(CURRENT_WINDOW);
}
}
if (number_of_files > 0)
{
sprintf((DEFCHAR *)temp_cmd,"%ld file(s) remain with outstanding changes",number_of_files);
display_error(0,(CHARTYPE *)temp_cmd,TRUE);
}
TRACE_RETURN();
return(QUIT);
}
/*man-start*********************************************************************
COMMAND
cappend - append text after column pointer
SYNTAX
CAppend [text]
DESCRIPTION
The CAPPEND command moves the column pointer to the end of the
focus line and appends the specified 'text'.
If no 'text' is specified, the column pointer moves to the first
trailing space.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
SEE ALSO
<CLAST>
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Cappend(CHARTYPE *params)
#else
short Cappend(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short rc=RC_OK;
/*--------------------------- processing ------------------------------*/
TRACE_FUNCTION("comm1.c: Cappend");
rc = column_command(params,COLUMN_CAPPEND);
TRACE_RETURN();
return(rc);
}
/*man-start*********************************************************************
COMMAND
ccancel - qquit from all files in the ring
SYNTAX
CCancel
DESCRIPTION
The CCANCEL command exits from THE quickly by executing the <QQUIT>
command for every file in the ring. Any changes made to any of
the files since the last <SAVE> will be lost.
COMPATIBILITY
XEDIT: N/A
KEDIT: N/A
SEE ALSO
<CANCEL>
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Ccancel(CHARTYPE *params)
#else
short Ccancel(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
/*--------------------------- processing ------------------------------*/
TRACE_FUNCTION("comm1.c: Ccancel");
/*---------------------------------------------------------------------*/
/* No arguments are allowed; error if any are present. */
/*---------------------------------------------------------------------*/
if (strcmp((DEFCHAR *)params,"") != 0)
{
display_error(1,(CHARTYPE *)params,FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
CURRENT_VIEW = vd_first;
while (CURRENT_VIEW != (VIEW_DETAILS *)NULL)
{
free_view_memory(TRUE,FALSE);
}
TRACE_RETURN();
return(QUIT);
}
/*man-start*********************************************************************
COMMAND
cdelete - delete text starting at column pointer
SYNTAX
CDelete [column target]
DESCRIPTION
The CDELETE command deletes characters starting from the current
column pointer for the specified <'column target'>.
If no <'column target'> is specified, the character at the column
pointer is deleted.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
STATUS
Incomplete. No string targets.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Cdelete(CHARTYPE *params)
#else
short Cdelete(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short rc=RC_OK;
short target_type=TARGET_ABSOLUTE|TARGET_RELATIVE|TARGET_STRING|TARGET_BLANK;
TARGET target;
LENGTHTYPE start_col=0,del_start=0;
unsigned int y=0,x=0;
/*--------------------------- processing ------------------------------*/
TRACE_FUNCTION("comm1.c: Cdelete");
/*---------------------------------------------------------------------*/
/* Validate the cursor position... */
/*---------------------------------------------------------------------*/
if (CURRENT_VIEW->current_window != WINDOW_COMMAND)
{
getyx(CURRENT_WINDOW,y,x);
rc = processable_line(CURRENT_VIEW,CURRENT_SCREEN.sl[y].line_number,CURRENT_SCREEN.sl[y].current);
switch(rc)
{
case LINE_SHADOW:
display_error(87,(CHARTYPE *)"",FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
break;
/* case LINE_TOF_EOF: MH12 */
case LINE_TOF:
case LINE_EOF:
display_error(36,(CHARTYPE *)"",FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
break;
default:
break;
}
}
/*---------------------------------------------------------------------*/
/* Determine at which column to start the search... */
/*---------------------------------------------------------------------*/
switch (CURRENT_VIEW->current_window)
{
case WINDOW_FILEAREA:
start_col = (CURRENT_VIEW->verify_col) + x;
if (start_col > CURRENT_VIEW->zone_end)
start_col = min(max_line_length,CURRENT_VIEW->zone_end+1);
if (start_col < CURRENT_VIEW->zone_start)
start_col = max(1,CURRENT_VIEW->zone_start-1);
break;
case WINDOW_PREFIX:
start_col = max(CURRENT_VIEW->current_column,max(1,CURRENT_VIEW->zone_start));
break;
case WINDOW_COMMAND:
pre_process_line(CURRENT_VIEW,CURRENT_VIEW->current_line,(LINE *)NULL);
start_col = CURRENT_VIEW->current_column;
break;
}
/*---------------------------------------------------------------------*/
/* Validate the parameters as valid targets... */
/*---------------------------------------------------------------------*/
initialise_target(&target);
rc = parse_target(params,(LINETYPE)start_col,&target,target_type,TRUE,TRUE,TRUE);
if (rc != RC_OK)
{
free_target(&target);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
/*---------------------------------------------------------------------*/
/* Find the valid column target. If found process the command... */
/*---------------------------------------------------------------------*/
if ((find_column_target(rec,rec_len,&target,start_col,TRUE,TRUE)) == RC_OK)
{
CURRENT_VIEW->current_column = start_col;
if (target.num_lines < 0)
{
if (start_col > CURRENT_VIEW->zone_end)
{
start_col--;
target.num_lines++;
}
del_start = start_col+target.num_lines;
(void)memdeln(rec,del_start,rec_len,-target.num_lines);
rec_len = calculate_rec_len(ADJUST_DELETE,rec_len,del_start,-target.num_lines);
/* rec_len += (rec_len>del_start)?target.num_lines:0;*/
}
else
{
if (start_col < CURRENT_VIEW->zone_start)
{
start_col++;
target.num_lines--;
}
del_start = start_col-1;
(void)memdeln(rec,del_start,rec_len,target.num_lines);
rec_len = calculate_rec_len(ADJUST_DELETE,rec_len,del_start,target.num_lines);
/* rec_len -= (rec_len>del_start)?target.num_lines:0;*/
}
if (CURRENT_VIEW->current_window == WINDOW_COMMAND)
{
post_process_line(CURRENT_VIEW,CURRENT_VIEW->current_line,(LINE *)NULL,TRUE);
pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
}
else
rc = THEcursor_column();
build_screen(current_screen);
display_screen(current_screen);
}
else
{
if (CURRENT_VIEW->current_window == WINDOW_COMMAND)
{
post_process_line(CURRENT_VIEW,CURRENT_VIEW->current_line,(LINE *)NULL,TRUE);
pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
}
}
free_target(&target);
TRACE_RETURN();
return(rc);
}
/*man-start*********************************************************************
COMMAND
cfirst - move column pointer to beginning of zone
SYNTAX
CFirst
DESCRIPTION
The CFIRST command moves the column pointer to the beginning of
the zone.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
SEE ALSO
<SET ZONE>
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Cfirst(CHARTYPE *params)
#else
short Cfirst(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short rc=RC_OK;
bool need_to_redisplay=FALSE;
/*--------------------------- processing ------------------------------*/
TRACE_FUNCTION("comm1.c: Cfirst");
/*---------------------------------------------------------------------*/
/* No arguments are allowed; error if any are present. */
/*---------------------------------------------------------------------*/
if (strcmp((DEFCHAR *)params,"") != 0)
{
display_error(1,(CHARTYPE *)params,FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
if (column_in_view(current_screen,CURRENT_VIEW->current_column-1))
need_to_redisplay = TRUE;
CURRENT_VIEW->current_column = CURRENT_VIEW->zone_start;
if (column_in_view(current_screen,CURRENT_VIEW->current_column-1))
need_to_redisplay = TRUE;
if (need_to_redisplay)
display_screen(current_screen);
TRACE_RETURN();
return(rc);
}
/*man-start*********************************************************************
COMMAND
change - change one string to another
SYNTAX
Change [/string1/string2/ [target] [n] [m]]
DESCRIPTION
The CHANGE command changes one string of text to another.
The first parameter to the change command is the old and new
string values, seperated by delimiters.
The first non alphabetic character after the 'change' command
is the delimiter.
<'target'> specifies how many lines are to be searched for
occurrences of 'string1' to be changed.
'n' determines how many occurrences of 'string1' are to be
changed to 'string2' on each line. 'n' may be specified as
'*' which will result in all occurrences of 'string1' will
be changed. '*' is equivalent to the current WIDTH of the
line.
'm' determines from which occurrence of 'string1' on the line
changes are to commence.
If no arguments are supplied to the CHANGE command, the last
change command, if any, is re-executed.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
DEFAULT
1 1 1
SEE ALSO
<SCHANGE>
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Change(CHARTYPE *params)
#else
short Change(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short rc=RC_OK;
/*--------------------------- processing ------------------------------*/
TRACE_FUNCTION("comm1.c: Change");
/*---------------------------------------------------------------------*/
/* If no arguments have been supplied, pass the last change command */
/* to be executed. If no last change command, return error 39. */
/*---------------------------------------------------------------------*/
if (blank_field(params))
{
if (blank_field(last_change_command))
{
display_error(39,(CHARTYPE *)params,FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
rc = execute_change_command(last_change_command,FALSE);
TRACE_RETURN();
return(rc);
}
rc = execute_change_command(params,FALSE);
TRACE_RETURN();
return(rc);
}
/*man-start*********************************************************************
COMMAND
cinsert - insert text starting at the column pointer
SYNTAX
CInsert text
DESCRIPTION
The CINSERT command inserts 'text' starting at the column position.
'text' can include leading or trailing space characters. Thus
CINSERT immediatley followed by 5 spaces, will insert 4 space
characters. The first space character is the command seperator.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Cinsert(CHARTYPE *params)
#else
short Cinsert(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short rc=RC_OK;
/*--------------------------- processing ------------------------------*/
TRACE_FUNCTION("comm1.c: Cinsert");
rc = column_command(params,COLUMN_CINSERT);
TRACE_RETURN();
return(rc);
}
/*man-start*********************************************************************
COMMAND
clast - move the column pointer to end of zone
SYNTAX
CLAst
DESCRIPTION
The CLAST command moves the column pointer to the end of the
zone.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
SEE ALSO
<SET ZONE>
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Clast(CHARTYPE *params)
#else
short Clast(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short rc=RC_OK;
bool need_to_redisplay=FALSE;
/*--------------------------- processing ------------------------------*/
TRACE_FUNCTION("comm1.c: Clast");
/*---------------------------------------------------------------------*/
/* No arguments are allowed; error if any are present. */
/*---------------------------------------------------------------------*/
if (strcmp((DEFCHAR *)params,"") != 0)
{
display_error(1,(CHARTYPE *)params,FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
if (column_in_view(current_screen,CURRENT_VIEW->current_column-1))
need_to_redisplay = TRUE;
CURRENT_VIEW->current_column = CURRENT_VIEW->zone_end;
if (column_in_view(current_screen,CURRENT_VIEW->current_column-1))
need_to_redisplay = TRUE;
if (need_to_redisplay)
display_screen(current_screen);
TRACE_RETURN();
return(rc);
}
/*man-start*********************************************************************
COMMAND
clocate - move the column pointer
SYNTAX
CLocate column target
DESCRIPTION
The CLOCATE command scans the file for the specified <'column target'>
beginning with the column following (or preceding) the column pointer.
Column targets can be specified as absolute targets, relative
targets or string targets.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
STATUS
Incomplete. No string targets.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Clocate(CHARTYPE *params)
#else
short Clocate(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short rc=RC_OK;
short target_type=TARGET_ABSOLUTE|TARGET_RELATIVE|TARGET_STRING|TARGET_BLANK;
TARGET target;
CHARTYPE *line=NULL;
LINE *curr=NULL;
LENGTHTYPE len=0,start_col=0;
unsigned int y=0,x=0;
/*--------------------------- processing ------------------------------*/
TRACE_FUNCTION("comm1.c: Clocate");
/*---------------------------------------------------------------------*/
/* Determine at which column to start the search... */
/*---------------------------------------------------------------------*/
switch (CURRENT_VIEW->current_window)
{
case WINDOW_FILEAREA:
if (compatible_feel == COMPAT_XEDIT)
{
curr = lll_find(CURRENT_FILE->first_line,CURRENT_FILE->last_line,CURRENT_VIEW->current_line,CURRENT_FILE->number_lines);
line = curr->line;
len = curr->length;
start_col = CURRENT_VIEW->current_column;
}
else
{
line = rec;
len = rec_len;
getyx(CURRENT_WINDOW,y,x);
start_col = (CURRENT_VIEW->verify_col) + x;
if (start_col > CURRENT_VIEW->zone_end)
start_col = min(max_line_length,CURRENT_VIEW->zone_end+1);
if (start_col < CURRENT_VIEW->zone_start)
start_col = max(1,CURRENT_VIEW->zone_start-1);
}
break;
case WINDOW_PREFIX:
line = rec;
len = rec_len;
start_col = max(CURRENT_VIEW->current_column,max(1,CURRENT_VIEW->zone_start));
break;
case WINDOW_COMMAND:
curr = lll_find(CURRENT_FILE->first_line,CURRENT_FILE->last_line,CURRENT_VIEW->current_line,CURRENT_FILE->number_lines);
line = curr->line;
len = curr->length;
start_col = CURRENT_VIEW->current_column;
break;
}
/*---------------------------------------------------------------------*/
/* Validate the parameters as valid targets... */
/*---------------------------------------------------------------------*/
initialise_target(&target);
rc = parse_target(params,(LINETYPE)start_col,&target,target_type,TRUE,TRUE,TRUE);
if (rc != RC_OK)
{
free_target(&target);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
/*---------------------------------------------------------------------*/
/* Find the valid column target. If found process the command... */
/*---------------------------------------------------------------------*/
if ((find_column_target(line,len,&target,start_col,TRUE,FALSE)) == RC_OK)
{
CURRENT_VIEW->current_column = start_col + target.num_lines;
if (CURRENT_VIEW->current_window != WINDOW_COMMAND)
rc = THEcursor_column();
build_screen(current_screen);
display_screen(current_screen);
}
free_target(&target);
TRACE_RETURN();
return(rc);
}
/*man-start*********************************************************************
COMMAND
cmatch - find matching bracket character
SYNTAX
CMATCH
DESCRIPTION
The CMATCH command searches for the matching bracket character to
the character under the cursor.
It handles nested sets of matching pairs.
The matching character pairs are []{}<>().
COMPATIBILITY
XEDIT: N/A
KEDIT: Compatible.
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Cmatch(CHARTYPE *params)
#else
short Cmatch(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
static CHARTYPE *match = (CHARTYPE *)"[]{}<>()";
unsigned short x=0,y=0,current_y=0;
CHARTYPE ch=0,match_ch=0;
register short i=0;
short direction_backward=0;
short matches=1,match_col=(-1),start_col=0,focus_column=0;
LINETYPE offset=0L;
LINE *curr=NULL;
LINETYPE focus_line=0L;
bool use_current=TRUE;
/*--------------------------- processing ------------------------------*/
TRACE_FUNCTION("comm1.c: Cmatch");
getyx(CURRENT_WINDOW,y,x);
/*---------------------------------------------------------------------*/
/* This command only allowed to be issued from with the MAIN window. */
/*---------------------------------------------------------------------*/
if (CURRENT_VIEW->current_window == WINDOW_FILEAREA)
{
current_y = get_row_for_focus_line(current_screen,CURRENT_VIEW->focus_line,
CURRENT_VIEW->current_row);
focus_line = CURRENT_VIEW->focus_line;
focus_column = CURRENT_VIEW->verify_col + x - 1;
ch = rec[focus_column];
use_current = FALSE;
}
else
{
current_y = CURRENT_VIEW->current_row;
focus_line = CURRENT_VIEW->current_line;
focus_column = CURRENT_VIEW->current_column - 1;
ch = CURRENT_SCREEN.sl[current_y].contents[focus_column];
use_current = TRUE;
}
/*---------------------------------------------------------------------*/
/* This command cannot be issued on TOF or BOF. */
/*---------------------------------------------------------------------*/
if (TOF(focus_line)
|| BOF(focus_line))
{
display_error(66,(CHARTYPE *)"",FALSE);
TRACE_RETURN();
return(RC_TOF_EOF_REACHED);
}
/*---------------------------------------------------------------------*/
/* This command cannot be entered on a shadow line. */
/*---------------------------------------------------------------------*/
if (CURRENT_SCREEN.sl[y].line_type == LINE_SHADOW)
{
display_error(87,(CHARTYPE *)"",FALSE);
TRACE_RETURN();
return(RC_TARGET_NOT_FOUND);
}
/*---------------------------------------------------------------------*/
/* Check if the character under the cursor is a valid match character. */
/*---------------------------------------------------------------------*/
match_ch = 0;
for (i=0;i<strlen((DEFCHAR *)match);i++)
if (ch == *(match+i))
{
direction_backward = (i % 2);
match_ch = (direction_backward) ? *(match+i-1) : *(match+i+1);
break;
}
if (match_ch == 0)
{
display_error(67,(CHARTYPE *)"",FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
/*---------------------------------------------------------------------*/
/* Calculate the actual position of the character in the LINE. */
/*---------------------------------------------------------------------*/
start_col = focus_column + ((direction_backward) ? (-1) : 1);
/*---------------------------------------------------------------------*/
/* Find the focus line linked list entry. */
/*---------------------------------------------------------------------*/
post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
curr = lll_find(CURRENT_FILE->first_line,CURRENT_FILE->last_line,focus_line,CURRENT_FILE->number_lines);
while (curr->next != NULL && curr->prev != NULL)
{
if (direction_backward)
{
for (i=start_col;i>(-1);i--)
{
if (*(curr->line+i) == ch)
matches++;
else
if (*(curr->line+i) == match_ch)
matches--;
if (matches == 0) /* found matching one */
{
match_col = i;
break;
}
}
if (match_col != (-1))
break;
curr = curr->prev;
offset--;
start_col = curr->length;
}
else
{
for (i=start_col;i<curr->length;i++)
{
if (*(curr->line+i) == ch)
matches++;
else
if (*(curr->line+i) == match_ch)
matches--;
if (matches == 0) /* found matching one */
{
match_col = i;
break;
}
}
if (match_col != (-1))
break;
curr = curr->next;
offset++;
start_col = 0;
}
}
/*---------------------------------------------------------------------*/
/* If no match found, return with error. */
/*---------------------------------------------------------------------*/
if (match_col == (-1)) /* no match found */
{
display_error(68,(CHARTYPE *)"",FALSE);
TRACE_RETURN();
return(RC_TARGET_NOT_FOUND);
}
/*---------------------------------------------------------------------*/
/* If we get here, we have found the matching character, so we have to */
/* move the cursor to the new column and/or line. */
/*---------------------------------------------------------------------*/
if (offset == 0L)
{
if (use_current)
CURRENT_VIEW->current_column = match_col+1;
if (match_col >= CURRENT_VIEW->verify_col-1
&& match_col <= (CURRENT_SCREEN.cols[WINDOW_FILEAREA]+(CURRENT_VIEW->verify_col-1))-1)
/*---------------------------------------------------------------------*/
/* If the new cursor position is in the same panel and on the same line*/
/* just move the cursor there and get out. */
/*---------------------------------------------------------------------*/
{
if (use_current)
{
build_screen(current_screen);
display_screen(current_screen);
wmove(CURRENT_WINDOW,y,x);
}
else
wmove(CURRENT_WINDOW,y,match_col-(CURRENT_VIEW->verify_col-1));
TRACE_RETURN();
return(RC_OK);
}
else
{
x = CURRENT_SCREEN.cols[WINDOW_FILEAREA] / 2;
CURRENT_VIEW->verify_col = max(1,match_col-(short)x);
build_screen(current_screen);
display_screen(current_screen);
wmove(CURRENT_WINDOW,y,(match_col-(CURRENT_VIEW->verify_col-1)));
TRACE_RETURN();
return(RC_OK);
}
}
/*---------------------------------------------------------------------*/
/* If a match IS found on a different line, further checks are required*/
/* for SCOPE. */
/*---------------------------------------------------------------------*/
if (IN_SCOPE(CURRENT_VIEW,curr))
{
/*---------------------------------------------------------------------*/
/* Set the cursor position for the matching character. */
/*---------------------------------------------------------------------*/
if (use_current)
{
CURRENT_VIEW->current_column = match_col+1;
CURRENT_VIEW->current_line += offset;
if (line_in_view(current_screen,CURRENT_VIEW->focus_line))
y = get_row_for_focus_line(current_screen,CURRENT_VIEW->focus_line,
CURRENT_VIEW->current_row);
else
{
CURRENT_VIEW->focus_line = CURRENT_VIEW->current_line;
y = CURRENT_VIEW->current_row;
}
pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
}
else
{
CURRENT_VIEW->focus_line += offset;
pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
if (line_in_view(current_screen,CURRENT_VIEW->focus_line))
y = get_row_for_focus_line(current_screen,CURRENT_VIEW->focus_line,
CURRENT_VIEW->current_row);
else
{
CURRENT_VIEW->current_line = CURRENT_VIEW->focus_line;
y = CURRENT_VIEW->current_row;
}
}
}
else
if (CURRENT_VIEW->scope_all)
{
curr->select = CURRENT_VIEW->display_low;
if (use_current)
{
CURRENT_VIEW->current_column = match_col+1;
CURRENT_VIEW->current_line += offset;
CURRENT_VIEW->focus_line = CURRENT_VIEW->current_line;
}
else
{
CURRENT_VIEW->focus_line += offset;
CURRENT_VIEW->current_line = CURRENT_VIEW->focus_line;
}
pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
y = CURRENT_VIEW->current_row;
}
else
{
display_error(68,(CHARTYPE *)"",FALSE);
TRACE_RETURN();
return(RC_TARGET_NOT_FOUND);
}
if (match_col >= CURRENT_VIEW->verify_col-1
&& match_col <= (CURRENT_SCREEN.cols[WINDOW_FILEAREA]+(CURRENT_VIEW->verify_col-1))-1)
x = match_col-(CURRENT_VIEW->verify_col-1);
else
{
x = CURRENT_SCREEN.cols[WINDOW_FILEAREA] / 2;
CURRENT_VIEW->verify_col = max(1,match_col-(short)x);
x = (match_col-(CURRENT_VIEW->verify_col-1));
}
build_screen(current_screen);
display_screen(current_screen);
wmove(CURRENT_WINDOW,y,x);
TRACE_RETURN();
return(RC_OK);
}
/*man-start*********************************************************************
COMMAND
cmsg - display text on command line
SYNTAX
CMSG [text]
DESCRIPTION
The CMSG command, primarily used in macros, displays 'text' on the
command line.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
SEE ALSO
<EMSG>, <MSG>
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Cmsg(CHARTYPE *params)
#else
short Cmsg(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
/*--------------------------- processing ------------------------------*/
TRACE_FUNCTION("comm1.c: Cmsg");
memset(cmd_rec,' ',max_line_length);
cmd_rec_len = strlen((DEFCHAR *)params);
memcpy(cmd_rec,params,cmd_rec_len);
if (curses_started
&& CURRENT_WINDOW_COMMAND != (WINDOW *)NULL)
{
wmove(CURRENT_WINDOW_COMMAND,0,0);
my_wclrtoeol(CURRENT_WINDOW_COMMAND);
put_string(CURRENT_WINDOW_COMMAND,0,0,cmd_rec,cmd_rec_len);
clear_command = FALSE;
}
TRACE_RETURN();
return(RC_OK);
}
/*man-start*********************************************************************
COMMAND
command - execute a command without translation
SYNTAX
COMMAND command [options]
DESCRIPTION
The COMMAND command executes the specified 'command' without
synonym or macro translation. THE does not attempt to execute
the command as a <macro> even if <SET IMPMACRO> is ON. The
command will be passed to the operating system if <SET IMPOS>
is ON.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short THECommand(CHARTYPE *params)
#else
short THECommand(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short rc=RC_OK;
/*--------------------------- processing ------------------------------*/
TRACE_FUNCTION("comm1.c: THECommand");
rc = command_line(params,COMMAND_ONLY_TRUE);
TRACE_RETURN();
return(rc);
}
/*man-start*********************************************************************
COMMAND
compress - reduce spaces to tabs
SYNTAX
COMPress [target]
DESCRIPTION
The COMPRESS command reduces multiple occurrences of spaces and
replaces them with tab characters in the <'target'> lines.
The current tab columns (set by <SET TABS>) are used in
determining where tab characters will replaces spaces.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
SEE ALSO
<EXPAND>, <SET TABS>
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Compress(CHARTYPE *params)
#else
short Compress(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short rc=RC_OK;
/*--------------------------- processing ------------------------------*/
TRACE_FUNCTION("comm1.c: Compress");
rc = execute_expand_compress(params,FALSE,TRUE,TRUE,TRUE);
TRACE_RETURN();
return(rc);
}
/*man-start*********************************************************************
COMMAND
controlchar - allow control characters to be entered
SYNTAX
CONTROLChar
DESCRIPTION
The CONTROLCHAR command prompts the user to enter a control
character; an ASCII character between 1 and 31 inclusive.
COMPATIBILITY
XEDIT: N/A
KEDIT: N/A
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short ControlChar(CHARTYPE *params)
#else
short ControlChar(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
unsigned short y=0,x=0;
int key=0;
/*--------------------------- processing ------------------------------*/
TRACE_FUNCTION("comm1.c: ControlChar");
getyx(CURRENT_WINDOW,y,x);
/*---------------------------------------------------------------------*/
/* If in the MAIN window, this command can only be issued on a real */
/* line. */
/*---------------------------------------------------------------------*/
if (CURRENT_VIEW->current_window == WINDOW_FILEAREA)
{
if (CURRENT_SCREEN.sl[y].line_type != LINE_LINE)
{
display_error(38,(CHARTYPE *)"",FALSE);
TRACE_RETURN();
return(RC_INVALID_ENVIRON);
}
}
display_prompt((CHARTYPE *)"Press the character you require.");
wmove(CURRENT_WINDOW,y,x);
wrefresh(CURRENT_WINDOW);
while(1)
{
key = my_getch(CURRENT_WINDOW);
break;
}
clear_msgline(-1);
if (islower(key))
key = toupper(key);
if (key >= (int)'A' /* was '@' for ASCII 0, but Text() command fails */
&& key <= (int)'_')
{
TRACE_RETURN();
return((RAW_KEY*2)+(short)key-(short)'@');
}
display_error(69,(CHARTYPE *)"- must be between 'A' and '_'",FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
/*man-start*********************************************************************
COMMAND
copy - copies text from one position to another
SYNTAX
COPY target1 target2
COPY BLOCK [RESET]
DESCRIPTION
With the first form of the COPY command, text is copied from
'target1' to the line specified by 'target2'. Text can
only be copied within the same view of the file.
The second form of the COPY command copies text within the
currently marked block to the current cursor position.
The text can be in the same file or a different file.
COMPATIBILITY
XEDIT: COPY BLOCK not available.
KEDIT: Adds extra functionality with [RESET] option.
With the cursor in the marked block this command in KEDIT
acts like <DUPLICATE> BLOCK.
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Copy(CHARTYPE *params)
#else
short Copy(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
CHARTYPE reset_block=SOURCE_UNKNOWN;
short rc=RC_OK;
LINETYPE start_line=0L,end_line=0L,true_line=0L,lines_affected=0L;
VIEW_DETAILS *source_view=NULL,*dest_view=NULL;
TARGET target1,target2;
short target_type1=TARGET_NORMAL|TARGET_BLOCK_ANY|TARGET_ALL|TARGET_SPARE;
short target_type2=TARGET_NORMAL;
bool lines_based_on_scope=FALSE;
/*--------------------------- processing ------------------------------*/
TRACE_FUNCTION("comm1.c: Copy");
initialise_target(&target1);
initialise_target(&target2);
if ((rc = validate_target(params,&target1,target_type1,get_true_line(TRUE),TRUE,TRUE)) != RC_OK)
{
free_target(&target1);
TRACE_RETURN();
return(rc);
}
/*---------------------------------------------------------------------*/
/* If there is no second argument, the only valid target type for the */
/* first argument then is BLOCK. */
/*---------------------------------------------------------------------*/
if (target1.spare == (-1))
{
if (target1.rt[0].target_type != TARGET_BLOCK_ANY
&& target1.rt[0].target_type != TARGET_BLOCK_CURRENT)
{
free_target(&target1);
display_error(3,(CHARTYPE *)"",FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
else
reset_block = SOURCE_BLOCK;
}
else
{
if (equal((CHARTYPE *)"reset",strtrunc(target1.rt[target1.spare].string),5))
reset_block = SOURCE_BLOCK_RESET;
else
reset_block = SOURCE_COMMAND;
}
/*---------------------------------------------------------------------*/
/* Validate the arguments following the target... */
/*---------------------------------------------------------------------*/
switch(reset_block)
{
case SOURCE_BLOCK:
case SOURCE_BLOCK_RESET:
/*---------------------------------------------------------------------*/
/* For box blocks, call the appropriate function... */
/*---------------------------------------------------------------------*/
if (MARK_VIEW->mark_type != M_LINE)
{
free_target(&target1);
box_operations(BOX_C,reset_block,FALSE,' ');
TRACE_RETURN();
return(RC_OK);
}
source_view = MARK_VIEW;
dest_view = CURRENT_VIEW;
start_line = MARK_VIEW->mark_start_line;
end_line = MARK_VIEW->mark_end_line;
true_line = get_true_line(FALSE);
lines_based_on_scope = FALSE;
break;
default:
if ((rc = validate_target(target1.rt[target1.spare].string,&target2,target_type2,get_true_line(TRUE),TRUE,TRUE)) != RC_OK)
{
free_target(&target2);
TRACE_RETURN();
return(rc);
}
source_view = CURRENT_VIEW;
dest_view = CURRENT_VIEW;
#if 0
if (TOF(target1.true_line))
{
target1.true_line = 1L;
target1.num_lines--;
}
#endif
start_line = target1.true_line;
if (target1.num_lines < 0)
end_line = (target1.true_line + target1.num_lines) + 1L;
else
end_line = (target1.true_line + target1.num_lines) - 1L;
true_line = target2.true_line + target2.num_lines;
lines_based_on_scope = TRUE;
break;
}
free_target(&target1);
free_target(&target2);
/*---------------------------------------------------------------------*/
/* If the destination line for the copy is the *** Bottom of File *** */
/* line, then subtract 1 to ensure lines don't get copied below the */
/* *** Bottom of File *** line. */
/*---------------------------------------------------------------------*/
if (BOF(true_line))
true_line--;
post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
rc = rearrange_line_blocks(COMMAND_COPY,(CHARTYPE)reset_block,start_line,
end_line,true_line,1,source_view,dest_view,lines_based_on_scope,
&lines_affected);
TRACE_RETURN();
return(rc);
}
/*man-start*********************************************************************
COMMAND
coverlay - overlay text starting at the column pointer
SYNTAX
COVerlay text
DESCRIPTION
The COVERLAY command overlays the supplied 'text' onto the
characters following the column position.
Spaces in the 'text' do not destroy the existing characters.
An underscore character "_" in the 'text' places a space in the
corresponding character position. Therefore you cannot use the
COVERLAY command to place underscores in a line.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Coverlay(CHARTYPE *params)
#else
short Coverlay(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short rc=RC_OK;
/*--------------------------- processing ------------------------------*/
TRACE_FUNCTION("comm1.c: Coverlay");
rc = column_command(params,COLUMN_COVERLAY);
TRACE_RETURN();
return(rc);
}
/*man-start*********************************************************************
COMMAND
creplace - replace text starting at the column pointer
SYNTAX
CReplace text
DESCRIPTION
The CREPLACE command replaces the current characters after the
column pointer with the supplied 'text'.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Creplace(CHARTYPE *params)
#else
short Creplace(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short rc=RC_OK;
/*--------------------------- processing ------------------------------*/
TRACE_FUNCTION("comm1.c: Creplace");
rc = column_command(params,COLUMN_CREPLACE);
TRACE_RETURN();
return(rc);
}
/*man-start*********************************************************************
COMMAND
cursor - move cursor to specified position
SYNTAX
CURsor Column
CURsor Screen UP|DOWN|LEFT|RIGHT
CURsor Screen row [col]
CURsor [Escreen] UP|DOWN
CURsor [Escreen|Kedit] LEFT|RIGHT
CURsor [Escreen] row [col]
CURsor CUA UP|DOWN|LEFT|RIGHT
CURsor CMdline [n]
CURsor HOME [SAVE]
CURsor File line [col]
CURsor GOTO line col
CURsor Mouse
DESCRIPTION
The CURSOR command allows the user to specify where the cursor
is to be positioned.
CURSOR 'Column' moves the cursor to the current column of the
<focus line>.
CURSOR 'Screen' 'UP'|'DOWN'|'LEFT'|'RIGHT' moves the cursor in the
indicated direction one line or column. If the cursor is
positioned on the first or last line of the screen, the cursor
wraps to the first or last enterable line. If the cursor is
positioned on the left or right edges of the screen, the cursor
moves to the left or right edge of the screen on the same line.
CURSOR 'Screen' 'row' ['col'] is similar to CURSOR 'Escreen'
'row' ['col'], but all coordinates are relative the the top left
corner of the screen, not the top left corner of the
<filearea>. Hence, 1,1 would be an invalid cursor position because
it would result in the cursor being moved to the <idline>.
Specification of 'row' and/or 'col' outside the boundaries of the
logical window is regarded as an error.
CURSOR ['Escreen'] 'UP'|'DOWN'|'LEFT'|'RIGHT' is similar to CURSOR
'Screen' 'UP'|'DOWN'|'LEFT'|'RIGHT', except that where scrolling
of the window is possible, then scrolling will take place.
CURSOR ['Escreen'] 'row' ['col'] moves the cursor to the specified
'row'/'col' position within the <filearea>. The top left corner of
the <filearea> is 1,1.
'row' and 'col' may be specified as '=', which will default to the
current row and/or column position.
If 'row' or 'col' are greater than the maximum number of rows or
columns in the <filearea>, the cursor will move to the last
row/column available.
If the specified 'row' is a <reserved line>, <scale line> or <tab line>
an error will be displayed.
If the 'row' specified is above the <Top-of-File line> or below the
<Bottom-of-File line> the cursor will be placed on the closest
one of these lines.
CURSOR 'Kedit' 'LEFT'|'RIGHT' mimics the default behaviour of
CURL and CURR in KEDIT.
CURSOR 'CUA' 'UP'|'DOWN'|'LEFT'|'RIGHT' moves the cursor in the
indicated direction one line or column. The behaviour of the
cursor at the the end of a line and at the start of a line is
consistent with the Common User Access (CUA) definition.
CURSOR 'CMdline' moves the cursor to the indicated column of the
<command line>.
CURSOR 'HOME' moves the cursor to the first column of the <command line>
(if not on the command line), or to the last row/column of
the <filearea> if on the command line. With the ['SAVE'] option,
the cursor will move to the last row/column of the <filearea> or
<prefix area> (which ever was the last position) if on the
<command line>.
CURSOR 'File' moves the cursor to the line and column of the file.
If the line and/or column are not currently displayed, an error
message is displayed.
CURSOR 'GOTO' moves the cursor to the specified line and column
of the file, whether the row and column are currently displayed or
not. If the 'line' and 'col' are currently displayed, then this
command behaves just like CURSOR 'FIle'. If not, then the
<current line> will be changed to the specified <line>.
CURSOR 'Mouse' moves the cursor to the position where a mouse button
was last activated. This command is specific to THE.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible. Added GOTO option.
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Cursor(CHARTYPE *params)
#else
short Cursor(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
register short idx=0;
#define CUR_PARAMS 4
CHARTYPE *word[CUR_PARAMS+1];
CHARTYPE strip[CUR_PARAMS];
unsigned short num_params=0;
bool time_to_leave=FALSE;
short error_number=1;
CHARTYPE *error_message=(CHARTYPE *)"";
short colno=1;
short rc=RC_OK;
short state=CURSOR_START;
short row=0,col=0;
LINETYPE line=0L;
/*--------------------------- processing ------------------------------*/
TRACE_FUNCTION("comm1.c: Cursor");
strip[0]=STRIP_BOTH;
strip[1]=STRIP_BOTH;
strip[2]=STRIP_BOTH;
strip[3]=STRIP_BOTH;
num_params = param_split(params,word,CUR_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
if (num_params ==0)
{
display_error(3,(CHARTYPE *)"",FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
error_message = word[0];
state = CURSOR_START;
idx = 0;
while(1)
{
switch(state)
{
case CURSOR_START:
if (equal((CHARTYPE *)"escreen",word[idx],1))
{
state = CURSOR_ESCREEN;
idx++;
break;
}
if (equal((CHARTYPE *)"screen",word[idx],1))
{
state = CURSOR_SCREEN;
idx++;
break;
}
if (equal((CHARTYPE *)"cua",word[idx],3))
{
state = CURSOR_CUA;
idx++;
break;
}
if (equal((CHARTYPE *)"left",word[idx],4))
{
if (num_params > 1)
{
state = CURSOR_ERROR;
error_message = word[idx];
error_number = 1;
break;
}
rc = THEcursor_left( CURSOR_ESCREEN, FALSE );
time_to_leave = TRUE;
break;
}
if (equal((CHARTYPE *)"right",word[idx],5))
{
if (num_params > 1)
{
state = CURSOR_ERROR;
error_message = word[idx];
error_number = 1;
break;
}
rc = THEcursor_right( CURSOR_ESCREEN, FALSE );
time_to_leave = TRUE;
break;
}
if (equal((CHARTYPE *)"up",word[idx],2))
{
if (num_params > 1)
{
state = CURSOR_ERROR;
error_message = word[idx];
error_number = 1;
break;
}
rc = THEcursor_up( CURSOR_ESCREEN );
time_to_leave = TRUE;
break;
}
if (equal((CHARTYPE *)"down",word[idx],4))
{
if (num_params > 1)
{
state = CURSOR_ERROR;
error_message = word[idx];
error_number = 1;
break;
}
rc = THEcursor_down( CURSOR_ESCREEN );
time_to_leave = TRUE;
break;
}
if (equal((CHARTYPE *)"home",word[idx],4))
{
state = CURSOR_HOME;
idx++;
break;
}
if (equal((CHARTYPE *)"column",word[idx],1))
{
state = CURSOR_COLUMN;
idx++;
break;
}
if (equal((CHARTYPE *)"cmdline",word[idx],2))
{
state = CURSOR_CMDLINE;
idx++;
break;
}
if (equal((CHARTYPE *)"file",word[idx],1))
{
state = CURSOR_FILE;
idx++;
break;
}
if (equal((CHARTYPE *)"goto",word[idx],4))
{
state = CURSOR_GOTO;
idx++;
break;
}
if (equal((CHARTYPE *)"kedit",word[idx],1))
{
state = CURSOR_KEDIT;
idx++;
break;
}
if (equal((CHARTYPE *)"mouse",word[idx],1))
{
state = CURSOR_MOUSE;
idx++;
break;
}
state = CURSOR_ESCREEN;
break;
case CURSOR_HOME:
if (num_params > 2)
{
state = CURSOR_ERROR;
error_message = word[idx];
error_number = 1;
break;
}
if (num_params == 2
&& !equal((CHARTYPE *)"save",word[1],4))
{
state = CURSOR_ERROR;
error_number = 1;
error_message = word[idx];
break;
}
if (num_params == 2)
rc = THEcursor_home(TRUE);
else
rc = THEcursor_home(FALSE);
time_to_leave = TRUE;
break;
case CURSOR_COLUMN:
if (num_params != 1)
{
state = CURSOR_ERROR;
error_message = word[idx];
error_number = 1;
break;
}
rc = THEcursor_column();
time_to_leave = TRUE;
break;
case CURSOR_FILE:
if (num_params > 3)
{
state = CURSOR_ERROR;
error_message = (CHARTYPE *)"";
error_number = 2;
break;
}
if (num_params < 2)
{
state = CURSOR_ERROR;
error_message = (CHARTYPE *)"";
error_number = 3;
break;
}
if (!valid_positive_integer(word[1]))
{
state = CURSOR_ERROR;
error_message = word[1];
error_number = 4;
break;
}
line = atol((DEFCHAR *)word[1]);
if (num_params == 3)
{
if (!valid_positive_integer(word[2]))
{
state = CURSOR_ERROR;
error_message = word[2];
error_number = 4;
break;
}
col = atoi((DEFCHAR *)word[2]);
}
else
col = 0;
rc = THEcursor_file(TRUE,line,col);
time_to_leave = TRUE;
break;
case CURSOR_GOTO:
if (num_params > 3)
{
state = CURSOR_ERROR;
error_message = (CHARTYPE *)"";
error_number = 2;
break;
}
if (num_params < 3)
{
state = CURSOR_ERROR;
error_message = (CHARTYPE *)"";
error_number = 3;
break;
}
if (!valid_positive_integer(word[1]))
{
state = CURSOR_ERROR;
error_message = word[1];
error_number = 4;
break;
}
line = atol((DEFCHAR *)word[1]);
if (num_params == 3)
{
if (!valid_positive_integer(word[2]))
{
state = CURSOR_ERROR;
error_message = word[2];
error_number = 4;
break;
}
col = atoi((DEFCHAR *)word[2]);
}
else
col = 0;
rc = THEcursor_goto(line,col);
time_to_leave = TRUE;
break;
case CURSOR_MOUSE:
if (num_params != 1)
{
state = CURSOR_ERROR;
error_message = word[idx];
error_number = 1;
break;
}
rc = THEcursor_mouse();
time_to_leave = TRUE;
break;
case CURSOR_CMDLINE:
if (num_params > 2)
{
state = CURSOR_ERROR;
error_message = word[idx];
error_number = 1;
break;
}
if (num_params == 2)
{
colno = atoi((DEFCHAR *)word[idx]);
if (colno < 1)
{
state = CURSOR_ERROR;
error_message = word[idx];
error_number = 1;
break;
}
}
rc = THEcursor_cmdline(colno);
time_to_leave = TRUE;
break;
case CURSOR_SCREEN:
case CURSOR_ESCREEN:
case CURSOR_CUA:
if (equal((CHARTYPE *)"left",word[idx],4))
{
if (num_params > 2)
{
state = CURSOR_ERROR;
error_message = word[idx];
error_number = 1;
break;
}
rc = THEcursor_left( state , FALSE );
time_to_leave = TRUE;
break;
}
if (equal((CHARTYPE *)"right",word[idx],5))
{
if (num_params > 2)
{
state = CURSOR_ERROR;
error_message = word[idx];
error_number = 1;
break;
}
rc = THEcursor_right( state, FALSE );
time_to_leave = TRUE;
break;
}
if (equal((CHARTYPE *)"up",word[idx],2))
{
if (num_params > 2)
{
state = CURSOR_ERROR;
error_message = word[idx];
error_number = 1;
break;
}
rc = THEcursor_up( state );
time_to_leave = TRUE;
break;
}
if (equal((CHARTYPE *)"down",word[idx],4))
{
if (num_params > 2)
{
state = CURSOR_ERROR;
error_message = word[idx];
error_number = 1;
break;
}
rc = THEcursor_down( state );
time_to_leave = TRUE;
break;
}
/* validate numbers */
if (strcmp((DEFCHAR *)word[idx],EQUIVCHARstr) == 0)
row = 0;
else
{
if (!valid_positive_integer(word[idx]))
{
state = CURSOR_ERROR;
error_message = word[idx];
error_number = 4;
break;
}
row = atoi((DEFCHAR *)word[idx]);
if (row == 0)
{
state = CURSOR_ERROR;
error_message = word[idx];
error_number = 5;
break;
}
}
idx++;
if (strcmp((DEFCHAR *)word[idx],"") == 0)
{
if ( state == CURSOR_SCREEN )
col = 1;
else
col = (CURRENT_VIEW->prefix&PREFIX_LOCATION_MASK) == PREFIX_LEFT ? CURRENT_VIEW->prefix_width + 1 : 1;
}
else
{
if (strcmp((DEFCHAR *)word[idx],EQUIVCHARstr) == 0)
col = 0;
else
{
if (!valid_positive_integer(word[idx]))
{
state = CURSOR_ERROR;
error_message = word[idx];
error_number = 4;
break;
}
col = atoi((DEFCHAR *)word[idx]);
if (col == 0)
{
state = CURSOR_ERROR;
error_message = word[idx];
error_number = 5;
break;
}
}
}
rc = THEcursor_move(TRUE,TRUE<(state==CURSOR_ESCREEN)?FALSE:TRUE,row,col);
time_to_leave = TRUE;
break;
case CURSOR_KEDIT:
if (equal((CHARTYPE *)"left",word[idx],4))
{
if (num_params > 2)
{
state = CURSOR_ERROR;
error_message = word[idx];
error_number = 1;
break;
}
rc = THEcursor_left( CURSOR_ESCREEN, TRUE );
time_to_leave = TRUE;
break;
}
if (equal((CHARTYPE *)"right",word[idx],5))
{
if (num_params > 2)
{
state = CURSOR_ERROR;
error_message = word[idx];
error_number = 1;
break;
}
rc = THEcursor_right( CURSOR_ESCREEN, TRUE );
time_to_leave = TRUE;
break;
}
state = CURSOR_ERROR;
error_message = word[idx];
error_number = 1;
break;
case CURSOR_ERROR:
display_error(error_number,error_message,FALSE);
rc = RC_INVALID_OPERAND;
time_to_leave = TRUE;
break;
}
if (time_to_leave)
break;
}
TRACE_RETURN();
return(rc);
}
|