Changeset View
Changeset View
Standalone View
Standalone View
src/include/ktexteditor/editor.h
Show All 35 Lines | |||||
36 | * are internal and subject to change. We mean it! | 36 | * are internal and subject to change. We mean it! | ||
37 | */ | 37 | */ | ||
38 | namespace KTextEditor | 38 | namespace KTextEditor | ||
39 | { | 39 | { | ||
40 | 40 | | |||
41 | class Application; | 41 | class Application; | ||
42 | class Command; | 42 | class Command; | ||
43 | class Document; | 43 | class Document; | ||
44 | class View; | ||||
44 | class EditorPrivate; | 45 | class EditorPrivate; | ||
45 | class ConfigPage; | 46 | class ConfigPage; | ||
46 | 47 | | |||
48 | | ||||
47 | /** | 49 | /** | ||
48 | * \brief Accessor interface for the KTextEditor framework. | 50 | * \brief Accessor interface for the KTextEditor framework. | ||
49 | * | 51 | * | ||
50 | * Topics: | 52 | * Topics: | ||
51 | * - \ref editor_intro | 53 | * - \ref editor_intro | ||
52 | * - \ref editor_config | 54 | * - \ref editor_config | ||
53 | * - \ref editor_commands | 55 | * - \ref editor_commands | ||
54 | * | 56 | * | ||
▲ Show 20 Lines • Show All 186 Lines • ▼ Show 20 Line(s) | 227 | public: | |||
241 | 243 | | |||
242 | /** | 244 | /** | ||
243 | * Get a list of available command line strings. | 245 | * Get a list of available command line strings. | ||
244 | * \return command line strings | 246 | * \return command line strings | ||
245 | * \see commands() | 247 | * \see commands() | ||
246 | */ | 248 | */ | ||
247 | virtual QStringList commandList() const = 0; | 249 | virtual QStringList commandList() const = 0; | ||
248 | 250 | | |||
251 | public: | ||||
252 | /** | ||||
253 | * Function that is called to expand a variable in @p text. | ||||
254 | */ | ||||
255 | using ExpandFunction = QString (*)(const QStringView& text, KTextEditor::View* view); | ||||
256 | | ||||
257 | /** | ||||
258 | * Registers a variable called @p name for exact matches. | ||||
259 | * For instance, a variable called "CurrentDocument:Path" could be | ||||
260 | * registered which then expands to the path the current document. | ||||
261 | * | ||||
262 | * @return true on success, false if the variable could not be registered, | ||||
263 | * e.g. because it already was registered previously. | ||||
264 | * | ||||
265 | * @since 5.57 | ||||
266 | */ | ||||
267 | bool registerVariableMatch(const QString& name, const QString& description, ExpandFunction expansionFunc); | ||||
268 | | ||||
269 | /** | ||||
270 | * Registers a variable for arbitrary text that matches the specified | ||||
271 | * prefix. For instance, a variable called "ENV:" could be registered | ||||
272 | * which then expands arbitrary environment variables, e.g. ENV:HOME | ||||
273 | * would expand to the user's home directory. | ||||
274 | * | ||||
275 | * @note A colon ':' is used as separator for the prefix and the text | ||||
276 | * after the colon that should be evaluated. | ||||
277 | * | ||||
278 | * @return true on success, false if a prefix could not be registered, | ||||
279 | * e.g. because it already was registered previously. | ||||
280 | * | ||||
281 | * @since 5.57 | ||||
282 | */ | ||||
283 | bool registerVariablePrefix(const QString& prefix, const QString& description, ExpandFunction expansionFunc); | ||||
284 | | ||||
285 | /** | ||||
286 | * Unregisters a variable that was previously registered with | ||||
287 | * registerVariableMatch(). | ||||
288 | * | ||||
289 | * @return true if the variable was successfully unregistered, and | ||||
290 | * false if the variable did not exist. | ||||
291 | * | ||||
292 | * @since 5.57 | ||||
293 | */ | ||||
294 | bool unregisterVariableMatch(const QString& variable); | ||||
295 | | ||||
296 | /** | ||||
297 | * Unregisters a prefix of variable that was previously registered with | ||||
298 | * registerVariableMatch(). | ||||
299 | * | ||||
300 | * @return true if the variable was successfully unregistered, and | ||||
301 | * false if the variable did not exist. | ||||
302 | * | ||||
303 | * @since 5.57 | ||||
304 | */ | ||||
305 | bool unregisterVariablePrefix(const QString& variable); | ||||
306 | | ||||
307 | /** | ||||
308 | * Expands a single @p variable, writing the expanded value to @p output. | ||||
309 | * | ||||
310 | * @return true on success, otherwise false. | ||||
311 | * | ||||
312 | * @since 5.57 | ||||
313 | */ | ||||
314 | bool expandVariable(const QString& variable, KTextEditor::View* view, QString& output) const; | ||||
315 | | ||||
316 | /** | ||||
317 | * Expands arbitrary @p text that may contain arbitrary many variables. | ||||
318 | * On success, the expanded text is written to @p output. | ||||
319 | * | ||||
320 | * @since 5.57 | ||||
321 | */ | ||||
322 | void expandText(const QString& text, KTextEditor::View* view, QString& output) const; | ||||
323 | | ||||
249 | private: | 324 | private: | ||
250 | /** | 325 | /** | ||
251 | * private d-pointer, pointing to the internal implementation | 326 | * private d-pointer, pointing to the internal implementation | ||
252 | */ | 327 | */ | ||
253 | EditorPrivate *const d; | 328 | EditorPrivate *const d; | ||
254 | }; | 329 | }; | ||
255 | 330 | | |||
256 | } | 331 | } | ||
257 | 332 | | |||
258 | #endif | 333 | #endif |