1 /* ide-buffer.h
2  *
3  * Copyright 2018-2019 Christian Hergert <chergert@redhat.com>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  *
18  * SPDX-License-Identifier: GPL-3.0-or-later
19  */
20 
21 #pragma once
22 
23 #if !defined (IDE_CODE_INSIDE) && !defined (IDE_CODE_COMPILATION)
24 # error "Only <libide-code.h> can be included directly."
25 #endif
26 
27 #include <gtksourceview/gtksource.h>
28 #include <libide-core.h>
29 
30 #include "ide-buffer-change-monitor.h"
31 #include "ide-diagnostics.h"
32 #include "ide-file-settings.h"
33 #include "ide-formatter.h"
34 #include "ide-location.h"
35 #include "ide-range.h"
36 #include "ide-rename-provider.h"
37 #include "ide-symbol.h"
38 
39 G_BEGIN_DECLS
40 
41 #define IDE_TYPE_BUFFER (ide_buffer_get_type())
42 
43 typedef enum
44 {
45   IDE_BUFFER_STATE_READY,
46   IDE_BUFFER_STATE_LOADING,
47   IDE_BUFFER_STATE_SAVING,
48   IDE_BUFFER_STATE_FAILED,
49 } IdeBufferState;
50 
51 IDE_AVAILABLE_IN_3_32
52 G_DECLARE_FINAL_TYPE (IdeBuffer, ide_buffer, IDE, BUFFER, GtkSourceBuffer)
53 
54 IDE_AVAILABLE_IN_3_32
55 GBytes                 *ide_buffer_dup_content                   (IdeBuffer               *self);
56 IDE_AVAILABLE_IN_3_32
57 gchar                  *ide_buffer_dup_title                     (IdeBuffer               *self);
58 IDE_AVAILABLE_IN_3_32
59 void                    ide_buffer_format_selection_async        (IdeBuffer               *self,
60                                                                   IdeFormatterOptions     *options,
61                                                                   GCancellable            *cancellable,
62                                                                   GAsyncReadyCallback      callback,
63                                                                   gpointer                 user_data);
64 IDE_AVAILABLE_IN_3_32
65 gboolean                ide_buffer_format_selection_finish       (IdeBuffer               *self,
66                                                                   GAsyncResult            *result,
67                                                                   GError                 **error);
68 IDE_AVAILABLE_IN_3_32
69 guint                   ide_buffer_get_change_count              (IdeBuffer               *self);
70 IDE_AVAILABLE_IN_3_32
71 IdeBufferChangeMonitor *ide_buffer_get_change_monitor            (IdeBuffer               *self);
72 IDE_AVAILABLE_IN_3_32
73 gboolean                ide_buffer_get_changed_on_volume         (IdeBuffer               *self);
74 IDE_AVAILABLE_IN_3_32
75 IdeDiagnostics         *ide_buffer_get_diagnostics               (IdeBuffer               *self);
76 IDE_AVAILABLE_IN_3_32
77 IdeLocation            *ide_buffer_get_insert_location           (IdeBuffer               *self);
78 IDE_AVAILABLE_IN_3_32
79 gboolean                ide_buffer_get_is_temporary              (IdeBuffer               *self);
80 IDE_AVAILABLE_IN_3_32
81 gboolean                ide_buffer_get_failed                    (IdeBuffer               *self);
82 IDE_AVAILABLE_IN_3_32
83 const GError           *ide_buffer_get_failure                   (IdeBuffer               *self);
84 IDE_AVAILABLE_IN_3_32
85 gchar                  *ide_buffer_dup_uri                       (IdeBuffer               *self);
86 IDE_AVAILABLE_IN_3_32
87 GFile                  *ide_buffer_get_file                      (IdeBuffer               *self);
88 IDE_AVAILABLE_IN_3_32
89 IdeFileSettings        *ide_buffer_get_file_settings             (IdeBuffer               *self);
90 IDE_AVAILABLE_IN_3_32
91 IdeFormatter           *ide_buffer_get_formatter                 (IdeBuffer               *self);
92 IDE_AVAILABLE_IN_3_32
93 gboolean                ide_buffer_get_highlight_diagnostics     (IdeBuffer               *self);
94 IDE_AVAILABLE_IN_3_32
95 void                    ide_buffer_get_iter_at_location          (IdeBuffer               *self,
96                                                                   GtkTextIter             *iter,
97                                                                   IdeLocation             *location);
98 IDE_AVAILABLE_IN_3_32
99 IdeLocation            *ide_buffer_get_iter_location             (IdeBuffer               *self,
100                                                                   const GtkTextIter       *iter);
101 IDE_AVAILABLE_IN_3_32
102 const gchar            *ide_buffer_get_language_id               (IdeBuffer               *self);
103 IDE_AVAILABLE_IN_3_32
104 void                    ide_buffer_set_language_id               (IdeBuffer               *self,
105                                                                   const gchar             *language_id);
106 IDE_AVAILABLE_IN_3_32
107 gchar                  *ide_buffer_get_line_text                 (IdeBuffer               *self,
108                                                                   guint                    line);
109 IDE_AVAILABLE_IN_3_32
110 gboolean                ide_buffer_get_loading                   (IdeBuffer               *self);
111 IDE_AVAILABLE_IN_3_32
112 gboolean                ide_buffer_get_read_only                 (IdeBuffer               *self);
113 IDE_AVAILABLE_IN_3_32
114 IdeRenameProvider      *ide_buffer_get_rename_provider           (IdeBuffer               *self);
115 IDE_AVAILABLE_IN_3_32
116 void                    ide_buffer_get_selection_bounds          (IdeBuffer               *self,
117                                                                   GtkTextIter             *insert,
118                                                                   GtkTextIter             *selection);
119 IDE_AVAILABLE_IN_3_32
120 IdeRange               *ide_buffer_get_selection_range           (IdeBuffer               *self);
121 IDE_AVAILABLE_IN_3_32
122 IdeBufferState          ide_buffer_get_state                     (IdeBuffer               *self);
123 IDE_AVAILABLE_IN_3_32
124 const gchar            *ide_buffer_get_style_scheme_name         (IdeBuffer               *self);
125 IDE_AVAILABLE_IN_3_32
126 void                    ide_buffer_get_symbol_at_location_async  (IdeBuffer               *self,
127                                                                   const GtkTextIter       *location,
128                                                                   GCancellable            *cancellable,
129                                                                   GAsyncReadyCallback      callback,
130                                                                   gpointer                 user_data);
131 IDE_AVAILABLE_IN_3_32
132 IdeSymbol              *ide_buffer_get_symbol_at_location_finish (IdeBuffer               *self,
133                                                                   GAsyncResult            *result,
134                                                                   GError                 **error);
135 IDE_AVAILABLE_IN_3_32
136 GPtrArray              *ide_buffer_get_symbol_resolvers          (IdeBuffer               *self);
137 IDE_AVAILABLE_IN_3_32
138 gchar                  *ide_buffer_get_word_at_iter              (IdeBuffer               *self,
139                                                                   const GtkTextIter       *iter);
140 IDE_AVAILABLE_IN_3_32
141 gboolean                ide_buffer_has_diagnostics               (IdeBuffer               *self);
142 IDE_AVAILABLE_IN_3_32
143 gboolean                ide_buffer_has_symbol_resolvers          (IdeBuffer               *self);
144 IDE_AVAILABLE_IN_3_32
145 IdeBuffer              *ide_buffer_hold                          (IdeBuffer               *self);
146 IDE_AVAILABLE_IN_3_32
147 IdeContext             *ide_buffer_ref_context                   (IdeBuffer               *self);
148 IDE_AVAILABLE_IN_3_32
149 void                    ide_buffer_rehighlight                   (IdeBuffer               *self);
150 IDE_AVAILABLE_IN_3_32
151 void                    ide_buffer_release                       (IdeBuffer               *self);
152 IDE_AVAILABLE_IN_3_32
153 void                    ide_buffer_save_file_async               (IdeBuffer               *self,
154                                                                   GFile                   *file,
155                                                                   GCancellable            *cancellable,
156                                                                   IdeNotification        **notif,
157                                                                   GAsyncReadyCallback      callback,
158                                                                   gpointer                 user_data);
159 IDE_AVAILABLE_IN_3_32
160 gboolean                ide_buffer_save_file_finish              (IdeBuffer               *self,
161                                                                   GAsyncResult            *result,
162                                                                   GError                 **error);
163 IDE_AVAILABLE_IN_3_32
164 void                    ide_buffer_set_change_monitor            (IdeBuffer               *self,
165                                                                   IdeBufferChangeMonitor  *change_monitor);
166 IDE_AVAILABLE_IN_3_32
167 void                    ide_buffer_set_diagnostics               (IdeBuffer               *self,
168                                                                   IdeDiagnostics          *diagnostics);
169 IDE_AVAILABLE_IN_3_32
170 void                    ide_buffer_set_highlight_diagnostics     (IdeBuffer               *self,
171                                                                   gboolean                 highlight_diagnostics);
172 IDE_AVAILABLE_IN_3_32
173 void                    ide_buffer_set_style_scheme_name         (IdeBuffer               *self,
174                                                                   const gchar             *style_scheme_name);
175 
176 G_END_DECLS
177