1 /* $OpenBSD: macro.c,v 1.14 2012/04/12 04:47:59 lum Exp $ */
3 /* This file is in the public domain. */
13 int inmacro = FALSE; /* Macro playback in progess */
14 int macrodef = FALSE; /* Macro recording in progress */
17 struct line *maclhead = NULL;
20 union macrodef macro[MAXMACRO];
24 definemacro(int f, int n)
26 struct line *lp1, *lp2;
31 ewprintf("already defining macro");
32 return (macrodef = FALSE);
35 /* free lines allocated for string arguments */
36 if (maclhead != NULL) {
37 for (lp1 = maclhead->l_fp; lp1 != maclhead; lp1 = lp2) {
44 if ((maclhead = lp1 = lalloc(0)) == NULL)
47 ewprintf("Defining Keyboard Macro...");
48 maclcur = lp1->l_fp = lp1->l_bp = lp1;
49 return (macrodef = TRUE);
54 finishmacro(int f, int n)
56 if (macrodef == TRUE) {
58 ewprintf("End Keyboard Macro Definition");
66 executemacro(int f, int n)
72 (macrocount >= MAXMACRO && macro[MAXMACRO - 1].m_funct
74 ewprintf("Macro too long. Aborting.");
83 for (i = n; i > 0; i--) {
84 maclcur = maclhead->l_fp;
87 for (j = 0; j < macrocount - 1; j++) {
88 funct = macro[j].m_funct;
89 if (funct == universal_argument) {
91 num = macro[++j].m_count;
94 if ((*funct)(flag, num) != TRUE) {