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/text.b | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'appl/acme/text.b') 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 && (q0 Date: Fri, 4 Nov 2016 13:35:03 +0200 Subject: acme: hande Pgup, Pgdown keys --- appl/acme/text.b | 14 ++++++++++++-- dis/acme/text.dis | Bin 19443 -> 19736 bytes 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'appl/acme/text.b') diff --git a/appl/acme/text.b b/appl/acme/text.b index 32c31ee6..0aa0d482 100644 --- a/appl/acme/text.b +++ b/appl/acme/text.b @@ -705,12 +705,22 @@ Text.typex(t : self ref Text, r : int, echomode : int) } return; Kdown or Keyboard->Down => - n = t.frame.maxlines/2; + n = t.frame.maxlines/3; + q0 = t.org+frcharofpt(t.frame, (t.frame.r.min.x, t.frame.r.min.y+n*t.frame.font.height)); + t.setorigin(q0, FALSE); + return; + Keyboard->Pgdown => + n = 2*t.frame.maxlines/3; q0 = t.org+frcharofpt(t.frame, (t.frame.r.min.x, t.frame.r.min.y+n*t.frame.font.height)); t.setorigin(q0, FALSE); return; Kup or Keyboard->Up => - n = t.frame.maxlines/2; + n = t.frame.maxlines/3; + q0 = t.backnl(t.org, n); + t.setorigin(q0, FALSE); + return; + Keyboard->Pgup => + n = 2*t.frame.maxlines/3; q0 = t.backnl(t.org, n); t.setorigin(q0, FALSE); return; diff --git a/dis/acme/text.dis b/dis/acme/text.dis index ef06f6f2..09c28b5d 100644 Binary files a/dis/acme/text.dis and b/dis/acme/text.dis differ -- cgit v1.2.3 From 39d2105807e5fdd337df2cb2907631b2ba5afad3 Mon Sep 17 00:00:00 2001 From: Yaroslav Kolomiiets Date: Fri, 4 Nov 2016 14:08:41 +0200 Subject: acme: handle ^A, ^E keys --- appl/acme/text.b | 15 +++++++++++++++ dis/acme/text.dis | Bin 19736 -> 20063 bytes 2 files changed, 15 insertions(+) (limited to 'appl/acme/text.b') diff --git a/appl/acme/text.b b/appl/acme/text.b index 0aa0d482..7fdce3f3 100644 --- a/appl/acme/text.b +++ b/appl/acme/text.b @@ -746,6 +746,21 @@ Text.typex(t : self ref Text, r : int, echomode : int) else if(t.q1 != t.file.buf.nc) t.show(t.q1+1, t.q1+1, TRUE); return; + 1 => # ^A: beginning of line + t.commit(TRUE); + # go to where ^U would erase, if not already at BOL + nnb = 0; + if(t.q0>0 && t.readc(t.q0-1)!='\n') + nnb = t.bswidth(16r15); + t.show(t.q0-nnb, t.q0-nnb, TRUE); + return; + 5 => # ^E: end of line + t.commit(TRUE); + q0 = t.q0; + while(q0