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
|
/***********************************************************************/
/* PREFIX.C - Prefix commands. */
/***********************************************************************/
/*
* 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: prefix.c,v 1.2 1999/07/31 06:05:05 mark Exp mark $";
#include <the.h>
#include <proto.h>
/*-------------------------- declarations -----------------------------*/
#ifdef HAVE_PROTO
static short parse_prefix_command(THE_PPC *,CHARTYPE *,CHARTYPE *);
static short invalidate_prefix(THE_PPC *);
static short prefix_makecurr(THE_PPC *,short,LINETYPE);
static short prefix_add(THE_PPC *,short,LINETYPE);
static short prefix_duplicate(THE_PPC *,short,LINETYPE);
static short prefix_copy(THE_PPC *,short,LINETYPE);
static short prefix_move(THE_PPC *,short,LINETYPE);
static short prefix_delete(THE_PPC *,short,LINETYPE);
static short prefix_shift_left(THE_PPC *,short,LINETYPE);
static short prefix_shift_right(THE_PPC *,short,LINETYPE);
static short prefix_tabline(THE_PPC *,short,LINETYPE);
static short prefix_scale(THE_PPC *,short,LINETYPE);
static short prefix_show(THE_PPC *,short,LINETYPE);
static short prefix_exclude(THE_PPC *,short,LINETYPE);
static short prefix_block_duplicate(THE_PPC *,short,LINETYPE);
static short prefix_block_copy(THE_PPC *,short,LINETYPE);
static short prefix_block_move(THE_PPC *,short,LINETYPE);
static short prefix_block_delete(THE_PPC *,short,LINETYPE);
static short prefix_block_shift_left(THE_PPC *,short,LINETYPE);
static short prefix_block_shift_right(THE_PPC *,short,LINETYPE);
static short prefix_block_exclude(THE_PPC *,short,LINETYPE);
static THE_PPC *find_bottom_ppc(THE_PPC *,short);
static THE_PPC *find_target_ppc(void);
static THE_PPC *calculate_target_line(void);
static short try_rexx_prefix_macro(THE_PPC *);
static CHARTYPE *substr(CHARTYPE *, CHARTYPE *, short, short);
static short post_prefix_add(THE_PPC *,short,LINETYPE);
#else
static short parse_prefix_command();
static short invalidate_prefix();
static short prefix_makecurr();
static short prefix_add();
static short prefix_duplicate();
static short prefix_copy();
static short prefix_move();
static short prefix_delete();
static short prefix_shift_left();
static short prefix_shift_right();
static short prefix_tabline();
static short prefix_scale();
static short prefix_show();
static short prefix_exclude();
static short prefix_block_duplicate();
static short prefix_block_copy();
static short prefix_block_move();
static short prefix_block_delete();
static short prefix_block_shift_left();
static short prefix_block_shift_right();
static short prefix_block_exclude();
static THE_PPC *find_bottom_ppc();
static THE_PPC *find_target_ppc();
static THE_PPC *calculate_target_line();
static short try_rexx_prefix_macro();
static CHARTYPE *substr();
static short post_prefix_add();
#endif
/*---------------------------------------------------------------------*/
/* The following two are to specify the first and last items in the */
/* linked list for prefix synonyms. */
/*---------------------------------------------------------------------*/
LINE *first_prefix_synonym=NULL;
LINE *last_prefix_synonym=NULL;
/*---------------------------------------------------------------------*/
#define THE_PPC_NO_TARGET (-1)
#define THE_PPC_NO_COMMAND (-2)
#define THE_PPC_TARGET_PREVIOUS 0
#define THE_PPC_TARGET_FOLLOWING 1
/* the above two defines correspond to the position in the pc[] array */
/* and should be changed if the position in pc[] array changes. */
#define NUMBER_PREFIX_COMMANDS 22
static PREFIX_COMMAND pc[NUMBER_PREFIX_COMMANDS] =
{
{(CHARTYPE *)"p",1,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,TRUE,FALSE,NULL,1L,FALSE,FALSE,0,NULL},
{(CHARTYPE *)"f",1,FALSE,FALSE,FALSE,FALSE,FALSE,TRUE,FALSE,FALSE,NULL,1L,FALSE,FALSE,0,NULL},
{(CHARTYPE *)"tabl",4,TRUE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,prefix_tabline,1L,FALSE,FALSE,0,NULL},
{(CHARTYPE *)"scale",5,TRUE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,prefix_scale,1L,FALSE,FALSE,0,NULL},
{(CHARTYPE *)"\"\"",2,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,prefix_block_duplicate,1L,FALSE,FALSE,40,NULL},
{(CHARTYPE *)"cc",2,TRUE,TRUE,FALSE,TRUE,TRUE,FALSE,FALSE,FALSE,prefix_block_copy,1L,FALSE,FALSE,30,NULL},
{(CHARTYPE *)"mm",2,TRUE,TRUE,FALSE,TRUE,TRUE,FALSE,FALSE,FALSE,prefix_block_move,1L,FALSE,FALSE,30,NULL},
{(CHARTYPE *)"dd",2,TRUE,TRUE,FALSE,TRUE,FALSE,FALSE,FALSE,FALSE,prefix_block_delete,1L,FALSE,FALSE,10,NULL},
{(CHARTYPE *)"xx",2,TRUE,TRUE,FALSE,TRUE,FALSE,FALSE,FALSE,TRUE,prefix_block_exclude,1L,FALSE,FALSE,30,NULL},
{(CHARTYPE *)"<<",2,TRUE,TRUE,FALSE,TRUE,FALSE,FALSE,FALSE,FALSE,prefix_block_shift_left,1L,FALSE,FALSE,30,NULL},
{(CHARTYPE *)">>",2,TRUE,TRUE,FALSE,TRUE,FALSE,FALSE,FALSE,FALSE,prefix_block_shift_right,1L,FALSE,FALSE,30,NULL},
{(CHARTYPE *)"\"",1,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,prefix_duplicate,1L,FALSE,FALSE,40,NULL},
{(CHARTYPE *)"c",1,TRUE,TRUE,TRUE,FALSE,TRUE,FALSE,FALSE,FALSE,prefix_copy,1L,FALSE,FALSE,30,NULL},
{(CHARTYPE *)"m",1,TRUE,TRUE,TRUE,FALSE,TRUE,FALSE,FALSE,FALSE,prefix_move,1L,FALSE,FALSE,30,NULL},
{(CHARTYPE *)"d",1,TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,prefix_delete,1L,FALSE,FALSE,10,NULL},
{(CHARTYPE *)"s",1,TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,TRUE,prefix_show,MAX_LONG,TRUE,TRUE,30,NULL},
{(CHARTYPE *)"x",1,TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,TRUE,prefix_exclude,1L,FALSE,FALSE,30,NULL},
{(CHARTYPE *)"<",1,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,prefix_shift_left,1L,FALSE,FALSE,30,NULL},
{(CHARTYPE *)">",1,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,prefix_shift_right,1L,FALSE,FALSE,30,NULL},
{(CHARTYPE *)"i",1,TRUE,TRUE,FALSE,FALSE,FALSE,TRUE,FALSE,FALSE,prefix_add,1L,FALSE,FALSE,60,post_prefix_add},
{(CHARTYPE *)"a",1,TRUE,TRUE,FALSE,FALSE,FALSE,TRUE,FALSE,FALSE,prefix_add,1L,FALSE,FALSE,60,post_prefix_add},
{(CHARTYPE *)"/",1,TRUE,TRUE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,prefix_makecurr,1L,FALSE,FALSE,50,NULL},
};
LINETYPE prefix_current_line;
bool in_prefix_macro=FALSE; /* indicate if processing prefix macro */
/***********************************************************************/
#ifdef HAVE_PROTO
short execute_prefix_commands(void)
#else
short execute_prefix_commands()
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short cmd_idx=0,rc=RC_OK;
CHARTYPE cmd[MAX_PREFIX_WIDTH+1];
CHARTYPE mult[MAX_PREFIX_WIDTH+1];
LINETYPE long_mult=0L;
short top_ppc=0,bot_ppc=0,target_ppc=0;
THE_PPC *curr_ppc=NULL;
TARGET target;
short target_type=TARGET_NORMAL;
unsigned short y=0,x=0;
int top_priority_idx=0;
/*--------------------------- processing ------------------------------*/
#ifdef THE_TRACE
trace_function("prefix.c: execute_prefix_commands");
#endif
post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
/*---------------------------------------------------------------------*/
/* Validate all pending prefix commands... */
/*---------------------------------------------------------------------*/
curr_ppc = CURRENT_FILE->first_ppc;
while(1)
{
if (curr_ppc == NULL)
break;
/*---------------------------------------------------------------------*/
/* If a set point command, validate the name. */
/*---------------------------------------------------------------------*/
if (*(curr_ppc->ppc_command) == '.')
{
if (isalpha(curr_ppc->ppc_command[1]))
{
if (execute_set_point(curr_ppc->ppc_command,curr_ppc->ppc_line_number,TRUE) != RC_OK)
{
invalidate_prefix(curr_ppc);
curr_ppc = curr_ppc->next;
continue;
}
clear_pending_prefix_command(curr_ppc,(LINE *)NULL);
curr_ppc = curr_ppc->next;
continue;
}
else
{
invalidate_prefix(curr_ppc);
curr_ppc = curr_ppc->next;
continue;
}
}
/*---------------------------------------------------------------------*/
/* If an invalid prefix command from last time, clear it. */
/*---------------------------------------------------------------------*/
if (*(curr_ppc->ppc_command) == '?')
{
clear_pending_prefix_command(curr_ppc,(LINE *)NULL);
curr_ppc = curr_ppc->next;
continue;
}
/*---------------------------------------------------------------------*/
/* To get here we have 'normal' prefix command. */
/*---------------------------------------------------------------------*/
if (rexx_support) /* if REXX support is in effect ... */
{
/*---------------------------------------------------------------------*/
/* first determine if the command is a prefix macro BEFORE looking for */
/* standard prefix commands. */
/*---------------------------------------------------------------------*/
rc = try_rexx_prefix_macro(curr_ppc);
/*---------------------------------------------------------------------*/
/* If at this point there are no more files in the ring; we assume that*/
/* this was caused by exitting the last file in the ring from a prefix */
/* macro, exit and ignore any more prefix commands. This is messy !!! */
/*---------------------------------------------------------------------*/
if (number_of_files == 0)
{
#ifdef THE_TRACE
trace_return();
#endif
return(RC_COMMAND_NO_FILES);
}
if (rc != RC_NOT_COMMAND)
{
curr_ppc = curr_ppc->next;
continue;
}
}
/*---------------------------------------------------------------------*/
/* if no prefix macro found for the prefix command, check to see if it */
/* is a standard prefix command. */
/*---------------------------------------------------------------------*/
if ((cmd_idx = parse_prefix_command(curr_ppc,cmd,mult)) == THE_PPC_NO_TARGET)
{
invalidate_prefix(curr_ppc);
curr_ppc = curr_ppc->next;
continue;
}
if (cmd_idx == THE_PPC_NO_COMMAND)
{
curr_ppc = curr_ppc->next;
continue;
}
/*---------------------------------------------------------------------*/
/* If running in read-only mode and the function selected is not valid */
/* display an error. */
/*---------------------------------------------------------------------*/
if (ISREADONLY(CURRENT_FILE)
&& !pc[cmd_idx].valid_in_readonly)
{
display_error(56,(CHARTYPE *)"",FALSE);
invalidate_prefix(curr_ppc);
continue;
}
/*---------------------------------------------------------------------*/
/* We now have a recognised command. We have to validate its parameters*/
/* and find any associated pending commands. */
/*---------------------------------------------------------------------*/
/*---------------------------------------------------------------------*/
/* Set the block_command flag for the current prefix command to the */
/* appropriate value for the prefix command. */
/*---------------------------------------------------------------------*/
curr_ppc->ppc_block_command = pc[cmd_idx].block_prefix_command;
/*---------------------------------------------------------------------*/
/* If the command does not allow parameters and there are parameters, */
/* error. */
/*---------------------------------------------------------------------*/
if (!pc[cmd_idx].multiples_allowed
&& strcmp((DEFCHAR *)mult,"") != 0)
{
invalidate_prefix(curr_ppc);
curr_ppc = curr_ppc->next;
continue;
}
/*---------------------------------------------------------------------*/
/* If the command does allow parameters and there are no parameters, */
/* set to default... */
/*---------------------------------------------------------------------*/
rc = RC_OK;
if (strcmp((DEFCHAR *)mult,"") == 0)
long_mult = pc[cmd_idx].default_target;
else
/*---------------------------------------------------------------------*/
/* ...otherwise validate the target supplied... */
/*---------------------------------------------------------------------*/
{
if (pc[cmd_idx].multiples_allowed)
{
if (pc[cmd_idx].full_target_allowed)
{
initialise_target(&target);
target.ignore_scope = pc[cmd_idx].ignore_scope;
if (pc[cmd_idx].use_last_not_in_scope /* S command */
&& mult[0] == '-')
rc = validate_target(mult,&target,target_type,find_last_not_in_scope(CURRENT_VIEW,NULL,curr_ppc->ppc_line_number,DIRECTION_FORWARD),TRUE,TRUE);
else
rc = validate_target(mult,&target,target_type,curr_ppc->ppc_line_number,TRUE,TRUE);
if (target.num_lines == 0L)
rc = RC_INVALID_OPERAND;
long_mult = target.num_lines;
free_target(&target);
}
else
if (!valid_positive_integer(mult))
rc = RC_INVALID_OPERAND;
else
long_mult = atol((DEFCHAR *)mult);
}
}
/*---------------------------------------------------------------------*/
/* If the target is invalid or not found, invalidate the command. */
/*---------------------------------------------------------------------*/
if (rc != RC_OK)
{
invalidate_prefix(curr_ppc);
curr_ppc = curr_ppc->next;
continue;
}
curr_ppc->ppc_cmd_param = long_mult;
curr_ppc = curr_ppc->next;
}
/*---------------------------------------------------------------------*/
/* For each valid pending command for the current view, execute the */
/* command. */
/*---------------------------------------------------------------------*/
curr_ppc = CURRENT_FILE->first_ppc;
top_priority_idx=(-1);
while(curr_ppc != NULL)
{
top_ppc = bot_ppc = target_ppc = (-1);
/*---------------------------------------------------------------------*/
/* Execute the function associated with the prefix command... */
/*---------------------------------------------------------------------*/
cmd_idx = curr_ppc->ppc_cmd_idx;
long_mult = curr_ppc->ppc_cmd_param;
if (cmd_idx != (-1)
&& cmd_idx != (-2)
&& pc[cmd_idx].function != NULL)
rc = (*pc[cmd_idx].function)(curr_ppc,cmd_idx,long_mult);
curr_ppc = curr_ppc->next;
/*---------------------------------------------------------------------*/
/* Determine the prefix command with the highest priority and save it. */
/*---------------------------------------------------------------------*/
if (cmd_idx >= 0)
{
if (top_priority_idx == (-1))
top_priority_idx = cmd_idx;
else
{
if (pc[cmd_idx].priority > pc[top_priority_idx].priority)
top_priority_idx = cmd_idx;
}
}
}
/*---------------------------------------------------------------------*/
/* The "cleared" pending prefix commands now need to be deleted from */
/* the linked list... */
/*---------------------------------------------------------------------*/
curr_ppc = CURRENT_FILE->first_ppc;
while(curr_ppc != NULL)
{
if (curr_ppc->ppc_cmd_idx == (-1))
curr_ppc = delete_pending_prefix_command(curr_ppc,CURRENT_FILE,NULL);
else
curr_ppc = curr_ppc->next;
}
/*---------------------------------------------------------------------*/
/* Now that we are here, display the new version of the screen. */
/*---------------------------------------------------------------------*/
if (top_priority_idx != (-1))
{
if (pc[top_priority_idx].post_function != NULL)
rc = (*pc[top_priority_idx].post_function)(curr_ppc,cmd_idx,long_mult);
}
pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
build_screen(current_screen);
display_screen(current_screen);
if (CURRENT_VIEW->current_window != WINDOW_COMMAND)
{
if (curses_started)
getyx(CURRENT_WINDOW,y,x);
CURRENT_VIEW->focus_line = get_focus_line_in_view(current_screen,CURRENT_VIEW->focus_line,y);
y = get_row_for_focus_line(current_screen,CURRENT_VIEW->focus_line,CURRENT_VIEW->current_row);
if (curses_started)
wmove(CURRENT_WINDOW,y,x);
pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
}
#ifdef THE_TRACE
trace_return();
#endif
return(RC_OK);
}
/***********************************************************************/
#ifdef HAVE_PROTO
static short parse_prefix_command(THE_PPC *curr_ppc,CHARTYPE *cmd,CHARTYPE *mult)
#else
static short parse_prefix_command(curr_ppc,cmd,mult)
THE_PPC *curr_ppc;
CHARTYPE *cmd,*mult;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
register short i=0,j=0;
short len_pcmd=0;
CHARTYPE pcmd[MAX_PREFIX_WIDTH+1];
short pos=0,rc=RC_OK;
LINE *curr=NULL;
/*--------------------------- processing ------------------------------*/
#ifdef THE_TRACE
trace_function("prefix.c: parse_prefix_command");
#endif
/*---------------------------------------------------------------------*/
/* For each pending prefix command for the current view, execute the */
/* appropriate command. */
/*---------------------------------------------------------------------*/
rc = THE_PPC_NO_TARGET;
strcpy((DEFCHAR *)pcmd,(DEFCHAR *)curr_ppc->ppc_command); /* get our own copy to pull apart */
if (blank_field(pcmd)) /* if prefix command is blank, return */
{
#ifdef THE_TRACE
trace_return();
#endif
return(THE_PPC_NO_COMMAND);
}
len_pcmd = strlen((DEFCHAR *)pcmd);
/*---------------------------------------------------------------------*/
/* For each prefix synonym, determine if it exists somewhere in the */
/* entered prefix command. */
/*---------------------------------------------------------------------*/
curr = first_prefix_synonym;
while(1)
{
if (curr == NULL)
break;
pos = memfind(pcmd,curr->name,len_pcmd,strlen((DEFCHAR *)curr->name),TRUE,FALSE,' ',' ');
if (pos == (-1))
{
curr = curr->next;
continue;
}
/*---------------------------------------------------------------------*/
/* Now that a match on synonym is made, determine the original prefix */
/* command associated with that synonym... */
/*---------------------------------------------------------------------*/
for (i=0;i<NUMBER_PREFIX_COMMANDS;i++)
{
if (strcmp((DEFCHAR *)pc[i].cmd,(DEFCHAR *)curr->line) == 0)
{
strcpy((DEFCHAR *)cmd,(DEFCHAR *)pc[i].cmd);
for (j=0;j<strlen((DEFCHAR *)curr->name);j++)
*(pcmd+pos+j) = ' ';
strtrunc(pcmd);
strcpy((DEFCHAR *)mult,(DEFCHAR *)pcmd);
curr_ppc->ppc_cmd_idx = i;
#ifdef THE_TRACE
trace_return();
#endif
return(i);
}
}
/*---------------------------------------------------------------------*/
/* To get here we found a prefix synonym, but no matching original */
/* command, so return an error. */
/*---------------------------------------------------------------------*/
curr_ppc->ppc_cmd_idx = (-1);
#ifdef THE_TRACE
trace_return();
#endif
return(rc);
}
/*---------------------------------------------------------------------*/
/* For each valid prefix command, check to see if a valid command */
/* exists somewhere in the entered prefix command. */
/*---------------------------------------------------------------------*/
for (i=0;i<NUMBER_PREFIX_COMMANDS;i++)
{
pos = memfind(pcmd,pc[i].cmd,len_pcmd,pc[i].cmd_len,TRUE,FALSE,' ',' ');
if (pos == (-1))
continue;
strcpy((DEFCHAR *)cmd,(DEFCHAR *)pc[i].cmd);
for (j=0;j<pc[i].cmd_len;j++)
*(pcmd+pos+j) = ' ';
strtrunc(pcmd);
strcpy((DEFCHAR *)mult,(DEFCHAR *)pcmd);
rc = i;
/*---------------------------------------------------------------------*/
/* Set a flag in ppc[] array to indicate which command is present. */
/*---------------------------------------------------------------------*/
curr_ppc->ppc_cmd_idx = i;
break;
}
/*---------------------------------------------------------------------*/
/* If command not found, set a flag in ppc[] array to indicate command */
/* is invalid. */
/*---------------------------------------------------------------------*/
if (rc == THE_PPC_NO_TARGET)
curr_ppc->ppc_cmd_idx = (-1);
#ifdef THE_TRACE
trace_return();
#endif
return(rc);
}
/***********************************************************************/
#ifdef HAVE_PROTO
static short prefix_makecurr(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
#else
static short prefix_makecurr(curr_ppc,cmd_idx,number_lines)
THE_PPC *curr_ppc;
short cmd_idx;
LINETYPE number_lines;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
LINETYPE top_line = curr_ppc->ppc_line_number;
/*--------------------------- processing ------------------------------*/
clear_pending_prefix_command(curr_ppc,(LINE *)NULL);
execute_makecurr(top_line);
if (number_lines != 0L)
CURRENT_VIEW->current_column = (LENGTHTYPE)number_lines;
return(0);
}
/***********************************************************************/
#ifdef HAVE_PROTO
static short prefix_tabline(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
#else
static short prefix_tabline(curr_ppc,cmd_idx,number_lines)
THE_PPC *curr_ppc;
short cmd_idx;
LINETYPE number_lines;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
LINETYPE top_line = curr_ppc->ppc_line_number;
short tab_row = 0;
/*--------------------------- processing ------------------------------*/
if ((tab_row = get_row_for_focus_line(current_screen,top_line,(-1))) != (-1))
{
CURRENT_VIEW->tab_base = POSITION_TOP;
CURRENT_VIEW->tab_off = tab_row+1;
CURRENT_VIEW->tab_on = TRUE;
}
clear_pending_prefix_command(curr_ppc,(LINE *)NULL);
return(0);
}
/***********************************************************************/
#ifdef HAVE_PROTO
static short prefix_scale(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
#else
static short prefix_scale(curr_ppc,cmd_idx,number_lines)
THE_PPC *curr_ppc;
short cmd_idx;
LINETYPE number_lines;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
LINETYPE top_line = curr_ppc->ppc_line_number;
short scale_row = 0;
/*--------------------------- processing ------------------------------*/
if ((scale_row = get_row_for_focus_line(current_screen,top_line,(-1))) != (-1))
{
CURRENT_VIEW->scale_base = POSITION_TOP;
CURRENT_VIEW->scale_off = scale_row+1;
CURRENT_VIEW->scale_on = TRUE;
}
clear_pending_prefix_command(curr_ppc,(LINE *)NULL);
return(0);
}
/***********************************************************************/
#ifdef HAVE_PROTO
static short prefix_show(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
#else
static short prefix_show(curr_ppc,cmd_idx,number_lines)
THE_PPC *curr_ppc;
short cmd_idx;
LINETYPE number_lines;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
register int i=0;
short rc=RC_OK;
LINETYPE top_line = curr_ppc->ppc_line_number;
LINETYPE target_line=0L;
LINE *curr=NULL;
/*--------------------------- processing ------------------------------*/
clear_pending_prefix_command(curr_ppc,(LINE *)NULL);
if (TOF(top_line)
|| BOF(top_line))
return(-1);
/*---------------------------------------------------------------------*/
/* Find the current line from where we start showing... */
/*---------------------------------------------------------------------*/
curr = lll_find(CURRENT_FILE->first_line,CURRENT_FILE->last_line,top_line,CURRENT_FILE->number_lines);
/*---------------------------------------------------------------------*/
/* If the line that the show command was entered is in scope, then */
/* return with an error. */
/*---------------------------------------------------------------------*/
if (IN_SCOPE(CURRENT_VIEW,curr))
{
invalidate_prefix(curr_ppc);
return(-1);
}
/*---------------------------------------------------------------------*/
/* For a negative target, show the lines from the end of the excluded */
/* block. */
/*---------------------------------------------------------------------*/
if (number_lines < 0)
{
target_line = find_last_not_in_scope(CURRENT_VIEW,curr,top_line,DIRECTION_FORWARD);
curr = lll_find(CURRENT_FILE->first_line,CURRENT_FILE->last_line,target_line,CURRENT_FILE->number_lines);
for(i=0;i>number_lines;i--)
{
curr->select = CURRENT_VIEW->display_high;
curr = curr->prev;
if (curr->prev == NULL
|| IN_SCOPE(CURRENT_VIEW,curr))
break;
}
}
else
/*---------------------------------------------------------------------*/
/* For a positive target, show the lines from the start of the excluded*/
/* block. */
/*---------------------------------------------------------------------*/
{
for(i=0;i<number_lines;i++)
{
curr->select = CURRENT_VIEW->display_high;
curr = curr->next;
if (curr->next == NULL
|| IN_SCOPE(CURRENT_VIEW,curr))
break;
}
}
return(rc);
}
/***********************************************************************/
#ifdef HAVE_PROTO
static short prefix_exclude(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
#else
static short prefix_exclude(curr_ppc,cmd_idx,number_lines)
THE_PPC *curr_ppc;
short cmd_idx;
LINETYPE number_lines;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short rc=RC_OK;
LINETYPE top_line = curr_ppc->ppc_line_number;
LINE *curr=NULL;
short direction=DIRECTION_FORWARD;
/*--------------------------- processing ------------------------------*/
clear_pending_prefix_command(curr_ppc,(LINE *)NULL);
if (TOF(top_line)
|| BOF(top_line))
return(-1);
/*---------------------------------------------------------------------*/
/* If the high value of SET DISPLAY is 255, we can't exclude any lines */
/* so exit. */
/*---------------------------------------------------------------------*/
if (CURRENT_VIEW->display_high == 255)
return(rc);
if (number_lines < 0)
direction = DIRECTION_BACKWARD;
else
direction = DIRECTION_FORWARD;
/*---------------------------------------------------------------------*/
/* Find the current line from where we start excluding... */
/*---------------------------------------------------------------------*/
curr = lll_find(CURRENT_FILE->first_line,CURRENT_FILE->last_line,top_line,CURRENT_FILE->number_lines);
/*---------------------------------------------------------------------*/
/* For the number of lines affected, change the select level if the */
/* line is in scope. */
/*---------------------------------------------------------------------*/
while(number_lines != 0)
{
if (IN_SCOPE(CURRENT_VIEW,curr))
curr->select = (short)CURRENT_VIEW->display_high + 1;
if (direction == DIRECTION_FORWARD)
curr = curr->next;
else
curr = curr->prev;
number_lines -= direction;
}
/*---------------------------------------------------------------------*/
/* Determine if current line is now not in scope... */
/*---------------------------------------------------------------------*/
curr = lll_find(CURRENT_FILE->first_line,CURRENT_FILE->last_line,CURRENT_VIEW->current_line,CURRENT_FILE->number_lines);
if (!IN_SCOPE(CURRENT_VIEW,curr))
CURRENT_VIEW->current_line = find_next_in_scope(CURRENT_VIEW,curr,CURRENT_VIEW->current_line,DIRECTION_FORWARD);
return(rc);
}
/***********************************************************************/
#ifdef HAVE_PROTO
static short prefix_add(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
#else
static short prefix_add(curr_ppc,cmd_idx,number_lines)
THE_PPC *curr_ppc;
short cmd_idx;
LINETYPE number_lines;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short rc=(-1);
LINETYPE top_line = curr_ppc->ppc_line_number;
/*--------------------------- processing ------------------------------*/
if (top_line == CURRENT_FILE->number_lines+1)
top_line--;
clear_pending_prefix_command(curr_ppc,(LINE *)NULL);
rc = insert_new_line((CHARTYPE *)"",0,number_lines,
top_line,FALSE,FALSE,TRUE,CURRENT_VIEW->display_low,FALSE,FALSE);
return(rc);
}
/***********************************************************************/
#ifdef HAVE_PROTO
static short prefix_duplicate(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_occ)
#else
static short prefix_duplicate(curr_ppc,cmd_idx,number_occ)
THE_PPC *curr_ppc;
short cmd_idx;
LINETYPE number_occ;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short rc=(-1);
LINETYPE top_line = curr_ppc->ppc_line_number;
LINETYPE lines_affected=0L;
/*--------------------------- processing ------------------------------*/
clear_pending_prefix_command(curr_ppc,(LINE *)NULL);
if (top_line != 0L
&& top_line != CURRENT_FILE->number_lines+1)
rc = rearrange_line_blocks(COMMAND_DUPLICATE,SOURCE_PREFIX,top_line,
top_line,top_line,(short)number_occ,
CURRENT_VIEW,CURRENT_VIEW,TRUE,&lines_affected);
return(rc);
}
/***********************************************************************/
#ifdef HAVE_PROTO
static short prefix_copy(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
#else
static short prefix_copy(curr_ppc,cmd_idx,number_lines)
THE_PPC *curr_ppc;
short cmd_idx;
LINETYPE number_lines;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
LINETYPE bottom_line=0L,target_line=0L,lines_affected=0L;
LINETYPE top_line = curr_ppc->ppc_line_number;
THE_PPC *target_ppc=NULL;
short rc=(-1);
/*--------------------------- processing ------------------------------*/
if ((target_ppc = calculate_target_line()) == NULL)
return(rc);
target_line = target_ppc->ppc_line_number+target_ppc->ppc_cmd_param;
bottom_line = top_line + number_lines - ((number_lines < 0L) ? (-1L) : 1L);
clear_pending_prefix_command(curr_ppc,(LINE *)NULL);
if (top_line != 0L
&& top_line != CURRENT_FILE->number_lines+1)
rc = rearrange_line_blocks(COMMAND_COPY,SOURCE_PREFIX,top_line,bottom_line,
target_line,1,CURRENT_VIEW,CURRENT_VIEW,TRUE,
&lines_affected);
return(rc);
}
/***********************************************************************/
#ifdef HAVE_PROTO
static short prefix_move(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
#else
static short prefix_move(curr_ppc,cmd_idx,number_lines)
THE_PPC *curr_ppc;
short cmd_idx;
LINETYPE number_lines;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
LINETYPE bottom_line=0L,target_line=0L,lines_affected=0L;
LINETYPE top_line = curr_ppc->ppc_line_number;
THE_PPC *target_ppc=NULL;
short rc=(-1);
/*--------------------------- processing ------------------------------*/
if ((target_ppc = calculate_target_line()) == NULL)
return(rc);
target_line = target_ppc->ppc_line_number+target_ppc->ppc_cmd_param;
clear_pending_prefix_command(curr_ppc,(LINE *)NULL);
bottom_line = top_line + number_lines - ((number_lines < 0L) ? (-1L) : 1L);
if (top_line != 0L
&& top_line != CURRENT_FILE->number_lines+1)
{
if ((rc = rearrange_line_blocks(COMMAND_MOVE_COPY_SAME,SOURCE_PREFIX,
top_line,bottom_line,target_line,1,CURRENT_VIEW,CURRENT_VIEW,TRUE,&lines_affected)) != RC_OK)
return(rc);
if (target_line < top_line)
{
top_line += number_lines;
target_line += number_lines;
bottom_line += number_lines;
}
rc = rearrange_line_blocks(COMMAND_MOVE_DELETE_SAME,SOURCE_PREFIX,top_line,
bottom_line,target_line,1,CURRENT_VIEW,CURRENT_VIEW,TRUE,
&lines_affected);
}
return(rc);
}
/***********************************************************************/
#ifdef HAVE_PROTO
static short prefix_delete(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
#else
static short prefix_delete(curr_ppc,cmd_idx,number_lines)
THE_PPC *curr_ppc;
short cmd_idx;
LINETYPE number_lines;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short rc=(-1);
LINETYPE top_line = curr_ppc->ppc_line_number;
LINETYPE bottom_line=0L,target_line=0L,lines_affected=0L;
/*--------------------------- processing ------------------------------*/
clear_pending_prefix_command(curr_ppc,(LINE *)NULL);
if (!TOF(top_line)
&& !BOF(top_line))
{
bottom_line = top_line + number_lines - ((number_lines < 0L) ? (-1L) : 1L);
target_line = (number_lines < 0L) ? (bottom_line) : (top_line);
rc = rearrange_line_blocks(COMMAND_DELETE,SOURCE_PREFIX,top_line,bottom_line,
target_line,1,CURRENT_VIEW,CURRENT_VIEW,TRUE,
&lines_affected);
}
return(rc);
}
/***********************************************************************/
#ifdef HAVE_PROTO
static short prefix_shift_left(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_cols)
#else
static short prefix_shift_left(curr_ppc,cmd_idx,number_cols)
THE_PPC *curr_ppc;
short cmd_idx;
LINETYPE number_cols;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
LINETYPE top_line = curr_ppc->ppc_line_number;
/*--------------------------- processing ------------------------------*/
clear_pending_prefix_command(curr_ppc,(LINE *)NULL);
if (top_line != 0L
&& top_line != CURRENT_FILE->number_lines+1)
{
execute_shift_command(TRUE,(short)number_cols,top_line,1L,TRUE,TARGET_UNFOUND,FALSE);
}
return(0);
}
/***********************************************************************/
#ifdef HAVE_PROTO
static short prefix_shift_right(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_cols)
#else
static short prefix_shift_right(curr_ppc,cmd_idx,number_cols)
THE_PPC *curr_ppc;
short cmd_idx;
LINETYPE number_cols;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
LINETYPE start_line = curr_ppc->ppc_line_number;
/*--------------------------- processing ------------------------------*/
clear_pending_prefix_command(curr_ppc,(LINE *)NULL);
if (start_line != 0L
&& start_line != CURRENT_FILE->number_lines+1)
{
execute_shift_command(FALSE,(short)number_cols,start_line,1L,TRUE,TARGET_UNFOUND,FALSE);
}
return(0);
}
/***********************************************************************/
#ifdef HAVE_PROTO
static short prefix_block_duplicate(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_occ)
#else
static short prefix_block_duplicate(curr_ppc,cmd_idx,number_occ)
THE_PPC *curr_ppc;
short cmd_idx;
LINETYPE number_occ;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short rc=(-1);
LINETYPE top_line=0L,bottom_line=0L,lines_affected=0L;
THE_PPC *bottom_ppc=NULL;
/*--------------------------- processing ------------------------------*/
if ((bottom_ppc = find_bottom_ppc(curr_ppc,cmd_idx)) == NULL)
return(rc);
top_line = min(curr_ppc->ppc_line_number,bottom_ppc->ppc_line_number);
bottom_line = max(curr_ppc->ppc_line_number,bottom_ppc->ppc_line_number);
top_line = (top_line == 0L) ? 1L : top_line;
bottom_line = (bottom_line == CURRENT_FILE->number_lines+1L) ? bottom_line-1L : bottom_line;
clear_pending_prefix_command(curr_ppc,(LINE *)NULL);
clear_pending_prefix_command(bottom_ppc,(LINE *)NULL);
rc = rearrange_line_blocks(COMMAND_DUPLICATE,SOURCE_PREFIX,top_line,bottom_line,
bottom_line,(short)number_occ,CURRENT_VIEW,CURRENT_VIEW,FALSE,
&lines_affected);
return(rc);
}
/***********************************************************************/
#ifdef HAVE_PROTO
static short prefix_block_copy(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
#else
static short prefix_block_copy(curr_ppc,cmd_idx,number_lines)
THE_PPC *curr_ppc;
short cmd_idx;
LINETYPE number_lines;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short rc=(-1);
LINETYPE top_line=0L,bottom_line=0L,target_line=0L,lines_affected=0L;
THE_PPC *bottom_ppc=NULL;
THE_PPC *target_ppc=NULL;
/*--------------------------- processing ------------------------------*/
if ((bottom_ppc = find_bottom_ppc(curr_ppc,cmd_idx)) == NULL)
return(rc);
if ((target_ppc = calculate_target_line()) == NULL)
return(rc);
target_line = target_ppc->ppc_line_number+target_ppc->ppc_cmd_param;
top_line = min(curr_ppc->ppc_line_number,bottom_ppc->ppc_line_number);
bottom_line = max(curr_ppc->ppc_line_number,bottom_ppc->ppc_line_number);
top_line = (top_line == 0L) ? 1L : top_line;
bottom_line = (bottom_line == CURRENT_FILE->number_lines+1L) ? bottom_line-1L : bottom_line;
clear_pending_prefix_command(curr_ppc,(LINE *)NULL);
clear_pending_prefix_command(bottom_ppc,(LINE *)NULL);
rc = rearrange_line_blocks(COMMAND_COPY,SOURCE_PREFIX,top_line,bottom_line,
target_line,1,CURRENT_VIEW,CURRENT_VIEW,FALSE,
&lines_affected);
return(rc);
}
/***********************************************************************/
#ifdef HAVE_PROTO
static short prefix_block_move(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
#else
static short prefix_block_move(curr_ppc,cmd_idx,number_lines)
THE_PPC *curr_ppc;
short cmd_idx;
LINETYPE number_lines;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short rc=(-1);
LINETYPE top_line=0L,bottom_line=0L,target_line=0L,num_lines=0L,lines_affected=0L;
THE_PPC *bottom_ppc=NULL;
THE_PPC *target_ppc=NULL;
/*--------------------------- processing ------------------------------*/
if ((bottom_ppc = find_bottom_ppc(curr_ppc,cmd_idx)) == NULL)
return(rc);
if ((target_ppc = calculate_target_line()) == NULL)
return(rc);
target_line = target_ppc->ppc_line_number+target_ppc->ppc_cmd_param;
top_line = min(curr_ppc->ppc_line_number,bottom_ppc->ppc_line_number);
bottom_line = max(curr_ppc->ppc_line_number,bottom_ppc->ppc_line_number);
top_line = (top_line == 0L) ? 1L : top_line;
bottom_line = (bottom_line == CURRENT_FILE->number_lines+1L) ? bottom_line-1L : bottom_line;
clear_pending_prefix_command(curr_ppc,(LINE *)NULL);
clear_pending_prefix_command(bottom_ppc,(LINE *)NULL);
if ((rc = rearrange_line_blocks(COMMAND_MOVE_COPY_SAME,SOURCE_PREFIX,
top_line,bottom_line,target_line,1,CURRENT_VIEW,CURRENT_VIEW,FALSE,&lines_affected)) != RC_OK)
return(rc);
if (target_line < top_line)
{
num_lines = bottom_line - top_line + 1L;
top_line += num_lines;
bottom_line += num_lines;
target_line += num_lines;
}
rc = rearrange_line_blocks(COMMAND_MOVE_DELETE_SAME,SOURCE_PREFIX,top_line,bottom_line,
target_line,1,CURRENT_VIEW,CURRENT_VIEW,FALSE,
&lines_affected);
return(rc);
}
/***********************************************************************/
#ifdef HAVE_PROTO
static short prefix_block_delete(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
#else
static short prefix_block_delete(curr_ppc,cmd_idx,number_lines)
THE_PPC *curr_ppc;
short cmd_idx;
LINETYPE number_lines;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short rc=(-1);
LINETYPE top_line=0L,bottom_line=0L,lines_affected=0L;
THE_PPC *bottom_ppc=NULL;
/*--------------------------- processing ------------------------------*/
if ((bottom_ppc = find_bottom_ppc(curr_ppc,cmd_idx)) == NULL)
return(rc);
top_line = min(curr_ppc->ppc_line_number,bottom_ppc->ppc_line_number);
bottom_line = max(curr_ppc->ppc_line_number,bottom_ppc->ppc_line_number);
top_line = (top_line == 0L) ? 1L : top_line;
bottom_line = (bottom_line == CURRENT_FILE->number_lines+1L) ? bottom_line-1L : bottom_line;
clear_pending_prefix_command(curr_ppc,(LINE *)NULL);
clear_pending_prefix_command(bottom_ppc,(LINE *)NULL);
rc = rearrange_line_blocks(COMMAND_DELETE,SOURCE_PREFIX,top_line,bottom_line,
bottom_line,1,CURRENT_VIEW,CURRENT_VIEW,FALSE,
&lines_affected);
return(rc);
}
/***********************************************************************/
#ifdef HAVE_PROTO
static short prefix_block_shift_left(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_cols)
#else
static short prefix_block_shift_left(curr_ppc,cmd_idx,number_cols)
THE_PPC *curr_ppc;
short cmd_idx;
LINETYPE number_cols;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
LINETYPE top_line=0L,bottom_line=0L;
THE_PPC *bottom_ppc=NULL;
/*--------------------------- processing ------------------------------*/
if ((bottom_ppc = find_bottom_ppc(curr_ppc,cmd_idx)) == NULL)
return(-1);
top_line = min(curr_ppc->ppc_line_number,bottom_ppc->ppc_line_number);
bottom_line = max(curr_ppc->ppc_line_number,bottom_ppc->ppc_line_number);
top_line = (top_line == 0L) ? 1L : top_line;
bottom_line = (bottom_line == CURRENT_FILE->number_lines+1L) ? bottom_line-1L : bottom_line;
clear_pending_prefix_command(curr_ppc,(LINE *)NULL);
clear_pending_prefix_command(bottom_ppc,(LINE *)NULL);
execute_shift_command(TRUE,(short)number_cols,top_line,bottom_line-top_line+1L,FALSE,TARGET_UNFOUND,FALSE);
return(0);
}
/***********************************************************************/
#ifdef HAVE_PROTO
static short prefix_block_shift_right(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_cols)
#else
static short prefix_block_shift_right(curr_ppc,cmd_idx,number_cols)
THE_PPC *curr_ppc;
short cmd_idx;
LINETYPE number_cols;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
LINETYPE top_line=0L,bottom_line=0L;
THE_PPC *bottom_ppc=NULL;
/*--------------------------- processing ------------------------------*/
if ((bottom_ppc = find_bottom_ppc(curr_ppc,cmd_idx)) == NULL)
return(-1);
top_line = min(curr_ppc->ppc_line_number,bottom_ppc->ppc_line_number);
bottom_line = max(curr_ppc->ppc_line_number,bottom_ppc->ppc_line_number);
top_line = (top_line == 0L) ? 1L : top_line;
bottom_line = (bottom_line == CURRENT_FILE->number_lines+1L) ? bottom_line-1L : bottom_line;
clear_pending_prefix_command(curr_ppc,(LINE *)NULL);
clear_pending_prefix_command(bottom_ppc,(LINE *)NULL);
execute_shift_command(FALSE,(short)number_cols,top_line,bottom_line-top_line+1L,FALSE,TARGET_UNFOUND,FALSE);
return(0);
}
/***********************************************************************/
#ifdef HAVE_PROTO
static short prefix_block_exclude(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
#else
static short prefix_block_exclude(curr_ppc,cmd_idx,number_lines)
THE_PPC *curr_ppc;
short cmd_idx;
LINETYPE number_lines;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short rc=RC_OK;
LINETYPE top_line=0L,bottom_line=0L,num_lines=0L,i=0L;
LINE *curr=NULL;
THE_PPC *bottom_ppc=NULL;
/*--------------------------- processing ------------------------------*/
if ((bottom_ppc = find_bottom_ppc(curr_ppc,cmd_idx)) == NULL)
return(-1);
top_line = min(curr_ppc->ppc_line_number,bottom_ppc->ppc_line_number);
bottom_line = max(curr_ppc->ppc_line_number,bottom_ppc->ppc_line_number);
top_line = (top_line == 0L) ? 1L : top_line;
bottom_line = (bottom_line == CURRENT_FILE->number_lines+1L) ? bottom_line-1L : bottom_line;
num_lines = bottom_line-top_line+1L;
clear_pending_prefix_command(curr_ppc,(LINE *)NULL);
clear_pending_prefix_command(bottom_ppc,(LINE *)NULL);
/*---------------------------------------------------------------------*/
/* If the high value of SET DISPLAY is 255, we can't exclude any lines */
/* so exit. */
/*---------------------------------------------------------------------*/
if (CURRENT_VIEW->display_high == 255)
return(rc);
/*---------------------------------------------------------------------*/
/* Find the current line from where we start excluding... */
/*---------------------------------------------------------------------*/
curr = lll_find(CURRENT_FILE->first_line,CURRENT_FILE->last_line,top_line,CURRENT_FILE->number_lines);
/*---------------------------------------------------------------------*/
/* For the number of lines affected, change the select level if the */
/* line is in scope. */
/*---------------------------------------------------------------------*/
for (i=0;i<num_lines;i++)
{
if (IN_SCOPE(CURRENT_VIEW,curr))
curr->select = (short)CURRENT_VIEW->display_high + 1;
curr = curr->next;
}
/*---------------------------------------------------------------------*/
/* Determine if current line is now not in scope... */
/*---------------------------------------------------------------------*/
curr = lll_find(CURRENT_FILE->first_line,CURRENT_FILE->last_line,CURRENT_VIEW->current_line,CURRENT_FILE->number_lines);
if (!IN_SCOPE(CURRENT_VIEW,curr))
CURRENT_VIEW->current_line = find_next_in_scope(CURRENT_VIEW,curr,CURRENT_VIEW->current_line,DIRECTION_FORWARD);
return(rc);
}
/***********************************************************************/
#ifdef HAVE_PROTO
static short invalidate_prefix(THE_PPC *curr_ppc)
#else
static short invalidate_prefix(curr_ppc)
THE_PPC *curr_ppc;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short len=0;
/*--------------------------- processing ------------------------------*/
if (*(curr_ppc->ppc_command) != '?')
{
len = strlen((DEFCHAR *)curr_ppc->ppc_command);
meminschr(curr_ppc->ppc_command,'?',0,CURRENT_VIEW->prefix_width,len);
*(curr_ppc->ppc_command+len+1) = '\0';
}
/*---------------------------------------------------------------------*/
/* ensure that there is no chance that a 'real' prefix command can be */
/* executed. */
/*---------------------------------------------------------------------*/
curr_ppc->ppc_cmd_idx = (-2);
return(RC_OK);
}
/***********************************************************************/
#ifdef HAVE_PROTO
void clear_pending_prefix_command(THE_PPC *curr_ppc,LINE *curr_line)
#else
void clear_pending_prefix_command(curr_ppc,curr_line)
THE_PPC *curr_ppc;
LINE *curr_line;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
LINE *curr=curr_line;
/*--------------------------- processing ------------------------------*/
/*---------------------------------------------------------------------*/
/* If curr_ppc == NULL, then do nothing. */
/*---------------------------------------------------------------------*/
if (curr_ppc == NULL)
return;
if (curr == (LINE *)NULL)
curr = lll_find(CURRENT_FILE->first_line,CURRENT_FILE->last_line,curr_ppc->ppc_line_number,CURRENT_FILE->number_lines);
curr->pre = NULL;
curr_ppc->ppc_cmd_idx = (-1);
curr_ppc->ppc_block_command = FALSE;
curr_ppc->ppc_shadow_line = FALSE;
return;
}
/***********************************************************************/
#ifdef HAVE_PROTO
THE_PPC *delete_pending_prefix_command(THE_PPC *curr_ppc,FILE_DETAILS *curr_file,LINE *curr_line)
#else
THE_PPC *delete_pending_prefix_command(curr_ppc,curr_file,curr_line)
THE_PPC *curr_ppc;
FILE_DETAILS *curr_file;
LINE *curr_line;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
LINE *curr=curr_line;
THE_PPC *return_ppc=NULL;
/*--------------------------- processing ------------------------------*/
/*---------------------------------------------------------------------*/
/* If curr_ppc == NULL, then do nothing. */
/*---------------------------------------------------------------------*/
if (curr_ppc == NULL)
return(NULL);
if (curr == (LINE *)NULL)
curr = lll_find(curr_file->first_line,curr_file->last_line,curr_ppc->ppc_line_number,curr_file->number_lines);
curr->pre = NULL;
return_ppc = pll_del(&(curr_file->first_ppc),&(curr_file->last_ppc),curr_ppc,DIRECTION_FORWARD);
return(return_ppc);
}
/***********************************************************************/
#ifdef HAVE_PROTO
static THE_PPC *find_bottom_ppc(THE_PPC *curr_ppc,short top_cmd_idx)
#else
static THE_PPC *find_bottom_ppc(curr_ppc,top_cmd_idx)
THE_PPC *curr_ppc;
short top_cmd_idx;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
THE_PPC *bottom_ppc=curr_ppc;
/*--------------------------- processing ------------------------------*/
while(bottom_ppc != NULL)
{
if (bottom_ppc != curr_ppc)
{
if (top_cmd_idx == bottom_ppc->ppc_cmd_idx)
return(bottom_ppc);
}
bottom_ppc = bottom_ppc->next;
}
return(NULL);
}
/***********************************************************************/
#ifdef HAVE_PROTO
static THE_PPC *find_target_ppc(void)
#else
static THE_PPC *find_target_ppc()
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
THE_PPC *target_ppc=NULL;
/*--------------------------- processing ------------------------------*/
target_ppc = CURRENT_FILE->first_ppc;
while(target_ppc != NULL)
{
if (target_ppc->ppc_cmd_idx == THE_PPC_TARGET_PREVIOUS
|| target_ppc->ppc_cmd_idx == THE_PPC_TARGET_FOLLOWING)
return(target_ppc);
target_ppc = target_ppc->next;
}
return(NULL);
}
/***********************************************************************/
#ifdef HAVE_PROTO
static THE_PPC *calculate_target_line(void)
#else
static THE_PPC *calculate_target_line()
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
THE_PPC *target_ppc=NULL;
/*--------------------------- processing ------------------------------*/
if ((target_ppc = find_target_ppc()) == NULL)
return(NULL);
target_ppc->ppc_cmd_param = 0L;
/*---------------------------------------------------------------------*/
/* If the target line is NOT top of file line and the target type is */
/* PREVIOUS, subtract 1 from the target line. */
/*---------------------------------------------------------------------*/
if (target_ppc->ppc_cmd_idx == THE_PPC_TARGET_PREVIOUS
&& !TOF(target_ppc->ppc_line_number))
target_ppc->ppc_cmd_param = (-1);
/*---------------------------------------------------------------------*/
/* If the target line is the bottom of file and the target type is */
/* FOLLOWING, sutract 1 from the target line. */
/*---------------------------------------------------------------------*/
if (target_ppc->ppc_cmd_idx == THE_PPC_TARGET_FOLLOWING
&& BOF(target_ppc->ppc_line_number))
target_ppc->ppc_cmd_param = (-1);
clear_pending_prefix_command(target_ppc,(LINE *)NULL);
return(target_ppc);
}
/***********************************************************************/
#ifdef HAVE_PROTO
static short try_rexx_prefix_macro(THE_PPC *curr_ppc)
#else
static short try_rexx_prefix_macro(curr_ppc)
THE_PPC *curr_ppc;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short ctr=0, parm_length=0, pmacro_rc=0, errnum = 0 ;
bool found_left=FALSE, found_right=FALSE;
LINETYPE line_number=0L;
CHARTYPE pm_parms[(MAX_PREFIX_WIDTH*4)+1], t_area[MAX_PREFIX_WIDTH+1],
parms[MAX_PREFIX_WIDTH+1], tmpstr[MAX_PREFIX_WIDTH+1],
orig_cmd[MAX_PREFIX_WIDTH+1];
short macrorc=0;
/*--------------------------- processing ------------------------------*/
strcpy((DEFCHAR *)orig_cmd,(DEFCHAR *)curr_ppc->ppc_command);
found_right = FALSE;
found_left = FALSE;
/*---------------------------------------------------------------------*/
/* Scan 'orig_cmd' from right to left looking for an embedded macro */
/* file name. */
/*---------------------------------------------------------------------*/
for (ctr = strlen((DEFCHAR *)orig_cmd); ctr >= 0 && !found_right; ctr--)
{
substr(&tmpstr[0], orig_cmd, 1, ctr);
strcpy((DEFCHAR *)t_area,(DEFCHAR *)tmpstr);
/*---------------------------------------------------------------------*/
/* First check if the prefix command is a synonym. */
/*---------------------------------------------------------------------*/
/* check for prefix synonym, if so use the macro name not the synonym */
get_valid_macro_file_name(find_prefix_synonym(t_area),temp_cmd,macro_suffix,&errnum);
if (errnum == 0)
found_right = TRUE;
}
/*---------------------------------------------------------------------*/
/* No valid macro file name found ? */
/* */
/* Scan 'temp_cmd' from left to right looking for an embedded macro */
/* file name. */
/*---------------------------------------------------------------------*/
if (!found_right)
for ( ctr = 0; ctr <= strlen((DEFCHAR *)orig_cmd) && !found_left; ctr++)
{
substr(&tmpstr[0], orig_cmd, ctr + 1, strlen((DEFCHAR *)temp_cmd) - ctr);
strcpy((DEFCHAR *)t_area,(DEFCHAR *)tmpstr);
/*---------------------------------------------------------------------*/
/* First check if the prefix command is a synonym. */
/*---------------------------------------------------------------------*/
/* check for prefix synonym, if so use the macro name not the synonym */
get_valid_macro_file_name(find_prefix_synonym(t_area),temp_cmd,macro_suffix,&errnum);
if (errnum == 0)
found_left = TRUE;
}
/*---------------------------------------------------------------------*/
/* We have a prefix macro... */
/*---------------------------------------------------------------------*/
if (found_right || found_left)
{
parm_length = strlen((DEFCHAR *)orig_cmd) - strlen((DEFCHAR *)t_area);
if (found_right)
substr(&tmpstr[0],orig_cmd,strlen((DEFCHAR *)t_area) + 1,parm_length);
else
substr(&tmpstr[0],orig_cmd,1,parm_length);
strcpy((DEFCHAR *)parms,(DEFCHAR *)tmpstr);
line_number = curr_ppc->ppc_line_number;
/*---------------------------------------------------------------------*/
/* If the prefix command was entered on a shadow line, pass this to */
/* the prefix macro... */
/*---------------------------------------------------------------------*/
if (curr_ppc->ppc_shadow_line)
sprintf((DEFCHAR *)pm_parms," PREFIX %s SHADOW %ld %s",t_area,line_number,parms);
else
sprintf((DEFCHAR *)pm_parms," PREFIX %s SET %ld %s",t_area,line_number,parms);
strcat((DEFCHAR *)temp_cmd,(DEFCHAR *)pm_parms); /* add on the parameter list */
prefix_current_line = line_number;
in_prefix_macro = TRUE;
/*---------------------------------------------------------------------*/
/* Go and execute the prefix macro. */
/*---------------------------------------------------------------------*/
pmacro_rc = execute_macro(temp_cmd,TRUE,¯orc);
in_prefix_macro = FALSE;
}
else
pmacro_rc = RC_NOT_COMMAND;
return(pmacro_rc);
}
/***********************************************************************/
#ifdef HAVE_PROTO
static CHARTYPE *substr(CHARTYPE *temp_string,CHARTYPE *string,short start,short length)
#else
static CHARTYPE *substr(temp_string, string, start, length)
CHARTYPE *temp_string, *string;
short start, length;
#endif
/***********************************************************************/
/* This function is like the REXX SUBSTR function, it returns a */
/* pointer to a string containing the result. */
/* Note: The address of the beginning of a blank string is passed to be*/
/* modified by address: substr(&tmpstr[0],<string>,<start>,<length>); */
/* ( In this case, the result is contained in 'tmpstr' :-) */
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
register int i=0, target_idx = 0;
/*--------------------------- processing ------------------------------*/
for (i = start - 1; target_idx <= length - 1; i++)
temp_string[target_idx++] = string[i];
temp_string[target_idx] = '\0'; /*MH*/
return(temp_string);
}
/***********************************************************************/
#ifdef HAVE_PROTO
void add_prefix_command(LINE *curr,LINETYPE line_number,bool block_command)
#else
void add_prefix_command(curr,line_number,block_command)
LINE *curr;
LINETYPE line_number;
bool block_command;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
register short i=0;
CHARTYPE temp_prefix_array[MAX_PREFIX_WIDTH+1];
THE_PPC *curr_ppc=NULL;
bool redisplay_screen=FALSE;
/*--------------------------- processing ------------------------------*/
#ifdef THE_TRACE
trace_function("prefix.c: add_prefix_command");
#endif
prefix_changed = FALSE;
/*---------------------------------------------------------------------*/
/* Copy the contexts of the prefix record area into a temporary area. */
/*---------------------------------------------------------------------*/
for (i=0;i<pre_rec_len;i++)
temp_prefix_array[i] = pre_rec[i];
temp_prefix_array[pre_rec_len] = '\0';
strtrunc(temp_prefix_array);
/*---------------------------------------------------------------------*/
/* If the prefix record area is blank, clear the pending prefix area. */
/*---------------------------------------------------------------------*/
if (blank_field(temp_prefix_array))
{
(void)delete_pending_prefix_command(curr->pre,CURRENT_FILE,curr);
redisplay_screen = TRUE;
}
else
{
/*---------------------------------------------------------------------*/
/* If the input line already points to an entry in the array, use the */
/* existing entry in the array, otherwise add to the next entry. */
/*---------------------------------------------------------------------*/
curr_ppc = pll_find(CURRENT_FILE->first_ppc,line_number);
if (curr_ppc == NULL) /* not found */
{
CURRENT_FILE->last_ppc = pll_add(CURRENT_FILE->first_ppc,CURRENT_FILE->last_ppc,sizeof(THE_PPC));
if (CURRENT_FILE->last_ppc == NULL)
{
display_error(30,(CHARTYPE *)"",FALSE);
#ifdef THE_TRACE
trace_return();
#endif
return;
}
if (CURRENT_FILE->first_ppc == NULL)
CURRENT_FILE->first_ppc = CURRENT_FILE->last_ppc;
curr_ppc = CURRENT_FILE->last_ppc;
}
curr->pre = curr_ppc;
strcpy((DEFCHAR *)curr_ppc->ppc_command,(DEFCHAR *)temp_prefix_array);
curr_ppc->ppc_line_number = line_number;
curr_ppc->ppc_block_command = block_command;
curr_ppc->ppc_cmd_idx = (-1);
if (IN_SCOPE(CURRENT_VIEW,curr))
curr_ppc->ppc_shadow_line = FALSE;
else
curr_ppc->ppc_shadow_line = TRUE;
}
/*---------------------------------------------------------------------*/
/* Clear the pending prefix command line. */
/* This removed by MH 20/01/96 to ensure end() in PREFIX works */
/*---------------------------------------------------------------------*/
#if 0
memset(pre_rec,' ',MAX_PREFIX_WIDTH);
pre_rec_len = 0;
pre_rec[MAX_PREFIX_WIDTH] = '\0';
#endif
if (redisplay_screen)
{
build_screen(current_screen);
display_screen(current_screen);
}
#ifdef THE_TRACE
trace_return();
#endif
return;
}
/***********************************************************************/
#ifdef HAVE_PROTO
short add_prefix_synonym(CHARTYPE *synonym,CHARTYPE *macroname)
#else
short add_prefix_synonym(synonym,macroname)
CHARTYPE *synonym,*macroname;
#endif
/***********************************************************************/
/* Parameters: */
/* synonym: synonym for prefix macro */
/* macroname: name of REXX macro file */
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
LINE *curr=NULL;
/*--------------------------- processing ------------------------------*/
#ifdef THE_TRACE
trace_function("prefix.c: add_prefix_synonym");
#endif
/*---------------------------------------------------------------------*/
/* First thing is to delete any definitions that may exist for the */
/* supplied synonym. */
/*---------------------------------------------------------------------*/
curr = first_prefix_synonym;
while(curr != NULL)
{
if (strcmp((DEFCHAR *)curr->name,(DEFCHAR *)synonym) == 0)
{
if (curr->name != NULL)
(*the_free)(curr->name);
if (curr->line != NULL)
(*the_free)(curr->line);
curr = lll_del(&first_prefix_synonym,&last_prefix_synonym,curr,DIRECTION_FORWARD);
}
else
curr = curr->next;
}
/*---------------------------------------------------------------------*/
/* Lastly append the synonym at the end of the linked list. */
/*---------------------------------------------------------------------*/
curr = lll_add(first_prefix_synonym,last_prefix_synonym,sizeof(LINE));
if (curr == NULL)
{
display_error(30,(CHARTYPE *)"",FALSE);
#ifdef THE_TRACE
trace_return();
#endif
return(RC_OUT_OF_MEMORY);
}
curr->line = (CHARTYPE *)(*the_malloc)((strlen((DEFCHAR *)macroname)+1)*sizeof(CHARTYPE));
if (curr->line == NULL)
{
display_error(30,(CHARTYPE *)"",FALSE);
#ifdef THE_TRACE
trace_return();
#endif
return(RC_OUT_OF_MEMORY);
}
strcpy((DEFCHAR *)curr->line,(DEFCHAR *)macroname);
curr->name = (CHARTYPE *)(*the_malloc)((strlen((DEFCHAR *)synonym)+1)*sizeof(CHARTYPE));
if (curr->name == NULL)
{
display_error(30,(CHARTYPE *)"",FALSE);
#ifdef THE_TRACE
trace_return();
#endif
return(RC_OUT_OF_MEMORY);
}
strcpy((DEFCHAR *)curr->name,(DEFCHAR *)synonym);
last_prefix_synonym = curr;
if (first_prefix_synonym == NULL)
first_prefix_synonym = last_prefix_synonym;
#ifdef THE_TRACE
trace_return();
#endif
return(RC_OK);
}
/*man***************************************************************************
NAME
find_prefix_synonym
SYNOPSIS
CHARTYPE *find_prefix_synonym(synonym)
CHARTYPE *synonym;
DESCRIPTION
The find_prefix_synonym function finds a synonym for 'synonym'
and returns that value. If no synonym exists, the 'synonym' is
returned unchanged.
This function is only available if REXX support is available.
RETURN VALUE
Either the macroname associated with 'synonym' or 'synonym'.
*******************************************************************************/
#ifdef HAVE_PROTO
CHARTYPE *find_prefix_synonym(CHARTYPE *synonym)
#else
CHARTYPE *find_prefix_synonym(synonym)
CHARTYPE *synonym;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
LINE *curr=NULL;
/*--------------------------- processing ------------------------------*/
#ifdef THE_TRACE
trace_function("prefix.c: find_prefix_synonym");
#endif
curr = first_prefix_synonym;
while(curr != NULL)
{
if (strcmp((DEFCHAR *)synonym,(DEFCHAR *)curr->name) == 0)
{
#ifdef THE_TRACE
trace_return();
#endif
return((CHARTYPE *)curr->line);
}
curr = curr->next;
}
#ifdef THE_TRACE
trace_return();
#endif
return(synonym);
}
/*man***************************************************************************
NAME
find_prefix_oldname
SYNOPSIS
CHARTYPE *find_prefix_oldname(oldname)
CHARTYPE *oldname;
DESCRIPTION
The find_prefix_oldname function finds the synonym for
'oldname' and returns that value. If no synonym exists, the
'oldname' is returned unchanged.
This function is only available if REXX support is available.
RETURN VALUE
Either the synonym associated with 'oldname' or 'oldname'.
*******************************************************************************/
#ifdef HAVE_PROTO
CHARTYPE *find_prefix_oldname(CHARTYPE *oldname)
#else
CHARTYPE *find_prefix_oldname(oldname)
CHARTYPE *oldname;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
LINE *curr=NULL;
/*--------------------------- processing ------------------------------*/
#ifdef THE_TRACE
trace_function("prefix.c: find_prefix_oldname");
#endif
curr = first_prefix_synonym;
while(curr != NULL)
{
if (strcmp((DEFCHAR *)oldname,(DEFCHAR *)curr->line) == 0)
{
#ifdef THE_TRACE
trace_return();
#endif
return(curr->name);
}
curr = curr->next;
}
#ifdef THE_TRACE
trace_return();
#endif
return(oldname);
}
/***********************************************************************/
#ifdef HAVE_PROTO
CHARTYPE *get_prefix_command(LINETYPE prefix_index)
#else
CHARTYPE *get_prefix_command(prefix_index)
LINETYPE prefix_index;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
/*--------------------------- processing ------------------------------*/
#ifdef THE_TRACE
trace_function("prefix.c: get_prefix_command");
#endif
/*---------------------------------------------------------------------*/
/* Just return a pointer to the prefix command associated with the */
/* supplied index. */
/*---------------------------------------------------------------------*/
#ifdef THE_TRACE
trace_return();
#endif
return(pc[prefix_index].cmd);
}
/***********************************************************************/
#ifdef HAVE_PROTO
static short post_prefix_add(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
#else
static short post_prefix_add(curr_ppc,cmd_idx,number_lines)
THE_PPC *curr_ppc;
short cmd_idx;
LINETYPE number_lines;
#endif
/***********************************************************************/
{
/*--------------------------- local data ------------------------------*/
short rc=RC_OK;
/*--------------------------- processing ------------------------------*/
rc = Sos_leftedge((CHARTYPE *)"");
if (CURRENT_VIEW->current_window == WINDOW_FILEAREA)
{
if (!BOF((CURRENT_VIEW->focus_line)+1L))
rc = THEcursor_down(TRUE);
}
return(rc);
}
|