File: grt_shell_window.h

package info (click to toggle)
mysql-workbench 6.3.8%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 113,932 kB
  • ctags: 87,814
  • sloc: ansic: 955,521; cpp: 427,465; python: 59,728; yacc: 59,129; xml: 54,204; sql: 7,091; objc: 965; makefile: 638; sh: 613; java: 237; perl: 30; ruby: 6; php: 1
file content (262 lines) | stat: -rw-r--r-- 7,191 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
/* 
 * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; version 2 of the
 * License.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301  USA
 */

#ifndef __GRT_SHELL_WINDOW_H__
#define __GRT_SHELL_WINDOW_H__

#include "grt/grt_manager.h"

namespace wb {
  class WBContext;
};

#include "mforms/treenodeview.h"
#include "mforms/code_editor.h"
#include "mforms/menubar.h"
#include "mforms/splitter.h"
#include "mforms/tabview.h"
#include "mforms/panel.h"
#include "mforms/textentry.h"
#include "mforms/textbox.h"
#include "mforms/form.h"
#include "mforms/label.h"
#include "mforms/button.h"
#include "mforms/selector.h"
#include "mforms/box.h"

class GRTCodeEditor;
class PythonDebugger;

class GRTShellWindow : public mforms::Form
{
  friend class PythonDebugger;
  
public:
  GRTShellWindow(wb::WBContext* context);

  bec::GRTManager *grtm();
  
  virtual void show(bool flag=true);
  
  bool execute_script(const std::string &script, const std::string &language);
  
  GRTCodeEditor *add_editor(bool is_script, const std::string &language);
  void add_new_script();
  void open_script_file();
  
  GRTCodeEditor *show_file_at_line(const std::string &path, int line);
  
  void open_file_in_editor(const std::string &path, bool is_script);
  
  void close_editor(GRTCodeEditor *editor);
  void refresh_files();

  void set_editor_title(GRTCodeEditor *editor, const std::string &title);

  bool request_quit();
  
  bool add_output(const std::string &text);  
  void activate_output_tab();

  GRTCodeEditor* get_editor_for(const std::string& path, bool select_tab);
  GRTCodeEditor *get_active_editor();

  void on_file_save(const std::string &file);
  
  bool can_close();
protected:
  wb::WBContext* _context;
  
  mforms::MenuBar _menu;
  mforms::Box _toolbar;
  mforms::Button *_save_button;
  mforms::Button *_save_as_button;
  mforms::Button *_clear_script_output_button;
  mforms::Button *_close_script_tab_button;

  mforms::Button *_run_button;
  mforms::Button *_step_button;
  mforms::Button *_step_into_button;
  mforms::Button *_step_out_button;
  mforms::Button *_continue_button;
  mforms::Button *_stop_button;
  mforms::Button *_pause_button;
  
  mforms::Button *_show_find_button;

  mforms::Box _content;
  mforms::Box _padding_box;
  mforms::Splitter _hsplitter;
#ifdef _WIN32
  mforms::Panel _side_header_panel;
#endif
  mforms::TabView _side_tab;
  mforms::TabView _main_tab;
  
  mforms::Button _file_add;
  mforms::Button _file_delete;
  mforms::TreeNodeView* _files_tree;
  mforms::ContextMenu _files_menu;

  mforms::Box _global_box1;
  mforms::Box _global_box2;
  mforms::Splitter _global_splitter;
  mforms::Selector _global_combo;
  mforms::TreeNodeView _global_tree;
  mforms::TextEntry _global_entry;
  mforms::TreeNodeView _global_list;
  mforms::ContextMenu _global_menu;
  bec::ValueInspectorBE *_inspector;

  mforms::Box _classes_box;
  mforms::Splitter _classes_splitter;
  mforms::Selector _classes_sorting;
  mforms::TreeNodeView _classes_tree;
  mforms::TextBox _classes_text;

  mforms::Splitter _modules_splitter;
  mforms::TreeNodeView _modules_tree;
  mforms::TextBox _modules_text;
  
  mforms::Splitter _notifs_splitter;
  mforms::TreeNodeView _notifs_tree;
  mforms::TextBox _notifs_text;
  
  mforms::Splitter _right_splitter;
  
  mforms::Box _shell_box;
  mforms::TextBox _shell_text;
  mforms::Box _shell_hbox;
  mforms::Label _shell_prompt;
  mforms::TextEntry _shell_entry;
  
  mforms::TabView _lower_tab;
#ifdef _WIN32
  mforms::Panel _lower_header_panel;
#endif
  mforms::TextBox _output_text;
  int _lower_tab_height;
  
  mforms::Splitter _snippet_splitter;
  mforms::TreeNodeView* _snippet_list;
  mforms::Button* _snippet_delete_button;
  mforms::Button* _snippet_copy_button;
  mforms::CodeEditor _snippet_text;

  mforms::ContextMenu _snippet_menu;
  int _global_snippet_count;
  std::string _comment_prefix;
  std::string _script_extension;

  PythonDebugger *_debugger;  

  std::vector<GRTCodeEditor*> _editors;
  
  void refresh_all();
  void side_tab_changed();

  void set_splitter_positions();

  bool capture_output(const grt::Message &msg, void *sender, bool send_to_output);
  
  void shell_action(mforms::TextEntryAction action);

  void handle_prompt(const std::string &text);
  void handle_output(const std::string &text);
  void handle_error(const std::string &text, const std::string &detail);
  
  void handle_global_menu(const std::string &action);
  
  void global_selected();
  void class_selected();
  void module_selected();
  void notif_selected();
  
  void delete_selected_file();

  void file_list_activated(mforms::TreeNodeRef node, int column);
  void add_files_from_dir(mforms::TreeNodeRef parent, const std::string &dir, bool is_script);
  
  void load_snippets_from(const std::string &path);
  void save_snippets();
  void refresh_snippets();
  void add_snippet();
  void del_snippet();
  void copy_snippet();
  void run_snippet();
  void scriptize_snippet();
  void snippet_selected();
  void snippet_changed(int line, int linesAdded);
  
  void snippet_menu_activate(const std::string &action);
  void file_menu_activate(const std::string &action);

  void shell_closed();

  void load_state();
  void save_state();

  void on_tab_changed();
  bool on_tab_closing(int index);

  virtual mforms::MenuBar *get_menubar() { return &_menu; }
private:
  void cut();
  void copy();
  void paste();
  void select_all();
  
  mforms::Button *add_tool_button(const std::string &image,
                       const boost::function<void ()> &action,
                       const std::string &tooltip,
                       bool left=true);
  void add_tool_separator();

  void execute_file();
  void save_file(bool save_as);
  void close_tab();
  void show_find_panel();

  void refresh_modules_tree();
  std::string get_module_node_description(const mforms::TreeNodeRef &node);
  
  void refresh_classes_tree();
  void refresh_classes_tree_by_name();
  void refresh_classes_tree_by_hierarchy();
  void refresh_classes_tree_by_package();
  std::string get_class_node_description(const mforms::TreeNodeRef &node);

  void globals_expand_toggle(const mforms::TreeNodeRef &node, bool expanded);
  std::string get_global_path_at_node(const mforms::TreeNodeRef &node);
  grt::ValueRef get_global_at_node(const mforms::TreeNodeRef &node);
  void refresh_globals_tree();
  
  void refresh_global_list();
  
  void refresh_notifs_list();
private:
  void debug_step();
  void debug_step_into();
  void debug_step_out();
  void debug_continue();
  void debug_stop();
  void debug_pause();
};

#endif