pyQode/pyqode.core — pull request #131 by ColinDuquesnoy (2014-06-23 09:01:32+00:00)
Title: Add managers and refactor namespaces

I recently made quite a lots of changes to the public API. The goal was to make the public API more pythonic and consistent.

What changed ?
---------------------

- frontend package removal: all the modules and subpackages have been move to pyqode.core (parent package)
- move pyqode.qt into pyqode.core
- add managers: a manager literally manages one specific aspect of CodeEdit, e.g. there are managers for modes and panels, for managing the backend, for loading and saving files. Instead of having a set of free functions in the frontend pacakges, all those functions has been moved to classes and have been tightly integrated into CodeEdit.

I am submitting this as a PR so that people who are already using the 2.0-beta code know that they will have to update their code. I am sorry for that but those changes had to be done before the final public release. I hope those changes will make the API easier to use!

Here is how the basic.py example now look like:

``` python
import sys
from pyqode.core import api
from pyqode.core import modes
from pyqode.core import panels
from pyqode.core.qt import QtWidgets

def main():
app = QtWidgets.QApplication(sys.argv)

# create editor and window
window = QtWidgets.QMainWindow()
editor = api.CodeEdit()
window.setCentralWidget(editor)

# start the backend as soon as possible
editor.backend.start('server.py')

# append some modes and panels
editor.modes.append(modes.CodeCompletionMode())
editor.modes.append(modes.PygmentsSyntaxHighlighter(editor.document()))
editor.modes.append(modes.CaretLineHighlighterMode())
editor.panels.append(panels.SearchAndReplacePanel(),
api.Panel.Position.BOTTOM)

print(editor.modes) # modes and panels are now iterables!
print(editor.panels)

# open a file
editor.file.open(__file__)

# run
window.show()
app.exec_()

if __name__ == "__main__":
main()
```

*ps: those changes have already been ported on pyqode.python. I will release a last beta once this has been merged.*