unofficial mirror of emacs-devel@gnu.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

* Re: tree-widget with unicode box chars
  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-06 19:07 ` Daniele Nicolodi
  1 sibling, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-05 14:00 UTC (permalink / raw)
  To: JD Smith; +Cc: emacs-devel

JD Smith <jdtsmith@gmail.com> writes:

> 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.

Thanks; pushed to Emacs 29.

This change was small enough to apply without assigning copyright to the
FSF, but for future patches you want to submit, it might make sense to
get the paperwork started now, so that subsequent patches can be applied
speedily. Would you be willing to sign such paperwork?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



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

* Re: tree-widget with unicode box chars
  2022-06-05 14:00 ` Lars Ingebrigtsen
@ 2022-06-05 22:38   ` JD Smith
  2022-06-05 22:43     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 5+ messages in thread
From: JD Smith @ 2022-06-05 22:38 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: emacs-devel

Great.   Please don’t forget to link the images in etc/images/tree-widget/* (e.g. nohandle-guide.xpm -> guide.xpm), or the default icon-tree will have a mismatched & ugly vertical guide.  There are two “theme” directories there: `default' and `folder'. 
 
JD

> On Jun 5, 2022, at 10:00 AM, Lars Ingebrigtsen <larsi@gnus.org> wrote:
> 
> JD Smith <jdtsmith@gmail.com> writes:
> 
>> 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.
> 
> Thanks; pushed to Emacs 29.




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

* Re: tree-widget with unicode box chars
  2022-06-05 22:38   ` JD Smith
@ 2022-06-05 22:43     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 5+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-05 22:43 UTC (permalink / raw)
  To: JD Smith; +Cc: emacs-devel

JD Smith <jdtsmith@gmail.com> writes:

> Great.  Please don’t forget to link the images in
> etc/images/tree-widget/* (e.g. nohandle-guide.xpm -> guide.xpm), or
> the default icon-tree will have a mismatched & ugly vertical guide.
> There are two “theme” directories there: `default' and `folder'.

Now done, but as copies, since we don't seem to do symlinks in the repo.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



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

* Re: tree-widget with unicode box chars
  2022-06-05  2:21 tree-widget with unicode box chars JD Smith
  2022-06-05 14:00 ` Lars Ingebrigtsen
@ 2022-06-06 19:07 ` Daniele Nicolodi
  1 sibling, 0 replies; 5+ messages in thread
From: Daniele Nicolodi @ 2022-06-06 19:07 UTC (permalink / raw)
  To: emacs-devel

On 05/06/2022 04:21, JD Smith wrote:
> 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).

Which unicode characters did you use to draw the tree in the image?

Thank you.

Cheers,
Dan




^ 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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).