alternative to assert
[gtkD.git] / gtkD / srcsv / gsv / SourceView.d
blob2cd54576bc6fb1230025cfc0345abe4f3c960be1
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GtkSourceView.html
26 * outPack = gsv
27 * outFile = SourceView
28 * strct = GtkSourceView
29 * realStrct=
30 * ctorStrct=
31 * clss = SourceView
32 * interf =
33 * class Code: Yes
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gtk_source_view_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - gsv.SourceBuffer
45 * - gtkc.gtk
46 * - glib.Str
47 * structWrap:
48 * - GtkSourceBuffer* -> SourceBuffer
49 * module aliases:
50 * local aliases:
53 module gsv.SourceView;
55 version(noAssert)
57 version(Tango)
59 import tango.io.Stdout; // use the tango loging?
63 private import gsvc.gsvtypes;
65 private import gsvc.gsv;
68 private import gsv.SourceBuffer;
69 private import gtkc.gtk;
70 private import glib.Str;
75 /**
76 * Description
78 private import gtk.TextView;
79 public class SourceView : TextView
82 /** the main Gtk struct */
83 protected GtkSourceView* gtkSourceView;
86 public GtkSourceView* getSourceViewStruct()
88 return gtkSourceView;
92 /** the main Gtk struct as a void* */
93 protected void* getStruct()
95 return cast(void*)gtkSourceView;
98 /**
99 * Sets our main struct and passes it to the parent class
101 public this (GtkSourceView* gtkSourceView)
103 version(noAssert)
105 if ( gtkSourceView is null )
107 int zero = 0;
108 version(Tango)
110 Stdout("struct gtkSourceView is null on constructor").newline;
112 else
114 printf("struct gtkSourceView is null on constructor");
116 zero = zero / zero;
119 else
121 assert(gtkSourceView !is null, "struct gtkSourceView is null on constructor");
123 super(cast(GtkTextView*)gtkSourceView);
124 this.gtkSourceView = gtkSourceView;
128 * Returns the GtkSourceBuffer being displayed by this source view.
129 * The reference count on the buffer is not incremented; the caller
130 * of this function won't own a new reference.
131 * text_view:
132 * a GtkSourceView
133 * Returns:
134 * a GtkSourceBuffer
136 public SourceBuffer getBuffer()
138 // GtkSourceBuffer* gtk_text_view_get_buffer (GtkTextView *text_view);
139 return new SourceBuffer( cast(GtkSourceBuffer*)gtk_text_view_get_buffer(cast(GtkTextView*)gtkSourceView) );
147 // imports for the signal processing
148 private import gobject.Signals;
149 private import gtkc.gdktypes;
150 int[char[]] connectedSignals;
152 void delegate(SourceView)[] onRedoListeners;
153 void addOnRedo(void delegate(SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
155 if ( !("redo" in connectedSignals) )
157 Signals.connectData(
158 getStruct(),
159 "redo",
160 cast(GCallback)&callBackRedo,
161 cast(void*)this,
162 null,
163 connectFlags);
164 connectedSignals["redo"] = 1;
166 onRedoListeners ~= dlg;
168 extern(C) static void callBackRedo(GtkSourceView* sourceviewStruct, SourceView sourceView)
170 bool consumed = false;
172 foreach ( void delegate(SourceView) dlg ; sourceView.onRedoListeners )
174 dlg(sourceView);
177 return consumed;
180 void delegate(SourceView)[] onUndoListeners;
181 void addOnUndo(void delegate(SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
183 if ( !("undo" in connectedSignals) )
185 Signals.connectData(
186 getStruct(),
187 "undo",
188 cast(GCallback)&callBackUndo,
189 cast(void*)this,
190 null,
191 connectFlags);
192 connectedSignals["undo"] = 1;
194 onUndoListeners ~= dlg;
196 extern(C) static void callBackUndo(GtkSourceView* sourceviewStruct, SourceView sourceView)
198 bool consumed = false;
200 foreach ( void delegate(SourceView) dlg ; sourceView.onUndoListeners )
202 dlg(sourceView);
205 return consumed;
211 * Creates a new GtkSourceView. An empty default buffer will be
212 * created for you. If you want to specify your own buffer, consider
213 * gtk_source_view_new_with_buffer().
214 * Returns:
215 * a new GtkSourceView
217 public this ()
219 // GtkWidget* gtk_source_view_new (void);
220 this(cast(GtkSourceView*)gtk_source_view_new() );
224 * Creates a new GtkSourceView widget displaying the buffer
225 * buffer. One buffer can be shared among many widgets.
226 * buffer:
227 * a GtkSourceBuffer.
228 * Returns:
229 * a new GtkTextView.
231 public this (SourceBuffer buffer)
233 // GtkWidget* gtk_source_view_new_with_buffer (GtkSourceBuffer *buffer);
234 this(cast(GtkSourceView*)gtk_source_view_new_with_buffer((buffer is null) ? null : buffer.getSourceBufferStruct()) );
238 * If TRUE line numbers will be displayed beside the text.
239 * view:
240 * a GtkSourceView.
241 * show:
242 * whether line numbers should be displayed.
244 public void setShowLineNumbers(int show)
246 // void gtk_source_view_set_show_line_numbers (GtkSourceView *view, gboolean show);
247 gtk_source_view_set_show_line_numbers(gtkSourceView, show);
251 * Returns whether line numbers are displayed beside the text.
252 * view:
253 * a GtkSourceView.
254 * Returns:
255 * TRUE if the line numbers are displayed.
257 public int getShowLineNumbers()
259 // gboolean gtk_source_view_get_show_line_numbers (GtkSourceView *view);
260 return gtk_source_view_get_show_line_numbers(gtkSourceView);
264 * If TRUE line markers will be displayed beside the text.
265 * view:
266 * a GtkSourceView.
267 * show:
268 * whether line markers should be displayed.
270 public void setShowLineMarkers(int show)
272 // void gtk_source_view_set_show_line_markers (GtkSourceView *view, gboolean show);
273 gtk_source_view_set_show_line_markers(gtkSourceView, show);
277 * Returns whether line markers are displayed beside the text.
278 * view:
279 * a GtkSourceView.
280 * Returns:
281 * TRUE if the line markers are displayed.
283 public int getShowLineMarkers()
285 // gboolean gtk_source_view_get_show_line_markers (GtkSourceView *view);
286 return gtk_source_view_get_show_line_markers(gtkSourceView);
290 * Sets the width of tabulation in characters.
291 * view:
292 * a GtkSourceView.
293 * width:
294 * width of tab in characters.
296 public void setTabsWidth(uint width)
298 // void gtk_source_view_set_tabs_width (GtkSourceView *view, guint width);
299 gtk_source_view_set_tabs_width(gtkSourceView, width);
303 * Returns the width of tabulation in characters.
304 * view:
305 * a GtkSourceView.
306 * Returns:
307 * width of tab.
309 public uint getTabsWidth()
311 // guint gtk_source_view_get_tabs_width (GtkSourceView *view);
312 return gtk_source_view_get_tabs_width(gtkSourceView);
316 * If TRUE auto indentation of text is enabled.
317 * view:
318 * a GtkSourceView.
319 * enable:
320 * whether to enable auto indentation.
322 public void setAutoIndent(int enable)
324 // void gtk_source_view_set_auto_indent (GtkSourceView *view, gboolean enable);
325 gtk_source_view_set_auto_indent(gtkSourceView, enable);
329 * Returns whether auto indentation of text is enabled.
330 * view:
331 * a GtkSourceView.
332 * Returns:
333 * TRUE if auto indentation is enabled.
335 public int getAutoIndent()
337 // gboolean gtk_source_view_get_auto_indent (GtkSourceView *view);
338 return gtk_source_view_get_auto_indent(gtkSourceView);
342 * If TRUE any tabulator character inserted is replaced by a group
343 * of space characters.
344 * view:
345 * a GtkSourceView.
346 * enable:
347 * whether to insert spaces instead of tabs.
349 public void setInsertSpacesInsteadOfTabs(int enable)
351 // void gtk_source_view_set_insert_spaces_instead_of_tabs (GtkSourceView *view, gboolean enable);
352 gtk_source_view_set_insert_spaces_instead_of_tabs(gtkSourceView, enable);
356 * Returns whether when inserting a tabulator character it should
357 * be replaced by a group of space characters.
358 * view:
359 * a GtkSourceView.
360 * Returns:
361 * TRUE if spaces are inserted instead of tabs.
363 public int getInsertSpacesInsteadOfTabs()
365 // gboolean gtk_source_view_get_insert_spaces_instead_of_tabs (GtkSourceView *view);
366 return gtk_source_view_get_insert_spaces_instead_of_tabs(gtkSourceView);
370 * If TRUE a margin is displayed
371 * view:
372 * a GtkSourceView.
373 * show:
374 * whether to show a margin.
376 public void setShowMargin(int show)
378 // void gtk_source_view_set_show_margin (GtkSourceView *view, gboolean show);
379 gtk_source_view_set_show_margin(gtkSourceView, show);
383 * Returns whether a margin is displayed.
384 * view:
385 * a GtkSourceView.
386 * Returns:
387 * TRUE if the margin is showed.
389 public int getShowMargin()
391 // gboolean gtk_source_view_get_show_margin (GtkSourceView *view);
392 return gtk_source_view_get_show_margin(gtkSourceView);
396 * Sets the position of the right margin in the given view.
397 * view:
398 * a GtkSourceView.
399 * margin:
400 * the position of the margin to set.
402 public void setMargin(uint margin)
404 // void gtk_source_view_set_margin (GtkSourceView *view, guint margin);
405 gtk_source_view_set_margin(gtkSourceView, margin);
409 * Gets the position of the right margin in the given view.
410 * view:
411 * a GtkSourceView.
412 * Returns:
413 * the position of the right margin.
415 public uint getMargin()
417 // guint gtk_source_view_get_margin (GtkSourceView *view);
418 return gtk_source_view_get_margin(gtkSourceView);
422 * If TRUE the current line is highlighted
423 * view:
424 * a GtkSourceView
425 * show:
426 * whether to highlight the current line
428 public void setHighlightCurrentLine(int show)
430 // void gtk_source_view_set_highlight_current_line (GtkSourceView *view, gboolean show);
431 gtk_source_view_set_highlight_current_line(gtkSourceView, show);
435 * Returns whether the current line is highlighted
436 * view:
437 * a GtkSourceView
438 * Returns:
439 * TRUE if the current line is highlighted
441 public int getHighlightCurrentLine()
443 // gboolean gtk_source_view_get_highlight_current_line (GtkSourceView *view);
444 return gtk_source_view_get_highlight_current_line(gtkSourceView);
448 * Associates a given pixbuf with a given marker_type.
449 * view:
450 * a GtkSourceView.
451 * marker_type:
452 * a marker type.
453 * pixbuf:
454 * a GdkPixbuf.
456 public void setMarkerPixbuf(char[] markerType, GdkPixbuf* pixbuf)
458 // void gtk_source_view_set_marker_pixbuf (GtkSourceView *view, const gchar *marker_type, GdkPixbuf *pixbuf);
459 gtk_source_view_set_marker_pixbuf(gtkSourceView, Str.toStringz(markerType), pixbuf);
463 * Gets the pixbuf which is associated with the given marker_type.
464 * view:
465 * a GtkSourceView.
466 * marker_type:
467 * a marker type.
468 * Returns:
469 * a GdkPixbuf if found, or NULL if not found.
471 public GdkPixbuf* getMarkerPixbuf(char[] markerType)
473 // GdkPixbuf* gtk_source_view_get_marker_pixbuf (GtkSourceView *view, const gchar *marker_type);
474 return gtk_source_view_get_marker_pixbuf(gtkSourceView, Str.toStringz(markerType));
478 * If TRUE HOME and END keys will move to the first/last non-space
479 * character of the line before moving to the start/end.
480 * view:
481 * a GtkSourceView.
482 * enable:
483 * whether to enable smart behavior for HOME and END keys.
485 public void setSmartHomeEnd(int enable)
487 // void gtk_source_view_set_smart_home_end (GtkSourceView *view, gboolean enable);
488 gtk_source_view_set_smart_home_end(gtkSourceView, enable);
492 * Returns whether HOME and END keys will move to the first/last non-space
493 * character of the line before moving to the start/end.
494 * view:
495 * a GtkSourceView.
496 * Returns:
497 * TRUE if smart behavior for HOME and END keys is enabled.
498 * Property Details
499 * The "auto-indent" property
500 * "auto-indent" gboolean : Read / Write
501 * Whether to enable auto indentation.
502 * Default value: FALSE
504 public int getSmartHomeEnd()
506 // gboolean gtk_source_view_get_smart_home_end (GtkSourceView *view);
507 return gtk_source_view_get_smart_home_end(gtkSourceView);