Make scrolling actions to work with zeroxed layers. - sam - An updated version of the sam text editor.
(HTM) git clone git://vernunftzentrum.de/sam.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit 29ec8916b4867f462599605a00dc1f04c4619b5b
(DIR) parent 2be8dae9931102b0e46c8c065d84684540147438
(HTM) Author: Rob King <jking@deadpixi.com>
Date: Thu, 1 Sep 2016 16:36:52 -0500
Make scrolling actions to work with zeroxed layers.
Diffstat:
doc/sam.1 | 9 ---------
samterm/main.c | 25 ++++++++++++++++++-------
samterm/mesg.c | 23 +++++++++++++----------
samterm/samterm.h | 3 ++-
4 files changed, 33 insertions(+), 27 deletions(-)
---
(DIR) diff --git a/doc/sam.1 b/doc/sam.1
@@ -1029,15 +1029,6 @@ Stores output of shell commands executed by
.Xr ed 1
.Sh BUGS
.Pp
-Mouse chords can be directed to either the front layer,
-or to the layer containing the mouse pointer.
-In the latter case,
-this allows a background layer to be scrolled using the mouse wheel.
-However,
-this does not always work if the layer in question has multiple duplicate frames.
-This is because the scrolling code identifies which layer to scroll by tag,
-which is common to all views open on that file.
-.Pp
The only human language in which colors may be specified is English.
.Pp
The only human language in which output is generated is English.
(DIR) diff --git a/samterm/main.c b/samterm/main.c
@@ -9,7 +9,7 @@
#include <commands.h>
extern unsigned long _bgpixel;
-extern void hmoveto(int, long);
+extern void hmoveto(int, long, Flayer *);
Text cmd;
Rune *scratch;
@@ -322,8 +322,8 @@ scrorigin(Flayer *l, int but, long p0)
case 2:
outTsll(Torigin, t->tag, p0, 1L);
break;
- case 3: case 5:
- horigin(t->tag,p0);
+ case 3:
+ horigin(t->tag, p0, NULL);
}
}
@@ -526,8 +526,19 @@ cmdbol(Flayer *l, long a, Text *t)
static long
cmdscrollupline(Flayer *l, long a, Text *t)
{
- if (l->origin > 0)
- hmoveto(t->tag, l->origin - 1);
+ if (l->origin > 0){
+ long x = l->origin - 1;
+ while (x > 0 && raspc(&t->rasp, x - 1) != '\n')
+ x--;
+
+ /* if (x > 0){
+ //x--;
+ while (x > 0 && raspc(&t->rasp, x) != '\n')
+ x--;
+ } */
+
+ horigin(t->tag, x, l);
+ }
return a;
}
@@ -539,7 +550,7 @@ cmdscrolldownline(Flayer *l, long a, Text *t)
long p1 = l->origin + frcharofpt(&l->f, Pt(l->f.r.min.x, l->f.r.max.y - l->f.fheight / 2));
if (p0 < tot && p1 < tot)
- horigin(t->tag, p0);
+ horigin(t->tag, p0, l);
return a;
}
@@ -707,7 +718,7 @@ cmddel(Flayer *l, long a, Text *t)
return a;
}
-static inline int
+int
getlayer(const Flayer *l, const Text *t)
{
int i;
(DIR) diff --git a/samterm/mesg.c b/samterm/mesg.c
@@ -22,7 +22,7 @@ int inshort(int);
long inlong(int);
long invlong(int);
void hsetdot(int, long, long);
-void hmoveto(int, long);
+void hmoveto(int, long, Flayer *);
void hsetsnarf(int);
void clrlock(void);
int snarfswap(char*, int, char**);
@@ -215,7 +215,7 @@ inmesg(Hmesg type, int count)
case Horigin:
if(whichmenu(m) >= 0)
- horigin(m, l);
+ horigin(m, l, NULL);
break;
case Hunlockfile:
@@ -241,7 +241,7 @@ inmesg(Hmesg type, int count)
case Hmoveto:
if(whichmenu(m)>=0)
- hmoveto(m, l);
+ hmoveto(m, l, NULL);
break;
case Hclean:
@@ -537,14 +537,17 @@ hsetdot(int m, long p0, long p1)
}
void
-horigin(int m, long p0)
+horigin(int m, long p0, Flayer *l)
{
Text *t = whichtext(m);
- Flayer *l = &t->l[t->front];
+ l = l ? l : &t->l[t->front];
long a;
ulong n;
Rune *r;
+ if (getlayer(l, t) < 0)
+ return; /* the user managed to close the layer during the round trip with the host */
+
if(!flprepare(l)){
l->origin = p0;
return;
@@ -565,13 +568,13 @@ horigin(int m, long p0)
}
void
-hmoveto(int m, long p0)
+hmoveto(int m, long p0, Flayer *l)
{
- Text *t = whichtext(m);
- Flayer *l = &t->l[t->front];
+ Text *t = whichtext(m);
+ l = l ? l : &t->l[t->front];
- if(p0<l->origin || p0-l->origin>l->f.nchars*9/10)
- outTsll(Torigin, m, p0, 2L);
+ if (p0 < l->origin || p0 - l->origin > l->f.nchars * 9/10)
+ outTsll(Torigin, m, p0, 2L);
}
void
(DIR) diff --git a/samterm/samterm.h b/samterm/samterm.h
@@ -117,7 +117,7 @@ void hcheck(int);
void rclear(Rasp*);
int whichmenu(int);
void hcut(int, long, long);
-void horigin(int, long);
+void horigin(int, long, Flayer *);
void hgrow(int, long, long, int);
int hdata(int, long, uchar*, int);
int hdatarune(int, long, Rune*, int);
@@ -158,3 +158,4 @@ void outshort(int);
void outlong(long);
void outvlong(void*);
void outsend(void);
+int getlayer(const Flayer *l, const Text *t);