Gnus development mailing list
 help / color / mirror / Atom feed
* A little idea for shr and table
@ 2010-10-11 16:59 Julien Danjou
  2010-10-11 18:39 ` Lars Magne Ingebrigtsen
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Julien Danjou @ 2010-10-11 16:59 UTC (permalink / raw)
  To: ding

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

Hi there,

I've used mm-shr for the last couple of days and I'm happy with it.

I'm just sad to see that there's no images in the tables. But i've got
a little idea that could work.

I heard that Ted had some code to create SVG images on the fly. That
could be used to just draw a couple of fixed size images to build the
table (equivalent to the current |, -, +). Since we can't know the size
of a char, we would know the size of the image we draw here to build the
table borders.

Then, it'd be possible to build table with the right column width and
line height to match all embedded images, and therefore draw a cute
table.

Using something like (propertize "" 'display '(space . (:width 100))),
we may be able to even draw borderless tables for free.

Yeah, I could probably give it a try, but I think that if Lars like the
idea he might want to play with it himself or just say "that won't
work". ;-)

-- 
Julien Danjou
// ᐰ <julien@danjou.info>   http://julien.danjou.info

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: A little idea for shr and table
  2010-10-11 16:59 A little idea for shr and table Julien Danjou
@ 2010-10-11 18:39 ` Lars Magne Ingebrigtsen
  2010-10-11 19:07   ` David Engster
  2010-10-11 19:35   ` Julien Danjou
  2010-10-11 19:07 ` Ted Zlatanov
  2010-10-12 12:48 ` Štěpán Němec
  2 siblings, 2 replies; 14+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-10-11 18:39 UTC (permalink / raw)
  To: ding

Julien Danjou <julien@danjou.info> writes:

> I heard that Ted had some code to create SVG images on the fly. That
> could be used to just draw a couple of fixed size images to build the
> table (equivalent to the current |, -, +). Since we can't know the size
> of a char, we would know the size of the image we draw here to build the
> table borders.
>
> Then, it'd be possible to build table with the right column width and
> line height to match all embedded images, and therefore draw a cute
> table.

But how do you mix images and text?  I've never seen that done nicely in
Emacs...

We don't know the size of the images before rendering, either, but we
could download them before rendering the tables.  

> Yeah, I could probably give it a try, but I think that if Lars like the
> idea he might want to play with it himself or just say "that won't
> work". ;-)

+----+ I'd love for it to work, but I'm not seeing how this would work...
| ** | Most images are higher than the text, and I don't think Emacs
+----+ allows text to flow around images like this.

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




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

* Re: A little idea for shr and table
  2010-10-11 18:39 ` Lars Magne Ingebrigtsen
@ 2010-10-11 19:07   ` David Engster
  2010-10-11 19:10     ` Lars Magne Ingebrigtsen
  2010-10-11 19:35   ` Julien Danjou
  1 sibling, 1 reply; 14+ messages in thread
From: David Engster @ 2010-10-11 19:07 UTC (permalink / raw)
  To: ding

Lars Magne Ingebrigtsen writes:
> +----+ I'd love for it to work, but I'm not seeing how this would work...
> | ** | Most images are higher than the text, and I don't think Emacs
> +----+ allows text to flow around images like this.

