all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: JD Smith <jdtsmith@gmail.com>
To: emacs-devel@gnu.org
Subject: tree-widget with unicode box chars
Date: Sat, 4 Jun 2022 22:21:10 -0400	[thread overview]
Message-ID: <0BE52CC1-428F-4D24-947D-2CB5B775A5CE@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 822 bytes --]

tree-widget.el provides both xpm icons and crude plain-text versions of the tree glyphs.  Most fixed-space fonts have unicode box-drawing characters, which can be used to draw high quality text-only trees.  Such unicode trees look identical in graphical or terminal Emacs (see attached for an example).  

This works just fine, but one small change is needed to accommodate this style.  `tree-widget-guide’ specifies a single vertical bar “guide” widget.  In the unicode tree, two separate vertical bars are needed — one “plain” (│), and one which connects to the horizontal “handle” preceding the node (├). A patch is attached implementing this.  For the default graphical-icon version to continue working, linking from nohandle-guide.* -> guide.* in etc/images/tree-widget/* would be necessary.


[-- Attachment #2.1: Type: text/html, Size: 1320 bytes --]

[-- Attachment #2.2: PastedGraphic-2.png --]
[-- Type: image/png, Size: 108740 bytes --]

[-- Attachment #2.3: Type: text/html, Size: 230 bytes --]

[-- Attachment #2.4: tree-widget.patch --]
[-- Type: application/octet-stream, Size: 2233 bytes --]

--- -	2022-06-04 22:15:22.000000000 -0400
+++ tree-widget.el	2022-06-04 22:15:20.000000000 -0400
@@ -319,6 +319,7 @@
   '(
     ("guide"     . arrow)
     ("no-guide"  . arrow)
+    ("nohandle-guide" . arrow)
     ("end-guide" . arrow)
     ("handle"    . arrow)
     ("no-handle" . arrow)
@@ -440,6 +441,13 @@
   :format    "%t"
   )
 
+(define-widget 'tree-widget-nohandle-guide 'item
+  "Vertical guide line, when there is no handle."
+  :tag       " |"
+  ;;:tag-glyph (tree-widget-find-image "nohandle-guide")
+  :format    "%t" 
+  )
+
 (define-widget 'tree-widget-end-guide 'item
   "End of a vertical guide line."
   :tag       " \\=`"
@@ -483,6 +491,7 @@
   :empty-icon     'tree-widget-empty-icon
   :leaf-icon      'tree-widget-leaf-icon
   :guide          'tree-widget-guide
+  :nohandle-guide 'tree-widget-nohandle-guide
   :end-guide      'tree-widget-end-guide
   :no-guide       'tree-widget-no-guide
   :handle         'tree-widget-handle
@@ -612,11 +621,13 @@
 ;;;; Expanded node.
         (let ((args     (widget-get tree :args))
               (guide    (widget-get tree :guide))
+              (nohandle-guide (widget-get tree :nohandle-guide))
               (noguide  (widget-get tree :no-guide))
               (endguide (widget-get tree :end-guide))
               (handle   (widget-get tree :handle))
               (nohandle (widget-get tree :no-handle))
               (guidi    (tree-widget-find-image "guide"))
+              (nohandle-guidi (tree-widget-find-image "nohandle-guide"))
               (noguidi  (tree-widget-find-image "no-guide"))
               (endguidi (tree-widget-find-image "end-guide"))
               (handli   (tree-widget-find-image "handle"))
@@ -648,8 +659,8 @@
             ;; Insert guide lines elements from previous levels.
             (dolist (f (reverse flags))
               (widget-create-child-and-convert
-               tree (if f guide noguide)
-               :tag-glyph (if f guidi noguidi))
+               tree (if f nohandle-guide noguide)
+               :tag-glyph (if f nohandle-guidi noguidi))
               (widget-create-child-and-convert
                tree nohandle :tag-glyph nohandli))
             ;; Insert guide line element for this level.

[-- Attachment #2.5: Type: text/html, Size: 266 bytes --]

             reply	other threads:[~2022-06-05  2:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-05  2:21 JD Smith [this message]
2022-06-05 14:00 ` tree-widget with unicode box chars Lars Ingebrigtsen
2022-06-05 22:38   ` JD Smith
2022-06-05 22:43     ` Lars Ingebrigtsen
2022-06-06 19:07 ` Daniele Nicolodi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0BE52CC1-428F-4D24-947D-2CB5B775A5CE@gmail.com \
    --to=jdtsmith@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.