--- /usr/local/plan9/src/cmd/acme/text.c Wed Jan 17 18:49:47 2018 +++ text.c Mon Feb 12 15:48:17 2018 @@ -693,9 +693,33 @@ return; case Kdown: if(t->what == Tag) - goto Tagdown; - n = t->fr.maxlines/3; - goto case_Down; + goto Tagdown; + typecommit(t); + /* 1rst check for being in the last line*/ + q0 = t->q0; + q1 = q0; + if (q1) q1--; + nnb = 0; + while(q0file->b.nc && textreadc(t, q0)!='\n') + q0++; + if (q0 == (t->file->b.nc)-1) { + textshow(t, q0, q0, TRUE); + return; + } + q0++; + /* find old pos in ln */ + while(q1>1 && textreadc(t, q1)!='\n'){ + nnb++; + q1--; + } + /* go right until reachg pos or \n */ + while(q0file->b.nc && (nnb>0 && textreadc(t, q0)!='\n')){ + q0++; + nnb--; + } + if (q0>1 && q0file->b.nc) + textshow(t, q0, q0, TRUE); + return; case Kscrollonedown: if(t->what == Tag) goto Tagdown; @@ -712,8 +736,14 @@ 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); + /* BOL - 1 if not first line of txt BOL*/ + if( t->q0-nnb > 1 && textreadc(t, t->q0-nnb-1)=='\n' ) nnb++; + textshow(t, t->q0-nnb, t->q0-nnb, TRUE); + return; case Kscrolloneup: if(t->what == Tag) goto Tagup;