File: qgscodeeditor.sip.in

package info (click to toggle)
qgis 3.40.10%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,183,672 kB
  • sloc: cpp: 1,595,771; python: 372,544; xml: 23,474; sh: 3,761; perl: 3,664; ansic: 2,257; sql: 2,137; yacc: 1,068; lex: 577; javascript: 540; lisp: 411; makefile: 161
file content (645 lines) | stat: -rw-r--r-- 15,300 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
/************************************************************************
 * This file has been generated automatically from                      *
 *                                                                      *
 * src/gui/codeeditors/qgscodeeditor.h                                  *
 *                                                                      *
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 ************************************************************************/







class QgsCodeInterpreter
{
%Docstring(signature="appended")
An interface for code interpreters.

.. versionadded:: 3.30
%End

%TypeHeaderCode
#include "qgscodeeditor.h"
%End
  public:
    virtual ~QgsCodeInterpreter();

    int exec( const QString &command );
%Docstring
Executes a ``command`` in the interpreter.

Returns an interpreter specific state value.
%End

    virtual int currentState() const;
%Docstring
Returns the current interpreter state.

The actual interpretation of the returned values depend on the
interpreter subclass.
%End

    virtual QString promptForState( int state ) const = 0;
%Docstring
Returns the interactive prompt string to use for the interpreter, given
a ``state``.
%End

  protected:
    virtual int execCommandImpl( const QString &command ) = 0;
%Docstring
Pure virtual method for executing commands in the interpreter.

Subclasses must implement this method. It will be called internally
whenever the public :py:func:`~QgsCodeInterpreter.exec` method is
called.
%End

};



class QgsCodeEditor : QsciScintilla
{
%Docstring(signature="appended")
A text editor based on QScintilla2.

.. note::

   may not be available in Python bindings, depending on platform support
%End

%TypeHeaderCode
#include "qgscodeeditor.h"
%End
  public:

    enum class Mode
    {
      ScriptEditor,
      OutputDisplay,
      CommandInput,
    };

    enum class MarginRole /BaseType=IntEnum/
    {
      LineNumbers,
      ErrorIndicators,
      FoldingControls,
    };

    enum class Flag /BaseType=IntFlag/
    {
      CodeFolding,
      ImmediatelyUpdateHistory,
    };

    typedef QFlags<QgsCodeEditor::Flag> Flags;


    static const int SEARCH_RESULT_INDICATOR;

    QgsCodeEditor( QWidget *parent /TransferThis/ = 0, const QString &title = QString(), bool folding = false, bool margin = false, QgsCodeEditor::Flags flags = QgsCodeEditor::Flags(), QgsCodeEditor::Mode mode = QgsCodeEditor::Mode::ScriptEditor );
%Docstring
Construct a new code editor.

:param parent: The parent QWidget
:param title: The title to show in the code editor dialog
:param folding: ``False``: Enable folding for code editor (deprecated,
                use ``flags`` instead)
:param margin: ``False``: Enable margin for code editor (deprecated)
:param flags: flags controlling behavior of code editor (since QGIS
              3.28)
:param mode: code editor mode (since QGIS 3.30)
%End

    void setTitle( const QString &title );
%Docstring
Set the widget title

:param title: widget title
%End

    virtual Qgis::ScriptLanguage language() const;
%Docstring
Returns the associated scripting language.

.. versionadded:: 3.30
%End

    virtual Qgis::ScriptLanguageCapabilities languageCapabilities() const;
%Docstring
Returns the associated scripting language capabilities.

.. versionadded:: 3.32
%End

    static QString languageToString( Qgis::ScriptLanguage language );
%Docstring
Returns a user-friendly, translated name of the specified script
``language``.

.. versionadded:: 3.30
%End

 void setMarginVisible( bool margin ) /Deprecated/;
%Docstring
Set margin visible state

:param margin: Set margin in the editor

.. deprecated:: 3.40

   Use base class methods for individual margins instead, or :py:func:`~QgsCodeEditor.setLineNumbersVisible`.
%End

 bool marginVisible() /Deprecated/;
%Docstring
Returns whether margins are in a visible state

.. deprecated:: 3.40

   Use base class methods for individual margins instead, or :py:func:`~QgsCodeEditor.lineNumbersVisible`.
%End

    void setLineNumbersVisible( bool visible );
%Docstring
Sets whether line numbers should be visible in the editor.

Defaults to ``False``.

.. seealso:: :py:func:`lineNumbersVisible`

.. versionadded:: 3.16
%End

    bool lineNumbersVisible() const;
%Docstring
Returns whether line numbers are visible in the editor.

.. seealso:: :py:func:`setLineNumbersVisible`

.. versionadded:: 3.16
%End

    void setFoldingVisible( bool folding );
%Docstring
Set whether the folding controls are visible in the editor.

.. seealso:: :py:func:`foldingVisible`
%End

    bool foldingVisible();
%Docstring
Returns ``True`` if the folding controls are visible in the editor.

.. seealso:: :py:func:`setFoldingVisible`
%End

    void insertText( const QString &text );
%Docstring
Insert text at cursor position, or replace any selected text if user has
made a selection.

:param text: The text to be inserted
%End

