pycrossword  0.4
Pure-Python implementation of a crossword puzzle generator and editor
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | List of all members
pycross.utils.synteditor.PluginSynEditorWidget Class Reference

Extended syntax editor dialog based on SynEditorWidget. More...

Inheritance diagram for pycross.utils.synteditor.PluginSynEditorWidget:
pycross.utils.synteditor.SynEditorWidget

Public Member Functions

def __init__ (self, methods, lexer=Qsci.QsciLexerPython(), source=None, minsize=(800, 500), icon='file.png', title=_('::Code Editor ::'))
 
def showEvent (self, event)
 On show event handler: updates the left panel from the current source code. More...
 
def add_central (self, lexer, source, autocomplete_source)
 Constructs the central widget (syntax editor). More...
 
def reset_methods (self)
 Fills the list of available API methods in the left panel from PluginSynEditorWidget::methods. More...
 
def on_actn_filter_regex_toggled (self, checked)
 On Toggle slot for the filter button (action): re-applies the filter with / without regex. More...
 
def on_filter_changed (self, text)
 On Changed slot for the filter edit: re-applies the filter with the new expression. More...
 
def on_editor_text_changed (self)
 On Changed slot for the syntax editor: update the checked state of source methods, update autocomplete source. More...
 
def on_lw_methods_select (self, current, previous)
 On Selection Changed slot for the source methods: scrolls to the selected method in the syntaxt editor. More...
 
def on_lw_methods_changed (self, item)
 On Changed slot for the source methods: adds or removes source method templates in the editor when checked/unchecked. More...
 
def on_lw_methods_dblclicked (self, item)
 On Double Clicked slot for the source methods: toggles the checked state of the dbl-clicked item. More...
 
- Public Member Functions inherited from pycross.utils.synteditor.SynEditorWidget
def add_elements (self, lexer, source, autocomplete_source)
 Constructs main layout blocks. More...
 
def add_bottom (self)
 Constructs the bottom layout with the OK and Cancel buttons. More...
 
def currenttext (self)
 Returns the current text in the syntax editor. More...
 

Public Attributes

 methods
 list list of methods exposed to plugins More...
 
 editor
 SynEditor the syntax editor widget More...
 
 splitter1
 QtWidgets.QSplitter horizontal splitter More...
 
 lo_methods
 
 lw_methods
 QtWidgets.QListWidget list of source methods (exposed to plugins) More...
 
 actn_clear_filter
 QtWidgets.QAction clear filter action More...
 
 actn_filter_regex
 QtWidgets.QAction toggle regex filter action More...
 
 le_filter
 QtWidgets.QLineEdit filter field for the source methods More...
 
 methods_widget
 
- Public Attributes inherited from pycross.utils.synteditor.SynEditorWidget
 layout_main
 QtWidgets.QVBoxLayout main window layout More...
 
 editor
 SynEditor the syntax editor More...
 
 layout_bottom
 
 btn_OK
 
 btn_cancel
 

Static Public Attributes

 RESRCH = re.compile(r'\n[ ]{4}[\w"#@]')
 regex pattern pattern for a method start More...
 

Private Member Functions

def _config_editor (self)
 Connects the syntax editor's textChanged signal to an internal handler. More...
 
def _get_autocomplete_source (self, source)
 Retrieves a list of variables referenced / created in the given source. More...
 
def _update_checked_methods (self)
 Checks or unchecks the source methods in the left panel based on the current editor text. More...
 
def _apply_filter (self, text)
 Filters the source methods in the left panel by a search expression. More...
 

Detailed Description

Extended syntax editor dialog based on SynEditorWidget.

Adds a left panel with available API methods exposed to custom plugins.

Constructor & Destructor Documentation

◆ __init__()

def pycross.utils.synteditor.PluginSynEditorWidget.__init__ (   self,
  methods,
  lexer = Qsci.QsciLexerPython(),
  source = None,
  minsize = (800, 500),
  icon = 'file.png',
  title = _(':: Code Editor ::') 
)
Parameters
methodslist list of methods exposed to plugins in the format returned by utils::utils::collect_pluggables()

Reimplemented from pycross.utils.synteditor.SynEditorWidget.

Member Function Documentation

◆ _apply_filter()

def pycross.utils.synteditor.PluginSynEditorWidget._apply_filter (   self,
  text 
)
private

Filters the source methods in the left panel by a search expression.

The filter can be simple or regex-based, depending on the Checked state of PluginSynEditorWidget::actn_filter_regex.

Parameters
textstr the search expression used as the filter

◆ _config_editor()

