Merge pull request #65 from hubhamster/pointtotype - 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 3184909efee9f81359fcd81a4fc4626fe8fa0c78
(DIR) parent e14578ad4611d277ba702e783cc619a52c409cd3
(HTM) Author: Rob King <deadpixi@users.noreply.github.com>
Date: Fri, 15 Sep 2017 20:38:49 -0500
Merge pull request #65 from hubhamster/pointtotype
Pointtotype
Diffstat:
doc/samrc.5 | 19 +++++++++++++++++++
samterm/main.c | 6 +++++-
samterm/menu.c | 2 ++
samterm/samrc.c | 11 +++++++++++
samterm/samterm.h | 1 +
5 files changed, 38 insertions(+), 1 deletion(-)
---
(DIR) diff --git a/doc/samrc.5 b/doc/samrc.5
@@ -226,6 +226,24 @@ The forms are:
snarfselection secondary
snarfselection clipboard
.Ed
+.It followfocus
+Determines window focus mode.
+It is of the form:
+.Bd -literal
+
+ followfocus B
+
+.Ed
+where
+.Em B
+is the string
+.Dq true
+or
+.Dq false "."
+If
+.Dq true ","
+then the window focus mode is set to follow the mouse pointer.
+In this mode typing is directed to the window currently underneath the mouse pointer.
.El
.Ss Defaults
The default keybindings and mouse chords are those documented in
@@ -237,6 +255,7 @@ and tabstops are set at every eight characters.
The default X selection is
.Do primary
.Dc "."
+The default window focus mode is "Click to focus". Typing is directed to the window which was last clicked.
.Ss "Modifier Keys"
The
.Em bind
(DIR) diff --git a/samterm/main.c b/samterm/main.c
@@ -31,6 +31,7 @@ bool autoindent = false;
char *machine = "localhost";
int exfd = -1;
const char *exname;
+bool followfocus = false;
void
removeext(void)
@@ -151,6 +152,8 @@ main(int argc, char *argv[])
scroll(which, 3, 3);
else
menu3hit();
+ }else if(followfocus && nwhich && nwhich!=which){
+ current(nwhich);
}
mouseunblock();
}
@@ -180,7 +183,8 @@ current(Flayer *nw)
flborder(which, false);
if(nw){
flushtyping(true);
- flupfront(nw);
+ if (!followfocus)
+ flupfront(nw);
flborder(nw, true);
buttons(Up);
t = (Text *)nw->user1;
(DIR) diff --git a/samterm/menu.c b/samterm/menu.c
@@ -180,6 +180,8 @@ menu3hit(void)
i = 0;
while(i!=t->front && t->l[i].textfn==0);
current(&t->l[i]);
+ if (followfocus)
+ flupfront(&t->l[i]);
}else if(!lock)
sweeptext(0, tag[m-NMENU3]);
break;
(DIR) diff --git a/samterm/samrc.c b/samterm/samrc.c
@@ -234,6 +234,16 @@ nametokeysym(const char *n)
}
static int
+dirfollowfocus(const char *s1, const char *s2, const char *s3, const char *s4, const char *s5)
+{
+ if (strcasecmp(s1, "true") != 0 && strcasecmp(s1, "false") != 0)
+ return -1;
+
+ followfocus = (strcasecmp(s1, "true") == 0);
+ return 0;
+}
+
+static int
dirsnarfselection(const char *s1, const char *s2, const char *s3, const char *s4, const char *s5)
{
extern const char *clipatom;
@@ -389,6 +399,7 @@ Directive directives[] ={
{" expandtabs %99s", 1, direxpandtabs},
{" autoindent %99s", 1, dirautoindent},
{" snarfselection %99s", 1, dirsnarfselection},
+ {" followfocus %99s", 1, dirfollowfocus},
{" %1[#]", 1, dircomment},
{" %1[^ ]", EOF, dircomment},
{NULL, 0, NULL}
(DIR) diff --git a/samterm/samterm.h b/samterm/samterm.h
@@ -93,6 +93,7 @@ extern bool hasunlocked;
extern int64_t snarflen;
extern Mouse mouse;
extern bool modified;
+extern bool followfocus;
wchar_t *stgettext(Flayer*, int64_t, uint64_t*);
void *alloc(uint64_t n);