|
|
1.1 ! root 1: #include <jerq.h> ! 2: #include <layer.h> ! 3: #include <queue.h> ! 4: #include "jerqproc.h" ! 5: #include "frame.h" ! 6: ! 7: frselect(f, pt) ! 8: register Frame *f; ! 9: Point pt; ! 10: { ! 11: register fix, var, oldvar; ! 12: if(f->s1 != f->s2){ ! 13: selectf(f, F_XOR); ! 14: f->nullsel=0; /* no double clicks this time */ ! 15: } ! 16: fix=charofpt(f, pt); /* fixed point */ ! 17: oldvar=fix; /* moving point tracks mouse */ ! 18: var=fix; ! 19: while(button1()){ ! 20: if(var!=oldvar){ ! 21: f->s1=oldvar; ! 22: f->s2=var; ! 23: order(f); ! 24: selectf(f, F_XOR); ! 25: oldvar=var; ! 26: } ! 27: var=charofpt(f, mouse.xy); ! 28: } ! 29: f->s1=fix; ! 30: f->s2=oldvar; ! 31: order(f); ! 32: if (f->nullsel && f->s2==f->s1 && f->lastch==f->s1){ ! 33: f->nullsel=0; ! 34: matchit(f); ! 35: selectf(f, F_XOR); ! 36: } ! 37: else { ! 38: f->nullsel=f->s2==f->s1; ! 39: f->lastch=f->s1; ! 40: } ! 41: } ! 42: order(f) ! 43: register Frame *f; ! 44: { ! 45: register a; ! 46: if(f->s1 > f->s2){ ! 47: a=f->s1; ! 48: f->s1=f->s2; ! 49: f->s2=a; ! 50: } ! 51: } ! 52: static char ltbrack[]="([{<"; ! 53: static char rtbrack[]=")]}>"; ! 54: extern char *index(); ! 55: matchit(f) ! 56: register Frame *f; ! 57: { ! 58: register i=-1,n=0; ! 59: register c; ! 60: register char *s = f->str.s; ! 61: int ch,me; ! 62: int N = f->str.n; ! 63: if ((f->s1 != N) ! 64: && (f->s1 == 0 || (me=s[f->s1-1]) == '\n' ! 65: || (i=index(ltbrack,me)-ltbrack)>=0)) { ! 66: ch = (i < 0) ? '\n' : rtbrack[i]; ! 67: for (i = f->s1; i<N && !((c=s[i])==ch && n==0); i++) ! 68: if (c==me) ! 69: n++; ! 70: else if (c==ch) ! 71: n--; ! 72: if ((c==ch && n==0) || (i==N && me=='\n')) ! 73: f->s2=i; ! 74: } ! 75: else if ((f->s1 != 0) ! 76: && (f->s1 >= N || (me=s[f->s1]) == '\n' ! 77: || (i=index(rtbrack, me=s[f->s2])-rtbrack)>=0)) { ! 78: ch = (i < 0) ? '\n' : ltbrack[i]; ! 79: for (i = f->s1-1; i>0 && !((c=s[i])==ch && n==0); i--) ! 80: if (c==me) ! 81: n++; ! 82: else if (c==ch) ! 83: n--; ! 84: if (c==ch && n==0) ! 85: f->s1=i+1; ! 86: else if (i==0 && me=='\n') /* ugh! */ ! 87: f->s1=i; /* end conditions! */ ! 88: } ! 89: else { ! 90: for (i=f->s1; i>0 && isalnum(s[i-1]); i--) ! 91: ; ! 92: f->s1=i; ! 93: for (i=f->s2; i<f->str.n && isalnum(s[i]); i++) ! 94: ; ! 95: f->s2=i; ! 96: } ! 97: if (f->s2 < N && ((c=s[f->s2]) == ' ' || c == '\t' || c == '\n')) ! 98: f->s2++; ! 99: } ! 100: ! 101: isalnum(c) ! 102: register char c; ! 103: { ! 104: return (c>='0' && c<='9') || ! 105: (c>='a' && c<='z') || ! 106: (c>='A' && c<='Z') || ! 107: c=='_'; ! 108: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.