home *** CD-ROM | disk | FTP | other *** search
- #include <exec/types.h>
- #include <pragmas/exec.h>
- #include <intuition/intuition.h>
- #include <string.h>
-
- int __saveds __asm Bracket (register __a0 char *cmdline, register __a2 APTR table[])
- {
- char __regargs * (*GetLine)();
- void __regargs (*RefreshStringGadget)();
- struct StringInfo __regargs * (*GetStringInfo)();
- char *p,t,o;
- struct StringInfo *si;
- int i,d,l,found;
-
- GetLine = table[12];
- GetStringInfo = table[20];
- RefreshStringGadget = table[5];
-
- p = GetLine ();
- si = GetStringInfo ();
-
- i = si->BufferPos;
-
- switch (t = p[i])
- {
- case '(' : o = ')'; d= 1; break;
- case ')' : o = '('; d=-1; break;
- case '{' : o = '}'; d= 1; break;
- case '}' : o = '{'; d=-1; break;
- case '[' : o = ']'; d= 1; break;
- case ']' : o = '['; d=-1; break;
- default : return;
- }
-
- i += d;
- l = 1;
- found = -1;
- while (i >= 0 && i <= si->NumChars)
- {
- if (p[i] == t) l++;
- else if (p[i] == o) l--;
- if (!l)
- {
- found = i;
- i = -2;
- }
- else i += d;
- }
-
- if (found >= 0) si->BufferPos = found;
-
- RefreshStringGadget ();
- }
-