diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd/acme/acme.c | 97 | ||||
| -rw-r--r-- | src/cmd/acme/scrl.c | 14 | ||||
| -rw-r--r-- | src/cmd/acme/text.c | 82 |
3 files changed, 106 insertions, 87 deletions
diff --git a/src/cmd/acme/acme.c b/src/cmd/acme/acme.c index bb774153..b4968fc0 100644 --- a/src/cmd/acme/acme.c +++ b/src/cmd/acme/acme.c @@ -1033,63 +1033,58 @@ Cursor2 boxcursor2 = { 0x00, 0x00, 0x00, 0x00} }; -void -iconinit(void) -{ - Rectangle r; - Image *tmp; - - if(tagcols[BACK] == nil) { - /* Blue */ - tagcols[BACK] = allocimagemix(display, DPalebluegreen, DWhite); - tagcols[HIGH] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DPalegreygreen); - tagcols[BORD] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DPurpleblue); - tagcols[TEXT] = display->black; - tagcols[HTEXT] = display->black; - - /* Yellow */ - textcols[BACK] = allocimagemix(display, DPaleyellow, DWhite); - textcols[HIGH] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DDarkyellow); - textcols[BORD] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DYellowgreen); - textcols[TEXT] = display->black; - textcols[HTEXT] = display->black; - } - - r = Rect(0, 0, Scrollwid, font->height+1); - if(button && eqrect(r, button->r)) - return; - - if(button){ - freeimage(button); - freeimage(modbutton); - freeimage(colbutton); - } - - button = allocimage(display, r, screen->chan, 0, DNofill); - draw(button, r, tagcols[BACK], nil, r.min); - border(button, r, ButtonBorder, tagcols[BORD], ZP); - - r = button->r; - modbutton = allocimage(display, r, screen->chan, 0, DNofill); - draw(modbutton, r, tagcols[BACK], nil, r.min); - border(modbutton, r, ButtonBorder, tagcols[BORD], ZP); - r = insetrect(r, ButtonBorder); - tmp = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DMedblue); - draw(modbutton, r, tmp, nil, ZP); - freeimage(tmp); - - r = button->r; - colbutton = allocimage(display, r, screen->chan, 0, DPurpleblue); - - but2col = allocimage(display, r, screen->chan, 1, 0xAA0000FF); - but3col = allocimage(display, r, screen->chan, 1, 0x006600FF); -} /* * /dev/snarf updates when the file is closed, so we must open our own * fd here rather than use snarffd */ +void +iconinit(void) +{ + Rectangle r; + Image *tmp; + + /* Blue */ + tagcols[BACK] = display->white; + tagcols[HIGH] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x72DEC2FF); + tagcols[BORD] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x72DEC2FF); + tagcols[TEXT] = display->black; + tagcols[HTEXT] = display->white; + + /* Yellow */ + textcols[BACK] = allocimagemix(display, DWhite, DWhite); + textcols[HIGH] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x72DEC2FF); + /* Halftone */ + textcols[BORD] = allocimage(display, Rect(0,0,2,2), CMAP8, 1, 0x000000FF); + draw(textcols[BORD], Rect(1,1,2,2), display->white, nil, ZP); + draw(textcols[BORD], Rect(0,0,1,1), display->white, nil, ZP); + textcols[TEXT] = display->black; + textcols[HTEXT] = display->black; + + if(button){ + freeimage(button); + freeimage(modbutton); + freeimage(colbutton); + } + /* Button */ + r = Rect(0, 0, Scrollwid, font->height+1); + button = allocimage(display, r, screen->chan, 0, DNofill); + draw(button, r, tagcols[BORD], nil, r.min); + r.max.x -= 4; + fillellipse(button, (Point){r.min.x + 5, r.min.y + 7}, 3, 3, display->white, ZP); + /* Mod Button */ + r = button->r; + modbutton = allocimage(display, r, screen->chan, 0, DNofill); + draw(modbutton, r, tagcols[BORD], nil, r.min); + r = insetrect(r, 2); + fillellipse(modbutton, (Point){r.min.x + 3, r.min.y + 5}, 3, 3, display->black, ZP); + r = button->r; + colbutton = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x72DEC2FF); + but2col = allocimage(display, r, screen->chan, 1, 0x000000FF); + but3col = allocimage(display, r, screen->chan, 1, 0x72DEC2FF); +} + /* rio truncates larges snarf buffers, so this avoids using the * service if the string is huge */ diff --git a/src/cmd/acme/scrl.c b/src/cmd/acme/scrl.c index 6504699d..ab489ea5 100644 --- a/src/cmd/acme/scrl.c +++ b/src/cmd/acme/scrl.c @@ -69,13 +69,13 @@ textscrdraw(Text *t) r1.max.x = Dx(r); r2 = scrpos(r1, t->org, t->org+t->fr.nchars, t->file->b.nc); if(!eqrect(r2, t->lastsr)){ - t->lastsr = r2; - draw(b, r1, t->fr.cols[BORD], nil, ZP); - draw(b, r2, t->fr.cols[BACK], nil, ZP); - r2.min.x = r2.max.x-1; - draw(b, r2, t->fr.cols[BORD], nil, ZP); - draw(t->fr.b, r, b, nil, Pt(0, r1.min.y)); -/*flushimage(display, 1); // BUG? */ + t->lastsr = r2; + draw(b, r1, t->fr.cols[BORD], nil, ZP); + r2.max.x = r2.max.x+1; + draw(b, r2, t->fr.cols[TEXT], nil, ZP); + r2.min.x = r2.max.x-1; + draw(b, r2, t->fr.cols[BORD], nil, ZP); + draw(t->fr.b, r, b, nil, Pt(0, r1.min.y)); } } diff --git a/src/cmd/acme/text.c b/src/cmd/acme/text.c index 09422dda..4f70867e 100644 --- a/src/cmd/acme/text.c +++ b/src/cmd/acme/text.c @@ -692,10 +692,27 @@ 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(t->q0>0 && textreadc(t, t->q0-1)!='\n') + nnb = textbswidth(t, 0x15); + while(q0<t->file->b.nc && textreadc(t, q0)!='\n') + q0++; + if (q0 == t->file->b.nc) { + textshow(t, q0, q0, TRUE); + return; + } + q0++; + while(nnb>=0 && q0<t->file->b.nc) { + if (textreadc(t, q0)=='\n') + break; + nnb--; + if (nnb >= 0) + q0++; + } + textshow(t, q0, q0, TRUE); + return; case Kscrollonedown: if(t->what == Tag) goto Tagdown; @@ -710,10 +727,26 @@ 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); + nnb = 0; + if(t->q0>0 && textreadc(t, t->q0-1)!='\n') + nnb = textbswidth(t, 0x15); + q1 = nnb; + if(t->q0-nnb > 1 && textreadc(t, t->q0-nnb-1)=='\n') + nnb++; + q0 = t->q0-nnb; + textshow(t, q0, q0, TRUE); + + nnb = textbswidth(t, 0x15); + if (nnb <= 1) + return; + q0 = q0-nnb; + while (q1>0 && textreadc(t, q0)!='\n') { + q1--; + q0++; + } + textshow(t, q0, q0, TRUE); + return; case Kscrolloneup: if(t->what == Tag) goto Tagup; @@ -726,25 +759,6 @@ texttype(Text *t, Rune r) textsetorigin(t, q0, TRUE); return; case Khome: - typecommit(t); - if(t->org > t->iq1) { - q0 = textbacknl(t, t->iq1, 1); - textsetorigin(t, q0, TRUE); - } else - textshow(t, 0, 0, FALSE); - return; - case Kend: - typecommit(t); - if(t->iq1 > t->org+t->fr.nchars) { - if(t->iq1 > t->file->b.nc) { - // should not happen, but does. and it will crash textbacknl. - t->iq1 = t->file->b.nc; - } - q0 = textbacknl(t, t->iq1, 1); - textsetorigin(t, q0, TRUE); - } else - textshow(t, t->file->b.nc, t->file->b.nc, FALSE); - return; case 0x01: /* ^A: beginning of line */ typecommit(t); /* go to where ^U would erase, if not already at BOL */ @@ -753,6 +767,7 @@ texttype(Text *t, Rune r) nnb = textbswidth(t, 0x15); textshow(t, t->q0-nnb, t->q0-nnb, TRUE); return; + case Kend: case 0x05: /* ^E: end of line */ typecommit(t); q0 = t->q0; @@ -760,19 +775,26 @@ texttype(Text *t, Rune r) q0++; textshow(t, q0, q0, TRUE); return; + case 0x03: /* Ctrl-c: copy */ case Kcmd+'c': /* %C: copy */ typecommit(t); cut(t, t, nil, TRUE, FALSE, nil, 0); return; + case 0x1a: /* Ctrl-z: undo */ case Kcmd+'z': /* %Z: undo */ typecommit(t); undo(t, nil, nil, TRUE, 0, nil, 0); return; + case 0x19: /* Ctrl-y: redo */ case Kcmd+'Z': /* %-shift-Z: redo */ typecommit(t); undo(t, nil, nil, FALSE, 0, nil, 0); return; - + case 0x13: /* Ctrl-S: put file */ + case Kcmd+'s': + typecommit(t); + put(&(t->w)->body, nil, nil, XXX, XXX, nil, 0); + return; Tagdown: /* expand tag to show all text */ if(!t->w->tagexpand){ @@ -796,6 +818,7 @@ texttype(Text *t, Rune r) } /* cut/paste must be done after the seq++/filemark */ switch(r){ + case 0x18: /* Ctrl-X: cut */ case Kcmd+'x': /* %X: cut */ typecommit(t); if(t->what == Body){ @@ -806,6 +829,7 @@ texttype(Text *t, Rune r) textshow(t, t->q0, t->q0, 1); t->iq1 = t->q0; return; + case 0x16: /* Ctrl-V: paste */ case Kcmd+'v': /* %V: paste */ typecommit(t); if(t->what == Body){ @@ -1661,4 +1685,4 @@ textreset(Text *t) t->q1 = 0; filereset(t->file); bufreset(&t->file->b); -} +}
\ No newline at end of file |