PCEF 0.1.1 documentation

Panels

«  Modes   ::   Contents   ::   Styling  »

Panels

This page contains documentation about the available pcef panels.

Folding Panel

Contains the generic panels (used by the generic code editor widget)

class pcef.panels.folding.FoldIndicator(start, end)[source]

A fold marker is used by the FoldPanel to display code folding indicators.

A fold marker is defined by two line number (start and end) and a boolean property that tells whether the code block is folded or not.

end = None

End line

folded = None

Is folded ?

hover = None

Is hover ?

start = None

Start line

class pcef.panels.folding.FoldPanel(parent=None)[source]

This Panel display folding indicators and manage folding/unfolding a text

The panel also handles line added/removed and update the indicators position automatically.

Note

It does not parse the code to put fold indicators, this is the task of a code folder mode. Instead it provides an easy way for other modes to put fold indicators on the left margin.

IDENTIFIER = 'Folding'

Panel identifier

addIndicator(start, end)[source]

Adds a fold indicator :param start: Start line (1 based) :param end: End line

clearIndicators()[source]

Remove all indicators

getIndicatorForLine(line)[source]

Returns the fold indicator whose start position equals the line :param line: Line nbr of the start position of the indicator to get. :return: FoldIndicator or None

install(editor)[source]

Install the Panel on the editor

leaveEvent(event)[source]

Clears indicator hover states and repaint

mouseMoveEvent(event)[source]

Detects indicator hover states

mouseReleaseEvent(event)[source]

Folds/Unfolds code blocks

paintEvent(event)[source]

Paints the widget

removeIndicator(indicator)[source]

Remove a fold indicator :param indicator: Indicator to remove

sizeHint()[source]

Returns a fixed size hint (16x16)

Line numbers Panel

Contains the generic panels (used by the generic code editor widget)

class pcef.panels.line_numbers.LineNumberPanel(parent=None)[source]

This Panel show the line numbers

IDENTIFIER = 'Line numbers'

Panel identifier

paintEvent(event)[source]

Paints the widgets: - paints the background - paint each visible blocks that intersects the widget bbox.

sizeHint()[source]

Return the size hint of the widget (depends on the editor font)

Markers Panel

Contains the generic panels (used by the generic code editor widget)

class pcef.panels.marker.Marker(position, icon, tooltip='')[source]

A marker is a rect drawn on a MarkersPanel at a specific block position.

Fields:
  • position: block count
  • icon: QIcon to draw
  • tooltip: text shown when mouse is over the marker
class pcef.panels.marker.MarkersPanel(name, markersReadOnly=False, parent=None)[source]

Panel used to draw a collection of marker. A marker is 16x16 icon placed at a specific line number.

A marker is added/removed when the user click on the the widget or manually (using addMarker).

Actually if there is no marker where the user clicked, the markerAddRequested signal is emitted as we don’t known what kind of marker we must add.

When a marker is removed by the user, the markerRemoved signal is emitted.

Note

The markers position is updated whenever a line is added/removed.

Note

The markers list is cleared when a new text is set on the text edit (see QCodeEdit.newTextSet signal)

Note

If a marker goes out of documents (line number <= 0) the markerOutOfDoc is emitted.

QSS = 'QToolTip {\n background-color: %(back)s;\n color: %(color)s;\n border: 1px solid %(color)s;\n padding: 2px;\n opacity: 220;\n }\n '

Stylesheet

addMarker(marker)[source]

Adds a marker to be displayed

addMarkerRequested = <PySide.QtCore.Signal object at 0xab9efe0>

Signal emitted with the line number where the marker must be added

clearMarkers()[source]

Clears the markers list

clearingMarkers = <PySide.QtCore.Signal object at 0xaba6080>

Signal emitted before clearing the markers when a new text is set to give

displayTooltip()[source]

Display the tooltip

leaveEvent(event)[source]

Resets prev line to -1 when we leave otherwise the tooltip won’t be shown next time we hover the marker

markerOutOfDoc = <PySide.QtCore.Signal object at 0xaba6040>

Signal emitted when a marker is out of the document. This usually

markerRemoved = <PySide.QtCore.Signal object at 0xaba6020>

Signal emitted when a marker is removed by the user.

markersReadOnly = None

prevent user from adding/removing markers with mouse click

