4 ;; SUMMARY: Select language and invoke OO-Browser.
5 ;; USAGE: GNU Emacs Lisp Library
6 ;; KEYWORDS: oop, tools
11 ;; ORIG-DATE: 5-Sep-92 at 23:31:03
12 ;; LAST-MOD: 3-Aug-99 at 22:41:31 by Bob Weiner
14 ;; Copyright (C) 1992, 1993, 1994, 1997, 1998 BeOpen.com
15 ;; See the file BR-COPY for license information.
17 ;; This file is part of the OO-Browser.
22 ;;; ************************************************************************
23 ;;; OO-Browser directory setting
24 ;;; ************************************************************************
26 ;; Try to add hyperbole/ or OO-Browser-specific part, hypb/, to the load-path.
27 (if (eq t (catch 'found
29 (function (lambda (path)
30 (if (string-match "\\(/hyperbole\\|/hypb\\)/?\\'" path)
34 (cond ((file-readable-p "hypb/")
35 (setq load-path (cons (expand-file-name "hypb/") load-path)))
36 ((file-readable-p "../hyperbole/")
37 (setq load-path (cons (expand-file-name "../hyperbole/") load-path)))))
39 ;; May define `locate-file' which is used below.
40 ;; A Hyperbole directory, such as oo-browser/hypb, must either already be in
41 ;; load-path or an explicit load of "hversion" must have been
42 ;; done already or else the following line will fail to load hversion.
43 ;; This is all documented in the OO-Browser installation instructions.
46 ;; Reinitialize br-directory on reload if initialization failed for any reason.
47 (and (boundp 'br-directory) (null br-directory) (makunbound 'br-directory))
49 (defvar br-directory (or (locate-file "br-help-ms" load-path)
50 (and (file-readable-p "br-help-ms")
51 (expand-file-name "./")))
52 "Directory where the OO-Browser executable code and help files are kept.
53 It must end with a directory separator character.")
54 (if (stringp br-directory)
55 (setq br-directory (file-name-directory br-directory))
57 "(br-start.el): OO-Browser failed to set br-directory. Try setting it manually."))
59 ;; Add OO-Browser Info directory to Info-directory-list after the Info
60 ;; manual reader package is loaded.
62 (let ((info-dir (expand-file-name "man/" br-directory)))
63 (if (file-exists-p info-dir)
64 (add-hook 'Info-directory-list info-dir t)))
65 (add-hook 'Info-mode-hook
68 (if (boundp 'br-directory)
69 (let ((info-dir (expand-file-name "man/" br-directory)))
70 (if (file-exists-p info-dir)
71 (add-hook 'Info-directory-list info-dir t))))))))
73 (if (not (fboundp 'defalias)) (fset 'defalias 'fset))
76 (defalias 'br-member 'member)
77 (defun br-member (elt list)
78 "Return non-nil if ELT is an element of LIST. Comparison done with `equal'.
79 The value is actually the tail of LIST whose car is ELT."
80 (while (and list (not (equal (car list) elt)))
81 (setq list (cdr list)))
84 ;;; ************************************************************************
85 ;;; Hyperbole subset directory setting (for mouse handling)
86 ;;; ************************************************************************
88 ;; Reinitialize hyperb:dir on reload if initialization failed for any reason.
89 (and (boundp 'hyperb:dir) (null hyperb:dir) (makunbound 'hyperb:dir))
91 (defvar hyperb:dir (or (locate-file "hmouse-tag.elc" load-path)
92 (and (file-readable-p "../hyperbole/")
93 (expand-file-name "../hyperbole/"))
94 (and (file-readable-p "hypb/")
95 (expand-file-name "hypb/")))
96 "Directory where the Hyperbole executable code is kept.
97 It must end with a directory separator character.")
98 (if (stringp hyperb:dir)
99 (setq hyperb:dir (file-name-directory hyperb:dir))
101 "(br-start.el): Failed to set hyperb:dir. Try setting it manually."))
103 ;;; ************************************************************************
104 ;;; Other public variables
105 ;;; ************************************************************************
107 (defconst br-ootags-executable
108 (or (locate-file "ootags" (list br-directory exec-directory)
110 (locate-file "ootags" exec-path ":.exe"))
111 "Full pathname to `ootags' executable or nil if not found.")
113 (defconst br-shell-executable
114 (or (locate-file "bash" exec-path ":.exe")
115 (locate-file "sh" exec-path ":.exe")
116 (locate-file "csh" exec-path ":.exe"))
117 "Full pathname to command shell executable or nil if not found.")
119 (defvar br-c-tags-flag
120 (if hyperb:microcruft-os-p
122 ;; !! Temporarily disable c-tags building under microcruft systems
123 ;; !! since is not working properly (it can hang the build).
125 ;; Set to t on MS OSs only if a valid shell and ootags.exe is found. This
126 ;; is required by the "br-c-ft.el" code.
127 ;; (and br-ootags-executable br-shell-executable t)
129 "*Non-nil means add C constructs when building C-based language Environments.")
131 ;; -f treats upper and lower case the same in sorting, also makes `a' sort
132 ;; list before `[a]', so default classes appear at the end of the list,
134 ;; -u leaves only unique elements in the sorted list
135 (defvar br-sort-options (if hyperb:microcruft-os-p nil "-fu")
136 "*String of options to send to the operating system `sort' command.
137 Use nil for none. The default sort command under MS OSes does not
138 support the options needed, so this must be set to nil in such cases.")
140 (defvar br-env-default-file "OOBR"
141 "*Standard file name for OO-Browser Environment storage.")
143 (defvar br-env-file nil
144 "Default file into which to save a class Environment.
145 Value is language-specific.")
147 ;;; ************************************************************************
148 ;;; Other required Elisp libraries
149 ;;; ************************************************************************
151 ;; Add br-directory and hyperb:dir to load-path so other OO-Browser libraries
153 (or (br-member br-directory load-path)
154 (setq load-path (cons br-directory load-path)))
155 (or (br-member hyperb:dir load-path)
156 (setq load-path (cons hyperb:dir load-path)))
159 (mapcar 'require '(br-init br-site))
161 ;;; ************************************************************************
163 ;;; ************************************************************************
166 (defun oo-browser (&optional same-env-flag)
167 "Prompt for an Environment over which to run the OO-Browser.
168 Optional prefix argument SAME-ENV-FLAG means browse the current Environment,
169 if any, without prompting. Otherwise, if called interactively, give the user
170 a choice whether to re-browse the last Environment or to browse a new one."
173 (if (and (not current-prefix-arg) br-env-file br-lang-prefix)
174 (y-or-n-p (format "(OO-Browser): Browse `%s' again? "
175 (or (and (not (eq br-env-name t)) br-env-name)
176 (br-env-substitute-home br-env-file))))
179 (if (and same-env-flag br-env-file br-lang-prefix)
180 (funcall (intern-soft (concat br-lang-prefix "browse")))
181 (call-interactively 'br-env-browse)))
184 (defun br-two-button-mouse ()
185 "Sets up the Action Key within OO-Browser listing buffers for a two button mouse.
186 The Action Key is placed on the left mouse button."
188 (setq hyperb:mouse-buttons 2)
189 (br-setup-mouse-keys)
191 "2-Button Mouse: Display OO-Browser listing items with the left mouse button."))
194 (defun br-three-button-mouse ()
195 "Sets up the Action Key within OO-Browser listing buffers for a three button mouse.
196 The Action Key is placed on the middle mouse button."
198 (setq hyperb:mouse-buttons 3)
199 (br-setup-mouse-keys)
201 "3-Button Mouse: Display OO-Browser listing items with the middle mouse button."))