commit f460c311450164c30dd3d030655f6125219d2708 from: Omar Polo via: Omar Polo date: Thu Jan 26 11:03:57 2023 UTC Kup and Kdown move the cursor up and down commit - ba51ae9877aef8da2a6ee49e354d9b8148b0e93a commit + f460c311450164c30dd3d030655f6125219d2708 blob - bc8d3e3e18ac853017273ec42409ed5757c1020e blob + 6b14477929069f099af363f1d3196e4872166a24 --- src/cmd/acme/text.c +++ src/cmd/acme/text.c @@ -717,9 +717,33 @@ texttype(Text *t, Rune r) 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; @@ -736,8 +760,14 @@ texttype(Text *t, Rune r) 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;