janet-lang / spork

Various Janet utility modules - the official "Contrib" library.
MIT License
122 stars 35 forks source link

getline: Ctrl-k does not delete from the cursor to the end of the line #167

Closed sogaiu closed 9 months ago

sogaiu commented 10 months ago

The janet(1) man page has:

Ctrl-K          Delete everything after the cursor on the input line.

and that works for janet.

The make-getline function in getline.janet has implementations for many bits of functionality, but not for responding to Ctrl-k.

I tried the following changes:

diff --git a/spork/getline.janet b/spork/getline.janet
index 0378bdf..5858478 100644
--- a/spork/getline.janet
+++ b/spork/getline.janet
@@ -338,6 +338,8 @@
             (kback)
             9 # tab
             (autocomplete)
+            11 # ctrl-k
+            (do (buffer/popn buf (- (length buf) pos)) (refresh))
             12 # ctrl-l
             (do (clear) (refresh))
             13 # enter

In limited testing, it seems to be working here.