month old bug fix from rob

This commit is contained in:
rsc 2005-03-18 18:05:48 +00:00
parent c1fca1adb0
commit 2a373ea419
2 changed files with 30 additions and 16 deletions

View file

@ -386,6 +386,14 @@ textinsert(Text *t, uint q0, Rune *r, uint n, int tofile)
} }
} }
void
typecommit(Text *t)
{
if(t->w != nil)
wincommit(t->w, t);
else
textcommit(t, TRUE);
}
void void
textfill(Text *t) textfill(Text *t)
@ -395,12 +403,8 @@ textfill(Text *t)
if(t->fr.lastlinefull || t->nofill) if(t->fr.lastlinefull || t->nofill)
return; return;
if(t->ncache > 0){ if(t->ncache > 0)
if(t->w != nil) typecommit(t);
wincommit(t->w, t);
else
textcommit(t, TRUE);
}
rp = fbufalloc(); rp = fbufalloc();
do{ do{
n = t->file->b.nc-(t->org+t->fr.nchars); n = t->file->b.nc-(t->org+t->fr.nchars);
@ -649,16 +653,13 @@ texttype(Text *t, Rune r)
switch(r){ switch(r){
case Kleft: case Kleft:
if(t->q0 > 0){ if(t->q0 > 0){
if(t->w) typecommit(t);
wincommit(t->w, t);
else
textcommit(t, TRUE);
textshow(t, t->q0-1, t->q0-1, TRUE); textshow(t, t->q0-1, t->q0-1, TRUE);
} }
return; return;
case Kright: case Kright:
if(t->q1 < t->file->b.nc){ if(t->q1 < t->file->b.nc){
wincommit(t->w, t); typecommit(t);
textshow(t, t->q1+1, t->q1+1, TRUE); textshow(t, t->q1+1, t->q1+1, TRUE);
} }
return; return;
@ -689,15 +690,28 @@ texttype(Text *t, Rune r)
textsetorigin(t, q0, TRUE); textsetorigin(t, q0, TRUE);
return; return;
case Khome: case Khome:
typecommit(t);
textshow(t, 0, 0, FALSE); textshow(t, 0, 0, FALSE);
return; return;
case Kend: case Kend:
if(t->w) typecommit(t);
wincommit(t->w, t);
else
textcommit(t, TRUE);
textshow(t, t->file->b.nc, t->file->b.nc, FALSE); textshow(t, t->file->b.nc, t->file->b.nc, FALSE);
return; return;
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);
textshow(t, t->q0-nnb, t->q0-nnb, TRUE);
return;
case 0x05: /* ^E: end of line */
typecommit(t);
q0 = t->q0;
while(q0<t->file->b.nc && textreadc(t, q0)!='\n')
q0++;
textshow(t, q0, q0, TRUE);
return;
} }
if(t->what == Body){ if(t->what == Body){
seq++; seq++;

View file

@ -80,9 +80,9 @@ wininit(Window *w, Window *clone, Rectangle r)
//assert(w->body.w == w); //assert(w->body.w == w);
if(clone){ if(clone){
w->dirty = clone->dirty; w->dirty = clone->dirty;
w->autoindent = clone->autoindent;
textsetselect(&w->body, clone->body.q0, clone->body.q1); textsetselect(&w->body, clone->body.q0, clone->body.q1);
winsettag(w); winsettag(w);
w->autoindent = clone->autoindent;
} }
} }