mouseMoveEvent(event)[source]

Shows a tooltip

mouseReleaseEvent(event)[source]

Adds/Remove markers on click

onLinesAdded(nbLines, tcPos, tcPosInBlock)[source]

Offsets markers positions with the number of line added

onLinesRemoved(nbLines, tcPos, tcPosInBlock)[source]

Offsets markers positions with the number of line removed

paintEvent(event)[source]

Paints the widget

removeMarker(marker)[source]

Removes a marker

sizeHint()[source]

Returns the widget size hint (based on the editor font size)

Search and replace Panel

Contains the search and replace Panel

class pcef.panels.search_and_replace.QSearchPanel(parent=None)[source]

Search (& replace) Panel. Allow the user to search for content in the editor

All occurrences are highlighted using text decorations.

The occurrence under the cursor is selected using the find method of the plain text edit. User can go backward and forward.

The Panel add a few actions to the editor menu(search, replace, next, previous, replace, replace all)

The Panel is shown with ctrl-f for a search, ctrl-r for a search and replace.

The Panel is hidden with ESC or by using the close button (white cross).

Note

The widget use a custom ui designed in Qt Designer

QSS = 'QWidget\n {\n background-color: %(bck)s;\n color: %(color)s;\n }\n\n QLineEdit\n {\n background-color: %(txt_bck)s;\n border: 1px solid %(highlight)s;\n border-radius: 3px;\n }\n\n QLineEdit:hover, QLineEdit:focus\n {\n border: 1px solid %(color)s;\n border-radius: 3px;\n }\n\n QPushButton\n {\n background-color: transparent;\n }\n\n QPushButton:hover\n {\n background-color: %(highlight)s;\n border: none;\n border-radius: 5px;\n color: %(color)s;\n }\n\n QPushButton:pressed\n {\n background-color: %(highlight)s;\n border: 2px black;\n border-radius: 5px;\n color: %(color)s;\n }\n\n QPushButton:disabled\n {\n color: %(highlight)s;\n }\n\n QCheckBox:hover\n {\n background-color: %(highlight)s;\n color: %(color)s;\n border-radius: 5px;\n }\n '

Stylesheet

clearDecorations()[source]

Remove all decorations

findNext()[source]

Finds the next occurrence

findPrevious()[source]

Finds the previous occurrence

getUserSearchFlag()[source]

Returns the user search flag

highlightAllOccurrences(txt)[source]

Highlight all occurrences

highlightOccurrences(txt, selectFirst=False)[source]

Highlights occurrences

Parameters:
  • txt – Text to highlight
  • selectFirst – True to select the first occurrence
install(editor)[source]

Install the Panel on the editor

keyPressEvent(event)[source]

Handles key pressed: Return = next occurence, Esc = close Panel

numOccurrences

Nb occurrences detected

numOccurrencesChanged = <PySide.QtCore.Signal object at 0xab9e6c0>

Emitted when the nbr of occurences has changed

on_checkBoxCase_stateChanged(state)[source]

Re-highlight occurences

on_checkBoxWholeWords_stateChanged(state)[source]

Re-highlight occurences

on_lineEditReplace_textChanged(text)[source]

Updates user interface

on_lineEditSearch_textChanged(text)[source]

Re-highlight occurences

on_pushButtonClose_clicked()[source]

Hides the Panel

on_pushButtonDown_clicked()[source]

Finds the next occurrence

on_pushButtonReplaceAll_clicked()[source]

Replace all occurences

on_pushButtonReplace_clicked()[source]

Replace current selection and select first next occurence

on_pushButtonUp_clicked()[source]

Finds the previous occurrence

selectFirst()[source]

Select the first next occurences

showSearchAndReplacePanel()[source]

Shows the search and replace Panel

showSearchPanel()[source]

Shows the search Panel

updateSearchResults()[source]

Updates the search results

Misc panels

Contains miscellaneous panels not used by the editors but that could be useful for the end user (at least them are examples or custom panels)

class pcef.panels.misc.UserMarkersPanel(icon=':/icons/rc/bookmark.png', parent=None)[source]

A simple marker Panel that let the user add/remove marker using mouse clicks. This could be used for bookmarks, breakpoints,...

«  Modes   ::   Contents   ::   Styling  »