~lucasemmoreira/hitter

818ad70a031b38b68c854112acdc2d8b17c56d18 — Lucas Moreira 2 years ago b0b243c
add: working version with home directory
3 files changed, 7 insertions(+), 5 deletions(-)

M src/config.janet
M src/main.janet
M src/tui.janet
M src/config.janet => src/config.janet +4 -3
@@ 1,8 1,9 @@
(defn read-from-file [file-path]
  (let [f (file/open file-path :r)
        content  (file/read f :all)]
    (file/close f)
    content))
        content (when f (file/read f :all))]
    (if content
      (do (file/close f) content)
      (error (string "no file found at " file-path)))))

(defn separate-name-url [coll]
  @[(map first coll) (map (fn [coll-in] (get coll-in 1)) coll)])

M src/main.janet => src/main.janet +2 -1
@@ 3,5 3,6 @@
(import ./hit :as hit)

(defn main [& args]
  (let [[names urls] (config/read-config "./urls")]
  (let [home-dir (get (os/environ) "HOME") 
	[names urls] (config/read-config (string home-dir "/.config/hitter/urls"))]
    (ui/run-ui [names urls])))

M src/tui.janet => src/tui.janet +1 -1
@@ 4,7 4,7 @@
(defn build-win [win names status]
  (nc/wclear win)
  (for i 0 (length names)
    (nc/mvwprintw win (inc i) 1 (string/format "%s %s" (get names i) (get status i))))
    (nc/mvwprintw win (inc i) 1 (string/format "%s %s" (string (get names i)) (string (get status i)))))
  (nc/box win 0 0)
  (nc/wrefresh win))