diff --git a/cl-todo.asd b/cl-todo.asd index 105a974..a57f918 100644 --- a/cl-todo.asd +++ b/cl-todo.asd @@ -16,7 +16,7 @@ :homepage "https://git.synoikos.de/daniel/cl-todo" :license "MIT" :version "0.1" - :depends-on (:cl-cffi-gtk) + :depends-on (:uiop :cl-cffi-gtk) :serial t :components ((:file "package") diff --git a/cl-todo.asd b/cl-todo.asd index 105a974..a57f918 100644 --- a/cl-todo.asd +++ b/cl-todo.asd @@ -16,7 +16,7 @@ :homepage "https://git.synoikos.de/daniel/cl-todo" :license "MIT" :version "0.1" - :depends-on (:cl-cffi-gtk) + :depends-on (:uiop :cl-cffi-gtk) :serial t :components ((:file "package") diff --git a/cl-todo.lisp b/cl-todo.lisp index 6a52857..0f2a425 100644 --- a/cl-todo.lisp +++ b/cl-todo.lisp @@ -8,6 +8,40 @@ (in-package :cl-todo) +(defvar *task-list* NIL) +(defconstant +runfile+ (uiop:native-namestring "~/.todo")) + + (defun launch () + (setf *task-list* (load-task-file)) ;;TODO ) + +(defun load-task-file (&optional (file-name +runfile+)) + "Load a list of (task) strings from the run file" + (with-open-file (f file-name :if-does-not-exist nil) + (when (null f) + (format t "~&No task file found at ~S" file-name) + (return-from load-task-file)) + (do* ((line (read-line f nil nil) + (read-line f nil nil)) + (tasks NIL)) + ((null line) tasks) + (setf tasks (append tasks (list line)))))) + +(defun write-task-list (&optional (lst *task-list*) (filename +runfile+)) + "Write the task list to file, one entry per line." + (let ((f (open filename :direction :output))) + (dolist (i lst) (format f "~&~S" i)) + (close f))) + +(defun add-task! (task) + "Append a task to the task list" + (setf *task-list* (append *task-list* (list task)))) + +(defun remove-task! (task) + "Remove a task from the list" + (setf *task-list* + (remove-if #'(lambda (s) (equalp s task)) + *task-list* :count 1))) + diff --git a/cl-todo.asd b/cl-todo.asd index 105a974..a57f918 100644 --- a/cl-todo.asd +++ b/cl-todo.asd @@ -16,7 +16,7 @@ :homepage "https://git.synoikos.de/daniel/cl-todo" :license "MIT" :version "0.1" - :depends-on (:cl-cffi-gtk) + :depends-on (:uiop :cl-cffi-gtk) :serial t :components ((:file "package") diff --git a/cl-todo.lisp b/cl-todo.lisp index 6a52857..0f2a425 100644 --- a/cl-todo.lisp +++ b/cl-todo.lisp @@ -8,6 +8,40 @@ (in-package :cl-todo) +(defvar *task-list* NIL) +(defconstant +runfile+ (uiop:native-namestring "~/.todo")) + + (defun launch () + (setf *task-list* (load-task-file)) ;;TODO ) + +(defun load-task-file (&optional (file-name +runfile+)) + "Load a list of (task) strings from the run file" + (with-open-file (f file-name :if-does-not-exist nil) + (when (null f) + (format t "~&No task file found at ~S" file-name) + (return-from load-task-file)) + (do* ((line (read-line f nil nil) + (read-line f nil nil)) + (tasks NIL)) + ((null line) tasks) + (setf tasks (append tasks (list line)))))) + +(defun write-task-list (&optional (lst *task-list*) (filename +runfile+)) + "Write the task list to file, one entry per line." + (let ((f (open filename :direction :output))) + (dolist (i lst) (format f "~&~S" i)) + (close f))) + +(defun add-task! (task) + "Append a task to the task list" + (setf *task-list* (append *task-list* (list task)))) + +(defun remove-task! (task) + "Remove a task from the list" + (setf *task-list* + (remove-if #'(lambda (s) (equalp s task)) + *task-list* :count 1))) + diff --git a/gtk-ui.lisp b/gtk-ui.lisp index e69de29..a91f3d9 100644 --- a/gtk-ui.lisp +++ b/gtk-ui.lisp @@ -0,0 +1,11 @@ +;;;; +;;;; A simple TODO app for the GNOME desktop +;;;; (mainly written to try out GTK+Lisp) +;;;; +;;;; (c) Daniel Vedder 2020 +;;;; Licensed under the terms of the MIT license +;;;; + +(defun launch-gui () + ;;TODO + ) diff --git a/cl-todo.asd b/cl-todo.asd index 105a974..a57f918 100644 --- a/cl-todo.asd +++ b/cl-todo.asd @@ -16,7 +16,7 @@ :homepage "https://git.synoikos.de/daniel/cl-todo" :license "MIT" :version "0.1" - :depends-on (:cl-cffi-gtk) + :depends-on (:uiop :cl-cffi-gtk) :serial t :components ((:file "package") diff --git a/cl-todo.lisp b/cl-todo.lisp index 6a52857..0f2a425 100644 --- a/cl-todo.lisp +++ b/cl-todo.lisp @@ -8,6 +8,40 @@ (in-package :cl-todo) +(defvar *task-list* NIL) +(defconstant +runfile+ (uiop:native-namestring "~/.todo")) + + (defun launch () + (setf *task-list* (load-task-file)) ;;TODO ) + +(defun load-task-file (&optional (file-name +runfile+)) + "Load a list of (task) strings from the run file" + (with-open-file (f file-name :if-does-not-exist nil) + (when (null f) + (format t "~&No task file found at ~S" file-name) + (return-from load-task-file)) + (do* ((line (read-line f nil nil) + (read-line f nil nil)) + (tasks NIL)) + ((null line) tasks) + (setf tasks (append tasks (list line)))))) + +(defun write-task-list (&optional (lst *task-list*) (filename +runfile+)) + "Write the task list to file, one entry per line." + (let ((f (open filename :direction :output))) + (dolist (i lst) (format f "~&~S" i)) + (close f))) + +(defun add-task! (task) + "Append a task to the task list" + (setf *task-list* (append *task-list* (list task)))) + +(defun remove-task! (task) + "Remove a task from the list" + (setf *task-list* + (remove-if #'(lambda (s) (equalp s task)) + *task-list* :count 1))) + diff --git a/gtk-ui.lisp b/gtk-ui.lisp index e69de29..a91f3d9 100644 --- a/gtk-ui.lisp +++ b/gtk-ui.lisp @@ -0,0 +1,11 @@ +;;;; +;;;; A simple TODO app for the GNOME desktop +;;;; (mainly written to try out GTK+Lisp) +;;;; +;;;; (c) Daniel Vedder 2020 +;;;; Licensed under the terms of the MIT license +;;;; + +(defun launch-gui () + ;;TODO + ) diff --git a/package.lisp b/package.lisp index 103c497..f217cc1 100644 --- a/package.lisp +++ b/package.lisp @@ -10,4 +10,4 @@ (:documentation "A simple TODO widget for the GNOME desktop") (:nicknames :todo) (:use :common-lisp) - (:export launch)) + (:export launch +runfile+))