# eric6.QScintilla.MiniEditor

Module implementing a minimalistic editor for simple editing tasks.

### Global Attributes

None

### Classes

MiniEditor | Class implementing a minimalistic editor for simple editing tasks.
MiniScintilla | Class implementing a QsciScintillaCompat subclass for handling focus events.

### Functions

None

## MiniEditor

Class implementing a minimalistic editor for simple editing tasks.

### Signals

editorSaved()
  emitted after the file has been saved

### Derived from

E5MainWindow

### Class Attributes

None

### Class Methods

None

### Methods

MiniEditor | Constructor
__about | Private slot to show a little About message.
__aboutQt | Private slot to handle the About Qt dialog.
__bindLexer | Private slot to set the correct lexer depending on language.
__bindName | Private method to generate a dummy filename for binding a lexer.
__checkActions | Private slot to check some actions for their enable/disable status and set the statusbar info.
__checkLanguage | Private method to check the selected language of the language submenu.
__contextMenuRequested | Private slot to show the context menu.
__convertTabs | Private slot to convert tabulators to spaces.
__createActions | Private method to create the actions.
__createEditActions | Private method to create the Edit actions.
__createFileActions | Private method to create the File actions.
__createHelpActions | Private method to create the Help actions.
__createMenus | Private method to create the menus of the menu bar.
__createSearchActions | Private method defining the user interface actions for the search commands.
__createStatusBar | Private method to initialize the status bar.
__createToolBars | Private method to create the various toolbars.
__cursorPositionChanged | Private slot to handle the cursorPositionChanged signal.
__deselectAll | Private slot handling the deselect all context menu action.
__documentWasModified | Private slot to handle a change in the documents modification status.
__getCurrentWord | Private method to get the word at the current position.
__getEditorConfig | Private method to get the requested option via EditorConfig.
__getOverrideValue | Private method to get an override value for the current file type.
__getWord | Private method to get the word at a position.
__initContextMenu | Private method used to setup the context menu.
__initContextMenuLanguages | Private method used to setup the Languages context sub menu.
__languageMenuTriggered | Private method to handle the selection of a lexer language.
__loadEditorConfig | Private method to load the EditorConfig properties.
__loadEditorConfigObject | Private method to load the EditorConfig properties for the given file name.
__loadFile | Private method to load the given file.
__markOccurrences | Private method to mark all occurrences of the current word.
__maybeSave | Private method to ask the user to save the file, if it was modified.
__modificationChanged | Private slot to handle the modificationChanged signal.
__newFile | Private slot to create a new file.
__open | Private slot to open a file.
__printFile | Private slot to print the text.
__printPreview | Private slot to generate a print preview.
__printPreviewFile | Private slot to show a print preview of the text.
__readSettings | Private method to read the settings remembered last time.
__readShortcut | Private function to read a single keyboard shortcut from the settings.
__redo | Private method to redo the last recorded change.
__resetLanguage | Private method used to reset the language selection.
__resizeLinenoMargin | Private slot to resize the line numbers margin.
__save | Private slot to save a file.
__saveAs | Private slot to save a file with a new name.
__saveCopy | Private slot to save a copy of the file with a new name.
__saveFile | Private method to save to the given file.
__searchClearMarkers | Private method to clear the search markers of the active window.
__searchNext | Private slot to handle the search next action.
__searchPrev | Private slot to handle the search previous action.
__selectAll | Private slot handling the select all context menu action.
__selectPygmentsLexer | Private method to select a specific pygments lexer.
__setCurrentFile | Private method to register the file name of the current file.
__setEolMode | Private method to configure the eol mode of the editor.
__setMargins | Private method to configure the margins.
__setMonospaced | Private method to set/reset a monospaced font.
__setSbFile | Private method to set the file info in the status bar.
__setTabAndIndent | Private method to set indentation size and style and tab width.
__setTextDisplay | Private method to configure the text display.
__showContextMenuLanguages | Private slot handling the aboutToShow signal of the languages context menu.
__strippedName | Private method to return the filename part of the given path.
__styleNeeded | Private slot to handle the need for more styling.
__undo | Private method to undo the last recorded change.
__whatsThis | Private slot called in to enter Whats This mode.
__writeFile | Private method to write the current editor text to a file.
__writeSettings | Private method to write the settings for reuse.
activeWindow | Public method to fulfill the ViewManager interface.
clearSearchIndicators | Public method to clear all search indicators.
closeEvent | Protected method to handle the close event.
getFileName | Public method to return the name of the file being displayed.
getLanguage | Public method to retrieve the language of the editor.
getSRHistory | Public method to get the search or replace history list.
gotoLine | Public slot to jump to the beginning of a line.
setLanguage | Public method to set a lexer language.
setSearchIndicator | Public method to set a search indicator for the given range.
setText | Public method to set the text programatically.
setWindowModified | Public method to set the window modification status.
showReplaceWidget | Public method to show the replace widget.
showSearchWidget | Public method to show the search widget.
textForFind | Public method to determine the selection or the current word for the next find operation.

