00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00024
00025 #ifndef INTI_GTK_SOURCE_BUFFER_H
00026 #define INTI_GTK_SOURCE_BUFFER_H
00027
00028 #ifndef INTI_GTK_TEXT_BUFFER_H
00029 #include <inti/gtk/textbuffer.h>
00030 #endif
00031
00032 #ifndef INTI_GTK_SOURCE_LANGUAGE_H
00033 #include <inti/gtk-sourceview/sourcelanguage.h>
00034 #endif
00035
00036 #ifndef INTI_GTK_SOURCE_TAG_H
00037 #include <inti/gtk-sourceview/sourcetag.h>
00038 #endif
00039
00040 #ifndef __GTK_SOURCE_BUFFER_H__
00041 #include <gtksourceview/gtksourcebuffer.h>
00042 #endif
00043
00044 namespace Inti {
00045
00046 namespace Gtk {
00047
00048 class SourceBuffer;
00049 class SourceBufferClass;
00050 class SourceLanguage;
00051 class SourceMarker;
00052
00060
00061 class SourceMarker : public TextMark
00062 {
00063 friend class G::Object;
00064
00065 SourceMarker(const SourceMarker&);
00066 SourceMarker& operator=(const SourceMarker&);
00067
00068 protected:
00071
00072 explicit SourceMarker(GtkSourceMarker *marker, bool reference = false);
00079
00081
00082 public:
00085
00086 virtual ~SourceMarker();
00088
00092
00093 GtkSourceMarker* gtk_source_marker() const { return (GtkSourceMarker*)instance; }
00095
00096 GtkSourceMarkerClass* gtk_source_marker_class() const;
00098
00099 operator GtkSourceMarker* () const;
00101
00102 bool is_gtk_source_marker() const;
00104
00105 String get_marker_type() const;
00107
00108 int get_line() const;
00110
00111 String get_name() const;
00113
00114 SourceBuffer* get_buffer() const;
00116
00117 SourceMarker* next() const;
00120
00121 SourceMarker* prev() const;
00124
00128
00129 void set_marker_type(const String& type);
00132
00134 };
00135
00146
00147 class SourceBuffer : public TextBuffer
00148 {
00149 friend class G::Object;
00150 friend class SourceBufferClass;
00151
00152 SourceBuffer(const SourceBuffer&);
00153 SourceBuffer& operator=(const SourceBuffer&);
00154
00155 protected:
00158
00159 explicit SourceBuffer(GtkSourceBuffer *buffer, bool reference = false);
00167
00171
00172 virtual void on_can_undo(bool can_undo);
00178
00179 virtual void on_can_redo(bool can_redo);
00185
00186 virtual void on_highlight_updated(TextIter& start, TextIter& end);
00193
00194 virtual void on_marker_updated(TextIter& where);
00201
00203
00204
00205 typedef G::Property<G::Unichar> EscapeCharPropertyType;
00206 typedef G::PropertyProxy<G::Object, EscapeCharPropertyType> EscapeCharPropertyProxy;
00207 static const EscapeCharPropertyType escape_char_property;
00208
00209 typedef G::Property<bool> CheckBracketsPropertyType;
00210 typedef G::PropertyProxy<G::Object, CheckBracketsPropertyType> CheckBracketsPropertyProxy;
00211 static const CheckBracketsPropertyType check_brackets_property;
00212
00213 typedef G::Property<bool> HighlightPropertyType;
00214 typedef G::PropertyProxy<G::Object, HighlightPropertyType> HighlightPropertyProxy;
00215 static const HighlightPropertyType highlight_property;
00216
00217 typedef G::Property<int> MaxUndoLevelsPropertyType;
00218 typedef G::PropertyProxy<G::Object, MaxUndoLevelsPropertyType> MaxUndoLevelsPropertyProxy;
00219 static const MaxUndoLevelsPropertyType max_undo_levels_property;
00220
00221 typedef G::Property<SourceLanguage*, G::Object*> LanguagePropertyType;
00222 typedef G::PropertyProxy<G::Object, LanguagePropertyType> LanguagePropertyProxy;
00223 static const LanguagePropertyType language_property;
00224
00225
00226
00227 typedef G::Signal1<void, bool> CanUndoSignalType;
00228 typedef G::SignalProxy<TypeInstance, CanUndoSignalType> CanUndoSignalProxy;
00229 static const CanUndoSignalType can_undo_signal;
00230
00231 typedef G::Signal1<void, bool> CanRedoSignalType;
00232 typedef G::SignalProxy<TypeInstance, CanRedoSignalType> CanRedoSignalProxy;
00233 static const CanRedoSignalType can_redo_signal;
00234
00235 typedef G::Signal2<void, GtkTextIter*, GtkTextIter*> HighlightUpdatedSignalType;
00236 typedef G::SignalProxy<TypeInstance, HighlightUpdatedSignalType> HighlightUpdatedSignalProxy;
00237 static const HighlightUpdatedSignalType highlight_updated_signal;
00238
00239 typedef G::Signal1<void, GtkTextIter*> MarkerUpdatedSignalType;
00240 typedef G::SignalProxy<TypeInstance, MarkerUpdatedSignalType> MarkerUpdatedSignalProxy;
00241 static const MarkerUpdatedSignalType marker_updated_signal;
00242
00243 public:
00246
00247 SourceBuffer(SourceTagTable *table = 0);
00250
00251 SourceBuffer(const SourceLanguage& language);
00254
00255 virtual ~SourceBuffer();
00257
00261
00262 GtkSourceBuffer* gtk_source_buffer() const { return (GtkSourceBuffer*)instance; }
00264
00265 GtkSourceBufferClass* gtk_source_buffer_class() const;
00267
00268 operator GtkSourceBuffer* () const;
00270
00271 bool is_gtk_source_buffer() const;
00273
00274 SourceTagTable* get_source_tag_table() const;
00277
00278 bool get_check_brackets() const;
00281
00282 bool get_highlight() const;
00285
00286 int get_max_undo_levels() const;
00289
00290 SourceLanguage* get_language() const;
00293
00294 G::Unichar get_escape_char() const;
00297
00298 bool can_undo() const;
00301
00302 bool can_redo() const;
00305
00306 SourceMarker* get_marker(const String& name) const;
00311
00312 std::vector<SourceMarker*> get_markers(const TextIter& start, const TextIter& end) const;
00317
00318 SourceMarker* get_first_marker() const;
00321
00322 SourceMarker* get_last_marker() const;
00325
00326 TextIter get_iter_at_marker(const SourceMarker& marker) const;
00329
00330 SourceMarker* get_next_marker(TextIter& iter) const;
00338
00339 SourceMarker* get_prev_marker(TextIter& iter) const;
00347
00351
00352 void set_check_brackets(bool check_brackets);
00360
00361 void set_bracket_match_style(const SourceTagStyle& style);
00364
00365 void set_highlight(bool highlight);
00381
00382 void set_max_undo_levels(int max_undo_levels);
00393
00394 void set_language(const SourceLanguage *language);
00401
00402 void set_escape_char(G::Unichar escape_char);
00410
00411 void undo();
00417
00418 void redo();
00421
00422 void begin_not_undoable_action();
00427
00428 void end_not_undoable_action();
00432
00433 SourceMarker* create_marker(const String& name, const String& type, const TextIter& where);
00456
00457 void move_marker(SourceMarker& marker, const TextIter& where);
00461
00462 void delete_marker(SourceMarker& marker);
00469
00473
00474 const EscapeCharPropertyProxy prop_escape_char()
00475 {
00476 return EscapeCharPropertyProxy(this, &escape_char_property);
00477 }
00479
00480 const CheckBracketsPropertyProxy prop_check_brackets()
00481 {
00482 return CheckBracketsPropertyProxy(this, &check_brackets_property);
00483 }
00485
00486 const HighlightPropertyProxy prop_highlight()
00487 {
00488 return HighlightPropertyProxy(this, &highlight_property);
00489 }
00491
00492 const MaxUndoLevelsPropertyProxy prop_max_undo_levels()
00493 {
00494 return MaxUndoLevelsPropertyProxy(this, &max_undo_levels_property);
00495 }
00497
00498 const LanguagePropertyProxy prop_language()
00499 {
00500 return LanguagePropertyProxy(this, &language_property);
00501 }
00503
00507
00508 const CanUndoSignalProxy sig_can_undo()
00509 {
00510 return CanUndoSignalProxy(this, &can_undo_signal);
00511 }
00514
00515 const CanRedoSignalProxy sig_can_redo()
00516 {
00517 return CanRedoSignalProxy(this, &can_redo_signal);
00518 }
00521
00522 const HighlightUpdatedSignalProxy sig_highlight_updated()
00523 {
00524 return HighlightUpdatedSignalProxy(this, &highlight_updated_signal);
00525 }
00528
00529 const MarkerUpdatedSignalProxy sig_marker_updated()
00530 {
00531 return MarkerUpdatedSignalProxy(this, &marker_updated_signal);
00532 }
00534
00536 };
00537
00538 }
00539
00540 }
00541
00542 #endif // INTI_GTK_SOURCE_BUFFER_H
00543