[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/gnosis 02a4e13520 12/19: [fix] display-images: Display ima
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/gnosis 02a4e13520 12/19: [fix] display-images: Display images only on graphical envs. |
Date: |
Thu, 5 Sep 2024 13:00:31 -0400 (EDT) |
branch: elpa/gnosis
commit 02a4e1352025e023d4345cd7dd71ae063d396538
Author: Thanos Apollo <public@thanosapollo.org>
Commit: Thanos Apollo <public@thanosapollo.org>
[fix] display-images: Display images only on graphical envs.
* Fix issues for running gnosis on tty & termux.
---
gnosis.el | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/gnosis.el b/gnosis.el
index caef741d52..db5a6f4c85 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -484,19 +484,21 @@ or =extra-image'. Instead of using =extra-image' post
review, prefer
=gnosis-display-extra' which displays the =extra-image' as well.
Refer to =gnosis-db-schema-extras' for informations on images stored."
- (let* ((img (gnosis-get image 'extras `(= id ,id)))
- (path-to-image (expand-file-name (or img "") (file-name-as-directory
gnosis-images-dir)))
- (image (create-image path-to-image 'png nil :width gnosis-image-width
:height gnosis-image-height))
- (image-width (car (image-size image t)))
- (frame-width (window-text-width))) ;; Width of the current window in
columns
- (cond ((or (not img) (string-empty-p img))
- (insert "\n\n"))
- ((and img (file-exists-p path-to-image))
- (let* ((padding-cols (/ (- frame-width (floor (/ image-width
(frame-char-width)))) 2))
- (padding (make-string (max 0 padding-cols) ?\s)))
- (insert "\n\n" padding) ;; Insert padding before the image
- (insert-image image)
- (insert "\n\n"))))))
+ ;; Only display images on graphical env
+ (when (display-graphic-p)
+ (let* ((img (gnosis-get image 'extras `(= id ,id)))
+ (path-to-image (expand-file-name (or img "")
(file-name-as-directory gnosis-images-dir)))
+ (image (create-image path-to-image 'png nil :width
gnosis-image-width :height gnosis-image-height))
+ (image-width (car (image-size image t)))
+ (frame-width (window-text-width))) ;; Width of the current window
in columns
+ (cond ((or (not img) (string-empty-p img))
+ (insert "\n\n"))
+ ((and img (file-exists-p path-to-image))
+ (let* ((padding-cols (/ (- frame-width (floor (/ image-width
(frame-char-width)))) 2))
+ (padding (make-string (max 0 padding-cols) ?\s)))
+ (insert "\n\n" padding) ;; Insert padding before the image
+ (insert-image image)
+ (insert "\n\n")))))))
(defun gnosis-display-mcq-options (id)
"Display answer options for mcq note ID."
- [nongnu] elpa/gnosis 48ca4aa6f2 07/19: [Refactor] Rewrite org-insert-heading, (continued)
- [nongnu] elpa/gnosis 48ca4aa6f2 07/19: [Refactor] Rewrite org-insert-heading, ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis a783b56772 10/19: New function: Add validate-custom-values., ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis 56ed928045 09/19: export-deck: Add demo export., ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis 1e8e5fc529 11/19: New variable-watcher: custom-values-watcher., ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis d034335bde 18/19: Packaging: Add version 0.4.2., ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis 4d90489c5b 05/19: elpaignore: Add manifest.scm, ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis 11e526b496 02/19: New module: gnosis-org: Use org-mode with gnosis., ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis cfa0462972 01/19: packaging: Version 0.4.2-dev, ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis 061633adca 03/19: packaging: Require emacsql-4.0.1., ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis 487d903de1 04/19: New file: Add manifest.scm, ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis 02a4e13520 12/19: [fix] display-images: Display images only on graphical envs.,
ELPA Syncer <=
- [nongnu] elpa/gnosis bb1469aad5 08/19: Update todos., ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis bc626d511c 16/19: dashboard: Update dashboard-mode keymap., ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis 8f0bb68c87 14/19: demo: Update formatting (aesthetics)., ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis 52da178372 15/19: Rewrite README as markdown, ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis 731f0ba491 19/19: Release version 0.4.2., ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis 907308c45e 06/19: makefile: Add tests & use quick (-Q) option., ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis 88a32f1918 13/19: edit-update-note: Update assertions., ELPA Syncer, 2024/09/05
- [nongnu] elpa/gnosis f9c6885cd5 17/19: doc: Update for new version., ELPA Syncer, 2024/09/05