all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* tree-widget with unicode box chars
@ 2022-06-05  2:21 JD Smith
  2022-06-05 14:00 ` Lars Ingebrigtsen
  2022-06-06 19:07 ` Daniele Nicolodi
  0 siblings, 2 replies; 5+ messages in thread
From: JD Smith @ 2022-06-05  2:21 UTC (permalink / raw)
  To: emacs-devel

[-- 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 --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-06-06 19:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-05  2:21 tree-widget with unicode box chars JD Smith
2022-06-05 14:00 ` Lars Ingebrigtsen
2022-06-05 22:38   ` JD Smith
2022-06-05 22:43     ` Lars Ingebrigtsen
2022-06-06 19:07 ` Daniele Nicolodi

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.