Nemiver  0.3
nmv-source-editor.h
Go to the documentation of this file.
1 // Author: Dodji Seketeli
2 /*
3  *This file is part of the Nemiver project
4  *
5  *Nemiver is free software; you can redistribute
6  *it and/or modify it under the terms of
7  *the GNU General Public License as published by the
8  *Free Software Foundation; either version 2,
9  *or (at your option) any later version.
10  *
11  *Nemiver is distributed in the hope that it will
12  *be useful, but WITHOUT ANY WARRANTY;
13  *without even the implied warranty of
14  *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  *See the GNU General Public License for more details.
16  *
17  *You should have received a copy of the
18  *GNU General Public License along with Nemiver;
19  *see the file COPYING.
20  *If not, write to the Free Software Foundation,
21  *Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22  *
23  *See COPYRIGHT file copyright information.
24  */
25 #ifndef __NMV_SOURCE_EDITOR_H__
26 #define __NMV_SOURCE_EDITOR_H__
27 
28 #include <list>
29 #include <functional>
30 #include <map>
31 #include <gtkmm/box.h>
32 #include <gtksourceviewmm/view.h>
34 #include "common/nmv-ustring.h"
35 #include "common/nmv-address.h"
36 #include "common/nmv-range.h"
37 #include "common/nmv-asm-instr.h"
38 #include "common/nmv-loc.h"
39 
40 using Gsv::View;
41 using Gsv::Buffer;
42 using Gtk::Box;
47 using std::list;
48 using std::map;
49 
50 NEMIVER_BEGIN_NAMESPACE (nemiver);
51 
52 extern const char* BREAKPOINT_ENABLED_CATEGORY;
53 extern const char* BREAKPOINT_DISABLED_CATEGORY;
54 extern const char* COUNTPOINT_CATEGORY;
55 extern const char* WHERE_CATEGORY;
56 
57 extern const char* WHERE_MARK;
58 
59 
60 class SourceEditor : public Box {
61  //non copyable
62  SourceEditor (const SourceEditor&);
63  SourceEditor& operator= (const SourceEditor&);
64  struct Priv;
65  SafePtr<Priv> m_priv;
66 
67  void init ();
68  SourceEditor ();
69 
70 public:
71 
72  enum BufferType {
75  BUFFER_TYPE_ASSEMBLY
76  };
77 
78 
79  explicit SourceEditor (Gtk::Window &a_parent_window,
80  const UString &a_root_dir,
81  Glib::RefPtr<Buffer> &a_buf,
82  bool a_composite = false);
83  virtual ~SourceEditor ();
84  View& source_view () const;
85  int current_line () const;
86  void current_line (int a_line);
87  int current_column () const;
88  const Loc* current_location () const;
89  void current_column (int &a_col);
90  bool move_where_marker_to_line (int a_line, bool a_do_scroll = true);
91  void unset_where_marker ();
92  bool set_visual_breakpoint_at_line (int a_line,
93  bool a_is_count_point,
94  bool a_enabled);
95  bool remove_visual_breakpoint_from_line (int a_line);
96  void clear_decorations ();
97  bool is_visual_breakpoint_set_at_line (int a_line) const;
98  bool scroll_to_line (int a_line);
99  void scroll_to_iter (Gtk::TextIter &a_iter);
100  void set_path (const UString &a_path);
101  void get_path (UString &a_path) const;
102  const UString& get_path () const;
103  void get_file_name (UString &a_file_name);
104  bool get_word_at_position (int a_x,
105  int a_y,
106  UString &a_word,
107  Gdk::Rectangle &a_start_rect,
108  Gdk::Rectangle &a_end_rect) const;
109 
110  bool do_search (const UString &a_str,
111  Gtk::TextIter &a_start,
112  Gtk::TextIter &a_end,
113  bool a_match_case=false,
114  bool a_match_entire_word=false,
115  bool a_search_backwards=false,
116  bool a_clear_selection=false);
117 
118  void setup_and_popup_menu (GdkEventButton *a_event,
119  Gtk::Widget *attach_to,
120  Gtk::Menu *custom_menu);
121 
122  static bool get_file_mime_type (const UString &a_path,
123  UString &a_mime_type);
124 
125  static bool setup_buffer_mime_and_lang (Glib::RefPtr<Buffer> &a_buf,
126  const std::string &a_mime_type =
127  "text/x-c++");
128 
129  static Glib::RefPtr<Buffer> create_source_buffer ();
130 
131  static bool load_file (Gtk::Window &a_parent,
132  const UString &a_path,
133  const std::list<std::string> &a_supported_encodings,
134  bool a_enable_syntaxt_highlight,
135  Glib::RefPtr<Buffer> &a_source_buffer);
136 
139 
151 
152  BufferType get_buffer_type () const;
153 
154  bool current_address (Address&) const;
155 
156  void register_assembly_source_buffer
157  (Glib::RefPtr<Buffer> &a_buf);
158 
159  void register_non_assembly_source_buffer
160  (Glib::RefPtr<Buffer> &a_buf);
161 
162  Glib::RefPtr<Buffer> get_assembly_source_buffer () const;
163 
164  Glib::RefPtr<Buffer> get_non_assembly_source_buffer () const;
165 
166  bool switch_to_assembly_source_buffer ();
167 
168  bool switch_to_non_assembly_source_buffer ();
169 
170  bool assembly_buf_addr_to_line (const Address&, bool, int&) const;
171  bool assembly_buf_line_to_addr (int, Address &) const;
172  bool get_assembly_address_range (common::Range &a) const;
173  bool move_where_marker_to_address (const Address &address,
174  bool do_scroll,
175  bool a_approximate);
176  bool place_cursor_at_line (size_t);
177  bool place_cursor_at_address (const Address &);
178  bool set_visual_breakpoint_at_address (const Address &a_address,
179  bool is_countpoint,
180  bool enabled);
181  bool remove_visual_breakpoint_from_address (const Address &);
182  bool scroll_to_address (const Address &a_address,
183  bool a_approximate);
184 
185  static bool add_asm (Gtk::Window &a_parent_window,
186  const common::DisassembleInfo &/*a_info*/,
187  const std::list<common::Asm> &a_asm,
188  bool a_append,
189  const list<UString> &a_src_search_dirs,
190  list<UString> &a_session_dirs,
191  std::map<UString, bool> &a_ignore_paths,
192  Glib::RefPtr<Buffer> &a_buf);
193 
194  static bool load_asm (Gtk::Window &a_parent_window,
195  const common::DisassembleInfo &/*a_info*/,
196  const std::list<common::Asm> &a_asm,
197  bool a_append,
198  const list<UString> &a_src_search_dirs,
199  list<UString> &a_session_dirs,
200  std::map<UString, bool> &a_ignore_paths,
201  Glib::RefPtr<Buffer> &a_buf);
202 
203 
205 
208  sigc::signal<void,
209  int/*line clicked*/,
210  bool/*dialog requested*/>&
211  marker_region_got_clicked_signal () const;
212  sigc::signal<void, const Gtk::TextBuffer::iterator&>&
213  insertion_changed_signal () const;
215 };//end class SourceEditor
216 
217 NEMIVER_END_NAMESPACE (nemiver)
218 
219 #endif //__NMV_DBG_SOURCE_EDITOR_H__
220 
nmv-safe-ptr-utils.h
nemiver::SourceEditor::BUFFER_TYPE_SOURCE
@ BUFFER_TYPE_SOURCE
Definition: nmv-source-editor.h:74
nemiver::common::DisassembleInfo
Definition: nmv-asm-instr.h:201
nmv-address.h
nemiver
Definition: nmv-address.h:31
nmv-asm-instr.h
nmv-ustring.h
nemiver::COUNTPOINT_CATEGORY
const char * COUNTPOINT_CATEGORY
nemiver::common::Range
This abstracts a range of integer values.
Definition: nmv-range.h:35
nemiver::common::UString
Definition: nmv-ustring.h:45
nemiver::BREAKPOINT_ENABLED_CATEGORY
const char * BREAKPOINT_ENABLED_CATEGORY
nemiver::WHERE_MARK
const char * WHERE_MARK
nemiver::SourceEditor::BufferType
BufferType
Definition: nmv-source-editor.h:72
nmv-range.h
nmv-loc.h
nemiver::common::Loc
The base type presenting a location.
Definition: nmv-loc.h:42
nemiver::common::Address
Definition: nmv-address.h:34
nemiver::WHERE_CATEGORY
const char * WHERE_CATEGORY
nemiver::BREAKPOINT_DISABLED_CATEGORY
const char * BREAKPOINT_DISABLED_CATEGORY
nemiver::common::SafePtr
Definition: nmv-safe-ptr.h:71
nemiver::SourceEditor
Definition: nmv-source-editor.h:60
nemiver::SourceEditor::BUFFER_TYPE_UNDEFINED
@ BUFFER_TYPE_UNDEFINED
Definition: nmv-source-editor.h:73