Initial Commit
[packages] / xemacs-packages / hyperbole / hui-ep-but.el
1 ;;; hui-ep-but.el --- Support for highlighting/flashing buttons under Epoch.
2
3 ;; Copyright (C) 1990-1995, Free Software Foundation, Inc.
4 ;; Developed with support from Motorola Inc.
5
6 ;; Author: Bob Weiner, Brown U.
7 ;; Maintainer: Mats Lidell <matsl@contactor.se>
8 ;; Keywords: faces, hypermedia
9
10 ;; This file is part of GNU Hyperbole.
11
12 ;; GNU Hyperbole is free software; you can redistribute it and/or
13 ;; modify it under the terms of the GNU General Public License as
14 ;; published by the Free Software Foundation; either version 3, or (at
15 ;; your option) any later version.
16
17 ;; GNU Hyperbole is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20 ;; General Public License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
26
27 ;;; Commentary:
28 ;;
29 ;;   This is truly prototype code.
30 ;;
31 ;;   Can't use epoch read-only buttons here because then outline-mode
32 ;;   becomes unusable; when it tries to do a 'subst-char-in-region'
33 ;;   epoch triggers a read-only error.
34 ;;
35
36 ;;; Code:
37
38 (if (and (boundp 'epoch::version) (stringp epoch::version)
39          (or noninteractive (string-lessp epoch::version "Epoch 4")))
40     nil
41   (error "(hui-ep-but.el): Load only under Epoch version 3 or lower."))
42
43 ;;;
44 ;;; Other required Elisp libraries
45 ;;;
46
47 (require 'hbut)
48
49 ;;;
50 ;;; Public variables
51 ;;;
52
53 ;;;
54 ;;; Public functions
55 ;;;
56
57 (fset 'hproperty:but-add 'epoch::add-button)
58
59 (defun hproperty:but-color ()
60   "Return current color of buffer's buttons."
61   (if hproperty:color-ptr
62       (car hproperty:color-ptr)
63     (epoch::foreground)))
64
65 (defun hproperty:but-create-all (&optional start-delim end-delim regexp-match)
66   "Mark all hyper-buttons in buffer as Epoch buttons, for later highlighting.
67 Will use optional strings START-DELIM and END-DELIM instead of default values.
68 If END-DELIM is a symbol, e.g. t, then START-DELIM is taken as a regular
69 expression which matches an entire button string.
70 If REGEXP-MATCH is non-nil, only buttons matching this argument are
71 highlighted."
72   (ebut:map (function (lambda (lbl start end)
73                         (hproperty:but-add start end hproperty:but)))
74             start-delim end-delim regexp-match 'include-delims))
75                
76 (defun hproperty:but-delete (&optional pos)
77   (epoch::delete-button-at (or pos (point))))
78
79 ;;;
80 ;;; Private functions
81 ;;;
82
83 (defmacro hproperty:list-cycle (list-ptr list)
84   "Move LIST-PTR to next element in LIST or when at end to first element."
85   (` (or (and (, list-ptr)
86               (setq (, list-ptr) (cdr (, list-ptr))))
87          (setq (, list-ptr) (, list)))))
88
89 ;;;
90 ;;; Private variables
91 ;;;
92
93 (defconst hproperty:color-list '( "red" "blue" "paleturquoise4" "mediumpurple2"
94 "lightskyblue3" "springgreen2" "salmon" "yellowgreen" "darkorchid2"
95 "aquamarine4" "slateblue4" "slateblue1" "olivedrab1" "goldenrod4"
96 "goldenrod3" "cadetblue2" "burlywood1" "slategrey" "mistyrose"
97 "limegreen" "lightcyan" "goldenrod" "gainsboro" "skyblue1" "honeydew"
98 "yellow2" "tomato3" "skyblue" "purple4" "orange3" "bisque3" "bisque2"
99 "grey34" "gray99" "gray63" "gray44" "gray37" "gray33" "gray26" "azure1"
100 "snow4" "peru" "red" "lightgoldenrod4" "mediumseagreen" "blush"
101 "mediumorchid2" "lightskyblue1" "darkslateblue" "midnightblue"
102 "lightsalmon1" "lemonchiffon" "yellow" "lightsalmon" "coral"
103 "dodgerblue3" "darkorange4" "blue" "royalblue4" "red" "green" "cyan"
104 "darkviolet" "darksalmon" "darkorange" "blue" "pink" "magenta2"
105 "sienna4" "khaki2" "grey75" "grey74" "grey73" "grey69" "grey68" "grey35"
106 "grey13" "gray90" "gray81" "gray55" "gray51" "gray31" "snow2" "pink3"
107 "grey7" "gray1" "red4" "red3" "tan" "red" "yellow" "mediumvioletred"
108 "lightslategrey" "lavenderblush4" "turquoise" "darkturquoise"
109 "darkslategrey" "lightskyblue" "lightsalmon4" "lightsalmon3"
110 "forestgreen" "dodgerblue4" "orchid" "rosybrown4" "brown" "peachpuff3"
111 "palegreen3" "orangered2" "rose" "lightcyan4" "indianred4" "indianred3"
112 "seagreen2" "indianred" "deeppink1" "navyblue" "lavender" "grey"
113 "deeppink" "salmon4" "salmon3" "oldlace" "grey78" "grey77" "grey54"
114 "grey45" "grey21" "gray97" "gray96" "gray95" "gray88" "gray87" "gray86"
115 "gray70" "gray57" "gray38" "gray12" "gray11" "plum3" "linen" "gray9"
116 "gray8" "blue4" "beige" "turquoise" "blue" "lemonchiffon4"
117 "darkseagreen1" "antiquewhite3" "mediumorchid" "springgreen"
118 "turquoise4" "steelblue3" "mistyrose2" "lightcyan2" "red" "firebrick2"
119 "royalblue" "cadetblue" "skyblue3" "yellow3" "salmon1" "orange4"
120 "hotpink" "grey90" "gray56" "gray39" "gray18" "gray14" "plum4" "grey6"
121 "gray6" "gold3" "gold1" "blue2" "tan2" "cyan" "mediumspringgreen"
122 "darkolivegreen2" "goldenrod" "lightsteelblue" "brown" "whip"
123 "chartreuse3" "violetred4" "royalblue2" "royalblue1" "papayawhip"
124 "mistyrose3" "lightcyan1" "aquamarine" "skyblue4" "hotpink4" "hotpink3"
125 "hotpink2" "dimgray" "tomato" "grey66" "grey65" "grey64" "grey33"
126 "grey27" "gray76" "gray69" "gray68" "grey0" "azure" "green"
127 "darkgoldenrod4" "darkgoldenrod3" "darkgoldenrod2" "darkgoldenrod"
128 "brown" "lightsalmon2" "deepskyblue4" "deepskyblue3" "deepskyblue2"
129 "deepskyblue" "darkorange1" "violetred3" "violetred2" "violetred1"
130 "slateblue3" "slateblue2" "drab" "indianred1" "firebrick1" "cadetblue4"
131 "violetred" "rosybrown" "blue" "firebrick" "grey100" "wheat4" "grey79"
132 "grey76" "grey61" "gray93" "gray84" "gray65" "gray36" "gray32" "gray13"
133 "gray10" "azure3" "snow1" "tan1" "gray" "darkolivegreen1" "blue"
134 "almond" "lavenderblush3" "lavenderblush2" "lavenderblush1"
135 "darkolivegreen" "lavenderblush" "aquamarine2" "red" "olivedrab2"
136 "mistyrose4" "mistyrose1" "lightcyan3" "lightcoral" "chartreuse"
137 "peachpuff" "palegreen" "mintcream" "skyblue2" "moccasin" "tomato1"
138 "orchid3" "maroon3" "salmon" "grey81" "grey62" "grey39" "grey38"
139 "grey37" "gray92" "gray83" "gray66" "gray54" "gray50" "gray30" "gray19"
140 "gray15" "azure4" "grey3" "tan3" "pink" "gray" "blue" "lightsteelblue2"
141 "lightsteelblue1" "green" "lightslategray" "lemonchiffon2"
142 "springgreen1" "greenyellow" "chartreuse2" "grey" "royalblue3"
143 "powderblue" "peachpuff2" "palegreen2" "cream" "slateblue" "seashell2"
144 "deeppink2" "darkkhaki" "maroon4" "sienna" "grey71" "grey67" "grey18"
145 "gray59" "gray43" "gray25" "bisque" "red1" "mediumslateblue"
146 "lightgoldenrod1" "goldenrod" "paleturquoise3" "lightskyblue4" "green"
147 "yellow" "smoke" "blue" "white" "steelblue4" "rosybrown3" "peachpuff1"
148 "palegreen1" "blueviolet" "seashell4" "sienna3" "grey40" "gray91"
149 "gray82" "gray5" "cyan2" "cyan1" "blue1" "snow" "lightgoldenrod2"
150 "lightslateblue" "mediumorchid3" "darkseagreen4" "springgreen3" "green"
151 "slategray4" "slategray3" "slategray2" "blue" "peachpuff4" "palegreen4"
152 "green" "orangered3" "goldenrod1" "ghostwhite" "firebrick4" "firebrick3"
153 "cadetblue3" "slategray" "seashell3" "honeydew3" "cornsilk4" "cornsilk2"
154 "purple1" "dimgrey" "khaki1" "ivory3" "grey70" "grey60" "grey32"
155 "grey22" "grey12" "gray98" "gray89" "gray71" "gray64" "gray60" "gray49"
156 "azure2" "gray3" "paleturquoise1" "mediumpurple1" "purple"
157 "lemonchiffon1" "blue" "navajowhite3" "darkorchid1" "orange"
158 "goldenrod2" "khaki" "chocolate2" "burlywood2" "honeydew1" "darkgreen"
159 "thistle3" "thistle2" "thistle1" "thistle" "maroon2" "maroon1" "grey53"
160 "grey44" "grey25" "gray74" "gray45" "gray41" "gray35" "gray27" "gray23"
161 "gray16" "brown4" "wheat" "coral" "tan4" "lightgoldenrodyellow" "blue"
162 "green" "gray" "palevioletred3" "mediumpurple4" "mediumpurple3"
163 "saddlebrown" "blue" "darkorchid4" "darkorchid3" "puff" "olivedrab4"
164 "lightblue4" "lightpink" "lightgray" "honeydew2" "cornsilk1" "lace"
165 "sienna1" "bisque4" "orchid" "khaki3" "grey84" "grey83" "grey82"
166 "grey72" "grey52" "grey43" "grey26" "grey14" "grey10" "gray75" "gray53"
167 "gray21" "gray20" "brown3" "grey8" "red2" "navy" "grey" "gold"
168 "mediumaquamarine" "lightgoldenrod" "darkslategray4" "darkseagreen3"
169 "darkseagreen2" "antiquewhite4" "white" "springgreen4" "lightyellow4"
170 "white" "aquamarine1" "turquoise3" "steelblue2" "rosybrown2" "pink"
171 "gray" "indianred2" "dodgerblue" "green" "seagreen1" "deeppink4"
172 "aliceblue" "magenta1" "pink" "sienna2" "orchid1" "gray100" "grey97"
173 "grey94" "grey87" "grey86" "grey51" "grey42" "grey19" "gray94" "gray85"
174 "gray61" "brown2" "khaki" "grey1" "gold4" "blue" "green" "grey"
175 "turquoise" "paleturquoise" "mediumorchid4" "antiquewhite2"
176 "lightyellow2" "violet" "salmon" "chartreuse1" "turquoise1" "sandybrown"
177 "orangered1" "lightpink1" "lightblue2" "lightblue1" "grey" "seagreen4"
178 "seagreen3" "lightblue" "deeppink3" "burlywood" "seashell" "hotpink1"
179 "gray" "yellow4" "yellow" "purple" "orange" "ivory4" "grey99" "grey89"
180 "grey63" "grey58" "grey49" "grey31" "grey24" "grey20" "green4" "green1"
181 "gray73" "gray67" "coral3" "coral2" "plum2" "pink4" "ivory" "gray4"
182 "gray2" "gold2" "aquamarine" "grey" "lightgoldenrod3" "darkolivegreen3"
183 "darkgoldenrod1" "goldenrod" "orchid" "chiffon" "navajowhite4"
184 "deepskyblue1" "lightyellow" "floralwhite" "blue" "mediumblue"
185 "chocolate4" "chocolate3" "burlywood4" "turquoise" "steelblue" "green"
186 "lawngreen" "honeydew4" "seagreen" "orchid4" "wheat1" "violet" "ivory1"
187 "grey88" "grey85" "grey57" "grey56" "grey55" "grey48" "grey47" "grey46"
188 "grey30" "grey17" "gray47" "gray29" "pink2" "grey5" "grey4" "green"
189 "gray0" "brown" "lightsteelblue4" "darkolivegreen4" "palevioletred4"
190 "blue" "darkslategray3" "darkslategray2" "darkslategray1"
191 "blanchedalmond" "palegoldenrod" "blue" "lightseagreen" "lemonchiffon3"
192 "darkslategray" "green" "darkseagreen" "antiquewhite" "darkorange2"
193 "chartreuse4" "blue" "rosybrown1" "olivedrab3" "lightpink2" "orangered"
194 "thistle4" "blue" "cornsilk" "salmon2" "orchid2" "ivory2" "grey93"
195 "grey92" "grey91" "grey36" "grey29" "grey28" "grey16" "gray79" "gray78"
196 "gray77" "gray48" "gray17" "coral4" "coral1" "plum1" "pink1" "grey9"
197 "grey2" "gray7" "cyan4" "blue3" "plum" "cornflowerblue" "lightskyblue2"
198 "antiquewhite1" "navajowhite2" "navajowhite1" "lightyellow3"
199 "navajowhite" "darkorange3" "whitesmoke" "turquoise2" "steelblue1"
200 "lightpink4" "lightblue3" "green" "chocolate1" "blue" "olivedrab"
201 "lightgrey" "chocolate" "magenta4" "magenta3" "yellow1" "purple3"
202 "purple2" "orange2" "orange1" "magenta" "bisque1" "wheat2" "maroon"
203 "khaki4" "grey96" "grey95" "grey80" "grey50" "grey41" "grey15" "grey11"
204 "gray80" "gray58" "gray40" "gray34" "gray22" "brown1" "snow3"
205 "mediumturquoise" "lightsteelblue3" "palevioletred2" "palevioletred1"
206 "paleturquoise2" "green" "palevioletred" "mediumorchid1" "white"
207 "mediumpurple" "lightyellow1" "dodgerblue2" "dodgerblue1" "violet"
208 "aquamarine3" "slategray1" "gray" "orangered4" "lightpink3" "blue"
209 "darkorchid" "cadetblue1" "burlywood3" "seashell1" "cornsilk3" "tomato4"
210 "tomato2" "wheat3" "grey98" "grey59" "grey23" "green3" "green2" "gray72"
211 "gray62" "gray52" "gray46" "gray42" "gray28" "gray24" "white" "cyan3"
212 "black" ))
213
214 (defvar hproperty:color-ptr nil
215   "Pointer to current color name table to use for Hyperbole buttons in Epoch.")
216
217 (defconst hproperty:good-colors
218   '(
219     "medium violet red" "indianred4" "firebrick1" "DarkGoldenrod" "NavyBlue"
220     "darkorchid" "tomato3" "mediumseagreen" "deeppink" "forestgreen"
221     "mistyrose4" "slategrey" "purple4" "dodgerblue3" "mediumvioletred"
222     "lightsalmon3" "orangered2" "turquoise4" "Gray55"
223     )
224   "Good colors for contrast against wheat background and black foreground.")
225
226 (provide 'hui-ep-but)
227
228
229 ;;; hui-ep-but.el ends here