    static QColor defaultColor( QgsCodeEditorColorScheme::ColorRole role, const QString &theme = QString() );
%Docstring
Returns the default color for the specified ``role``.

The optional ``theme`` argument can be used to specify a color
``theme``. A blank ``theme`` indicates the default color scheme.

Available themes are stored in
:py:class:`QgsCodeEditorColorSchemeRegistry`, and can be retrieved via
:py:func:`QgsGui.codeEditorColorSchemeRegistry()`.

.. versionadded:: 3.16
%End

    static QColor color( QgsCodeEditorColorScheme::ColorRole role );
%Docstring
Returns the color to use in the editor for the specified ``role``.

This color will be the default theme color for the role, unless the user
has manually selected a custom color scheme for the editor.

.. seealso:: :py:func:`setColor`

.. versionadded:: 3.16
%End

    static void setColor( QgsCodeEditorColorScheme::ColorRole role, const QColor &color );
%Docstring
Sets the ``color`` to use in the editor for the specified ``role``.

This color will be stored as the new default color for the role, to be
used for all code editors.

Set ``color`` to an invalid QColor in order to clear the stored color
value and reset it to the default color.

.. seealso:: :py:func:`color`

.. versionadded:: 3.16
%End

    static QFont getMonospaceFont();
%Docstring
Returns the monospaced font to use for code editors.

.. versionadded:: 3.16
%End


    void addWarning( int lineNumber, const QString &warning );
%Docstring
Adds a ``warning`` message and indicator to the specified a
``lineNumber``.

.. seealso:: :py:func:`clearWarnings`

.. versionadded:: 3.16
%End

    void clearWarnings();
%Docstring
Clears all warning messages from the editor.

.. seealso:: :py:func:`addWarning`

.. versionadded:: 3.16
%End

    QgsCodeEditor::Mode mode() const;
%Docstring
Returns the code editor mode.

.. versionadded:: 3.30
%End

    bool isCursorOnLastLine() const;
%Docstring
Returns ``True`` if the cursor is on the last line of the document.

.. versionadded:: 3.28
%End

    void setHistoryFilePath( const QString &path );
%Docstring
Sets the file path to use for recording and retrieving previously
executed commands.

.. note::

   Applies to code editors in the QgsCodeEditor.Mode.CommandInput mode only.

.. versionadded:: 3.30
%End

    QStringList history() const;
%Docstring
Returns the list of commands previously executed in the editor.

.. note::

   Applies to code editors in the QgsCodeEditor.Mode.CommandInput mode only.

.. versionadded:: 3.30
%End

    QgsCodeInterpreter *interpreter() const;
%Docstring
Returns the attached code interpreter, or ``None`` if not set.

.. seealso:: :py:func:`setInterpreter`

.. versionadded:: 3.30
%End

    void setInterpreter( QgsCodeInterpreter *newInterpreter );
%Docstring
Sets an attached code interpreter for executing commands when the editor
is in the QgsCodeEditor.Mode.CommandInput mode.

.. seealso:: :py:func:`interpreter`

.. versionadded:: 3.30
%End

    int linearPosition() const;
%Docstring
Convenience function to return the cursor position as a linear index

.. versionadded:: 3.36
%End

    void setLinearPosition( int position );
%Docstring
Convenience function to set the cursor position as a linear index

.. versionadded:: 3.36
%End

    int selectionStart() const;
%Docstring
Convenience function to return the start of the selection as a linear
index Contrary to the getSelection method, this method returns the
cursor position if no selection is made.

.. versionadded:: 3.36
%End

    int selectionEnd() const;
%Docstring
Convenience function to return the end of the selection as a linear
index Contrary to the getSelection method, this method returns the
cursor position if no selection is made.

.. versionadded:: 3.36
%End

    void setLinearSelection( int start, int end );
%Docstring
Convenience function to set the selection using linear indexes

.. versionadded:: 3.36
%End

    virtual void callTip();

    int wrapPosition( int line = -1 );
%Docstring
Returns the linear position of the start of the last wrapped part for
the specified line, or for the current line if line = -1 If wrapping is
disabled, returns -1 instead

.. versionadded:: 3.40
%End

  public slots:

    void runCommand( const QString &command, bool skipHistory = false );
%Docstring
Runs a command in the editor.

An :py:func:`~QgsCodeEditor.interpreter` must be set.

Since QGIS 3.32, if ``skipHistory`` is ``True`` then the command will
not be automatically added to the widget's history.

.. versionadded:: 3.30
%End

    virtual void moveCursorToStart();
%Docstring
Moves the cursor to the start of the document and scrolls to ensure it
is visible.

.. versionadded:: 3.28
%End

    virtual void moveCursorToEnd();
%Docstring
Moves the cursor to the end of the document and scrolls to ensure it is
visible.

.. versionadded:: 3.28
%End

    void showPreviousCommand();
%Docstring
Shows the previous command from the session in the editor.

.. note::

   Applies to code editors in the QgsCodeEditor.Mode.CommandInput mode only.

.. versionadded:: 3.30
%End

