Mercurial > emacs
annotate lisp/eshell/em-prompt.el @ 109581:06384b3caebf
Add ability to put Gtk+ tool bar on the left/right/bottom or top. Default top.
* lisp/menu-bar.el (menu-bar-showhide-tool-bar-menu-customize-enable-left)
(menu-bar-showhide-tool-bar-menu-customize-disable)
(menu-bar-showhide-tool-bar-menu-customize-enable-right)
(menu-bar-showhide-tool-bar-menu-customize-enable-top)
(menu-bar-showhide-tool-bar-menu-customize-enable-bottom): New functions
(menu-bar-showhide-tool-bar-menu): If tool bar is moveable,
make a menu for Options => toolbar that can move it.
* src/frame.c (Qtool_bar_position): New variable.
(make_frame): Set tool_bar_position to Qtop.
(frame_parms): Add tool-bar-position.
(x_report_frame_params): Store tool_bar_position.
(x_set_fringe_width): Reset wm size hint after fringe changes.
* src/frame.h (struct frame): Add tool_bar_position.
(Qbottom): Declare.
* src/gtkutil.c (FRAME_TOTAL_PIXEL_WIDTH): New macro.
(xg_frame_set_char_size): Add FRAME_TOOLBAR_WIDTH to pixelwidth.
(xg_height_or_width_changed): Use FRAME_TOTAL_PIXEL_WIDTH.
(xg_create_frame_widgets): Create a hobox for placing widgets
vertically. Use gtk_box_pack_start.
(xg_height_or_width_changed): Renamed from xg_height_changed.
(x_wm_set_size_hint): Add FRAME_TOOLBAR_WIDTH to base_width.
(xg_update_frame_menubar, free_frame_menubar): Change to
xg_height_or_width_changed.
(xg_tool_bar_detach_callback): Update left/right/top/bottom tool bar
size correctly. Remove hardcoded 4, instead use handlebox size -
toolbar size.
(xg_tool_bar_attach_callback): Update left/right/top/bottom tool bar
size correctly. Use handlebox size + toolbar size as additional
size.
(xg_pack_tool_bar): POS is a new parameter.
Set orientation of tool bar based on pos.
Only make handlebox_widget if NULL.
Check if tool bar goes to vbox or hbox depending on pos.
(xg_update_tool_bar_sizes): New function.
(update_frame_tool_bar): Remove old_req, new_req. Do not get tool bar
height, call xg_update_tool_bar_sizes instead.
(free_frame_tool_bar): Remove from hbox or vbox depending on
toolbar_in_hbox, Set all FRAME_TOOLBAR_*_(WIDTH|HEIGHT) to zero.
(xg_change_toolbar_position): New function.
* src/gtkutil.h (xg_change_toolbar_position): Declare.
* src/window.c (calc_absolute_offset): Check for FRAME_TOOLBAR_TOP_HEIGHT
and FRAME_TOOLBAR_LEFT_WIDTH.
* src/xfns.c (x_set_tool_bar_position): New function.
(xic_set_statusarea): Use FRAME_TOOLBAR_TOP_HEIGHT.
(x_frame_parm_handlers): Add x_set_tool_bar_position.
(syms_of_xfns): if USE_GTK, provide move-toolbar.
* src/xterm.c (x_set_window_size_1): Add FRAME_TOOLBAR_WIDTH to pixelwidth.
* src/xterm.h (struct x_output): Add toolbar_top_height,
toolbar_bottom_height, toolbar_left_width, toolbar_right_width. Remove
toolbar_height.
if USE_GTK: Add hbox_widget and toolbar_in_hbox.
(FRAME_TOOLBAR_TOP_HEIGHT, FRAME_TOOLBAR_BOTTOM_HEIGHT)
(FRAME_TOOLBAR_LEFT_WIDTH, FRAME_TOOLBAR_RIGHT_WIDTH): New macros.
(FRAME_TOOLBAR_HEIGHT): Is now TOP_HEIGHT + BOTTOM_HEIGHT.
author | Jan D. <jan.h.d@swipnet.se> |
---|---|
date | Thu, 29 Jul 2010 18:49:59 +0200 |
parents | 1d1d5d9bd884 |
children | f57f72bb4757 376148b31b5e |
rev | line source |
---|---|
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
32526
diff
changeset
|
1 ;;; em-prompt.el --- command prompts |
29876 | 2 |
95152
ad5d26b1d5d1
Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents:
94661
diff
changeset
|
3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, |
106815 | 4 ;; 2008, 2009, 2010 Free Software Foundation, Inc. |
29876 | 5 |
32526 | 6 ;; Author: John Wiegley <johnw@gnu.org> |
7 | |
29876 | 8 ;; This file is part of GNU Emacs. |
9 | |
94661
b5b0801a7637
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
10 ;; GNU Emacs is free software: you can redistribute it and/or modify |
29876 | 11 ;; it under the terms of the GNU General Public License as published by |
94661
b5b0801a7637
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
12 ;; the Free Software Foundation, either version 3 of the License, or |
b5b0801a7637
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; (at your option) any later version. |
29876 | 14 |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
94661
b5b0801a7637
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
29876 | 22 |
87071
a6d0cce41261
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
23 ;;; Commentary: |
29876 | 24 |
87071
a6d0cce41261
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
25 ;; Most of the prompt navigation commands of `comint-mode' are |
a6d0cce41261
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
26 ;; supported, such as C-c C-n, C-c C-p, etc. |
a6d0cce41261
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
27 |
a6d0cce41261
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
28 ;;; Code: |
a6d0cce41261
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
29 |
a6d0cce41261
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
30 (eval-when-compile (require 'eshell)) |
29876 | 31 |
95152
ad5d26b1d5d1
Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents:
94661
diff
changeset
|
32 ;;;###autoload |
ad5d26b1d5d1
Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents:
94661
diff
changeset
|
33 (eshell-defgroup eshell-prompt nil |
29876 | 34 "This module provides command prompts, and navigation between them, |
35 as is common with most shells." | |
36 :tag "Command prompts" | |
37 :group 'eshell-module) | |
38 | |
39 ;;; User Variables: | |
40 | |
41 (defcustom eshell-prompt-load-hook '(eshell-prompt-initialize) | |
42 "*A list of functions to call when loading `eshell-prompt'." | |
43 :type 'hook | |
44 :group 'eshell-prompt) | |
45 | |
46 (defcustom eshell-prompt-function | |
47 (function | |
48 (lambda () | |
106298
3a4157b5e536
* eshell/em-prompt.el (eshell-prompt-function): Abbreviate pwd, since
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104783
diff
changeset
|
49 (concat (abbreviate-file-name (eshell/pwd)) |
29876 | 50 (if (= (user-uid) 0) " # " " $ ")))) |
106298
3a4157b5e536
* eshell/em-prompt.el (eshell-prompt-function): Abbreviate pwd, since
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104783
diff
changeset
|
51 "A function that returns the Eshell prompt string. |
29876 | 52 Make sure to update `eshell-prompt-regexp' so that it will match your |
53 prompt." | |
54 :type 'function | |
55 :group 'eshell-prompt) | |
56 | |
57 (defcustom eshell-prompt-regexp "^[^#$\n]* [#$] " | |
58 "*A regexp which fully matches your eshell prompt. | |
59 This setting is important, since it affects how eshell will interpret | |
60 the lines that are passed to it. | |
61 If this variable is changed, all Eshell buffers must be exited and | |
62 re-entered for it to take effect." | |
63 :type 'regexp | |
64 :group 'eshell-prompt) | |
65 | |
66 (defcustom eshell-highlight-prompt t | |
67 "*If non-nil, Eshell should highlight the prompt." | |
68 :type 'boolean | |
69 :group 'eshell-prompt) | |
70 | |
63533
b7ea6515f1ba
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-431
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
71 (defface eshell-prompt |
29876 | 72 '((((class color) (background light)) (:foreground "Red" :bold t)) |
73 (((class color) (background dark)) (:foreground "Pink" :bold t)) | |
74 (t (:bold t))) | |
75 "*The face used to highlight prompt strings. | |
76 For highlighting other kinds of strings -- similar to shell mode's | |
77 behavior -- simply use an output filer which changes text properties." | |
78 :group 'eshell-prompt) | |
104783
ddf360111014
Mark face aliases with "-face" suffix as obsolete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
79 (define-obsolete-face-alias 'eshell-prompt-face 'eshell-prompt "22.1") |
29876 | 80 |
81 (defcustom eshell-before-prompt-hook nil | |
82 "*A list of functions to call before outputting the prompt." | |
83 :type 'hook | |
84 :options '(eshell-begin-on-new-line) | |
85 :group 'eshell-prompt) | |
86 | |
87 (defcustom eshell-after-prompt-hook nil | |
88 "*A list of functions to call after outputting the prompt. | |
89 Note that if `eshell-scroll-show-maximum-output' is non-nil, then | |
90 setting `eshell-show-maximum-output' here won't do much. It depends | |
91 on whether the user wants the resizing to happen while output is | |
92 arriving, or after." | |
93 :type 'hook | |
94 :options '(eshell-show-maximum-output) | |
95 :group 'eshell-prompt) | |
96 | |
97 ;;; Functions: | |
98 | |
99 (defun eshell-prompt-initialize () | |
100 "Initialize the prompting code." | |
101 (unless eshell-non-interactive-p | |
102 (add-hook 'eshell-post-command-hook 'eshell-emit-prompt nil t) | |
103 | |
104 (make-local-variable 'eshell-prompt-regexp) | |
105 (if eshell-prompt-regexp | |
106 (set (make-local-variable 'paragraph-start) eshell-prompt-regexp)) | |
107 | |
108 (set (make-local-variable 'eshell-skip-prompt-function) | |
109 'eshell-skip-prompt) | |
110 | |
111 (define-key eshell-command-map [(control ?n)] 'eshell-next-prompt) | |
112 (define-key eshell-command-map [(control ?p)] 'eshell-previous-prompt))) | |
113 | |
114 (defun eshell-emit-prompt () | |
115 "Emit a prompt if eshell is being used interactively." | |
116 (run-hooks 'eshell-before-prompt-hook) | |
117 (if (not eshell-prompt-function) | |
118 (set-marker eshell-last-output-end (point)) | |
119 (let ((prompt (funcall eshell-prompt-function))) | |
120 (and eshell-highlight-prompt | |
121 (add-text-properties 0 (length prompt) | |
122 '(read-only t | |
63533
b7ea6515f1ba
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-431
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
123 face eshell-prompt |
29876 | 124 rear-nonsticky (face read-only)) |
125 prompt)) | |
126 (eshell-interactive-print prompt))) | |
127 (run-hooks 'eshell-after-prompt-hook)) | |
128 | |
129 (defun eshell-backward-matching-input (regexp arg) | |
130 "Search backward through buffer for match for REGEXP. | |
131 Matches are searched for on lines that match `eshell-prompt-regexp'. | |
132 With prefix argument N, search for Nth previous match. | |
133 If N is negative, find the next or Nth next match." | |
134 (interactive (eshell-regexp-arg "Backward input matching (regexp): ")) | |
135 (let* ((re (concat eshell-prompt-regexp ".*" regexp)) | |
136 (pos (save-excursion (end-of-line (if (> arg 0) 0 1)) | |
137 (if (re-search-backward re nil t arg) | |
138 (point))))) | |
139 (if (null pos) | |
140 (progn (message "Not found") | |
141 (ding)) | |
142 (goto-char pos) | |
143 (eshell-bol)))) | |
144 | |
145 (defun eshell-forward-matching-input (regexp arg) | |
146 "Search forward through buffer for match for REGEXP. | |
147 Matches are searched for on lines that match `eshell-prompt-regexp'. | |
148 With prefix argument N, search for Nth following match. | |
149 If N is negative, find the previous or Nth previous match." | |
150 (interactive (eshell-regexp-arg "Forward input matching (regexp): ")) | |
151 (eshell-backward-matching-input regexp (- arg))) | |
152 | |
153 (defun eshell-next-prompt (n) | |
154 "Move to end of Nth next prompt in the buffer. | |
155 See `eshell-prompt-regexp'." | |
156 (interactive "p") | |
157 (forward-paragraph n) | |
158 (eshell-skip-prompt)) | |
159 | |
160 (defun eshell-previous-prompt (n) | |
161 "Move to end of Nth previous prompt in the buffer. | |
162 See `eshell-prompt-regexp'." | |
163 (interactive "p") | |
164 (eshell-next-prompt (- (1+ n)))) | |
165 | |
166 (defun eshell-skip-prompt () | |
167 "Skip past the text matching regexp `eshell-prompt-regexp'. | |
168 If this takes us past the end of the current line, don't skip at all." | |
169 (let ((eol (line-end-position))) | |
170 (if (and (looking-at eshell-prompt-regexp) | |
171 (<= (match-end 0) eol)) | |
172 (goto-char (match-end 0))))) | |
173 | |
87071
a6d0cce41261
Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents:
78220
diff
changeset
|
174 (provide 'em-prompt) |
29876 | 175 |
95152
ad5d26b1d5d1
Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents:
94661
diff
changeset
|
176 ;; Local Variables: |
ad5d26b1d5d1
Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents:
94661
diff
changeset
|
177 ;; generated-autoload-file: "esh-groups.el" |
ad5d26b1d5d1
Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents:
94661
diff
changeset
|
178 ;; End: |
ad5d26b1d5d1
Use eshell-defgroup rather than defgroup.
Glenn Morris <rgm@gnu.org>
parents:
94661
diff
changeset
|
179 |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
180 ;; arch-tag: 01c1574b-ce70-4e89-bc38-e6619f61e208 |
29876 | 181 ;;; em-prompt.el ends here |