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.

54 lines
1.7 KiB

  1. /*****************************************************************************
  2. ExeG()
  3. This function executes a G command.
  4. Gq Get string from Q-register q into buffer
  5. G* Get last filespec string into buffer
  6. G_ Get last search string into buffer
  7. :Gq Type Q-register q on terminal
  8. *****************************************************************************/
  9. #include "zport.h" /* define portability identifiers */
  10. #include "tecoc.h" /* define general identifiers */
  11. #include "defext.h" /* define external global variables */
  12. #include "deferr.h" /* define identifiers for error messages */
  13. DEFAULT ExeG() /* execute a G command */
  14. {
  15. charptr TxtBeg; /* beginning of a text area */
  16. charptr TxtEnd; /* end of a text area */
  17. DBGFEN(1,"ExeG",NULL);
  18. if (IncCBP() == FAILURE) { /* move to char after G */
  19. DBGFEX(1,DbgFNm,"FAILURE");
  20. return FAILURE;
  21. }
  22. if (*CBfPtr == '*') { /* if it's G* */
  23. TxtBeg = FBfBeg;
  24. TxtEnd = FBfPtr;
  25. } else if (*CBfPtr == '_') { /* else if it's G_ */
  26. TxtBeg = SBfBeg;
  27. TxtEnd = SBfPtr;
  28. } else { /* else it's Gq */
  29. if (FindQR() == FAILURE) {
  30. return FAILURE;
  31. }
  32. if (QR->Start == NULL) { /* if empty */
  33. RefLen = 0;
  34. CmdMod = '\0'; /* clear modifiers flags */
  35. EStTop = EStBot; /* clear expression stack */
  36. DBGFEX(1,DbgFNm,"SUCCESS, Q-register empty");
  37. return SUCCESS;
  38. }
  39. TxtBeg = QR->Start;
  40. TxtEnd = QR->End_P1;
  41. }
  42. if (CmdMod & COLON) { /* if it's :G */
  43. TypBuf(TxtBeg, TxtEnd);
  44. } else { /* else (no : modifier) */
  45. if (InsStr(TxtBeg, TxtEnd-TxtBeg) == FAILURE) {
  46. DBGFEX(1,DbgFNm,"FAILURE");
  47. return FAILURE;
  48. }
  49. }
  50. CmdMod = '\0'; /* clear modifiers flags */
  51. EStTop = EStBot; /* clear expression stack */
  52. DBGFEX(1,DbgFNm,"SUCCESS");
  53. return SUCCESS;
  54. }