# eric4.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

KQMainWindow

### Class Attributes

None

### Methods

MiniEditor | Constructor
__about | Private slot to show a little About message.
__aboutKde | Private slot to handle the About KDE dialog.
__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.
__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.
__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.
__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 | Public method to redo the last recorded change.
__replace | Private method to handle the replace action.
__resetLanguage | Private method used to reset the language selection.
__save | Private slot to save a file.
__saveAs | Private slot to save a file with a new name.
__saveFile | Private method to save to the given file.
__search | Private method to handle the search action.
__searchClearMarkers | Private method to clear the search markers of the active window.
__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.
__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 | Public method to undo the last recorded change.
__whatsThis | Private slot called in to enter Whats This mode.
__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 | Public 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.
readLine0 | Public slot to read the first line from a file.
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.
textForFind | Public method to determine the selection or the current word for the next find operation.

#### MiniEditor (Constructor)

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

Constructor

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

#### MiniEditor.__about

__about()

Private slot to show a little About message.

#### MiniEditor.__aboutKde

__aboutKde()

Private slot to handle the About KDE dialog.

#### 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 or QString)
pyname=
  name of the pygments lexer to use (string)

#### MiniEditor.__bindName

__bindName(txt)

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

txt
  first line of text to use in the generation process (QString or 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.__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.__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

#### MiniEditor.__initContextMenu

__initContextMenu()

Private method used to setup the context menu

#### MiniEditor.__initContextMenuLanguages

__initContextMenuLanguages()

Private method used to setup the Languages context sub menu.

#### MiniEditor.__languageMenuTriggered

__languageMenuTriggered(act)

Private method to handle the selection of a lexer language.

act
  reference to the action that was triggered (QAction)

#### MiniEditor.__loadFile

__loadFile(fileName, filetype = None)

Private method to load the given file.

fileName
  name of the file to load (QString)
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 (E4Action)
category
  category the action belongs to (string or QString)
prefClass
  preferences class used as the storage area

#### MiniEditor.__redo

__redo()

Public method to redo the last recorded change.

#### MiniEditor.__replace

__replace()

Private method to handle the replace action.

#### MiniEditor.__resetLanguage

__resetLanguage()

Private method used to reset the language selection.

#### MiniEditor.__save

__save()

Private slot to save a file.

#### MiniEditor.__saveAs

__saveAs()

Private slot to save a file with a new name.

#### MiniEditor.__saveFile

__saveFile(fileName)

Private method to save to the given file.

fileName
  name of the file to save to (QString)

Returns:
  flag indicating success (boolean)

#### MiniEditor.__search

__search()

Private method to handle the search action.

#### MiniEditor.__searchClearMarkers

__searchClearMarkers()

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

#### 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 or QString)

#### 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.__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 (QString)

Returns:
  filename part (QString)

#### MiniEditor.__styleNeeded

__styleNeeded(position)

Private slot to handle the need for more styling.

position
  end position, that needs styling (integer)

#### MiniEditor.__undo

__undo()

Public method to undo the last recorded change.

#### MiniEditor.__whatsThis

__whatsThis()

Private slot called in to enter Whats This mode.

#### 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)

Public 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 (QString)

#### 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 (QStringList)

#### MiniEditor.readLine0

readLine0(fn, createIt = False)

Public slot to read the first line from a file.

fn
  filename to read from (string or QString)
createIt
  flag indicating the creation of a new file, if the given one doesn't exist (boolean)

Returns:
  first line of the file (string)

#### 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 or QString)
filetype
  type of the source file (string)

#### MiniEditor.textForFind

textForFind()

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

Returns:
  selection or current word (QString)

Up

## MiniScintilla

Class implementing a QsciScintillaCompat subclass for handling focus events.

### Derived from

QsciScintillaCompat

### Class Attributes

None

### Methods

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

#### MiniScintilla (Constructor)

MiniScintilla(parent = None)

Constructor

parent
  parent widget (QWidget)
flags
  window flags

#### 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)

Public 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)

Up