    void showNextCommand();
%Docstring
Shows the next command from the session in the editor.

.. note::

   Applies to code editors in the QgsCodeEditor.Mode.CommandInput mode only.

.. versionadded:: 3.30
%End

    void showHistory();
%Docstring
Shows the command history dialog.

.. note::

   Applies to code editors in the QgsCodeEditor.Mode.CommandInput mode only.

.. versionadded:: 3.30
%End

    void removeHistoryCommand( int index );
%Docstring
Removes the command at the specified ``index`` from the history of the
code editor.

.. versionadded:: 3.30
%End

    void clearSessionHistory();
%Docstring
Clears the history of commands run in the current session.

.. note::

   Applies to code editors in the QgsCodeEditor.Mode.CommandInput mode only.

.. versionadded:: 3.30
%End

    void clearPersistentHistory();
%Docstring
Clears the entire persistent history of commands run in the editor.

.. note::

   Applies to code editors in the QgsCodeEditor.Mode.CommandInput mode only.

.. versionadded:: 3.30
%End

    bool writeHistoryFile();
%Docstring
Stores the commands executed in the editor to the persistent history
file.

.. versionadded:: 3.30
%End

    void reformatCode();
%Docstring
Applies code reformatting to the editor.

This is only supported for editors which return the
:py:class:`Qgis`.ScriptLanguageCapability.Reformat capability from
:py:func:`~QgsCodeEditor.languageCapabilities`.

.. versionadded:: 3.32
%End

    virtual bool checkSyntax();
%Docstring
Applies syntax checking to the editor.

This is only supported for editors which return the
:py:class:`Qgis`.ScriptLanguageCapability.CheckSyntax capability from
:py:func:`~QgsCodeEditor.languageCapabilities`.

.. versionadded:: 3.32
%End

    virtual void toggleComment();
%Docstring
Toggle comment for the selected text.

This is only supported for editors which return the
:py:class:`Qgis`.ScriptLanguageCapability.ToggleComment capability from
:py:func:`~QgsCodeEditor.languageCapabilities`.

.. versionadded:: 3.32
%End

  signals:

    void sessionHistoryCleared();
%Docstring
Emitted when the history of commands run in the current session is
cleared.

.. versionadded:: 3.30
%End

    void persistentHistoryCleared();
%Docstring
Emitted when the persistent history of commands run in the editor is
cleared.

.. versionadded:: 3.30
%End

  protected:
    static bool isFixedPitch( const QFont &font );
%Docstring
Returns ``True`` if a ``font`` is a fixed pitch font.
%End

    virtual void focusOutEvent( QFocusEvent *event );

    virtual void keyPressEvent( QKeyEvent *event );

    virtual void contextMenuEvent( QContextMenuEvent *event );

    virtual bool eventFilter( QObject *watched, QEvent *event );


    virtual void initializeLexer();
%Docstring
Called when the dialect specific code lexer needs to be initialized (or
reinitialized).

The default implementation does nothing.

.. versionadded:: 3.16
%End

    QColor lexerColor( QgsCodeEditorColorScheme::ColorRole role ) const;
%Docstring
Returns the color to use in the lexer for the specified ``role``.

.. versionadded:: 3.16
%End

    QFont lexerFont() const;
%Docstring
Returns the font to use in the lexer.

.. versionadded:: 3.16
%End

    void runPostLexerConfigurationTasks();
%Docstring
Performs tasks which must be run after a lexer has been set for the
widget.

.. versionadded:: 3.16
%End

    void updateSoftHistory();
%Docstring
Updates the soft history by storing the current editor text in the
history.

.. versionadded:: 3.30
%End

    void updatePrompt();
%Docstring
Triggers an update of the interactive prompt part of the editor.

.. note::

   Applies to code editors in the QgsCodeEditor.Mode.CommandInput mode only.

.. versionadded:: 3.30
%End

    virtual void populateContextMenu( QMenu *menu );
%Docstring
Called when the context ``menu`` for the widget is about to be shown,
after it has been fully populated with the standard actions created by
the base class.

This method provides an opportunity for subclasses to add additional
non-standard actions to the context menu.

.. versionadded:: 3.30
%End

    virtual QString reformatCodeString( const QString &string );
%Docstring
Applies code reformatting to a ``string`` and returns the result.

This is only supported for editors which return the
:py:class:`Qgis`.ScriptLanguageCapability.Reformat capability from
:py:func:`~QgsCodeEditor.languageCapabilities`.

.. versionadded:: 3.32
%End

    virtual void showMessage( const QString &title, const QString &message, Qgis::MessageLevel level );
%Docstring
Shows a user facing message (eg a warning message).

The default implementation uses QMessageBox.

.. versionadded:: 3.32
%End

};

QFlags<QgsCodeEditor::Flag> operator|(QgsCodeEditor::Flag f1, QFlags<QgsCodeEditor::Flag> f2);



/************************************************************************
 * This file has been generated automatically from                      *
 *                                                                      *
 * src/gui/codeeditors/qgscodeeditor.h                                  *
 *                                                                      *
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 ************************************************************************/