diff options
author | Ori Bernstein <ori@eigenstate.org> | 2020-09-22 11:42:15 -0700 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2020-09-22 11:42:15 -0700 |
commit | 313aebb96478c37be8f39754875c02dcb3f896cc (patch) | |
tree | 880c9ba449631562b136135e3e9a7e6169d178f6 /sys/src/cmd/acme/exec.c | |
parent | c1c904776c1536e854c5c1717a104353f885c3cd (diff) |
acme: import changes from plan9port (thanks jxy)
Import the following improvements and bugfixes from plan9port:
4650064a acme: scale window bodies on resize, not including tag space
d28913a9 acme: save/restore multiline tags in Dump/Load
d2df5d6c acme: fix crash in X |cat with multiple windows
3d6e5cb5 acme: preserve window position and selection during Get
Diffstat (limited to 'sys/src/cmd/acme/exec.c')
-rw-r--r-- | sys/src/cmd/acme/exec.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/sys/src/cmd/acme/exec.c b/sys/src/cmd/acme/exec.c index 7011ad7b3..cff114312 100644 --- a/sys/src/cmd/acme/exec.c +++ b/sys/src/cmd/acme/exec.c @@ -506,15 +506,27 @@ zeroxx(Text *et, Text *t, Text*, int, int, Rune*, int) winunlock(t->w); } +typedef struct TextAddr TextAddr; +struct TextAddr { + long lorigin; // line+rune for origin + long rorigin; + long lq0; // line+rune for q0 + long rq0; + long lq1; // line+rune for q1 + long rq1; +}; + void get(Text *et, Text *t, Text *argt, int flag1, int, Rune *arg, int narg) { char *name; Rune *r; int i, n, dirty, samename, isdir; + TextAddr *addr, *a; Window *w; Text *u; Dir *d; + long q0, q1; if(flag1) if(et==nil || et->w==nil) @@ -537,6 +549,14 @@ get(Text *et, Text *t, Text *argt, int flag1, int, Rune *arg, int narg) return; } } + addr = emalloc((t->file->ntext)*sizeof(TextAddr)); + for(i=0; i<t->file->ntext; i++) { + a = &addr[i]; + u = t->file->text[i]; + a->lorigin = nlcount(u, 0, u->org, &a->rorigin); + a->lq0 = nlcount(u, 0, u->q0, &a->rq0); + a->lq1 = nlcount(u, u->q0, u->q1, &a->rq1); + } r = bytetorune(name, &n); for(i=0; i<t->file->ntext; i++){ u = t->file->text[i]; @@ -562,8 +582,18 @@ get(Text *et, Text *t, Text *argt, int flag1, int, Rune *arg, int narg) for(i=0; i<t->file->ntext; i++){ u = t->file->text[i]; textsetselect(&u->w->tag, u->w->tag.file->nc, u->w->tag.file->nc); + if(samename) { + a = &addr[i]; + // warning(nil, "%d %d %d %d %d %d\n", a->lorigin, a->rorigin, a->lq0, a->rq0, a->lq1, a->rq1); + q0 = nlcounttopos(u, 0, a->lq0, a->rq0); + q1 = nlcounttopos(u, q0, a->lq1, a->rq1); + textsetselect(u, q0, q1); + q0 = nlcounttopos(u, 0, a->lorigin, a->rorigin); + textsetorigin(u, q0, FALSE); + } textscrdraw(u); } + free(addr); xfidlog(w, "get"); } |