Support scrolling even for zeroxed layers. - sam - An updated version of the sa… | |
git clone git://vernunftzentrum.de/sam.git | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit 6aef2cc353e5ab781a6a36761fb8518f1296e163 | |
parent 9e3cf08d5206503fa620136bd8b89528f5ca882c | |
Author: Rob King <[email protected]> | |
Date: Thu, 1 Sep 2016 22:03:26 -0500 | |
Support scrolling even for zeroxed layers. | |
The scrolling code worked without any (obvious) issues for all cases, | |
except when the scrolled layer was a background layer which was a | |
duplicate of another layer. | |
The reason is that to scroll upwards, we have to send a Torigin message | |
to the host (to get us to move up a line; we might not be able to do so | |
simply by checking character-by-character because above us might be a | |
hole in the rasp). The Horigin response did not include a mechanism to | |
indicate which layer we wanted to scroll; it always assumed the first | |
layer for the tag is the one we wanted. | |
Note that this breaks the protocol between sam and samterm. Other sam | |
implementations will no longer work with this samterm and vice-versa. | |
This was going to happen sooner or later anyway (to support UTF outside | |
of the Basic Multilingual Plane), so... | |
Diffstat: | |
sam/mesg.c | 12 +++++++----- | |
sam/moveto.c | 4 ++-- | |
sam/sam.h | 2 +- | |
samterm/flayer.h | 3 +-- | |
samterm/main.c | 26 +++++++++++--------------- | |
samterm/mesg.c | 23 +++++++++++++++++++---- | |
samterm/samterm.h | 1 + | |
7 files changed, 42 insertions(+), 29 deletions(-) | |
--- | |
diff --git a/sam/mesg.c b/sam/mesg.c | |
@@ -172,7 +172,7 @@ inmesg(Tmesg type) | |
Rune buf[1025]; | |
int i, m; | |
short s; | |
- long l, l1; | |
+ long l, l1, l2; | |
File *f; | |
Posn p0, p1; | |
Range r; | |
@@ -248,11 +248,13 @@ inmesg(Tmesg type) | |
break; | |
case Torigin: | |
- s = inshort(); | |
- l = inlong(); | |
- l1 = inlong(); | |
+ s = inshort(); /* tag */ | |
+ l = inlong(); /* position */ | |
+ l1 = inlong(); /* lines to seek past position */ | |
+ l2 = inlong(); /* cookie to return (identifies layer) */ | |
journaln(0, l1); | |
- lookorigin(whichfile(s), l, l1); | |
+ journaln(0, l2); | |
+ lookorigin(whichfile(s), l, l1, l2); | |
break; | |
case Tstartfile: | |
diff --git a/sam/moveto.c b/sam/moveto.c | |
@@ -35,7 +35,7 @@ tellpat(void) | |
#define CHARSHIFT 128 | |
void | |
-lookorigin(File *f, Posn p0, Posn ls) | |
+lookorigin(File *f, Posn p0, Posn ls, long rl) | |
{ | |
int nl, nc, c; | |
Posn oldp0; | |
@@ -58,7 +58,7 @@ lookorigin(File *f, Posn p0, Posn ls) | |
p0 = 0; | |
}else | |
p0 = oldp0; | |
- outTsl(Horigin, f->tag, p0); | |
+ outTsll(Horigin, f->tag, p0, rl); | |
} | |
int | |
diff --git a/sam/sam.h b/sam/sam.h | |
@@ -275,7 +275,7 @@ Address lineaddr(Posn, Address, int); | |
void listfree(List*); | |
void load(File*); | |
File *lookfile(String*, int); | |
-void lookorigin(File*, Posn, Posn); | |
+void lookorigin(File*, Posn, Posn, long); | |
int lookup(int); | |
void move(File*, Address); | |
void moveto(File*, Range); | |
diff --git a/samterm/flayer.h b/samterm/flayer.h | |
@@ -13,8 +13,7 @@ enum{ | |
typedef struct Flayer Flayer; | |
/* note that we track background color, but not foreground | |
- * all layers have the same foreground color, but they may have different | |
- * background colors. | |
+ * all layers have the same foreground color | |
*/ | |
struct Flayer | |
{ | |
diff --git a/samterm/main.c b/samterm/main.c | |
@@ -316,11 +316,11 @@ scrorigin(Flayer *l, int but, long p0) | |
Text *t=(Text *)l->user1; | |
switch(but){ | |
- case 1: case 4: | |
- outTsll(Torigin, t->tag, l->origin, p0); | |
+ case 1: | |
+ outTslll(Torigin, t->tag, l->origin, p0, t->front); | |
break; | |
case 2: | |
- outTsll(Torigin, t->tag, p0, 1L); | |
+ outTslll(Torigin, t->tag, p0, 1L, t->front); | |
break; | |
case 3: | |
horigin(t->tag, p0, NULL); | |
@@ -386,7 +386,7 @@ center(Flayer *l, long a) | |
if (!t->lock && (a < l->origin || l->origin + l->f.nchars < a)){ | |
a = (a > t->rasp.nrunes) ? t->rasp.nrunes : a; | |
- outTsll(Torigin, t->tag, a, 2L); | |
+ outTslll(Torigin, t->tag, a, 2L, getlayer(l, t)); | |
return 1; | |
} | |
@@ -408,7 +408,7 @@ onethird(Flayer *l, long a) | |
lines = ((s.max.y-s.min.y)/l->f.fheight+1)/3; | |
if (lines < 2) | |
lines = 2; | |
- outTsll(Torigin, t->tag, a, lines); | |
+ outTslll(Torigin, t->tag, a, lines, t->front); | |
return 1; | |
} | |
return 0; | |
@@ -459,7 +459,7 @@ static long | |
cmdscrollup(Flayer *l, long a, Text *t) | |
{ | |
flushtyping(0); | |
- outTsll(Torigin, t->tag, l->origin, l->f.maxlines + 1); | |
+ outTslll(Torigin, t->tag, l->origin, l->f.maxlines + 1, getlayer(l, t)); | |
return a; | |
} | |
@@ -511,11 +511,12 @@ cmdbol(Flayer *l, long a, Text *t) | |
{ | |
flsetselect(l, a, a); | |
flushtyping(1); | |
- while(a > 0) | |
- if(raspc(&t->rasp, --a) == '\n') { | |
+ while (a > 0){ | |
+ if (raspc(&t->rasp, --a) == '\n'){ | |
a++; | |
break; | |
} | |
+ } | |
flsetselect(l, a, a); | |
center(l, a); | |
@@ -526,13 +527,8 @@ cmdbol(Flayer *l, long a, Text *t) | |
static long | |
cmdscrollupline(Flayer *l, long a, Text *t) | |
{ | |
- if (l->origin > 0){ | |
- long x = l->origin - 1; | |
- while (x > 0 && raspc(&t->rasp, x - 1) != '\n') | |
- x--; | |
- | |
- horigin(t->tag, x, l); | |
- } | |
+ if (l->origin > 0) | |
+ hmoveto(t->tag, l->origin - 1, l); | |
return a; | |
} | |
diff --git a/samterm/mesg.c b/samterm/mesg.c | |
@@ -96,7 +96,7 @@ inmesg(Hmesg type, int count) | |
{ | |
Text *t; | |
int i, m; | |
- long l; | |
+ long l, l2; | |
Flayer *lp; | |
char syscmd[512]; | |
@@ -214,8 +214,12 @@ inmesg(Hmesg type, int count) | |
break; | |
case Horigin: | |
- if(whichmenu(m) >= 0) | |
- horigin(m, l, NULL); | |
+ l2 = inlong(6); | |
+ if(whichmenu(m) >= 0){ | |
+ Text *t = whichtext(m); | |
+ Flayer *rl = &t->l[l2]; | |
+ horigin(m, l, rl); | |
+ } | |
break; | |
case Hunlockfile: | |
@@ -402,6 +406,17 @@ outTss(Tmesg type, int s1, int s2) | |
} | |
void | |
+outTslll(Tmesg type, int s1, long l1, long l2, long l3) | |
+{ | |
+ outstart(type); | |
+ outshort(s1); | |
+ outlong(l1); | |
+ outlong(l2); | |
+ outlong(l3); | |
+ outsend(); | |
+} | |
+ | |
+void | |
outTsll(Tmesg type, int s1, long l1, long l2) | |
{ | |
outstart(type); | |
@@ -574,7 +589,7 @@ hmoveto(int m, long p0, Flayer *l) | |
l = l ? l : &t->l[t->front]; | |
if (p0 < l->origin || p0 - l->origin > l->f.nchars * 9/10) | |
- outTsll(Torigin, m, p0, 2L); | |
+ outTslll(Torigin, m, p0, 2L, getlayer(l, t)); | |
} | |
void | |
diff --git a/samterm/samterm.h b/samterm/samterm.h | |
@@ -148,6 +148,7 @@ void outTs(Tmesg, int); | |
void outT0(Tmesg); | |
void outTl(Tmesg, long); | |
void outTslS(Tmesg, int, long, Rune*); | |
+void outTslll(Tmesg, int, long, long, long); | |
void outTsll(Tmesg, int, long, long); | |
void outTsl(Tmesg, int, long); | |
void outTsv(Tmesg, int, void*); |