Minor refactoring, no functional changes
This commit is contained in:
parent
670b9b86d6
commit
52ab0cc458
49
contact.scm
49
contact.scm
|
@ -23,13 +23,13 @@
|
|||
(chicken process-context)
|
||||
(chicken string)
|
||||
(chicken time)
|
||||
srfi-1
|
||||
srfi-18
|
||||
(srfi 1)
|
||||
(srfi 18)
|
||||
(prefix getopt-long getopt:)
|
||||
nrepl
|
||||
qt-light
|
||||
(prefix nrepl nrepl:)
|
||||
(prefix uri-common uri:)
|
||||
(prefix vcarded vcard:))
|
||||
(prefix vcarded vcard:)
|
||||
qt-light)
|
||||
|
||||
|
||||
(define qt-app #f) ;; The <qt-application> object.
|
||||
|
@ -39,28 +39,37 @@
|
|||
;; Start & run the application.
|
||||
(define (init)
|
||||
(let [(cli-args (parse-cli-args (command-line-arguments)))]
|
||||
;; If --help, then print a usage message and quit.
|
||||
(if (alist-ref 'help cli-args)
|
||||
(cli-usage))
|
||||
;; Set up some global state, prepare the QT app.
|
||||
;; Otherwise, let’s get our threads started!
|
||||
(let [(qt-thread (init-qt cli-args))
|
||||
(nrepl-thread (init-nrepl cli-args))
|
||||
(repl-thread (thread-start! repl))]
|
||||
;; Wait for the QT program, even after stdin is closed off.
|
||||
(thread-join! qt-thread))))
|
||||
|
||||
|
||||
;; Set up some global variables (for easier live REPL use), prepare the QT app.
|
||||
(define (init-qt cli-args)
|
||||
(set! qt-app (qt:init))
|
||||
(set! qt-win (create-window))
|
||||
(init-window qt-win)
|
||||
;; Kick off the QT thread, then open the cli free-arg vCard file, if provided.
|
||||
;; That is, like `$ contact freeArgFile.vcf`.
|
||||
(let [(qt-thread (thread-start! qt-loop))
|
||||
(last-free-arg (condition-case (last (car cli-args)) (var () #f)))]
|
||||
(if last-free-arg
|
||||
(open-vcard-file qt-win last-free-arg))
|
||||
qt-thread))
|
||||
|
||||
(let ;; Start QT loop.
|
||||
[(qt-thread (thread-start! qt-loop))
|
||||
;; Kick off the remote-REPL…
|
||||
(nrepl-thread
|
||||
|
||||
;; Kick off our remote TCP-accessible REPL, if the user enabled it at cli.
|
||||
(define (init-nrepl cli-args)
|
||||
(if (alist-ref 'repl cli-args)
|
||||
(thread-start!
|
||||
(lambda ()
|
||||
(nrepl (string->number (alist-ref 'repl cli-args)))))))]
|
||||
;; Open the free-argument file.
|
||||
(if (condition-case (not (null? (last (car cli-args)))) (var () #f))
|
||||
(open-vcard-file qt-win (last (car cli-args))))
|
||||
;; … and also provide a local REPL.
|
||||
(repl)
|
||||
;; Wait for the QT program, even after stdin is closed off.
|
||||
(thread-join! qt-thread))))
|
||||
(nrepl:nrepl (string->number (alist-ref 'repl cli-args)))))))
|
||||
|
||||
|
||||
;; Print a “usage” help message, telling the user how to run the program.
|
||||
|
@ -147,7 +156,9 @@
|
|||
(lambda ()
|
||||
(open-vcard-file
|
||||
window
|
||||
(qt:get-open-filename "birdo" "/home/jaidyn/Contacts"))))))))
|
||||
(qt:get-open-filename
|
||||
"Select a contact file…"
|
||||
(conc (get-environment-variable "HOME") "/Contacts")))))))))
|
||||
|
||||
|
||||
;; Parse a vCard file and populate the window’s forms with its contents.
|
||||
|
|
Ŝarĝante…
Reference in New Issue