commit - 4ac5f249ad40f3452fc87dc9a3f4b9d9546c83b0
commit + 17ab31aac6639e210613691669163b0c2874d1ce
blob - cdea842c9b1203e2f8a8671c3155e6cdb896835f
blob + 95c2e0ce577b97120ccb62ef206d76f6fa868ea1
--- src/cmd/sam/io.c
+++ src/cmd/sam/io.c
int remotefd1 = 1;
void
-bootterm(char *machine, char **argv, char **end)
+bootterm(char *machine, char **argv)
{
int ph2t[2], pt2h[2];
close(remotefd0);
close(remotefd1);
argv[0] = "samterm";
- *end = 0;
execvp(samterm, argv);
fprint(2, "can't exec %s: %r\n", samterm);
_exits("damn");
close(pt2h[0]);
close(pt2h[1]);
argv[0] = "samterm";
- *end = 0;
execvp(samterm, argv);
fprint(2, "can't exec: ");
perror(samterm);
}
void
-startup(char *machine, int Rflag, char **argv, char **end, char **files)
+startup(char *machine, int Rflag, char **argv, char **files)
{
if(machine)
connectto(machine, files);
if(!Rflag)
- bootterm(machine, argv, end);
+ bootterm(machine, argv);
downloaded = 1;
outTs(Hversion, VERSION);
}
blob - b88bf1487e7e9e5ce50bcacb24bc88868b910ee6
blob + 6e34f664a260a9b56587bf8011030dac9271bca9
--- src/cmd/sam/mesg.h
+++ src/cmd/sam/mesg.h
Hsnarflen, /* report length of implicit snarf */
Hack, /* request acknowledgement */
Hexit,
- Hplumb, /* return plumb message to terminal */
+ Hplumb, /* return plumb message to terminal - version 1 */
HMAX,
}Hmesg;
typedef struct Header{
blob - b5b16a1056e33a6ff1493bd83bc3ac7a36cfd0ab
blob + acfa465743b8dddc666c51d59ee26f92be6bdba3
--- src/cmd/sam/sam.c
+++ src/cmd/sam/sam.c
{
int volatile i;
String *t;
- char **ap, **arg;
-
- arg = argv++;
- ap = argv;
- while(argc>1 && argv[0] && argv[0][0]=='-'){
- switch(argv[0][1]){
- case 'd':
- dflag++;
- break;
-
- case 'r':
- --argc, argv++;
- if(argc == 1)
- usage();
- machine = *argv;
- break;
-
- case 'R':
- Rflag++;
- break;
-
- case 't':
- --argc, argv++;
- if(argc == 1)
- usage();
- samterm = *argv;
- break;
-
- case 's':
- --argc, argv++;
- if(argc == 1)
- usage();
- rsamname = *argv;
- break;
-
- case 'x': /* x11 option - strip the x */
- strcpy(*argv+1, *argv+2);
- *ap++ = *argv++;
- *ap++ = *argv;
- argc--;
- break;
-
- case 'W':
- --argc, argv++;
- break;
+ char *termargs[10], **ap;
+
+ ap = termargs;
+ *ap++ = "samterm";
+ ARGBEGIN{
+ case 'd':
+ dflag++;
+ break;
+ case 'r':
+ machine = EARGF(usage());
+ break;
+ case 'R':
+ Rflag++;
+ break;
+ case 't':
+ samterm = EARGF(usage());
+ break;
+ case 's':
+ rsamname = EARGF(usage());
+ break;
+ default:
+ dprint("sam: unknown flag %c\n", ARGC());
+ usage();
+ /* options for samterm */
+ case 'a':
+ *ap++ = "-a";
+ break;
+ case 'W':
+ *ap++ = "-W";
+ *ap++ = EARGF(usage());
+ break;
+ }ARGEND
+ *ap = nil;
- default:
- dprint("sam: unknown flag %c\n", argv[0][1]);
- exits("usage");
- }
- --argc, argv++;
- }
Strinit(&cmdstr);
Strinit0(&lastpat);
Strinit0(&lastregexp);
disk = diskinit();
if(home == 0)
home = "/";
+fprint(2, "argc %d argv %s\n", argc, *argv);
if(!dflag)
- startup(machine, Rflag, arg, ap, argv);
+ startup(machine, Rflag, termargs, argv);
notify(notifyf);
getcurwd();
- if(argc>1){
- for(i=0; i<argc-1; i++){
+ if(argc>0){
+ for(i=0; i<argc; i++){
if(!setjmp(mainloop)){
t = tmpcstr(argv[i]);
Straddc(t, '\0');
blob - 0641be81a239f44c8d6abba9f8f5f53cac9ef293
blob + eefb4b344fb583ff97c301b51a681f13fa1701f1
--- src/cmd/sam/sam.h
+++ src/cmd/sam/sam.h
int skipbl(void);
void snarf(File*, Posn, Posn, Buffer*, int);
void sortname(File*);
-void startup(char*, int, char**, char**, char**);
+void startup(char*, int, char**, char**);
void state(File*, int);
int statfd(int, ulong*, uvlong*, long*, long*, long*);
int statfile(char*, ulong*, uvlong*, long*, long*, long*);
blob - c308993a5afb247a5ed9223785469943cd4cf465
blob + 729b72cf55395340ee9458725dd8c7ef21979634
--- src/cmd/samterm/flayer.c
+++ src/cmd/samterm/flayer.c
int
flselect(Flayer *l)
{
- int ret = 0;
+ int ret;
if(l->visible!=All)
flupfront(l);
frselect(&l->f, mousectl);
+ ret = 0;
if(l->f.p0==l->f.p1){
if(mousep->msec-l->click<Clicktime && l->f.p0+l->origin==l->p0){
ret = 1;
blob - c56ea5f84c5fe09a78d13e30420433240ed54462
blob + ed75af79bc91ac12a9c6e1e27a197641626777f4
--- src/cmd/samterm/main.c
+++ src/cmd/samterm/main.c
char hostlock = 1;
char hasunlocked = 0;
int maxtab = 8;
+int chord;
+int autoindent;
void
threadmain(int argc, char *argv[])
{
- int i, got, scr;
+ int i, got, scr, w;
Text *t;
Rectangle r;
Flayer *nwhich;
scr = which && ptinrect(mousep->xy, which->scroll);
if(mousep->buttons)
flushtyping(1);
- if(mousep->buttons&1){
+ if(chord==1 && !mousep->buttons)
+ chord = 0;
+ if(chord)
+ chord |= mousep->buttons;
+ else if(mousep->buttons&1){
if(nwhich){
if(nwhich!=which)
current(nwhich);
t->lock++;
}else if(t!=&cmd)
outcmd();
+ if(mousep->buttons&1)
+ chord = mousep->buttons;
}
}
}else if((mousep->buttons&2) && which){
menu3hit();
}
mouseunblock();
+ }
+ if(chord){
+ t = (Text*)which->user1;
+ if(!t->lock && !hostlock){
+ w = which-t->l;
+ if(chord&2){
+ cut(t, w, 1, 1);
+ chord &= ~2;
+ }else if(chord&4){
+ paste(t, w);
+ chord &= ~4;
+ }
+ }
}
}
}
-
void
resize(void)
{
}
int
-onethird(Flayer *l, long a)
+thirds(Flayer *l, long a, int n)
{
Text *t;
Rectangle s;
if(a > t->rasp.nrunes)
a = t->rasp.nrunes;
s = insetrect(l->scroll, 1);
- lines = ((s.max.y-s.min.y)/l->f.font->height+1)/3;
+ lines = (n*(s.max.y-s.min.y)/l->f.font->height+1)/3;
if (lines < 2)
lines = 2;
outTsll(Torigin, t->tag, a, lines);
return 0;
}
+int
+onethird(Flayer *l, long a)
+{
+ return thirds(l, a, 1);
+}
+
+int
+twothirds(Flayer *l, long a)
+{
+ return thirds(l, a, 2);
+}
+
void
flushtyping(int clearesc)
{
}
}
*p++ = c;
- if(c == '\n' || p >= buf+sizeof(buf)/sizeof(buf[0]))
+ if(autoindent)
+ if(c == '\n'){
+ /* autoindent */
+ int cursor, ch;
+ cursor = ctlu(&t->rasp, 0, a+(p-buf)-1);
+ while(p < buf+nelem(buf)){
+ ch = raspc(&t->rasp, cursor++);
+ if(ch == ' ' || ch == '\t')
+ *p++ = ch;
+ else
+ break;
+ }
+ }
+ if(c == '\n' || p >= buf+nelem(buf))
break;
}
if(p > buf){
blob - 3d2df85d01ecf6fed9e44eb22ddc75392e526db8
blob + 2aca0842fff84bf00fede20056346e7aa8533199
--- src/cmd/samterm/plan9.c
+++ src/cmd/samterm/plan9.c
#define STACK 16384
void
+usage(void)
+{
+ fprint(2, "usage: samterm -a -W winsize\n");
+ threadexitsall("usage");
+}
+
+void
getscreen(int argc, char **argv)
{
- int i;
char *t;
- /* not exactly right */
- for(i=0; i<argc-1; i++){
- if(strcmp(argv[i], "-W") == 0)
- winsize = argv[i+1];
- }
+ ARGBEGIN{
+ case 'a':
+ autoindent = 1;
+ break;
+ case 'W':
+ winsize = EARGF(usage());
+ break;
+ default:
+ usage();
+ }ARGEND
if(initdraw(panic1, nil, "sam") < 0){
fprint(2, "samterm: initdraw: %r\n");
blob - dfe2f345be0ca60b226063459c5455b8cbb709e7
blob + 5ba7c31504a862bb50c05fe3354df0619caa491f
--- src/cmd/samterm/samterm.h
+++ src/cmd/samterm/samterm.h
extern int plumbfd;
extern int hostfd[2];
extern int exiting;
+extern int autoindent;
#define gettext sam_gettext /* stupid gcc built-in functions */
Rune *gettext(Flayer*, long, ulong*);