1 ;;; fringe.el --- change fringes appearance in various ways
3 ;; Copyright (C) 2002, 2003 Free Software Foundation, Inc.
5 ;; Author: Simon Josefsson <simon@josefsson.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
28 ;; This file contains helpful functions for customizing the appearance
31 ;; The code is influenced by scroll-bar.el and avoid.el. The author
32 ;; gratefully acknowledge comments and suggestions made by Miles
33 ;; Bader, Eli Zaretski, Richard Stallman, Pavel JanÃk and others which
34 ;; improved this package.
38 ;; Standard fringe bitmaps
40 (defconst no-fringe-bitmap
0)
41 (defconst undef-fringe-bitmap
1)
42 (defconst left-truncation-fringe-bitmap
2)
43 (defconst right-truncation-fringe-bitmap
3)
44 (defconst up-arrow-fringe-bitmap
4)
45 (defconst down-arrow-fringe-bitmap
5)
46 (defconst continued-line-fringe-bitmap
6)
47 (defconst continuation-line-fringe-bitmap
7)
48 (defconst overlay-arrow-fringe-bitmap
8)
49 (defconst top-left-angle-fringe-bitmap
9)
50 (defconst top-right-angle-fringe-bitmap
10)
51 (defconst bottom-left-angle-fringe-bitmap
11)
52 (defconst bottom-right-angle-fringe-bitmap
12)
53 (defconst left-bracket-fringe-bitmap
13)
54 (defconst right-bracket-fringe-bitmap
14)
55 (defconst filled-box-cursor-fringe-bitmap
15)
56 (defconst hollow-box-cursor-fringe-bitmap
16)
57 (defconst hollow-square-fringe-bitmap
17)
58 (defconst bar-cursor-fringe-bitmap
18)
59 (defconst hbar-cursor-fringe-bitmap
19)
60 (defconst empty-line-fringe-bitmap
20)
63 ;; Control presence of fringes
67 (defun set-fringe-mode-1 (ignore value
)
68 "Call `set-fringe-mode' with VALUE.
69 See `fringe-mode' for valid values and their effect.
70 This is usually invoked when setting `fringe-mode' via customize."
71 (set-fringe-mode value
))
73 (defun set-fringe-mode (value)
74 "Set `fringe-mode' to VALUE and put the new value into effect.
75 See `fringe-mode' for possible values and their effect."
76 (setq fringe-mode value
)
78 ;; Apply it to default-frame-alist.
79 (let ((parameter (assq 'left-fringe default-frame-alist
)))
81 (setcdr parameter
(if (consp fringe-mode
)
84 (setq default-frame-alist
85 (cons (cons 'left-fringe
(if (consp fringe-mode
)
88 default-frame-alist
))))
89 (let ((parameter (assq 'right-fringe default-frame-alist
)))
91 (setcdr parameter
(if (consp fringe-mode
)
94 (setq default-frame-alist
95 (cons (cons 'right-fringe
(if (consp fringe-mode
)
98 default-frame-alist
))))
100 ;; Apply it to existing frames.
101 (let ((frames (frame-list)))
103 (modify-frame-parameters
105 (list (cons 'left-fringe
(if (consp fringe-mode
)
108 (cons 'right-fringe
(if (consp fringe-mode
)
111 (setq frames
(cdr frames
)))))
114 (defcustom fringe-mode nil
115 "*Specify appearance of fringes on all frames.
116 This variable can be nil (the default) meaning the fringes should have
117 the default width (8 pixels), it can be an integer value specifying
118 the width of both left and right fringe (where 0 means no fringe), or
119 a cons cell where car indicates width of left fringe and cdr indicates
120 width of right fringe (where again 0 can be used to indicate no
122 To set this variable in a Lisp program, use `set-fringe-mode' to make
124 Setting the variable with a customization buffer also takes effect.
125 If you only want to modify the appearance of the fringe in one frame,
126 you can use the interactive function `toggle-fringe'"
127 :type
'(choice (const :tag
"Default width" nil
)
128 (const :tag
"No fringes" 0)
129 (const :tag
"Only right" (0 . nil
))
130 (const :tag
"Only left" (nil .
0))
131 (const :tag
"Half width" (5 .
5))
132 (const :tag
"Minimal" (1 .
1))
133 (integer :tag
"Specific width")
134 (cons :tag
"Different left/right sizes"
135 (integer :tag
"Left width")
136 (integer :tag
"Right width")))
139 :set
'set-fringe-mode-1
)
141 (defun fringe-query-style (&optional all-frames
)
142 "Query user for fringe style.
143 Returns values suitable for left-fringe and right-fringe frame parameters.
144 If ALL-FRAMES, the negation of the fringe values in
145 `default-frame-alist' is used when user enters the empty string.
146 Otherwise the negation of the fringe value in the currently selected
147 frame parameter is used."
148 (let ((mode (intern (completing-read
149 "Select fringe mode for all frames (type ? for list): "
150 '(("none") ("default") ("left-only")
151 ("right-only") ("half") ("minimal"))
153 (cond ((eq mode
'none
) 0)
154 ((eq mode
'default
) nil
)
155 ((eq mode
'left-only
) '(nil .
0))
156 ((eq mode
'right-only
) '(0 . nil
))
157 ((eq mode
'half
) '(5 .
5))
158 ((eq mode
'minimal
) '(1 .
1))
159 ((eq mode
(intern ""))
160 (if (eq 0 (cdr (assq 'left-fringe
163 (frame-parameters (selected-frame))))))
168 (defun fringe-mode (&optional mode
)
169 "Set the default appearance of fringes on all frames.
171 When called interactively, query the user for MODE. Valid values
172 for MODE include `none', `default', `left-only', `right-only',
173 `minimal' and `half'.
175 When used in a Lisp program, MODE can be a cons cell where the
176 integer in car specifies the left fringe width and the integer in
177 cdr specifies the right fringe width. MODE can also be a single
178 integer that specifies both the left and the right fringe width.
179 If a fringe width specification is nil, that means to use the
180 default width (8 pixels). This command may round up the left and
181 right width specifications to ensure that their sum is a multiple
182 of the character width of a frame. It never rounds up a fringe
185 Fringe widths set by `set-window-fringes' override the default
186 fringe widths set by this command. This command applies to all
187 frames that exist and frames to be created in the future. If you
188 want to set the default appearance of fringes on the selected
189 frame only, see the command `set-fringe-style'."
190 (interactive (list (fringe-query-style 'all-frames
)))
191 (set-fringe-mode mode
))
194 (defun set-fringe-style (&optional mode
)
195 "Set the default appearance of fringes on the selected frame.
197 When called interactively, query the user for MODE. Valid values
198 for MODE include `none', `default', `left-only', `right-only',
199 `minimal' and `half'.
201 When used in a Lisp program, MODE can be a cons cell where the
202 integer in car specifies the left fringe width and the integer in
203 cdr specifies the right fringe width. MODE can also be a single
204 integer that specifies both the left and the right fringe width.
205 If a fringe width specification is nil, that means to use the
206 default width (8 pixels). This command may round up the left and
207 right width specifications to ensure that their sum is a multiple
208 of the character width of a frame. It never rounds up a fringe
211 Fringe widths set by `set-window-fringes' override the default
212 fringe widths set by this command. If you want to set the
213 default appearance of fringes on all frames, see the command
215 (interactive (list (fringe-query-style)))
216 (modify-frame-parameters
218 (list (cons 'left-fringe
(if (consp mode
) (car mode
) mode
))
219 (cons 'right-fringe
(if (consp mode
) (cdr mode
) mode
)))))
221 (defsubst fringe-columns
(side &optional real
)
222 "Return the width, measured in columns, of the fringe area on SIDE.
223 If optional argument REAL is non-nil, return a real floating point
224 number instead of a rounded integer value.
225 SIDE must be the symbol `left' or `right'."
226 (funcall (if real
'/ 'ceiling
)
227 (or (funcall (if (eq side
'left
) 'car
'cadr
)
230 (float (frame-char-width))))
234 ;;; arch-tag: 6611ef60-0869-47ed-8b93-587ee7d3ff5d
235 ;;; fringe.el ends here