summary refs log tree commit diff
path: root/src/main.janet
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.janet')
-rw-r--r--src/main.janet20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/main.janet b/src/main.janet
index 4034dc9..9a6f42b 100644
--- a/src/main.janet
+++ b/src/main.janet
@@ -4,24 +4,22 @@
 
 (defn kay/select/move
   [buf direction]
-  (let [data (buf :data)
-        selection (buf :selection)]
+  (let [selection (buf :selection)]
     (struct ;(kvs buf)
             :selection (match selection
                          {:head head :tail tail}
                          (struct ;(kvs selection)
-                                 :head (direction head data)
-                                 :tail (direction tail data))))))
+                                 :head (direction head buf)
+                                 :tail (direction tail buf))))))
 
 (defn kay/select/head
   [buf direction]
-  (let [data (buf :data)
-        selection (buf :selection)]
+  (let [selection (buf :selection)]
     (struct ;(kvs buf)
             :selection (match selection
                          {:head head :tail tail}
                          (struct ;(kvs selection)
-                                 :head (direction head data)
+                                 :head (direction head buf)
                                  :tail tail)))))
 
 (defn kay/select/flip
@@ -40,7 +38,7 @@
       (:matches key (chr "c") {:ctrl true}) [[:quit] buf]
       (:matches key (chr "y") {}) (do (:yank kay/env buf)
                                       [[] buf])
-      (:matches key (chr "i") {}) (do (:paste kay/env)
+      (:matches key (chr "i") {}) (do (:request-paste kay/env)
                                       [[] buf])
       (:matches key (chr "p") {}) [[] (struct ;(kvs buf)
                                               :scroll-row (max 0 (dec (buf :scroll-row))))]
@@ -69,6 +67,8 @@
     (run @[(:next-event kay/env)]
          buf)))
 
-(with [buf (kay/open (with [f (file/open (string kay/path))]
-                       (buffer (:read f :all))))]
+(with [buf (kay/open (if-with [f (file/open (string kay/path))]
+                       (buffer (:read f :all))
+                       @"\n")
+                     kay/path)]
   (run @[] buf))