### Static Methods

None

#### MiniEditor (Constructor)

MiniEditor(filename="", filetype="", parent=None, name=None)

Constructor

filename
  name of the file to open (string)
filetype
  type of the source file (string)
parent
  reference to the parent widget (QWidget)
name
  object name of the window (string)

#### MiniEditor.__about

__about()

Private slot to show a little About message.

#### MiniEditor.__aboutQt

__aboutQt()

Private slot to handle the About Qt dialog.

#### MiniEditor.__bindLexer

__bindLexer(filename, pyname="")

Private slot to set the correct lexer depending on language.

filename
  filename used to determine the associated lexer language (string)
pyname=
  name of the pygments lexer to use (string)

#### MiniEditor.__bindName

__bindName(line0)

Private method to generate a dummy filename for binding a lexer.

line0
  first line of text to use in the generation process (string)

Returns:
  dummy file name to be used for binding a lexer (string)

#### MiniEditor.__checkActions

__checkActions(setSb=True)

Private slot to check some actions for their enable/disable status and set the statusbar info.

setSb
  flag indicating an update of the status bar is wanted (boolean)

#### MiniEditor.__checkLanguage

__checkLanguage()

Private method to check the selected language of the language submenu.

#### MiniEditor.__contextMenuRequested

__contextMenuRequested(coord)

Private slot to show the context menu.

coord
  the position of the mouse pointer (QPoint)

#### MiniEditor.__convertTabs

__convertTabs()

Private slot to convert tabulators to spaces.

#### MiniEditor.__createActions

__createActions()

Private method to create the actions.

#### MiniEditor.__createEditActions

__createEditActions()

Private method to create the Edit actions.

#### MiniEditor.__createFileActions

__createFileActions()

Private method to create the File actions.

#### MiniEditor.__createHelpActions

__createHelpActions()

Private method to create the Help actions.

#### MiniEditor.__createMenus

__createMenus()

Private method to create the menus of the menu bar.

#### MiniEditor.__createSearchActions

__createSearchActions()

Private method defining the user interface actions for the search commands.

#### MiniEditor.__createStatusBar

__createStatusBar()

Private method to initialize the status bar.

#### MiniEditor.__createToolBars

__createToolBars()

Private method to create the various toolbars.

#### MiniEditor.__cursorPositionChanged

__cursorPositionChanged(line, pos)

Private slot to handle the cursorPositionChanged signal.

line
  line number of the cursor
pos
  position in line of the cursor

#### MiniEditor.__deselectAll

__deselectAll()

Private slot handling the deselect all context menu action.

#### MiniEditor.__documentWasModified

__documentWasModified()

Private slot to handle a change in the documents modification status.

#### MiniEditor.__getCurrentWord

__getCurrentWord()

Private method to get the word at the current position.

Returns:
  the word at that current position

#### MiniEditor.__getEditorConfig

__getEditorConfig(option, nodefault=False, config=None)

Private method to get the requested option via EditorConfig.

