/[eiffelstudio]/branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/commands/eb_open_shell_cmd.e
ViewVC logotype

Contents of /branches/Eiffel_57_docking/Src/Eiffel/interface/new_graphical/commands/eb_open_shell_cmd.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 62171 - (show annotations)
Tue Aug 1 01:27:17 2006 UTC (13 years, 4 months ago) by larryl
File size: 8016 byte(s)
First commit docking tabbed Eiffel Studio.
1 indexing
2 description : "Command to open a shell with an editor."
3 legal: "See notice at end of class."
4 status: "See notice at end of class."
5 date : "$Date$"
6 revision : "$Revision$"
7
8 class
9 EB_OPEN_SHELL_COMMAND
10
11 inherit
12 EB_DEVELOPMENT_WINDOW_COMMAND
13 redefine
14 initialize
15 end
16
17 EB_TOOLBARABLE_AND_MENUABLE_COMMAND
18 redefine
19 new_toolbar_item,
20 new_sd_toolbar_item,
21 tooltext
22 end
23
24 SHARED_EIFFEL_PROJECT
25
26 SYSTEM_CONSTANTS
27
28 EB_SHARED_PREFERENCES
29 export
30 {NONE} all
31 end
32
33 EB_CONSTANTS
34
35 EXECUTION_ENVIRONMENT
36
37 create
38 make
39
40 feature {NONE} -- Initialization
41
42 initialize is
43 -- Enable `Current'.
44 do
45 is_sensitive := True
46 end
47
48 feature -- Basic operations
49
50 new_toolbar_item (display_text: BOOLEAN): EB_COMMAND_TOOL_BAR_BUTTON is
51 -- Create a new toolbar button for this command.
52 do
53 Result := Precursor (display_text)
54 Result.drop_actions.extend (agent drop (?))
55 Result.drop_actions.set_veto_pebble_function (agent is_droppable)
56 end
57
58 new_sd_toolbar_item (display_text: BOOLEAN): EB_SD_COMMAND_TOOL_BAR_BUTTON is
59 -- Create a new toolbar button for this command.
60 do
61 Result := Precursor (display_text)
62 Result.drop_actions.extend (agent drop (?))
63 Result.drop_actions.set_veto_pebble_function (agent is_droppable)
64 end
65
66 feature {NONE} -- Update
67
68 drop (s: STONE) is
69 local
70 cs: CLASSI_STONE
71 fs: FEATURE_STONE
72 cl_syntax_s: CL_SYNTAX_STONE
73 do
74 fs ?= s
75 if fs /= Void then
76 process_feature (fs)
77 else
78 cl_syntax_s ?= s
79 if cl_syntax_s /= Void then
80 process_class_syntax (cl_syntax_s)
81 else
82 cs ?= s
83 if cs /= Void then
84 process_class (cs)
85 end
86 end
87 end
88 end
89
90 feature {NONE} -- Implementation
91
92 process_feature (fs: FEATURE_STONE) is
93 -- Process feature stone.
94 require
95 fs_not_void: fs /= Void
96 local
97 req: COMMAND_EXECUTOR
98 cmd_string: STRING
99 do
100 -- feature text area
101 cmd_string := command_shell_name
102 if not cmd_string.is_empty then
103 replace_target (cmd_string, fs.file_name)
104 cmd_string.replace_substring_all ("$line", fs.line_number.out)
105 create req
106 req.execute (cmd_string)
107 end
108 end
109
110 process_class (cs: CLASSI_STONE) is
111 -- Process class stone.
112 require
113 cs_not_void: cs /= Void
114 local
115 req: COMMAND_EXECUTOR
116 cmd_string: STRING
117 conv_f: FEATURE_STONE
118 do
119 conv_f ?= cs
120 if conv_f = Void then
121 cmd_string := command_shell_name
122 if not cmd_string.is_empty then
123 replace_target(cmd_string, cs.file_name)
124 cmd_string.replace_substring_all ("$line", "1")
125 create req
126 req.execute (cmd_string)
127 end
128 end
129 end
130
131 process_class_syntax (syn: CL_SYNTAX_STONE) is
132 -- Process class syntax stone.
133 require
134 syn_not_void: syn /= Void
135 local
136 req: COMMAND_EXECUTOR
137 cmd_string: STRING
138 do
139 cmd_string := command_shell_name
140 if not cmd_string.is_empty then
141 replace_target(cmd_string, syn.file_name)
142 cmd_string.replace_substring_all ("$line", syn.syntax_message.line.out)
143 create req
144 req.execute (cmd_string)
145 end
146 end
147
148 replace_target (cmd: STRING; fn:STRING) is
149 -- Find out if `fn' is a relativ path or not and if it is
150 -- one, complete it to make it absolute, so that the shell
151 -- editor will be able to load the file
152 require
153 cmd_not_void: cmd /= Void
154 local
155 target_string: STRING
156 do
157 if fn = Void then
158 target_string := ""
159 else
160 target_string := fn.twin
161 target_string.prepend_character ('%"')
162 target_string.append_character ('%"')
163 end
164 cmd.replace_substring_all ("$target", target_string)
165 end
166
167 execute is
168 -- Redefine
169 local
170 req: COMMAND_EXECUTOR
171 cmd_string: STRING
172 line_nb, first_line, cursor_line: INTEGER
173
174 development_window: EB_DEVELOPMENT_WINDOW
175 editor: EB_SMART_EDITOR
176 empty: BOOLEAN
177 do
178 development_window := target
179 editor := development_window.editors_manager.current_editor
180 if editor /= Void then
181 empty := editor.is_empty
182
183 cmd_string := command_shell_name
184 if not empty then
185 -- We ensure that we target the editor line to the cursor position, however if the cursor
186 -- is not visible we take the `first_line_displayed'.
187 cursor_line := editor.cursor_y_position
188 first_line := editor.first_line_displayed
189 if first_line > cursor_line then
190 line_nb := first_line
191 elseif
192 first_line < cursor_line and
193 cursor_line < first_line + editor.number_of_lines_displayed
194 then
195 line_nb := cursor_line
196 else
197 line_nb := first_line
198 end
199 end
200 if not cmd_string.is_empty then
201 replace_target (cmd_string, window_file_name)
202 if not empty then
203 cmd_string.replace_substring_all ("$line", line_nb.out)
204 else
205 cmd_string.replace_substring_all ("$line", once "")
206 end
207 create req
208 req.execute (cmd_string)
209 end
210 end
211 end
212
213 window_file_name: STRING is
214 -- Provides the filename of the current edited element, if possible.
215 local
216 fs: FILED_STONE
217 do
218 fs ?= target.stone
219 if fs /= Void then
220 Result := fs.file_name
221 end
222 end
223
224 feature {NONE} -- Implementation properties
225
226 command_shell_name: STRING is
227 -- Name of the command to execute in the shell dialog.
228 do
229 Result := preferences.misc_data.external_editor_command.twin
230 end
231
232 menu_name: STRING is
233 -- Name as it appears in the menu (with & symbol).
234 do
235 Result := Interface_names.m_external_editor
236 end
237
238 pixmap: EV_PIXMAP is
239 -- Pixmaps representing the command.
240 do
241 Result := pixmaps.icon_pixmaps.command_send_to_external_editor_icon
242 end
243
244 pixel_buffer: EV_PIXEL_BUFFER is
245 -- Pixel buffer representing the command.
246 do
247 Result := pixmaps.icon_pixmaps.command_send_to_external_editor_icon_buffer
248 end
249
250 tooltip: STRING is
251 -- Tooltip for the toolbar button.
252 do
253 Result := Interface_names.e_shell
254 end
255
256 tooltext: STRING is
257 -- Textp for the toolbar button.
258 do
259 Result := Interface_names.b_shell
260 end
261
262 description: STRING is
263 -- Description for this command.
264 do
265 Result := Interface_names.e_shell
266 end
267
268 name: STRING is "Open_shell"
269 -- Name of the command. Used to store the command in the
270 -- preferences.
271
272 is_droppable (st: ANY): BOOLEAN is
273 -- Can `st' be dropped?
274 local
275 conv_st: STONE
276 l_ex: CLASSI_STONE
277 l_ex_c: CLASSC_STONE
278 do
279 conv_st ?= st
280 Result := conv_st /= Void and then conv_st.is_storable
281 if Result then
282 -- If it is an external class, then we cannot drop.
283 l_ex ?= st
284 if l_ex /= Void then
285 Result := not l_ex.class_i.is_external_class
286 else
287 l_ex_c ?= st
288 if l_ex_c /= Void then
289 Result := not l_ex_c.e_class.is_true_external
290 end
291 end
292 end
293 end
294
295 indexing
296 copyright: "Copyright (c) 1984-2006, Eiffel Software"
297 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
298 licensing_options: "http://www.eiffel.com/licensing"
299 copying: "[
300 This file is part of Eiffel Software's Eiffel Development Environment.
301
302 Eiffel Software's Eiffel Development Environment is free
303 software; you can redistribute it and/or modify it under
304 the terms of the GNU General Public License as published
305 by the Free Software Foundation, version 2 of the License
306 (available at the URL listed under "license" above).
307
308 Eiffel Software's Eiffel Development Environment is
309 distributed in the hope that it will be useful, but
310 WITHOUT ANY WARRANTY; without even the implied warranty
311 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
312 See the GNU General Public License for more details.
313
314 You should have received a copy of the GNU General Public
315 License along with Eiffel Software's Eiffel Development
316 Environment; if not, write to the Free Software Foundation,
317 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
318 ]"
319 source: "[
320 Eiffel Software
321 356 Storke Road, Goleta, CA 93117 USA
322 Telephone 805-685-1006, Fax 805-685-6869
323 Website http://www.eiffel.com
324 Customer support http://support.eiffel.com
325 ]"
326
327 end -- class EB_OPEN_SHELL_CMD

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23