#include "flayer.h"
#include "samterm.h"
+int mainstacksize = 16*1024;
+
Text cmd;
Rune *scratch;
long nscralloc;
void
threadmain(int argc, char *argv[])
{
- int i, got, scr, chord;
+ int i, got, nclick, scr, chord;
Text *t;
Rectangle r;
Flayer *nwhich;
+ ulong p;
getscreen(argc, argv);
iconinit();
}
}
}else if(mousep->buttons&(1|8)){
- if(nwhich){
- if(nwhich!=which)
- current(nwhich);
- else if(scr)
- scroll(which, (mousep->buttons&8) ? 4 : 1);
- else{
- t=(Text *)which->user1;
- if(flselect(which)){
- outTsl(Tdclick, t->tag, which->p0);
- t->lock++;
- }else if(t!=&cmd)
- outcmd();
- if(mousep->buttons&1)
- chord = mousep->buttons;
- }
+ if(scr)
+ scroll(which, (mousep->buttons&8) ? 4 : 1);
+ else if(nwhich && nwhich!=which)
+ current(nwhich);
+ else{
+ t=(Text *)which->user1;
+ nclick = flselect(which, &p);
+ if(nclick > 0){
+ if(nclick > 1)
+ outTsl(Ttclick, t->tag, p);
+ else
+ outTsl(Tdclick, t->tag, p);
+ t->lock++;
+ }else if(t!=&cmd)
+ outcmd();
+ if(mousep->buttons&1)
+ chord = mousep->buttons;
}
}else if((mousep->buttons&2) && which){
if(scr)
typeend = -1;
}
-#define BACKSCROLLKEY Kup
-#define ENDKEY Kend
-#define ESC 0x1B
-#define HOMEKEY Khome
-#define LEFTARROW Kleft
-#define LINEEND 0x05
-#define LINESTART 0x01
-#define PAGEDOWN Kpgdown
-#define PAGEUP Kpgup
-#define RIGHTARROW Kright
-#define SCROLLKEY Kdown
-
int
nontypingkey(int c)
{
switch(c){
- case BACKSCROLLKEY:
- case ENDKEY:
- case HOMEKEY:
- case LEFTARROW:
- case LINEEND:
- case LINESTART:
- case PAGEDOWN:
- case PAGEUP:
- case RIGHTARROW:
- case SCROLLKEY:
+ case Kup:
+ case Kdown:
+ case Khome:
+ case Kend:
+ case Kpgdown:
+ case Kpgup:
+ case Kleft:
+ case Kright:
+ case Ksoh:
+ case Kenq:
+ case Kstx:
+ case Kbel:
return 1;
}
return 0;
backspacing = 0;
while((c = kbdchar())>0){
if(res == RKeyboard){
- if(nontypingkey(c) || c==ESC)
+ if(nontypingkey(c) || c==Kesc)
break;
/* backspace, ctrl-u, ctrl-w, del */
- if(c=='\b' || c==0x15 || c==0x17 || c==0x7F){
+ if(c==Kbs || c==Knack || c==Ketb || c==Kdel){
backspacing = 1;
break;
}
flushtyping(0);
onethird(l, a);
}
- if(c==SCROLLKEY || c==PAGEDOWN){
+ if(c==Kdown || c==Kpgdown){
flushtyping(0);
center(l, l->origin+l->f.nchars+1);
/* backspacing immediately after outcmd(): sorry */
- }else if(c==BACKSCROLLKEY || c==PAGEUP){
+ }else if(c==Kup || c==Kpgup){
flushtyping(0);
a0 = l->origin-l->f.nchars;
if(a0 < 0)
a0 = 0;
center(l, a0);
- }else if(c == RIGHTARROW){
+ }else if(c == Kright){
flushtyping(0);
a0 = l->p0;
if(a0 < t->rasp.nrunes)
a0++;
flsetselect(l, a0, a0);
center(l, a0);
- }else if(c == LEFTARROW){
+ }else if(c == Kleft){
flushtyping(0);
a0 = l->p0;
if(a0 > 0)
a0--;
flsetselect(l, a0, a0);
center(l, a0);
- }else if(c == HOMEKEY){
+ }else if(c == Khome){
flushtyping(0);
center(l, 0);
- }else if(c == ENDKEY){
+ }else if(c == Kend){
flushtyping(0);
center(l, t->rasp.nrunes);
- }else if(c == LINESTART || c == LINEEND){
+ }else if(c == Ksoh || c == Kenq){
flushtyping(1);
- if(c == LINESTART)
+ if(c == Ksoh)
while(a > 0 && raspc(&t->rasp, a-1)!='\n')
a--;
else
/* backspacing immediately after outcmd(): sorry */
if(l->f.p0>0 && a>0){
switch(c){
- case '\b':
- case 0x7F: /* del */
+ case Kbs:
+ case Kdel: /* del */
l->p0 = del(&t->rasp, l->origin, a);
break;
- case 0x15: /* ctrl-u */
+ case Knack: /* ctrl-u */
l->p0 = ctlu(&t->rasp, l->origin, a);
break;
- case 0x17: /* ctrl-w */
+ case Ketb: /* ctrl-w */
l->p0 = ctlw(&t->rasp, l->origin, a);
break;
}
}
}
}
+ }else if(c == Kstx){
+ t = &cmd;
+ for(l=t->l; l->textfn==0; l++)
+ ;
+ current(l);
+ flushtyping(0);
+ a = t->rasp.nrunes;
+ flsetselect(l, a, a);
+ center(l, a);
+ }else if(c == Kbel){
+ int i;
+ if(work == nil)
+ return;
+ if(which != work){
+ current(work);
+ return;
+ }
+ t = (Text*)work->user1;
+ l = &t->l[t->front];
+ for(i=t->front; t->nwin>1 && (i = (i+1)%NL) != t->front; )
+ if(t->l[i].textfn != 0){
+ l = &t->l[i];
+ break;
+ }
+ current(l);
}else{
- if(c==ESC && typeesc>=0){
+ if(c==Kesc && typeesc>=0){
l->p0 = typeesc;
l->p1 = a;
flushtyping(1);