def pycross.utils.synteditor.PluginSynEditorWidget._config_editor (   self)
private

Connects the syntax editor's textChanged signal to an internal handler.

◆ _get_autocomplete_source()

def pycross.utils.synteditor.PluginSynEditorWidget._get_autocomplete_source (   self,
  source 
)
private

Retrieves a list of variables referenced / created in the given source.

Parameters
sourcestr source text to extract variables from
Returns
list list of variables – see utils::utils::get_script_members()

◆ _update_checked_methods()

def pycross.utils.synteditor.PluginSynEditorWidget._update_checked_methods (   self)
private

Checks or unchecks the source methods in the left panel based on the current editor text.

The method searches the function signatures of the source methods in the current editor and if found, checks the corresponding method to mark it as used.

◆ add_central()

def pycross.utils.synteditor.PluginSynEditorWidget.add_central (   self,
  lexer,
  source,
  autocomplete_source 
)

Constructs the central widget (syntax editor).

Parameters
lexerQsci.QsciLexer lexer object responsible for parsing / highlighting
sourcestr|None source code to place in the editor upon creation
autocomplete_sourcelist|None list of variables & functions serving as the autocompletion source (see utils::utils::get_script_members())

Reimplemented from pycross.utils.synteditor.SynEditorWidget.

◆ on_actn_filter_regex_toggled()

def pycross.utils.synteditor.PluginSynEditorWidget.on_actn_filter_regex_toggled (   self,
  checked 
)

On Toggle slot for the filter button (action): re-applies the filter with / without regex.

◆ on_editor_text_changed()

def pycross.utils.synteditor.PluginSynEditorWidget.on_editor_text_changed (   self)

On Changed slot for the syntax editor: update the checked state of source methods, update autocomplete source.

◆ on_filter_changed()

def pycross.utils.synteditor.PluginSynEditorWidget.on_filter_changed (   self,
  text 
)

On Changed slot for the filter edit: re-applies the filter with the new expression.

◆ on_lw_methods_changed()

def pycross.utils.synteditor.PluginSynEditorWidget.on_lw_methods_changed (   self,
  item 
)

On Changed slot for the source methods: adds or removes source method templates in the editor when checked/unchecked.

◆ on_lw_methods_dblclicked()

def pycross.utils.synteditor.PluginSynEditorWidget.on_lw_methods_dblclicked (   self,
  item 
)

On Double Clicked slot for the source methods: toggles the checked state of the dbl-clicked item.

◆ on_lw_methods_select()

def pycross.utils.synteditor.PluginSynEditorWidget.on_lw_methods_select (   self,
  current,
  previous 
)

On Selection Changed slot for the source methods: scrolls to the selected method in the syntaxt editor.

◆ reset_methods()

def pycross.utils.synteditor.PluginSynEditorWidget.reset_methods (   self)

Fills the list of available API methods in the left panel from PluginSynEditorWidget::methods.

◆ showEvent()

def pycross.utils.synteditor.PluginSynEditorWidget.showEvent (   self,
  event 
)

On show event handler: updates the left panel from the current source code.

Member Data Documentation

◆ actn_clear_filter

pycross.utils.synteditor.PluginSynEditorWidget.actn_clear_filter

QtWidgets.QAction clear filter action

◆ actn_filter_regex

pycross.utils.synteditor.PluginSynEditorWidget.actn_filter_regex

QtWidgets.QAction toggle regex filter action

◆ editor

pycross.utils.synteditor.PluginSynEditorWidget.editor

SynEditor the syntax editor widget

◆ le_filter

pycross.utils.synteditor.PluginSynEditorWidget.le_filter

QtWidgets.QLineEdit filter field for the source methods

◆ lo_methods

pycross.utils.synteditor.PluginSynEditorWidget.lo_methods

◆ lw_methods

pycross.utils.synteditor.PluginSynEditorWidget.lw_methods

QtWidgets.QListWidget list of source methods (exposed to plugins)

◆ methods

pycross.utils.synteditor.PluginSynEditorWidget.methods

list list of methods exposed to plugins

◆ methods_widget

pycross.utils.synteditor.PluginSynEditorWidget.methods_widget

◆ RESRCH

pycross.utils.synteditor.PluginSynEditorWidget.RESRCH = re.compile(r'\n[ ]{4}[\w"#@]')
static

regex pattern pattern for a method start

◆ splitter1

pycross.utils.synteditor.PluginSynEditorWidget.splitter1

QtWidgets.QSplitter horizontal splitter


The documentation for this class was generated from the following file: