aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetter Rodhelind <petter.rodhelind@gmail.com>2017-05-11 08:04:35 +0200
committerPetter Rodhelind <petter.rodhelind@gmail.com>2017-05-11 08:04:35 +0200
commit31f188eef9af8a8ca3a7c493f18fcc74c00861a3 (patch)
tree93b23c6ff38198dc9431197b72e67160bc735292
parentbfd823b33025c7b5958a9d815f7762f83bc34a71 (diff)
downloadplan9port-31f188eef9af8a8ca3a7c493f18fcc74c00861a3.tar.gz
plan9port-31f188eef9af8a8ca3a7c493f18fcc74c00861a3.tar.bz2
plan9port-31f188eef9af8a8ca3a7c493f18fcc74c00861a3.zip
Add support for tab expansion (because everyone else is stupid and I am forced to follow along)
Tab expansion inserts spaces instead of TAB character. Number of spaces is dependent upon your current tab stop setting, which can be changed by running "Tab n". As of now, it's not possible to turn it on and off during runtime. You can however see whether it's compiled or not by executing the command "Tabexpand". The console will show either 1 or 0. This will be taken care of in a later commit.
-rw-r--r--src/cmd/acme/dat.h1
-rw-r--r--src/cmd/acme/exec.c19
-rw-r--r--src/cmd/acme/text.c8
-rw-r--r--src/cmd/acme/wind.c1
4 files changed, 29 insertions, 0 deletions
diff --git a/src/cmd/acme/dat.h b/src/cmd/acme/dat.h
index df1a6422..74107a11 100644
--- a/src/cmd/acme/dat.h
+++ b/src/cmd/acme/dat.h
@@ -268,6 +268,7 @@ struct Window
int utflastqid;
int utflastboff;
int utflastq;
+ uchar tabexpand; /* expand tab char with space*body.tabstop */
int tagsafe; /* taglines is correct */
int tagexpand;
int taglines;
diff --git a/src/cmd/acme/exec.c b/src/cmd/acme/exec.c
index 2a259533..e0dcb191 100644
--- a/src/cmd/acme/exec.c
+++ b/src/cmd/acme/exec.c
@@ -53,6 +53,7 @@ void putall(Text*, Text*, Text*, int, int, Rune*, int);
void sendx(Text*, Text*, Text*, int, int, Rune*, int);
void sort(Text*, Text*, Text*, int, int, Rune*, int);
void tab(Text*, Text*, Text*, int, int, Rune*, int);
+void tabexpand(Text*, Text*, Text*, int, int, Rune*, int);
void zeroxx(Text*, Text*, Text*, int, int, Rune*, int);
typedef struct Exectab Exectab;
@@ -92,6 +93,7 @@ static Rune LSend[] = { 'S', 'e', 'n', 'd', 0 };
static Rune LSnarf[] = { 'S', 'n', 'a', 'r', 'f', 0 };
static Rune LSort[] = { 'S', 'o', 'r', 't', 0 };
static Rune LTab[] = { 'T', 'a', 'b', 0 };
+static Rune LTabexpand[] = { 'T', 'a', 'b', 'e', 'x', 'p', 'a', 'n', 'd', 0 };
static Rune LUndo[] = { 'U', 'n', 'd', 'o', 0 };
static Rune LZerox[] = { 'Z', 'e', 'r', 'o', 'x', 0 };
@@ -123,6 +125,7 @@ Exectab exectab[] = {
{ LSnarf, cut, FALSE, TRUE, FALSE },
{ LSort, sort, FALSE, XXX, XXX },
{ LTab, tab, FALSE, XXX, XXX },
+ { LTabexpand, tabexpand, FALSE, XXX, XXX },
{ LUndo, undo, FALSE, TRUE, XXX },
{ LZerox, zeroxx, FALSE, XXX, XXX },
{ nil, 0, 0, 0, 0 }
@@ -1359,6 +1362,22 @@ tab(Text *et, Text *_0, Text *argt, int _1, int _2, Rune *arg, int narg)
}
void
+tabexpand(Text *et, Text *_0, Text *argt, int _1, int _2, Rune *arg, int narg)
+{
+ Window *w;
+
+ USED(_0);
+ USED(_1);
+ USED(_2);
+
+ if(et==nil || et->w==nil)
+ return;
+ w = et->w;
+
+ printf("tabexpand: %d\n", w->tabexpand);
+}
+
+void
runproc(void *argvp)
{
/* args: */
diff --git a/src/cmd/acme/text.c b/src/cmd/acme/text.c
index 0452c2b1..faa87d99 100644
--- a/src/cmd/acme/text.c
+++ b/src/cmd/acme/text.c
@@ -758,6 +758,14 @@ texttype(Text *t, Rune r)
} else
textshow(t, t->file->b.nc, t->file->b.nc, FALSE);
return;
+ case 0x09: /* ^I (TAB) */
+ if(t->w->tabexpand == TRUE){
+ for(i=0; i < t->w->body.tabstop; i++){
+ texttype(t, ' ');
+ }
+ return;
+ }else
+ break; /* fall through to normal code */
case 0x01: /* ^A: beginning of line */
typecommit(t);
/* go to where ^U would erase, if not already at BOL */
diff --git a/src/cmd/acme/wind.c b/src/cmd/acme/wind.c
index 712eb1dc..2401ee67 100644
--- a/src/cmd/acme/wind.c
+++ b/src/cmd/acme/wind.c
@@ -80,6 +80,7 @@ wininit(Window *w, Window *clone, Rectangle r)
w->filemenu = TRUE;
w->maxlines = w->body.fr.maxlines;
w->autoindent = globalautoindent;
+ w->tabexpand = TRUE;
if(clone){
w->dirty = clone->dirty;
w->autoindent = clone->autoindent;