Introduction
Introduction Statistics Contact Development Disclaimer Help
Add the Cscroll{up,down}line commands. - sam - An updated version of the sam te…
git clone git://vernunftzentrum.de/sam.git
Log
Files
Refs
LICENSE
---
commit 21076f0c6d1007710b95fb6f69b2af0d34453ec4
parent d8d972951595b12f68a1ef9707f71c3a93e7f04b
Author: Rob King <[email protected]>
Date: Thu, 1 Sep 2016 11:45:48 -0500
Add the Cscroll{up,down}line commands.
(Also more fixes to the new mouse chording code.)
Credit to Chris Siebenmann for the implementation of the
Cscroll{up,down}line commands.
Diffstat:
Makefile | 1 +
README.rst | 1 +
chords.h.def | 20 ++++++++++++++++----
commands.h.def | 38 +++++++++++++++++--------------
include/commands.h | 2 ++
samterm/main.c | 85 +++++++++++++++++++-------------
6 files changed, 92 insertions(+), 55 deletions(-)
---
diff --git a/Makefile b/Makefile
@@ -22,6 +22,7 @@ config.mk:
lXg:
cd libXg; $(MAKE)
+
lframe:
cd libframe; $(MAKE)
diff --git a/README.rst b/README.rst
@@ -44,6 +44,7 @@ Installation and configuration is fairly simple:
- Copy `config.mk.def` to `config.mk` and modify as needed.
- Copy `config.h.def` to `config.h` and modify as needed.
- Copy `commands.h.def` to `commands.h` and modify as needed.
+- Copy `chords.h.def` to `chords.h` and modify as needed.
- Run `make clean all`
- Run `make install` or, if needed, `sudo make install`
diff --git a/chords.h.def b/chords.h.def
@@ -7,6 +7,13 @@
* end - the end state (i.e. what mouse buttons are now pressed)
* action - one of the commands listed in commands.h (or commands.h.def)
*
+ * The following values are available for state definitions:
+ * None - No buttons are pressed
+ * B[1-5] - Button n is pressed
+ *
+ * The Bn masks can be combined using the "|" operator, so
+ * "B1|B2" means "both buttons 1 and 2 pressed".
+ *
* The default configuration shipped with sam has the mouse chords of the
* "classic" Unix sam of the 1980s.
*/
@@ -14,10 +21,15 @@
{B1, B1|B2, Kcommand, Ccut},
{B1, B1|B3, Kcommand, Cpaste},
-/* The lines below "cancel" the mouse movement that is implicit above.
- * If these lines are not present, dot will move to where the mouse is
- * after the chords above. Some people might like that: if so, just
- * remove these lines.
+{B4, 0, Kcommand, Cscrollupline},
+{B5, 0, Kcommand, Cscrolldownline},
+
+/* The lines below "cancel" the mouse movement that is implicit above
+ * in the Ccut and Cpaste chords. If these lines are not present, dot
+ * will move to where the mouse is after the chords above are used.
+ *
+ * Some people might like that kind of behavior: if so, just remove
+ * these lines.
*/
{B1|B3, B1, Kcommand, Cnone},
{B1|B2, B1, Kcommand, Cnone},
diff --git a/commands.h.def b/commands.h.def
@@ -15,23 +15,27 @@
*
* Available commands are:
*
- * Cnone - ignore the key
- * Clineup - move up by line
- * Clinedown - move down by line
- * Ccharright - move right by character
- * Ccharleft - move left by character
- * Cdelbol - delete to beginning of line
- * Cdelword - delete previous word
- * Cdel - delete previous character
- * Cjump - jump to and from the command window
- * Cescape - highlight recently typed text
- * Csnarf - copy text to the snarf buffer
- * Cpaste - paste text from the snarf buffer
- * Ccut - cut text to the snarf buffer
- * Cexchange - exchange operating system and sam snarf buffers
- * Cwrite - write the current file to disk
- * Cbol - move to beginning of line
- * Ceol - move to end of line
+ * Cnone - ignore the key
+ * Cscrollup - scroll up by screen
+ * Cscrolldown - scroll down by screen
+ * Cscrollupline - scroll up by line
+ * Cscrolldownline - scroll down by line
+ * Clineup - move up by line
+ * Clinedown - move down by line
+ * Ccharright - move right by character
+ * Ccharleft - move left by character
+ * Cdelbol - delete to beginning of line
+ * Cdelword - delete previous word
+ * Cdel - delete previous character
+ * Cjump - jump to and from the command window
+ * Cescape - highlight recently typed text
+ * Csnarf - copy text to the snarf buffer
+ * Cpaste - paste text from the snarf buffer
+ * Ccut - cut text to the snarf buffer
+ * Cexchange - exchange operating system and sam snarf buffers
+ * Cwrite - write the current file to disk
+ * Cbol - move to beginning of line
+ * Ceol - move to end of line
*
* The default configuration shipped with sam has the keyboard commands mapped
* to the "classic" Unix sam of the 1980s, plus the WordStar Diamond for cursor
diff --git a/include/commands.h b/include/commands.h
@@ -14,6 +14,8 @@ enum{
Cescape,
Cscrolldown,
Cscrollup,
+ Cscrolldownline,
+ Cscrollupline,
Cjump,
Ccharright,
Ccharleft,
diff --git a/samterm/main.c b/samterm/main.c
@@ -9,6 +9,7 @@
#include <commands.h>
extern unsigned long _bgpixel;
+extern void hmoveto(int, long);
Text cmd;
Rune *scratch;
@@ -126,12 +127,6 @@ main(int argc, char *argv[])
scroll(which, 3, fwdbut == 3 ? 3 : 1);
else
menu3hit();
- }else if((mouse.buttons&16)){
- flushtyping(0);
- scroll(which, 5, 5);
- }else if((mouse.buttons&8)){
- flushtyping(0);
- scroll(which, 4, 4);
}
mouseunblock();
}
@@ -387,16 +382,15 @@ ctlu(Rasp *r, long o, long p)
int
center(Flayer *l, long a)
{
- Text *t;
+ Text *t = l->user1;
- t = l->user1;
- if(!t->lock && (a<l->origin || l->origin+l->f.nchars<a)){
- if(a > t->rasp.nrunes)
- a = t->rasp.nrunes;
- outTsll(Torigin, t->tag, a, 2L);
- return 1;
- }
- return 0;
+ 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);
+ return 1;
+ }
+
+ return 0;
}
int
@@ -530,6 +524,27 @@ 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);
+ return a;
+}
+
+static long
+cmdscrolldownline(Flayer *l, long a, Text *t)
+{
+ long tot = scrtotal(l);
+ long p0 = l->origin + frcharofpt(&l->f, Pt(l->f.r.min.x, l->f.r.min.y + l-…
+ long p1 = l->origin + frcharofpt(&l->f, Pt(l->f.r.min.x, l->f.r.max.y - l-…
+
+ if (p0 < tot && p1 < tot)
+ horigin(t->tag, p0);
+
+ return a;
+}
+
+static long
cmdlineup(Flayer *l, long a, Text *t)
{
flsetselect(l, a, a);
@@ -775,25 +790,27 @@ struct CommandEntry{
};
CommandEntry commands[Cmax] ={
- [Cnone] = {cmdnone, 0},
- [Cscrolldown] = {cmdscrolldown, 0},
- [Cscrollup] = {cmdscrollup, 0},
- [Ccharleft] = {cmdcharleft, 0},
- [Ccharright] = {cmdcharright, 0},
- [Clineup] = {cmdlineup, 0},
- [Clinedown] = {cmdlinedown, 0},
- [Cjump] = {cmdjump, 0},
- [Cescape] = {cmdescape, 0},
- [Csnarf] = {cmdsnarf, 0},
- [Ccut] = {cmdcut, 0},
- [Cpaste] = {cmdpaste, 0},
- [Cexchange] = {cmdexchange, 0},
- [Cdelword] = {cmddelword, 1},
- [Cdelbol] = {cmddelbol, 1},
- [Cdel] = {cmddel, 1},
- [Cwrite] = {cmdwrite, 1},
- [Ceol] = {cmdeol, 0},
- [Cbol] = {cmdbol, 0}
+ [Cnone] = {cmdnone, 0},
+ [Cscrolldown] = {cmdscrolldown, 0},
+ [Cscrollup] = {cmdscrollup, 0},
+ [Cscrolldownline] = {cmdscrolldownline, 0},
+ [Cscrollupline] = {cmdscrollupline, 0},
+ [Ccharleft] = {cmdcharleft, 0},
+ [Ccharright] = {cmdcharright, 0},
+ [Clineup] = {cmdlineup, 0},
+ [Clinedown] = {cmdlinedown, 0},
+ [Cjump] = {cmdjump, 0},
+ [Cescape] = {cmdescape, 0},
+ [Csnarf] = {cmdsnarf, 0},
+ [Ccut] = {cmdcut, 0},
+ [Cpaste] = {cmdpaste, 0},
+ [Cexchange] = {cmdexchange, 0},
+ [Cdelword] = {cmddelword, 1},
+ [Cdelbol] = {cmddelbol, 1},
+ [Cdel] = {cmddel, 1},
+ [Cwrite] = {cmdwrite, 1},
+ [Ceol] = {cmdeol, 0},
+ [Cbol] = {cmdbol, 0}
};
void
You are viewing proxied material from vernunftzentrum.de. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.