ref: 04eee6ee86b9f7eafcbbbcd4312a1c1faa38fc7a
parent: 69d4e9e10a45517ad32d399bfbf61390d5a43208
author: Aidan K. Wiggins <akw@oneiri.one>
date: Sat Apr 12 00:11:57 EDT 2025
Tweak Kleft/Kright, block in center().
--- a/sam/mesg.c
+++ b/sam/mesg.c
@@ -168,8 +168,8 @@
Rune buf[1025];
char cbuf[64];
int i, m;
- short s;
- long l, l1;
+ short s, s1;
+ long l;
vlong v;
File *f;
Posn p0, p1, p;
@@ -249,10 +249,10 @@
case Torigin:
s = inshort();
l = inlong()-1;
- l1 = inlong();
+ s1 = inshort();
journaln(0, l1);
f = whichfile(s);
- while(l1--)
+ while(s1--)
if(filereadc(f, --l) == '\n')
break;
outTsl(Horigin, s, ++l);
--- a/samterm/flayer.c
+++ b/samterm/flayer.c
@@ -284,7 +284,7 @@
else
flsetselect(l, sel, l->origin+f->p1);
}
- center(l, l->origin, n, 1);
+ center(l, l->origin, n);
}
int
--- a/samterm/io.c
+++ b/samterm/io.c
@@ -153,6 +153,12 @@
}
void
+setblock(int set)
+{
+ block = set;
+}
+
+void
frscroll(Frame *, int n)
{
int b;
--- a/samterm/main.c
+++ b/samterm/main.c
@@ -398,8 +398,11 @@
continue;
outTsls(Trequest, t->tag, n+c, len-c);
t->lock++;
- if(waitforio(1) & (1 << RHost))
- rcv();
+
+ /* waitforio(1) unsets the block. */
+ setblock(~(1 << RHost));
+ waitforio(1);
+ rcv();
}while((n += len) < m);
}
@@ -415,7 +418,7 @@
/* todo: cleanup. */
void
-center(Flayer *l, long a, long nl, int req)
+center(Flayer *l, long a, int nl)
{
Frame *f = &l->f;
Text *t = l->user1;
@@ -422,14 +425,15 @@
Rune r;
int n;
+ if(t->tag == Untagged)
+ return;
+
a = bound(t, a);
- if(req){
- if(nl > 0)
- a += f->nchars;
- n = bound(t, a + nl * l->width);
- if(n != a)
- request(t, n < a? n: a, n < a? a: n);
- }
+ if(nl > 0)
+ a += f->nchars;
+ n = bound(t, a + (nl? nl: -1) * l->width);
+ if(n != a)
+ request(t, n < a? n: a, n < a? a: n);
if(nl <= 0){
while(nl++ <= 0 && a > 0)
@@ -574,25 +578,25 @@
if(c == '\n' || typeend-typestart > nelem(buf))
flushtyping(0);
if(!t->lock && a < l->origin || a > l->origin+l->f.nchars)
- center(l, a, -(l->f.maxlines/3), 0);
+ center(l, a, -(l->f.maxlines/3));
}
switch(c){
case Kdown:
flushtyping(0);
- center(l, l->origin, 1, 1);
+ center(l, l->origin, 1);
break;
case Kpgdown:
flushtyping(0);
- center(l, l->origin, l->f.maxlines, 1);
+ center(l, l->origin, l->f.maxlines);
break;
case Kup:
flushtyping(0);
- center(l, l->origin, -1, 1);
+ center(l, l->origin, -1);
break;
case Kpgup:
flushtyping(0);
- center(l, l->origin, -l->f.maxlines, 1);
+ center(l, l->origin, -l->f.maxlines);
break;
case Kleft:
flushtyping(0);
@@ -599,8 +603,10 @@
a0 = l->p0;
a0 -= (l->p0 > 0);
flsetselect(l, a0, a0);
- if(a0 - l->origin < 0)
- center(l, l->origin, -1, 1);
+ if(a0 == l->origin-1)
+ center(l, l->origin, -1);
+ else if(a0 < l->origin-1 || a0 > l->origin+l->f.nchars)
+ center(l, a0, -1);
break;
case Kright:
flushtyping(0);
@@ -607,16 +613,18 @@
a0 = l->p1;
a0 += a < t->rasp.nrunes;
flsetselect(l, a0, a0);
- if(a0-l->origin >= l->f.nchars)
- center(l, l->origin, 1, 1);
+ if(a0 == l->origin+l->f.nchars)
+ center(l, l->origin, 1);
+ else if(a0 < l->origin || a0 > l->origin+l->f.nchars)
+ center(l, a0, -1);
break;
case Khome:
flushtyping(0);
- center(l, 0, 0, 1);
+ center(l, 0, 0);
break;
case Kend:
flushtyping(0);
- center(l, t->rasp.nrunes, 0, 1);
+ center(l, t->rasp.nrunes, 0);
break;
case Ksoh: /* ctrl+a */
flushtyping(1);
@@ -687,7 +695,7 @@
flushtyping(0);
a = t->rasp.nrunes;
flsetselect(l, a, a);
- center(l, a, 0, 1);
+ center(l, a, 0);
break;
case Kbel:
if(work == nil)
--- a/samterm/mesg.c
+++ b/samterm/mesg.c
@@ -224,7 +224,7 @@
for(i = 0; i < NL; i++){
lp = &cmd.l[i];
if(lp->textfn && l > lp->origin+lp->f.nchars)
- center(lp, l >= 0? l: lp->p1, 0, 0);
+ center(lp, l >= 0? l: lp->p1, 0);
}
break;
@@ -593,9 +593,9 @@
goto Checksel; /* all's well */
a = t->l[i].origin+l->f.nchars;
n = t->rasp.nrunes-a;
- if(n==0)
+ if(n == 0)
goto Checksel;
- if(n>TBLOCKSIZE)
+ if(n > TBLOCKSIZE)
n = TBLOCKSIZE;
n = rcontig(&t->rasp, a, a+n, 1);
if(n > 0){
@@ -618,7 +618,7 @@
t->lock++; /* for the Tcheck */
reqd++;
}
- Checksel:
+ Checksel:
flsetselect(l, l->p0, l->p1);
}
}
--- a/samterm/samterm.h
+++ b/samterm/samterm.h
@@ -113,7 +113,7 @@
int kbdchar(void);
int qpeekc(void);
void cut(Text*, int, int, int);
-void center(Flayer*, long, long, int);
+void center(Flayer*, long, int);
void paste(Text*, int);
void snarf(Text*, int);
Rune raspc(Rasp*, long);
@@ -161,6 +161,7 @@
void dumperrmsg(int, int, int, int);
int screensize(int*, int*);
long bound(Text*, long);
+void setblock(int);
#include "mesg.h"
void outT0(Tmesg);
--- a/samterm/scroll.c
+++ b/samterm/scroll.c
@@ -165,7 +165,6 @@
p0 *= (but == 1 || but == 4)? -1: 1;
o = l->origin;
}
- mouseunblock();
- center(l, o, p0, 1);
+ center(l, o, p0);
}
}
--
⑨