TEACL is a fork of TECOC created for the purpose of describing diffs in a document being collaboratively edited
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.6 KiB

  1. /*****************************************************************************
  2. ExeD()
  3. This function executes a D command.
  4. nD Delete n characters.
  5. m,nD Delete between m and n
  6. *****************************************************************************/
  7. #include "zport.h" /* define portability identifiers */
  8. #include "tecoc.h" /* define general identifiers */
  9. #include "defext.h" /* define external global variables */
  10. #include "deferr.h" /* define identifiers for error messages */
  11. DEFAULT ExeD() /* execute a D command */
  12. {
  13. LONG Status;
  14. DBGFEN(1,"ExeD",NULL);
  15. if (CmdMod & MARGIS) { /* if it's m,nD */
  16. DBGFEX(1,DbgFNm,"ExeK()");
  17. return ExeK();
  18. }
  19. if (EStTop == EStBot) { /* if no numeric argument */
  20. NArgmt = 1; /* default is 1D */
  21. } else {
  22. UMinus(); /* if it's -D, make it -1D */
  23. if (GetNmA() == FAILURE) { /* get numeric argument */
  24. DBGFEX(1,DbgFNm,"FAILURE");
  25. return FAILURE;
  26. }
  27. }
  28. Status = -1; /* -1 means success */
  29. if (NArgmt > 0) {
  30. if ((GapEnd+NArgmt) > EBfEnd) { /* if out of range */
  31. Status = 0; /* 0 means failure */
  32. } else {
  33. GapEnd += NArgmt; /* delete */
  34. }
  35. } else {
  36. if ((GapBeg+NArgmt) < EBfBeg) { /* if out of range */
  37. Status = 0; /* 0 means failure */
  38. } else {
  39. GapBeg += NArgmt; /* delete */
  40. }
  41. }
  42. if (CmdMod & COLON) { /* if it's :D */
  43. CmdMod = '\0'; /* clear modifiers flags */
  44. DBGFEX(1,DbgFNm,"PushEx()");
  45. return PushEx(Status, OPERAND);
  46. }
  47. if (Status == 0) {
  48. ErrMsg(ERR_DTB); /* DTB = "delete too big" */
  49. DBGFEX(1,DbgFNm,"FAILURE");
  50. return FAILURE;
  51. }
  52. CmdMod = '\0'; /* clear modifiers flags */
  53. DBGFEX(1,DbgFNm,"SUCCESS");
  54. return SUCCESS;
  55. }