comparison lisp/wid-edit.el @ 18598:e12b4c195b2b

Synched with 1.9944.
author Per Abrahamsen <abraham@dina.kvl.dk>
date Fri, 04 Jul 1997 09:44:36 +0000
parents f0c2a091d91f
children d95acbbb4ac7
comparison
equal deleted inserted replaced
18597:515b7c955cd8 18598:e12b4c195b2b
2 ;; 2 ;;
3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc. 3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc.
4 ;; 4 ;;
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk> 5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
6 ;; Keywords: extensions 6 ;; Keywords: extensions
7 ;; Version: 1.9942 7 ;; Version: 1.9944
8 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/ 8 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/
9 9
10 ;; This file is part of GNU Emacs. 10 ;; This file is part of GNU Emacs.
11 11
12 ;; GNU Emacs is free software; you can redistribute it and/or modify 12 ;; GNU Emacs is free software; you can redistribute it and/or modify
127 (defgroup widgets nil 127 (defgroup widgets nil
128 "Customization support for the Widget Library." 128 "Customization support for the Widget Library."
129 :link '(custom-manual "(widget)Top") 129 :link '(custom-manual "(widget)Top")
130 :link '(url-link :tag "Development Page" 130 :link '(url-link :tag "Development Page"
131 "http://www.dina.kvl.dk/~abraham/custom/") 131 "http://www.dina.kvl.dk/~abraham/custom/")
132 :link '(emacs-library-link :tag "Lisp File" "widget.el")
132 :prefix "widget-" 133 :prefix "widget-"
133 :group 'extensions 134 :group 'extensions
134 :group 'hypermedia) 135 :group 'hypermedia)
135 136
136 (defgroup widget-documentation nil 137 (defgroup widget-documentation nil
389 ;; Terminating space is not part of the field, but necessary in 390 ;; Terminating space is not part of the field, but necessary in
390 ;; order for local-map to work. Remove next sexp if local-map works 391 ;; order for local-map to work. Remove next sexp if local-map works
391 ;; at the end of the overlay. 392 ;; at the end of the overlay.
392 (save-excursion 393 (save-excursion
393 (goto-char to) 394 (goto-char to)
394 (when widget-field-add-space 395 (cond ((null (widget-get widget :size))
395 (insert-and-inherit " ")) 396 (forward-char 1))
397 (widget-field-add-space
398 (insert-and-inherit " ")))
396 (setq to (point))) 399 (setq to (point)))
397 (if widget-field-add-space 400 (if (or widget-field-add-space
401 (null (widget-get widget :size)))
398 (add-text-properties (1- to) to 402 (add-text-properties (1- to) to
399 '(front-sticky nil start-open t read-only to)) 403 '(front-sticky nil start-open t read-only to))
400 (add-text-properties to (1+ to) 404 (add-text-properties to (1+ to)
401 '(front-sticky nil start-open t read-only to))) 405 '(front-sticky nil start-open t read-only to)))
402 (add-text-properties (1- from) from 406 (add-text-properties (1- from) from
403 '(rear-nonsticky t end-open t read-only from)) 407 '(rear-nonsticky t end-open t read-only from))
404 (let ((map (widget-get widget :keymap)) 408 (let ((map (widget-get widget :keymap))
405 (face (or (widget-get widget :value-face) 'widget-field-face)) 409 (face (or (widget-get widget :value-face) 'widget-field-face))
406 (help-echo (widget-get widget :help-echo)) 410 (help-echo (widget-get widget :help-echo))
407 (overlay (make-overlay from to nil nil t))) 411 (overlay (make-overlay from to nil
412 nil (or (not widget-field-add-space)
413 (widget-get widget :size)))))
408 (unless (or (stringp help-echo) (null help-echo)) 414 (unless (or (stringp help-echo) (null help-echo))
409 (setq help-echo 'widget-mouse-help)) 415 (setq help-echo 'widget-mouse-help))
410 (widget-put widget :field-overlay overlay) 416 (widget-put widget :field-overlay overlay)
411 (overlay-put overlay 'detachable nil) 417 (overlay-put overlay 'detachable nil)
412 (overlay-put overlay 'field widget) 418 (overlay-put overlay 'field widget)
1266 1272
1267 (defun widget-field-end (widget) 1273 (defun widget-field-end (widget)
1268 "Return the end of WIDGET's editing field." 1274 "Return the end of WIDGET's editing field."
1269 (let ((overlay (widget-get widget :field-overlay))) 1275 (let ((overlay (widget-get widget :field-overlay)))
1270 ;; Don't subtract one if local-map works at the end of the overlay. 1276 ;; Don't subtract one if local-map works at the end of the overlay.
1271 (and overlay (if widget-field-add-space 1277 (and overlay (if (or widget-field-add-space
1278 (null (widget-get widget :size)))
1272 (1- (overlay-end overlay)) 1279 (1- (overlay-end overlay))
1273 (overlay-end overlay))))) 1280 (overlay-end overlay)))))
1274 1281
1275 (defun widget-field-find (pos) 1282 (defun widget-field-find (pos)
1276 "Return the field at POS. 1283 "Return the field at POS.
1783 (defun widget-url-link-action (widget &optional event) 1790 (defun widget-url-link-action (widget &optional event)
1784 "Open the url specified by WIDGET." 1791 "Open the url specified by WIDGET."
1785 (require 'browse-url) 1792 (require 'browse-url)
1786 (funcall browse-url-browser-function (widget-value widget))) 1793 (funcall browse-url-browser-function (widget-value widget)))
1787 1794
1795 ;;; The `file-link' Widget.
1796
1797 (define-widget 'file-link 'link
1798 "A link to a file."
1799 :action 'widget-file-link-action)
1800
1801 (defun widget-file-link-action (widget &optional event)
1802 "Find the file specified by WIDGET."
1803 (find-file (widget-value widget)))
1804
1805 ;;; The `emacs-library-link' Widget.
1806
1807 (define-widget 'emacs-library-link 'link
1808 "A link to an Emacs Lisp library file."
1809 :action 'widget-emacs-library-link-action)
1810
1811 (defun widget-emacs-library-link-action (widget &optional event)
1812 "Find the Emacs Library file specified by WIDGET."
1813 (find-file (locate-library (widget-value widget))))
1814
1788 ;;; The `editable-field' Widget. 1815 ;;; The `editable-field' Widget.
1789 1816
1790 (define-widget 'editable-field 'default 1817 (define-widget 'editable-field 'default
1791 "An editable text field." 1818 "An editable text field."
1792 :convert-widget 'widget-value-convert-widget 1819 :convert-widget 'widget-value-convert-widget