From 7e86c01285e50008148bb359c61f64640a812303 Mon Sep 17 00:00:00 2001 From: Yaroslav Kolomiiets Date: Thu, 18 Aug 2016 15:23:32 +0300 Subject: acme: handle Home, End keys --- appl/acme/ecmd.b | 2 +- appl/acme/look.b | 4 ++-- appl/acme/row.b | 2 +- appl/acme/text.b | 34 ++++++++++++++++++++++++---------- appl/acme/text.m | 2 +- appl/acme/util.b | 2 +- appl/acme/wind.b | 2 +- appl/acme/xfid.b | 8 ++++---- 8 files changed, 35 insertions(+), 21 deletions(-) (limited to 'appl') diff --git a/appl/acme/ecmd.b b/appl/acme/ecmd.b index c31643f1..e05c4e47 100644 --- a/appl/acme/ecmd.b +++ b/appl/acme/ecmd.b @@ -772,7 +772,7 @@ nl_cmd(t: ref Text, cp: ref Cmd): int addr = lineaddr(1, a, 1); } } - t.show(addr.r.q0, addr.r.q1); + t.show(addr.r.q0, addr.r.q1, TRUE); return TRUE; } diff --git a/appl/acme/look.b b/appl/acme/look.b index 1004b803..ca288d0a 100644 --- a/appl/acme/look.b +++ b/appl/acme/look.b @@ -273,7 +273,7 @@ search(ct : ref Text, r : string, n : int) : int } if(n <= nb && s.s[b:b+n] == r[0:n]){ if(ct.w != nil){ - ct.show(q, q+n); + ct.show(q, q+n, TRUE); ct.w.settag(); }else{ ct.q0 = q; @@ -698,7 +698,7 @@ openfile(t : ref Text, e : Expand) : (ref Window, Expand) r.q0 = t.q0; r.q1 = t.q1; } - t.show(r.q0, r.q1); + t.show(r.q0, r.q1, TRUE); t.w.settag(); seltext = t; if(e.jump) diff --git a/appl/acme/row.b b/appl/acme/row.b index 478ec930..5e1a3775 100644 --- a/appl/acme/row.b +++ b/appl/acme/row.b @@ -714,7 +714,7 @@ Row.loadx(row : self ref Row, file : string, initing : int) } if(q0>w.body.file.buf.nc || q1>w.body.file.buf.nc || q0>q1) q0 = q1 = 0; - w.body.show(q0, q1); + w.body.show(q0, q1, TRUE); w.maxlines = min(w.body.frame.nlines, max(w.maxlines, w.body.frame.maxlines)); } b.close(); diff --git a/appl/acme/text.b b/appl/acme/text.b index 953a08ea..32c31ee6 100644 --- a/appl/acme/text.b +++ b/appl/acme/text.b @@ -130,8 +130,10 @@ KF : con 16rF000; Kup : con KF | 16r0E; Kleft : con KF | 16r11; Kright : con KF | 16r12; +Kend : con KF | 16r18; Kdown : con 16r80; + nulltext : Text; newtext() : ref Text @@ -181,7 +183,7 @@ Text.redraw(t : self ref Text, r : Rect, f : ref Draw->Font, b : ref Image, odx if(t.frame.maxlines > 0){ t.reset(); t.columnate(t.w.dlp, t.w.ndl); - t.show(0, 0); + t.show(0, 0, TRUE); } }else{ t.fill(); @@ -712,19 +714,27 @@ Text.typex(t : self ref Text, r : int, echomode : int) q0 = t.backnl(t.org, n); t.setorigin(q0, FALSE); return; + Keyboard->Home => + t.commit(TRUE); + t.show(0, 0, FALSE); + return; + Kend or Keyboard->End => + t.commit(TRUE); + t.show(t.file.buf.nc, t.file.buf.nc, FALSE); + return; Kleft or Keyboard->Left => t.commit(TRUE); if(t.q0 != t.q1) - t.show(t.q0, t.q0); + t.show(t.q0, t.q0, TRUE); else if(t.q0 != 0) - t.show(t.q0-1, t.q0-1); + t.show(t.q0-1, t.q0-1, TRUE); return; Kright or Keyboard->Right => t.commit(TRUE); if(t.q0 != t.q1) - t.show(t.q1, t.q1); + t.show(t.q1, t.q1, TRUE); else if(t.q1 != t.file.buf.nc) - t.show(t.q1+1, t.q1+1); + t.show(t.q1+1, t.q1+1, TRUE); return; } if(t.what == Body){ @@ -737,11 +747,11 @@ Text.typex(t : self ref Text, r : int, echomode : int) exec->cut(t, t, TRUE, TRUE); t.eq0 = ~0; if (r == 16r08 || r == 16r7f){ # erase character : odd if a char then erased - t.show(t.q0, t.q0); + t.show(t.q0, t.q0,TRUE); return; } } - t.show(t.q0, t.q0); + t.show(t.q0, t.q0, TRUE); case(r){ 16r1B => if(t.eq0 != ~0) @@ -1007,17 +1017,21 @@ Text.select(t : self ref Text, double : int) } } -Text.show(t : self ref Text, q0 : int, q1 : int) +Text.show(t : self ref Text, q0 : int, q1 : int, doselect : int) { qe : int; nl : int; q : int; - if(t.what != Body) + if(t.what != Body){ + if(doselect) + t.setselect(q0, q1); return; + } if(t.w!=nil && t.frame.maxlines==0) t.col.grow(t.w, 1, 0); - t.setselect(q0, q1); + if(doselect) + t.setselect(q0, q1); qe = t.org+t.frame.nchars; if(t.org<=q0 && (q0scrdraw(t); w.owner = owner; diff --git a/appl/acme/wind.b b/appl/acme/wind.b index aa4e1950..96b7cb62 100644 --- a/appl/acme/wind.b +++ b/appl/acme/wind.b @@ -267,7 +267,7 @@ Window.undo(w : self ref Window, isundo : int) w.utflastqid = -1; body = w.body; (body.q0, body.q1) = body.file.undo(isundo, body.q0, body.q1); - body.show(body.q0, body.q1); + body.show(body.q0, body.q1, TRUE); f = body.file; for(i=0; inoscroll, but that didn't seem right in practice t.show(min(w.wrselrange.q0, t.file.buf.nc), - min(w.wrselrange.q1, t.file.buf.nc)); + min(w.wrselrange.q1, t.file.buf.nc), TRUE); scrdraw(t); QWconsctl=> w.echomode = EM_NORMAL; @@ -535,7 +535,7 @@ Xfid.write(x : self ref Xfid) if(tq1 >= q0) tq1 += nr; if(!t.w.noscroll) - t.show(tq0, tq1); + t.show(tq0, tq1, TRUE); scrdraw(t); w.settag(); r = nil; @@ -586,7 +586,7 @@ Xfid.write(x : self ref Xfid) } (q0, nr) = t.bsinsert(q0, r, nr, TRUE); if(qid!=QWwrsel && !t.w.noscroll) - t.show(q0+nr, q0+nr); + t.show(q0+nr, q0+nr, TRUE); scrdraw(t); }else t.insert(q0, r, nr, TRUE, 0); @@ -642,7 +642,7 @@ loop : }else if(strncmp(p, "show", 4) == 0){ # show dot t = w.body; - t.show(t.q0, t.q1); + t.show(t.q0, t.q1, TRUE); m = 4; }else if(strncmp(p, "name ", 5) == 0){ # set file name -- cgit v1.2.3