home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / alt / lucidem / help / 821 < prev    next >
Encoding:
Text File  |  1992-12-24  |  5.6 KB  |  114 lines

  1. x-gateway: rodan.UU.NET from help-lucid-emacs to alt.lucid-emacs.help; Thu, 24 Dec 1992 22:26:20 EST
  2. Message-ID: <9212250147.AA15972@thymus.synaptics>
  3. Subject: Idea: graphical extents
  4. Reply-To: daveg@synaptics.com
  5. Date: Thu, 24 Dec 1992 17:47:38 -0800
  6. From: daveg@thymus.synaptics.com (Dave Gillespie)
  7. Newsgroups: alt.lucid-emacs.help
  8. Path: sparky!uunet!wendy-fate.uu.net!help-lucid-emacs
  9. Sender: help-lucid-emacs-request@lucid.com
  10. Lines: 102
  11.  
  12. I made this suggestion to the FSF's Emacs 19 people a while ago, and
  13. they said it sounded interesting but that they wouldn't be ready for
  14. it for quite a while.  It occurs to me that Lucid Emacs probably has
  15. all the pieces in place right now.
  16.  
  17. The idea is to make another type of extent, a "graphical extent."
  18. It would be characterized by the usual two markers into a buffer
  19. and a face, plus a graphical type and two pairs (x,y) of floats
  20. with 0 <= x < 1 and 0 <= y < 1.
  21.  
  22. The start-position of the extent identifies a character cell in
  23. the buffer, and the first (x,y) pair identifies a position within
  24. that cell, together identifying any pixel in the buffer.  The
  25. end-position and the other (x,y) pair identify another pixel in
  26. the buffer.
  27.  
  28. The two graphical types that come to mind are lines, where the
  29. extent shows up as a diagonal line between the two points, of
  30. the face's foreground color, overlayed over the text; and
  31. rectangles, where the two points are the corners of an outline
  32. rectangle of the foreground color.
  33.  
  34. The nice property of this notation is that, as far as I can tell,
  35. the set of pixels on the screen that could be affected by one
  36. of these graphical extents is strictly a subset of the pixels that
  37. are affected by a regular textual extent.  So all the regular
  38. optimizations still apply, e.g., if both markers of an extent are
  39. off the beginning or end of the screen, the display routines can
  40. ignore the extent.
  41.  
  42. Line extents would be useful for all sorts of things, ranging from
  43. prettying up buffers containing forms or tables, to displaying
  44. actual graphics in an Emacs buffer.  In principle, given nothing
  45. but line extents it would be possible to write a decent little
  46. graphics editor for putting figures in Emacs documents.  Line
  47. extents would also be enough to let Calc draw simple graphs all
  48. by itself, rather than relying on a hokey and fragile interface
  49. to GNUPLOT as it does now.
  50.  
  51. Rectangle extents would allow a more appropriate kind of
  52. highlighting for rectangle operations.  I posted a suggestion
  53. along those lines a while ago here, but I was envisioning
  54. some way of faking it up with a group of regular extents.
  55. Imagine how easy it would be with a single rectangle extent
  56. instead!
  57.  
  58. Another nice graphical type would be filled rectangles, or even
  59. filled polygons.  As soon as you have filled objects you run into
  60. the issue of drawing order, though, which the current extent data
  61. structure probably isn't well-suited to handle.  (I haven't looked
  62. at the code, this is just guessing.)  I guess even a filled rectangle
  63. extent where the behavior is undefined if any non-whitespace text
  64. or other graphical extents intersect the rectangle would still be
  65. useful sometimes.
  66.  
  67. Another enhancement would be to allow the (x,y) offsets to go
  68. beyond the 0..1 range.  For example, it would be nice to be able
  69. to draw an arrow to the right of a line of text, even though the
  70. endpoints of the strokes of the arrow would not be inside character
  71. cells.  I wouldn't be surprised if it would be easy to relax the
  72. range restriction on the "x" offsets, although relaxing the "y"
  73. restriction would probably make clipping a horrible nightmare.
  74. Relaxing "x" would be enough for most purposes.  In fact relaxing
  75. just the upper bound on "x" would be enough.
  76.  
  77. Suppose you wanted to display a change bar to the right of a set
  78. of lines in a buffer.  The most mangeable way to do this would
  79. probably be to put the two markers on the *first* character of
  80. the first and last line of the marker, then put the "x" offsets
  81. at, say, (- (window-width) 0.5).  (The really right way to do
  82. this would be to have a flag on graphical extents saying to
  83. interpret the "x" offsets as absolute rather than relative to
  84. the character position of the marker; then you can simply put
  85. the extent around the part of the buffer that has changed, and
  86. the bars will automatically wind up where you want them even as
  87. the text is edited further.  One could call this creeping
  88. featurism, I suppose.)  (But then, now that I think about it,
  89. most of the ideas I had in mind would be served by having "x"
  90. *always* be an absolute position, with the markers only used to
  91. find the "y" baseline.  Hmm.)
  92.  
  93. It's not totally clear how to interpret the "x" offsets when the
  94. font is proportional, or when the marker points to a character with
  95. a "wide" display like a tab or a "^M".  If you let the "x" offset
  96. go outside the character cell, you could just scale it so that 1.0
  97. equals the width of a space in the underlying font.
  98.  
  99. The idea behind using floats instead of integer pixel values for
  100. the offsets is to make it easy on programs that don't want to know
  101. about the details of the font being used.  Putting a rectangular
  102. box around some text, for example, is just a matter of using
  103. (0,0) for the upper-left offsets, and (0.999,0.999) for the
  104. lower-right offsets.  If you get the pixel position by multiplying
  105. the offset by the character width or height, and rounding down to
  106. an integer, then (0.999,0.999) will specify the lower-right corner
  107. of the character cell in a nice, font-independent way.
  108.  
  109. Anyway, I may someday have time to work on this myself, but I
  110. wouldn't be surprised if Jamie or another person who already knows
  111. the lemacs internals could do it in an afternoon.  Hint, hint.  :-)
  112.  
  113.                                 -- Dave
  114.