If there is no EditorConfig defined, the equivalent built-in option will be used (Preferences.getEditor(). The option must be given as the Preferences option key. The mapping to the EditorConfig option name will be done within this method.

option (str)
  Preferences option key
nodefault (bool)
  flag indicating to not get the default value from Preferences but return None instead
config (dict)
  reference to an EditorConfig object or None

Returns:
  value of requested setting or None if nothing was found and nodefault parameter was True

Return Type:
  any

#### MiniEditor.__getOverrideValue

__getOverrideValue(option)

Private method to get an override value for the current file type.

option (str)
  Preferences option key

Returns:
  override value; None in case nothing is defined

Return Type:
  any

#### MiniEditor.__getWord

__getWord(line, index)

Private method to get the word at a position.

line
  number of line to look at (int)
index
  position to look at (int)

Returns:
  the word at that position (string)

#### MiniEditor.__initContextMenu

__initContextMenu()

Private method used to setup the context menu.

#### MiniEditor.__initContextMenuLanguages

__initContextMenuLanguages()

Private method used to setup the Languages context sub menu.

Returns:
  reference to the generated menu (QMenu)

#### MiniEditor.__languageMenuTriggered

__languageMenuTriggered(act)

Private method to handle the selection of a lexer language.

act
  reference to the action that was triggered (QAction)

#### MiniEditor.__loadEditorConfig

__loadEditorConfig(fileName="")

Private method to load the EditorConfig properties.

fileName (str)
  name of the file

#### MiniEditor.__loadEditorConfigObject

__loadEditorConfigObject(fileName)

Private method to load the EditorConfig properties for the given file name.

fileName (str)
  name of the file

Returns:
  EditorConfig dictionary

Return Type:
  dict

#### MiniEditor.__loadFile

__loadFile(fileName, filetype=None)

Private method to load the given file.

fileName
  name of the file to load (string)
filetype
  type of the source file (string)

#### MiniEditor.__markOccurrences

__markOccurrences()

Private method to mark all occurrences of the current word.

#### MiniEditor.__maybeSave

__maybeSave()

Private method to ask the user to save the file, if it was modified.

Returns:
  flag indicating, if it is ok to continue (boolean)

#### MiniEditor.__modificationChanged

__modificationChanged(m)

Private slot to handle the modificationChanged signal.

m
  modification status

#### MiniEditor.__newFile

__newFile()

Private slot to create a new file.

#### MiniEditor.__open

__open()

Private slot to open a file.

#### MiniEditor.__printFile

__printFile()

Private slot to print the text.

#### MiniEditor.__printPreview

__printPreview(printer)

Private slot to generate a print preview.

printer
  reference to the printer object (QScintilla.Printer.Printer)

#### MiniEditor.__printPreviewFile

__printPreviewFile()

Private slot to show a print preview of the text.

#### MiniEditor.__readSettings

__readSettings()

Private method to read the settings remembered last time.

#### MiniEditor.__readShortcut

__readShortcut(act, category)

Private function to read a single keyboard shortcut from the settings.

act
  reference to the action object (E5Action)
category
  category the action belongs to (string)

#### MiniEditor.__redo

__redo()

Private method to redo the last recorded change.

#### MiniEditor.__resetLanguage

__resetLanguage()

Private method used to reset the language selection.

#### MiniEditor.__resizeLinenoMargin

__resizeLinenoMargin()

Private slot to resize the line numbers margin.

#### MiniEditor.__save

__save()

Private slot to save a file.

Returns:
  flag indicating success (boolean)

#### MiniEditor.__saveAs

__saveAs()

Private slot to save a file with a new name.

Returns:
  flag indicating success (boolean)

#### MiniEditor.__saveCopy

__saveCopy()

Private slot to save a copy of the file with a new name.

#### MiniEditor.__saveFile

__saveFile(fileName)

Private method to save to the given file.

fileName (str)
  name of the file to save to

Returns:
  flag indicating success

Return Type:
  bool

#### MiniEditor.__searchClearMarkers

__searchClearMarkers()

Private method to clear the search markers of the active window.

#### MiniEditor.__searchNext

__searchNext()

Private slot to handle the search next action.

#### MiniEditor.__searchPrev

__searchPrev()

Private slot to handle the search previous action.

#### MiniEditor.__selectAll

__selectAll()

Private slot handling the select all context menu action.

#### MiniEditor.__selectPygmentsLexer

__selectPygmentsLexer()

Private method to select a specific pygments lexer.

Returns:
  name of the selected pygments lexer (string)

#### MiniEditor.__setCurrentFile

__setCurrentFile(fileName)

Private method to register the file name of the current file.

fileName
  name of the file to register (string)

#### MiniEditor.__setEolMode

__setEolMode()

Private method to configure the eol mode of the editor.

#### MiniEditor.__setMargins

__setMargins()

Private method to configure the margins.

#### MiniEditor.__setMonospaced

__setMonospaced(on)

Private method to set/reset a monospaced font.

on
  flag to indicate usage of a monospace font (boolean)

#### MiniEditor.__setSbFile

__setSbFile(line=None, pos=None)

Private method to set the file info in the status bar.

line
  line number to display (int)
pos
  character position to display (int)

#### MiniEditor.__setTabAndIndent

__setTabAndIndent()

Private method to set indentation size and style and tab width.

#### MiniEditor.__setTextDisplay

__setTextDisplay()

Private method to configure the text display.

#### MiniEditor.__showContextMenuLanguages

__showContextMenuLanguages()

Private slot handling the aboutToShow signal of the languages context menu.

#### MiniEditor.__strippedName

__strippedName(fullFileName)

Private method to return the filename part of the given path.

fullFileName
  full pathname of the given file (string)

Returns:
  filename part (string)

#### MiniEditor.__styleNeeded

__styleNeeded(position)

Private slot to handle the need for more styling.

position
  end position, that needs styling (integer)

#### MiniEditor.__undo

__undo()

Private method to undo the last recorded change.

#### MiniEditor.__whatsThis

__whatsThis()

Private slot called in to enter Whats This mode.

#### MiniEditor.__writeFile

__writeFile(fileName)

Private method to write the current editor text to a file.

fileName (str)
  name of the file to be written to

Returns:
  flag indicating success

Return Type:
  bool

#### MiniEditor.__writeSettings

__writeSettings()

Private method to write the settings for reuse.

#### MiniEditor.activeWindow

activeWindow()

Public method to fulfill the ViewManager interface.

Returns:
  reference to the text edit component (QsciScintillaCompat)

#### MiniEditor.clearSearchIndicators

clearSearchIndicators()

Public method to clear all search indicators.

#### MiniEditor.closeEvent

closeEvent(event)

Protected method to handle the close event.

event
  close event (QCloseEvent)

#### MiniEditor.getFileName

getFileName()

Public method to return the name of the file being displayed.

Returns:
  filename of the displayed file (string)

#### MiniEditor.getLanguage

getLanguage()

Public method to retrieve the language of the editor.

Returns:
  language of the editor (string)

#### MiniEditor.getSRHistory

getSRHistory(key)

Public method to get the search or replace history list.

key
  list to return (must be 'search' or 'replace')

Returns:
  the requested history list (list of strings)

#### MiniEditor.gotoLine

gotoLine(line, pos=1)

Public slot to jump to the beginning of a line.

line (int)
  line number to go to
pos= (int)
  position in line to go to

#### MiniEditor.setLanguage

setLanguage(filename, initTextDisplay=True, pyname="")

Public method to set a lexer language.

filename
  filename used to determine the associated lexer language (string)
initTextDisplay
  flag indicating an initialization of the text display is required as well (boolean)
pyname=
  name of the pygments lexer to use (string)

#### MiniEditor.setSearchIndicator

setSearchIndicator(startPos, indicLength)

Public method to set a search indicator for the given range.

startPos
  start position of the indicator (integer)
indicLength
  length of the indicator (integer)

#### MiniEditor.setText

setText(txt, filetype=None)

Public method to set the text programatically.

txt
  text to be set (string)
filetype
  type of the source file (string)

#### MiniEditor.setWindowModified

setWindowModified(modified)

Public method to set the window modification status.

modified (bool)
  flag indicating the modification status

#### MiniEditor.showReplaceWidget

showReplaceWidget()

Public method to show the replace widget.

#### MiniEditor.showSearchWidget

showSearchWidget()

Public method to show the search widget.

#### MiniEditor.textForFind

textForFind()

Public method to determine the selection or the current word for the next find operation.

Returns:
  selection or current word (string)

Up

## MiniScintilla

Class implementing a QsciScintillaCompat subclass for handling focus events.

### Derived from

QsciScintillaCompat

### Class Attributes

None

### Class Methods

None

### Methods

MiniScintilla | Constructor
focusInEvent | Protected method called when the editor receives focus.
focusOutEvent | Protected method called when the editor loses focus.
getFileName | Public method to return the name of the file being displayed.
removeTrailingWhitespace | Public method to remove trailing whitespace.

### Static Methods

None

#### MiniScintilla (Constructor)

MiniScintilla(parent=None)

Constructor

parent
  parent widget (QWidget)

#### MiniScintilla.focusInEvent

focusInEvent(event)

Protected method called when the editor receives focus.

This method checks for modifications of the current file and rereads it upon request. The cursor is placed at the current position assuming, that it is in the vicinity of the old position after the reread.

event
  the event object (QFocusEvent)

#### MiniScintilla.focusOutEvent

focusOutEvent(event)

Protected method called when the editor loses focus.

event
  the event object (QFocusEvent)

#### MiniScintilla.getFileName

getFileName()

Public method to return the name of the file being displayed.

Returns:
  filename of the displayed file (string)

#### MiniScintilla.removeTrailingWhitespace

removeTrailingWhitespace()

Public method to remove trailing whitespace.

Up