Actually, it is possible by using sliced images (see
`insert-sliced-image'). I've played around with it to get a nicer image
display and smoother scrolling for emacs-w3m, but I gave up (the funny
thing is that w3m is using exactly this technique when running in a
terminal). But it is very difficult to do right in Emacs since you have
to take into account the font height, line-spacing, etc.

-David



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

* Re: A little idea for shr and table
  2010-10-11 16:59 A little idea for shr and table Julien Danjou
  2010-10-11 18:39 ` Lars Magne Ingebrigtsen
@ 2010-10-11 19:07 ` Ted Zlatanov
  2010-10-12 12:48 ` Štěpán Němec
  2 siblings, 0 replies; 14+ messages in thread
From: Ted Zlatanov @ 2010-10-11 19:07 UTC (permalink / raw)
  To: ding

On Mon, 11 Oct 2010 18:59:36 +0200 Julien Danjou <julien@danjou.info> wrote: 

JD> I heard that Ted had some code to create SVG images on the fly. That
JD> could be used to just draw a couple of fixed size images to build the
JD> table (equivalent to the current |, -, +). Since we can't know the size
JD> of a char, we would know the size of the image we draw here to build the
JD> table borders.

Yeah, that's very easy.  You don't even need SVG, just make an image of
the required size.  But with SVG you can make it look nice while loading.

Ted




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

* Re: A little idea for shr and table
  2010-10-11 19:07   ` David Engster
@ 2010-10-11 19:10     ` Lars Magne Ingebrigtsen
  2010-10-11 19:18       ` David Engster
  2010-10-11 19:21       ` Lars Magne Ingebrigtsen
  0 siblings, 2 replies; 14+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-10-11 19:10 UTC (permalink / raw)
  To: ding

David Engster <deng@randomsample.de> writes:

> Actually, it is possible by using sliced images (see
> `insert-sliced-image').

Oh, interesting.

> I've played around with it to get a nicer image display and smoother
> scrolling for emacs-w3m, but I gave up (the funny thing is that w3m is
> using exactly this technique when running in a terminal). But it is
> very difficult to do right in Emacs since you have to take into
> account the font height, line-spacing, etc.

But slicing the images will probably always give a better result in
shr, since we're not actually displaying images side-by-side with text.
I'll try playing with this...

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




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

* Re: A little idea for shr and table
  2010-10-11 19:10     ` Lars Magne Ingebrigtsen
@ 2010-10-11 19:18       ` David Engster
  2010-10-11 19:21       ` Lars Magne Ingebrigtsen
  1 sibling, 0 replies; 14+ messages in thread
From: David Engster @ 2010-10-11 19:18 UTC (permalink / raw)
  To: ding

Lars Magne Ingebrigtsen writes:
> David Engster <deng@randomsample.de> writes:
>> I've played around with it to get a nicer image display and smoother
>> scrolling for emacs-w3m, but I gave up (the funny thing is that w3m is
>> using exactly this technique when running in a terminal). But it is
>> very difficult to do right in Emacs since you have to take into
>> account the font height, line-spacing, etc.
>
> But slicing the images will probably always give a better result in
> shr, since we're not actually displaying images side-by-side with text.
> I'll try playing with this...

Note that insert-sliced-image will give you gaps with a
line-spacing>1. You don't have to override the line-spacing for the
whole buffer, though; you can set the line-height text property on the
newlines in the sliced-image area instead (I've written a small function
for this; see http://www.randomsample.de/dru5/node/24).

-David



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

* Re: A little idea for shr and table
  2010-10-11 19:10     ` Lars Magne Ingebrigtsen
  2010-10-11 19:18       ` David Engster
@ 2010-10-11 19:21       ` Lars Magne Ingebrigtsen
  2010-10-11 19:25         ` David Engster
  1 sibling, 1 reply; 14+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-10-11 19:21 UTC (permalink / raw)
  To: ding

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

>> Actually, it is possible by using sliced images (see
>> `insert-sliced-image').
>
> Oh, interesting.

I did the following:

diff --git a/lisp/shr.el b/lisp/shr.el
index 4031386..c308879 100644
--- a/lisp/shr.el
+++ b/lisp/shr.el
@@ -309,7 +309,10 @@ redirects somewhere else."
     (let ((image (ignore-errors
 		   (shr-rescale-image data))))
       (when image
-	(put-image image point alt)))))
+	(let ((size (image-size image t)))
+	(insert-sliced-image image alt nil
+			     (/ (cdr size) (min (frame-char-height) 10))
+			     1))))))
 
 (defun shr-rescale-image (data)
   (if (or (not (fboundp 'imagemagick-types))

The result was an Emacs that was unbearably slow to use.  Scrolling a
page took seconds.
   
-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




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

* Re: A little idea for shr and table
  2010-10-11 19:21       ` Lars Magne Ingebrigtsen
@ 2010-10-11 19:25         ` David Engster
  0 siblings, 0 replies; 14+ messages in thread
From: David Engster @ 2010-10-11 19:25 UTC (permalink / raw)
  To: ding

Lars Magne Ingebrigtsen writes:
> The result was an Emacs that was unbearably slow to use.  Scrolling a
> page took seconds.

Ah, yes. Now that you mention it, I remember that being a problem,
too...

-David



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

* Re: A little idea for shr and table
  2010-10-11 18:39 ` Lars Magne Ingebrigtsen
  2010-10-11 19:07   ` David Engster
@ 2010-10-11 19:35   ` Julien Danjou
  2010-10-11 19:38     ` Lars Magne Ingebrigtsen
  1 sibling, 1 reply; 14+ messages in thread
From: Julien Danjou @ 2010-10-11 19:35 UTC (permalink / raw)
  To: ding

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

On Mon, Oct 11 2010, Lars Magne Ingebrigtsen wrote:

> But how do you mix images and text?  I've never seen that done nicely in
> Emacs...
>
> We don't know the size of the images before rendering, either, but we
> could download them before rendering the tables.  

Or you can readjust (recompute/display) the table as they arrive,
probably.

>> Yeah, I could probably give it a try, but I think that if Lars like the
>> idea he might want to play with it himself or just say "that won't
>> work". ;-)
>
> +----+ I'd love for it to work, but I'm not seeing how this would work...
> | ** | Most images are higher than the text, and I don't think Emacs
> +----+ allows text to flow around images like this.

I'm not sure you really need this… At least most of the HTML examples
I've in mind use table to display images side by side, not with text
along.

-- 
Julien Danjou
// ᐰ <julien@danjou.info>   http://julien.danjou.info

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: A little idea for shr and table
  2010-10-11 19:35   ` Julien Danjou
@ 2010-10-11 19:38     ` Lars Magne Ingebrigtsen
  2010-10-12 14:10       ` Ted Zlatanov
  0 siblings, 1 reply; 14+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-10-11 19:38 UTC (permalink / raw)
  To: ding

Julien Danjou <julien@danjou.info> writes:

> Or you can readjust (recompute/display) the table as they arrive,
> probably.

It's possible.  But not very simple to do.  :-)

>> +----+ I'd love for it to work, but I'm not seeing how this would work...
>> | ** | Most images are higher than the text, and I don't think Emacs
>> +----+ allows text to flow around images like this.
>
> I'm not sure you really need this… At least most of the HTML examples
> I've in mind use table to display images side by side, not with text
> along.

But you usually have <td><img></td><td>Text bla bla bla</td>.  Then you
have text flowing down the image.

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




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

* Re: A little idea for shr and table
  2010-10-11 16:59 A little idea for shr and table Julien Danjou
  2010-10-11 18:39 ` Lars Magne Ingebrigtsen
  2010-10-11 19:07 ` Ted Zlatanov
@ 2010-10-12 12:48 ` Štěpán Němec
  2010-10-12 20:44   ` James Cloos
  2 siblings, 1 reply; 14+ messages in thread
From: Štěpán Němec @ 2010-10-12 12:48 UTC (permalink / raw)
  To: ding

Julien Danjou <julien@danjou.info> writes:

> Hi there,
>
> I've used mm-shr for the last couple of days and I'm happy with it.
>
> I'm just sad to see that there's no images in the tables. But i've got
> a little idea that could work.
>
> I heard that Ted had some code to create SVG images on the fly. That
> could be used to just draw a couple of fixed size images to build the
> table (equivalent to the current |, -, +). Since we can't know the size
> of a char, we would know the size of the image we draw here to build the
> table borders.
>
> Then, it'd be possible to build table with the right column width and
> line height to match all embedded images, and therefore draw a cute
> table.
>
> Using something like (propertize "" 'display '(space . (:width 100))),
> we may be able to even draw borderless tables for free.
>
> Yeah, I could probably give it a try, but I think that if Lars like the
> idea he might want to play with it himself or just say "that won't
> work". ;-)

FWIW, I like ASCII art better, so I'd prefer to at least have an option
to get text-only tables if the "fancy" method becomes the default.

Štěpán



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

* Re: A little idea for shr and table
  2010-10-11 19:38     ` Lars Magne Ingebrigtsen
@ 2010-10-12 14:10       ` Ted Zlatanov
  2010-10-12 14:27         ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 14+ messages in thread
From: Ted Zlatanov @ 2010-10-12 14:10 UTC (permalink / raw)
  To: ding

On Mon, 11 Oct 2010 21:38:49 +0200 Lars Magne Ingebrigtsen <larsi@gnus.org> wrote: 

LMI> But you usually have <td><img></td><td>Text bla bla bla</td>.  Then you
LMI> have text flowing down the image.

Can you use any of the rectangle pasting functionality?  IOW format the
text to the desired length in a temp buffer, then rectangle-paste it at
the right offset.

Ted




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

* Re: A little idea for shr and table
  2010-10-12 14:10       ` Ted Zlatanov
@ 2010-10-12 14:27         ` Lars Magne Ingebrigtsen
  0 siblings, 0 replies; 14+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-10-12 14:27 UTC (permalink / raw)
  To: ding

Ted Zlatanov <tzz@lifelogs.com> writes:

> Can you use any of the rectangle pasting functionality?  IOW format the
> text to the desired length in a temp buffer, then rectangle-paste it at
> the right offset.

That's how the tables are constructed now.  The problem is with the
Emacs display, where you can't have two lines of stuff at the end of the
line and one at the beginning.

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




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

* Re: A little idea for shr and table
  2010-10-12 12:48 ` Štěpán Němec
@ 2010-10-12 20:44   ` James Cloos
  0 siblings, 0 replies; 14+ messages in thread
From: James Cloos @ 2010-10-12 20:44 UTC (permalink / raw)
  To: ding; +Cc: Štěpán Němec

>>>>> "ŠN" == Štěpán Němec <stepnem@gmail.com> writes:

ŠN> FWIW, I like ASCII art better, so I'd prefer to at least have an option
ŠN> to get text-only tables if the "fancy" method becomes the default.

And utf8-art, too, please.

-JimC
-- 
James Cloos <cloos@jhcloos.com>         OpenPGP: 1024D/ED7DAEA6





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

end of thread, other threads:[~2010-10-12 20:44 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-11 16:59 A little idea for shr and table Julien Danjou
2010-10-11 18:39 ` Lars Magne Ingebrigtsen
2010-10-11 19:07   ` David Engster
2010-10-11 19:10     ` Lars Magne Ingebrigtsen
2010-10-11 19:18       ` David Engster
2010-10-11 19:21       ` Lars Magne Ingebrigtsen
2010-10-11 19:25         ` David Engster
2010-10-11 19:35   ` Julien Danjou
2010-10-11 19:38     ` Lars Magne Ingebrigtsen
2010-10-12 14:10       ` Ted Zlatanov
2010-10-12 14:27         ` Lars Magne Ingebrigtsen
2010-10-11 19:07 ` Ted Zlatanov
2010-10-12 12:48 ` Štěpán Němec
2010-10-12 20:44   ` James Cloos

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 NNTP newsgroup(s).