diff options
Diffstat (limited to 'src/cmd/acme/text.c')
-rw-r--r-- | src/cmd/acme/text.c | 67 |
1 files changed, 58 insertions, 9 deletions
diff --git a/src/cmd/acme/text.c b/src/cmd/acme/text.c index c53694c6..e82a3a30 100644 --- a/src/cmd/acme/text.c +++ b/src/cmd/acme/text.c @@ -681,10 +681,19 @@ texttype(Text *t, Rune r) textshow(t, t->q1+1, t->q1+1, TRUE); return; case Kdown: - if(t->what == Tag) - goto Tagdown; - n = t->fr.maxlines/3; - goto case_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 Kscrollonedown: if(t->what == Tag) goto Tagdown; @@ -699,10 +708,25 @@ texttype(Text *t, Rune r) textsetorigin(t, q0, TRUE); return; case Kup: - if(t->what == Tag) - goto Tagup; - n = t->fr.maxlines/3; - goto case_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 Kscrolloneup: if(t->what == Tag) goto Tagup; @@ -734,17 +758,38 @@ 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); @@ -760,7 +805,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 */ |