summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2023-12-25 17:33:48 +0200
committerThanos Apollo <[email protected]>2023-12-25 17:33:48 +0200
commit6687492980c8220f4d95c0e3991b6b24c83808fb (patch)
tree4134ed226a87da481b31dde8bd2944ad0dc5f5f0
parent79d7f34030d427dad6d7bca2bc825fa35ee8e94c (diff)
Add gnosis-display--image
Images need to be at gnosis-images-dir
-rw-r--r--gnosis.el11
1 files changed, 11 insertions, 0 deletions
diff --git a/gnosis.el b/gnosis.el
index 357e596..ea982b6 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -101,6 +101,16 @@ Example:
(insert (propertize "\n\n-----\n" 'face 'gnosis-face-seperator))
(fill-paragraph (insert (concat "\n" (propertize extras 'face 'gnosis-face-extra)))))))
+(defun gnosis-display--image (id)
+ "Display image for note ID."
+ (let* ((img (gnosis-get 'images 'extras `(= id ,id)))
+ (path-to-image (concat gnosis-images-dir "/" img))
+ (image (create-image path-to-image 'png nil :width 500 :height 300)))
+ (when img
+ (with-current-buffer (switch-to-buffer (get-buffer-create "*gnosis*"))
+ (insert "\n\n")
+ (insert-image image)))))
+
(cl-defun gnosis--prompt (prompt &optional (downcase nil) (split nil))
"PROMPT user for input until `q' is given.
@@ -234,6 +244,7 @@ Returns a list of the form (ef-increase ef-decrease ef)."
(defun gnosis-review-mcq (id)
"Display multiple choice answers for question ID."
+ (gnosis-display--image id)
(let ((answer (gnosis-get 'answer 'notes `(= id ,id)))
(choices (gnosis-get 'options 'notes `(= id ,id)))
(user-choice (gnosis-mcq-answer id)))