Introduction
Introduction Statistics Contact Development Disclaimer Help
Treated tab expansion as a normal command. - sam - An updated version of the sa…
git clone git://vernunftzentrum.de/sam.git
Log
Files
Refs
LICENSE
---
commit 8e2e9e5d024f89ba01f40f68a8d4cdd04b47c454
parent aaf4e09b9bc9910b3502e4d781ea89d902fa0306
Author: Rob King <[email protected]>
Date: Tue, 13 Sep 2016 10:55:22 -0500
Treated tab expansion as a normal command.
This removes a fairly large special case in the input code, further
simplifying things.
Diffstat:
samterm/main.c | 37 ++++++++++++++++++++-----------
samterm/samrc.c | 6 +++---
samterm/samterm.h | 1 +
3 files changed, 28 insertions(+), 16 deletions(-)
---
diff --git a/samterm/main.c b/samterm/main.c
@@ -816,6 +816,27 @@ cmdwrite(Flayer *l, long a, Text *t)
}
static long
+cmdtab(Flayer *l, long a, Text *t)
+{
+ flushtyping(0);
+
+ if (!expandtabs)
+ pushkbd('\t');
+ else{
+ int col = 0, nspaces = 8, off = a;
+ int i;
+ while (off > 0 && raspc(&t->rasp, off - 1) != '\n')
+ off--, col++;
+
+ nspaces = tabwidth - col % tabwidth;
+ for (i = 0; i < nspaces; i++)
+ pushkbd(' ');
+ }
+
+ return a;
+}
+
+static long
cmdnone(Flayer *l, long a, Text *t)
{
return a;
@@ -850,9 +871,11 @@ CommandEntry commands[Cmax] ={
[Cdel] = {cmddel, true, true},
[Cwrite] = {cmdwrite, true, false},
[Ceol] = {cmdeol, false, false},
- [Cbol] = {cmdbol, false, false}
+ [Cbol] = {cmdbol, false, false},
+ [Ctab] = {cmdtab, false, false}
};
+
void
type(Flayer *l, int res) /* what a bloody mess this is -- but it's getting …
{
@@ -879,18 +902,6 @@ type(Flayer *l, int res) /* what a bloody mess this is …
if (k.k == Kcommand)
break;
- if (expandtabs && k.c == '\t' && k.k != Kcomposed){
- int col = 0, nspaces = 8, off = a;
- int i;
- while (off > 0 && raspc(&t->rasp, off - 1) != '\n')
- off--, col++;
-
- nspaces = tabwidth - col % tabwidth;
- for (i = 0; i < nspaces; i++)
- pushkbd(' ');
- break;
- }
-
*p++ = k.c;
if (k.c == '\n' || p >= buf + sizeof(buf) / sizeof(buf[0]))
break;
diff --git a/samterm/samrc.c b/samterm/samrc.c
@@ -133,10 +133,10 @@ static Defaultbinding defaultbindings[] ={
/* More fundamental stuff: backspace, delete, etc. */
{0, XK_BackSpace, Kcommand, Cdel},
{0, XK_Delete, Kcommand, Cdel},
+ {0, XK_Tab, Kcommand, Ctab},
{0, XK_Return, Kraw, '\n'},
{0, XK_KP_Enter, Kraw, '\n'},
{0, XK_Linefeed, Kraw, '\r'},
- {0, XK_Tab, Kraw, '\t'},
{0, XK_KP_0, Kraw, '0'},
{0, XK_KP_1, Kraw, '1'},
{0, XK_KP_2, Kraw, '2'},
@@ -156,12 +156,12 @@ static Defaultbinding defaultbindings[] ={
/* Support traditional control sequences. */
{ControlMask, XK_h, Kcommand, Cdel},
- {ControlMask, XK_i, Kraw, '\t'},
+ {ControlMask, XK_i, Kcommand, Ctab},
{ControlMask, XK_j, Kraw, '\n'},
{ControlMask, XK_m, Kraw, '\r'},
/* Use Control-Tab to insert a literal tab when tab expansion is enabled. …
- {ControlMask, XK_Tab, Kcomposed, '\t'},
+ {ControlMask, XK_Tab, Kraw, '\t'},
{0, 0, Kend, 0}
};
diff --git a/samterm/samterm.h b/samterm/samterm.h
@@ -27,6 +27,7 @@ enum{
Cwrite, /* write file */
Ceol, /* move to beginning of line */
Cbol, /* move to end of line */
+ Ctab, /* insert a possibly expanded tab */
Cmax /* invalid command */
};
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.