aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/acme/text.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/acme/text.c')
-rw-r--r--src/cmd/acme/text.c64
1 files changed, 63 insertions, 1 deletions
diff --git a/src/cmd/acme/text.c b/src/cmd/acme/text.c
index 4832de8e..e47c97d2 100644
--- a/src/cmd/acme/text.c
+++ b/src/cmd/acme/text.c
@@ -243,6 +243,9 @@ textload(Text *t, uint q0, char *file, int setqid)
dbuf = nil;
while((n=dirread(fd, &dbuf)) > 0){
for(i=0; i<n; i++){
+ if(dbuf[i].name[0] == '.'){
+ continue; /* do not list dot files */
+ }
dl = emalloc(sizeof(Dirlist));
j = strlen(dbuf[i].name);
tmp = emalloc(j+1+1);
@@ -745,19 +748,74 @@ texttype(Text *t, Rune r)
} else
textshow(t, t->file->b.nc, t->file->b.nc, FALSE);
return;
+ case 0x09: /* ^I (TAB) */
+ if(t->what!=Body)
+ break;
+ 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 */
nnb = 0;
if(t->q0>0 && textreadc(t, t->q0-1)!='\n')
nnb = textbswidth(t, 0x15);
+ /* if already at beginning, wrap backwards to previous line if possible */
+ if (nnb == 0 && t->q0>0) {
+ textshow(t, t->q0-1, t->q0-1, TRUE);
+ return;
+ }
textshow(t, t->q0-nnb, t->q0-nnb, TRUE);
return;
case 0x05: /* ^E: end of line */
typecommit(t);
q0 = t->q0;
+ /* if already at end, wrap forward to the next line if possible */
+ if (q0<t->file->b.nc && textreadc(t, q0) == '\n') {
+ q0++;
+ textshow(t, q0, q0, TRUE);
+ return;
+ }
+ while(q0<t->file->b.nc && textreadc(t, q0)!='\n')
+ q0++;
+ textshow(t, q0, q0, TRUE);
+ return;
+ case 0x0E: /* ^N: move one line down */
+ typecommit(t);
+ q0 = t->q0;
+ nnb = 0;
+ if(q0>0 && textreadc(t, q0-1)!='\n')
+ nnb = textbswidth(t, 0x15);
while(q0<t->file->b.nc && textreadc(t, q0)!='\n')
q0++;
+ if (q0+1 <= t->file->b.nc)
+ q0++;
+ while(q0<t->file->b.nc && textreadc(t, q0)!='\n' && nnb--)
+ q0++;
+ textshow(t, q0, q0, TRUE);
+ return;
+ case 0x10: /* ^P: move one line up */
+ typecommit(t);
+ q0 = t->q0;
+ nnb = 0;
+ n = 0;
+ if(q0>0 && textreadc(t, q0-1)!='\n')
+ nnb = textbswidth(t, 0x15);
+ q0 -= nnb;
+ if (q0>0)
+ q0--;
+ while (q0>0 && textreadc(t, q0-1)!='\n')
+ if (q0 == 0)
+ break;
+ else {
+ q0--;
+ n++;
+ }
+ q0 += (nnb > n) ? n : nnb;
textshow(t, q0, q0, TRUE);
return;
case Kcmd+'c': /* %C: copy */
@@ -771,7 +829,11 @@ texttype(Text *t, Rune r)
case Kcmd+'Z': /* %-shift-Z: redo */
typecommit(t);
undo(t, nil, nil, FALSE, 0, nil, 0);
- return;
+ return;
+ case Kcmd+'s': /* %S: save/put file */
+ typecommit(t);
+ put(&t->w->body, nil, nil, XXX, XXX, nil, 0);
+ return;
Tagdown:
/* expand tag to show all text */