Ejemplo n.º 1
0
def run_ninja():
    """First obtain the execution args and create the resources folder."""
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    # Change the process name only for linux yet
    if sys.platform != "win32" and sys.platform != "darwin":
        try:
            import ctypes

            libc = ctypes.CDLL("libc.so.6")
            procname = "ninja-ide"
            libc.prctl(15, "%s\0" % procname, 0, 0, 0)
        except:
            print("The process couldn't be renamed'")
    # Set the application name
    (filenames, projects_path, extra_plugins, linenos, log_level, log_file) = cliparser.parse()
    # Create NINJA-IDE user folder structure for plugins, themes, etc
    resources.create_home_dir_structure()
    from ninja_ide.tools.logger import NinjaLogger

    NinjaLogger.argparse(log_level, log_file)

    # Start the UI
    from ninja_ide.gui import ide

    ide.start(filenames, projects_path, extra_plugins, linenos)
def run_ninja():
    """First obtain the execution args and create the resources folder."""
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    # Change the process name only for linux yet
    if not settings.IS_WINDOWS and not settings.IS_MAC_OS:
        try:
            import ctypes
            libc = ctypes.cdll.LoadLibrary('libc.so.6')
            # Set the application name
            libc.prctl(PR_SET_NAME, b"%s\0" % PROCNAME, 0, 0, 0)
        except:
            print("The process couldn't be renamed'")
    filenames, projects_path, extra_plugins, linenos, log_level, log_file = \
        cliparser.parse()
    resources.create_home_dir_structure()
    # Load Logger
    from ninja_ide.tools.logger import NinjaLogger
    NinjaLogger.argparse(log_level, log_file)

    # Load Settings
    settings.load_settings()
    QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling, settings.HDPI)
    if settings.CUSTOM_SCREEN_RESOLUTION:
        os.environ["QT_SCALE_FACTOR"] = settings.CUSTOM_SCREEN_RESOLUTION
    # Start the UI
    app = QApplication(sys.argv)
    from ninja_ide import ninja_style
    app.setStyle(ninja_style.NinjaStyle(resources.load_theme()))

    from ninja_ide import gui
    gui.start_ide(app, filenames, projects_path, extra_plugins, linenos)

    sys.exit(app.exec_())
Ejemplo n.º 3
0
def run_ninja():
    """First obtain the execution args and create the resources folder."""
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    # Change the process name only for linux yet
    if not settings.IS_WINDOWS and not settings.IS_MAC_OS:
        try:
            import ctypes
            libc = ctypes.CDLL('libc.so.6')
            #Set the application name
            procname = 'ninja-ide'
            libc.prctl(15, '%s\0' % procname, 0, 0, 0)
        except:
            print("The process couldn't be renamed'")
    filenames, projects_path, extra_plugins, linenos, log_level, log_file = \
        cliparser.parse()
    resources.create_home_dir_structure()
    # Load Logger
    from ninja_ide.tools.logger import NinjaLogger
    NinjaLogger.argparse(log_level, log_file)

    # Load Settings
    settings.load_settings()
    # Start the UI
    app = QApplication(sys.argv)

    from ninja_ide import gui
    gui.start_ide(app, filenames, projects_path, extra_plugins, linenos)

    sys.exit(app.exec_())
Ejemplo n.º 4
0
 def __init__(self, locator, metadata=None):
     QObject.__init__(self)
     self.locator = locator
     if metadata is None:
         self.metadata = {}
     else:
         self.metadata = metadata
     klass = self.__class__
     plugin_name = "%s.%s" % (klass.__module__, klass.__name__)
     self.logger = NinjaLogger('ninja_ide.plugins.%s' % plugin_name)
     # set the path!
     try:
         self_module = self.__module__
         path = os.path.abspath(sys.modules[self_module].__file__)
         self._path = os.path.dirname(path)
     except BaseException:
         self._path = ''
Ejemplo n.º 5
0
def run_ninja():
    """First obtain the execution args and create the resources folder."""
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    # Change the process name only for linux yet
    is_linux = sys.platform == "darwin" or sys.platform == "win32"
    if is_linux:
        try:
            import ctypes
            libc = ctypes.cdll.LoadLibrary('libc.so.6')
            # Set the application name
            libc.prctl(PR_SET_NAME, b"%s\0" % PROCNAME, 0, 0, 0)
        except OSError:
            print("The process couldn't be renamed'")
    filenames, projects_path, extra_plugins, linenos, log_level, log_file = \
        cliparser.parse()
    # Create the QApplication object before using the
    # Qt modules to avoid warnings
    app = QApplication(sys.argv)
    from ninja_ide import resources
    from ninja_ide.core import settings
    resources.create_home_dir_structure()
    # Load Logger
    from ninja_ide.tools.logger import NinjaLogger
    NinjaLogger.argparse(log_level, log_file)

    # Load Settings
    settings.load_settings()
    QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling, settings.HDPI)
    if settings.CUSTOM_SCREEN_RESOLUTION:
        os.environ["QT_SCALE_FACTOR"] = settings.CUSTOM_SCREEN_RESOLUTION
    from ninja_ide import ninja_style
    app.setStyle(ninja_style.NinjaStyle(resources.load_theme()))

    # Add Font Awesome
    family = QFontDatabase.applicationFontFamilies(
        QFontDatabase.addApplicationFont(':font/awesome'))[0]
    font = QFont(family)
    font.setStyleName('Solid')
    app.setFont(font)

    from ninja_ide import gui
    # Start the UI
    gui.start_ide(app, filenames, projects_path, extra_plugins, linenos)

    sys.exit(app.exec_())
Ejemplo n.º 6
0
def run_ninja():
    """First obtain the execution args and create the resources folder."""
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    # Change the process name only for linux yet
    is_linux = sys.platform == "darwin" or sys.platform == "win32"
    if is_linux:
        try:
            import ctypes
            libc = ctypes.cdll.LoadLibrary('libc.so.6')
            # Set the application name
            libc.prctl(PR_SET_NAME, b"%s\0" % PROCNAME, 0, 0, 0)
        except OSError:
            print("The process couldn't be renamed'")
    filenames, projects_path, extra_plugins, linenos, log_level, log_file = \
        cliparser.parse()
    # Create the QApplication object before using the
    # Qt modules to avoid warnings
    app = QApplication(sys.argv)
    from ninja_ide import resources
    from ninja_ide.core import settings
    resources.create_home_dir_structure()
    # Load Logger
    from ninja_ide.tools.logger import NinjaLogger
    NinjaLogger.argparse(log_level, log_file)

    # Load Settings
    settings.load_settings()
    QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling, settings.HDPI)
    if settings.CUSTOM_SCREEN_RESOLUTION:
        os.environ["QT_SCALE_FACTOR"] = settings.CUSTOM_SCREEN_RESOLUTION
    from ninja_ide import ninja_style
    app.setStyle(ninja_style.NinjaStyle(resources.load_theme()))

    from ninja_ide import gui
    # Start the UI
    gui.start_ide(app, filenames, projects_path, extra_plugins, linenos)

    sys.exit(app.exec_())
Ejemplo n.º 7
0
def run_ninja():
    """First obtain the execution args and create the resources folder."""
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    # Change the process name only for linux yet
    if sys.platform != 'win32' and sys.platform != 'darwin':
        try:
            import ctypes
            libc = ctypes.CDLL('libc.so.6')
            procname = 'ninja-ide'
            libc.prctl(15, '%s\0' % procname, 0, 0, 0)
        except:
            print("The process couldn't be renamed'")
    #Set the application name
    (filenames, projects_path, extra_plugins, linenos, log_level,
     log_file) = cliparser.parse()
    # Create NINJA-IDE user folder structure for plugins, themes, etc
    resources.create_home_dir_structure()
    from ninja_ide.tools.logger import NinjaLogger
    NinjaLogger.argparse(log_level, log_file)

    # Start the UI
    from ninja_ide.gui import ide
    ide.start(filenames, projects_path, extra_plugins, linenos)
Ejemplo n.º 8
0
class Plugin(QObject):
    '''
    Base class for ALL Plugin
    All plugins should inherit from this class
    '''

    def __init__(self, locator, metadata=None):
        QObject.__init__(self)
        self.locator = locator
        if metadata is None:
            self.metadata = {}
        else:
            self.metadata = metadata
        klass = self.__class__
        plugin_name = "%s.%s" % (klass.__module__, klass.__name__)
        self.logger = NinjaLogger('ninja_ide.plugins.%s' % plugin_name)
        #set the path!
        try:
            self_module = self.__module__
            path = os.path.abspath(sys.modules[self_module].__file__)
            self._path = os.path.dirname(path)
        except:
            self._path = ''

    def initialize(self):
        """The initialization of the Plugin should be here."""
        self.logger.info("Initializing Plugin...")

    def finish(self):
        pass

    def get_preferences_widget(self):
        pass

    @property
    def path(self):
        return self._path
Ejemplo n.º 9
0
class Plugin(QObject):
    '''
    Base class for ALL Plugin
    All plugins should inherit from this class
    '''

    def __init__(self, locator, metadata=None):
        QObject.__init__(self)
        self.locator = locator
        if metadata is None:
            self.metadata = {}
        else:
            self.metadata = metadata
        klass = self.__class__
        plugin_name = "%s.%s" % (klass.__module__, klass.__name__)
        self.logger = NinjaLogger('ninja_ide.plugins.%s' % plugin_name)
        # set the path!
        try:
            self_module = self.__module__
            path = os.path.abspath(sys.modules[self_module].__file__)
            self._path = os.path.dirname(path)
        except BaseException:
            self._path = ''

    def initialize(self):
        """The initialization of the Plugin should be here."""
        self.logger.info("Initializing Plugin...")

    def finish(self):
        pass

    def get_preferences_widget(self):
        pass

    @property
    def path(self):
        return self._path
Ejemplo n.º 10
0
 def __init__(self, locator, metadata=None):
     QObject.__init__(self)
     self.locator = locator
     if metadata is None:
         self.metadata = {}
     else:
         self.metadata = metadata
     klass = self.__class__
     plugin_name = "%s.%s" % (klass.__module__, klass.__name__)
     self.logger = NinjaLogger('ninja_ide.plugins.%s' % plugin_name)
     #set the path!
     try:
         self_module = self.__module__
         path = os.path.abspath(sys.modules[self_module].__file__)
         self._path = os.path.dirname(path)
     except:
         self._path = ''
Ejemplo n.º 11
0
from ninja_ide.core import settings
from ninja_ide.core.file_handling import file_manager
from ninja_ide.tools.completion import completer_widget
from ninja_ide.gui.ide import IDE
from ninja_ide.gui.main_panel import itab_item
from ninja_ide.gui.editor import highlighter
from ninja_ide.gui.editor import syntax_highlighter
from ninja_ide.gui.editor import helpers
from ninja_ide.gui.editor import minimap
from ninja_ide.gui.editor import sidebar_widget
from ninja_ide.gui.editor import python_syntax

from ninja_ide.tools.logger import NinjaLogger

BRACE_DICT = {')': '(', ']': '[', '}': '{', '(': ')', '[': ']', '{': '}'}
logger = NinjaLogger('ninja_ide.gui.editor.editor')

if sys.version_info.major == 3:
    python3 = True
else:
    python3 = False


class Editor(QPlainTextEdit, itab_item.ITabItem):

    ###############################################################################
    # EDITOR SIGNALS
    ###############################################################################
    """
    modificationChanged(bool)
    fileSaved(QPlainTextEdit)
Ejemplo n.º 12
0
# You should have received a copy of the GNU General Public License
# along with NINJA-IDE; If not, see <http://www.gnu.org/licenses/>.

from __future__ import absolute_import

from PyQt4.QtCore import SIGNAL
from threading import Thread
import win32con
import win32file
import win32event
import pywintypes
import os
from ninja_ide.core import file_manager

from ninja_ide.tools.logger import NinjaLogger
logger = NinjaLogger('ninja_ide.core.filesystem_notifications.windows')
DEBUG = logger.debug

from ninja_ide.core.filesystem_notifications import base_watcher
ADDED = base_watcher.ADDED
DELETED = base_watcher.DELETED
REMOVE = base_watcher.REMOVE
RENAME = base_watcher.RENAME
MODIFIED = base_watcher.MODIFIED

ACTIONS = {1: ADDED, 2: DELETED, 3: MODIFIED, 4: RENAME, 5: RENAME}

# Thanks to Claudio Grondi for the correct set of numbers
FILE_LIST_DIRECTORY = 0x0001

watchmask = win32con.FILE_NOTIFY_CHANGE_FILE_NAME | \
Ejemplo n.º 13
0
from ninja_ide import translations
from ninja_ide.core import settings
from ninja_ide.core.file_handling import file_manager
from ninja_ide.tools import ui_tools
from ninja_ide.tools import json_manager
from ninja_ide.gui.ide import IDE
# from ninja_ide.gui.dialogs import add_to_project
from ninja_ide.gui.dialogs import project_properties_widget
from ninja_ide.gui.dialogs import new_project_manager
from ninja_ide.gui.explorer.explorer_container import ExplorerContainer
from ninja_ide.gui.explorer import actions
from ninja_ide.gui.explorer.nproject import NProject
from ninja_ide.tools.logger import NinjaLogger

logger = NinjaLogger('ninja_ide.gui.explorer.tree_projects_widget')
DEBUG = logger.debug


class ProjectTreeColumn(QDialog):

    # Signals
    dockWidget = pyqtSignal('PyQt_PyObject')
    undockWidget = pyqtSignal()
    changeTitle = pyqtSignal('PyQt_PyObject', 'QString')
    updateLocator = pyqtSignal()

    def __init__(self, parent=None):
        super(ProjectTreeColumn, self).__init__(parent)
        vbox = QVBoxLayout(self)
        # vbox.setSizeConstraint(QVBoxLayout.SetDefaultConstraint)
Ejemplo n.º 14
0
import os
import sys
import copy
import urllib2
import zipfile
import traceback

try:
    import json
except ImportError:
    import simplejson as json

from ninja_ide import resources
from ninja_ide.tools.logger import NinjaLogger

logger = NinjaLogger("ninja_ide.core.plugin_manager")
REQUIREMENTS = "requirements.txt"
COMMAND_FOR_PIP_INSTALL = "pip install -r %s"


class ServiceLocator(object):

    """
    Hold the services and allows the interaction between NINJA-IDE and plugins
    """

    def __init__(self, services=None):
        self.__services = services if services else {}

    def get_service(self, name):
        return self.__services.get(name)
Ejemplo n.º 15
0
from PyQt4.QtGui import QMessageBox
from PyQt4.QtGui import QIcon
from PyQt4.QtGui import QCompleter
from PyQt4.QtGui import QDirModel
from PyQt4.QtCore import Qt
from PyQt4.QtCore import SIGNAL
from PyQt4.QtCore import QThread
from PyQt4.QtCore import QDir

from ninja_ide.core import plugin_manager
from ninja_ide.core.file_handling import file_manager
from ninja_ide.tools import ui_tools
from ninja_ide import translations
from ninja_ide.tools.logger import NinjaLogger

logger = NinjaLogger('ninja_ide.gui.dialogs.plugin_manager')

HTML_STYLE = """
<html>
<body>
    <h2>{name}</h2>
    <p><i>Version: {version}</i></p>
    <h3>{description}</h3>
    <br><p><b>Author:</b> {author}</p>
    <p>More info about the Plugin: <a href='{link}'>Website</a></p>
</body>
</html>
"""


def _get_plugin(plugin_name, plugin_list):
Ejemplo n.º 16
0
# NINJA-IDE is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NINJA-IDE; If not, see <http://www.gnu.org/licenses/>.

from __future__ import absolute_import

#import fsevents
#from PyQt4.QtCore import SIGNAL

from ninja_ide.tools.logger import NinjaLogger

logger = NinjaLogger('ninja_ide.core.filesystem_notifications.darwin')
DEBUG = logger.debug

from ninja_ide.core.filesystem_notifications import base_watcher

ADDED = base_watcher.ADDED
DELETED = base_watcher.DELETED
REMOVE = base_watcher.REMOVE
RENAME = base_watcher.RENAME
MODIFIED = base_watcher.MODIFIED


class NinjaFileSystemWatcher(base_watcher.BaseWatcher):
    def __init__(self):
        super(NinjaFileSystemWatcher, self).__init__()
        #self.observer = fsevents.Observer()
Ejemplo n.º 17
0
from PyQt4.QtGui import QListWidget
from PyQt4.QtGui import QCompleter
from PyQt4.QtGui import QDirModel
from PyQt4.QtGui import QPixmap
from PyQt4.QtCore import Qt
from PyQt4.QtCore import SIGNAL

from ninja_ide import resources
from ninja_ide.core import settings
from ninja_ide.core import plugin_interfaces
from ninja_ide.core import file_manager
from ninja_ide.tools import json_manager
from ninja_ide.tools.logger import NinjaLogger


logger = NinjaLogger('ninja_ide.gui.dialogs.wizard_new_project')
logger.info("loaded")
DEBUG = logger.debug


###############################################################################
# Wizard handler and Python Project handler
###############################################################################

class WizardNewProject(QWizard):
    """
    Wizard to create a new project (of any kind), it implements the base
    behavior. Also, it set two special projects type handler
    (PythonProjectHandler, ImportFromSourcesProjectHandler)
    """
    def __init__(self, parent):
Ejemplo n.º 18
0
from ninja_ide import resources
from ninja_ide.core import file_manager
from ninja_ide.core import settings
from ninja_ide.core.filesystem_notifications import NinjaFileSystemWatcher
from ninja_ide.gui.main_panel import tab_widget
from ninja_ide.gui.editor import editor
from ninja_ide.gui.editor import highlighter
from ninja_ide.gui.editor import helpers
from ninja_ide.gui.main_panel import browser_widget
from ninja_ide.gui.main_panel import image_viewer
from ninja_ide.tools import runner

from ninja_ide.tools.logger import NinjaLogger

logger = NinjaLogger('ninja_ide.gui.main_panel.main_container')

__mainContainerInstance = None


def MainContainer(*args, **kw):
    global __mainContainerInstance
    if __mainContainerInstance is None:
        __mainContainerInstance = __MainContainer(*args, **kw)
    return __mainContainerInstance


class __MainContainer(QSplitter):

###############################################################################
# MainContainer SIGNALS
Ejemplo n.º 19
0
#
# You should have received a copy of the GNU General Public License
# along with NINJA-IDE; If not, see <http://www.gnu.org/licenses/>.

import _ast
from PyQt5.QtCore import (QThread, pyqtSignal, QTimer)
from ninja_ide.gui.editor.checkers import (register_checker, remove_checker)
from ninja_ide import resources
from ninja_ide import translations
from ninja_ide.core import settings
from ninja_ide.dependencies.pyflakes_mod import checker
from ninja_ide.tools import ui_tools
from ninja_ide.tools.logger import NinjaLogger
from ninja_ide.core.file_handling import file_manager

logger = NinjaLogger(__file__)


class ErrorsChecker(QThread):

    checkerCompleted = pyqtSignal()

    def __init__(self, neditor):
        super().__init__()
        self._neditor = neditor
        self._path = ''
        self.checks = {}

        self.checker_icon = ui_tools.colored_icon(
            ":img/bicho", resources.get_color('ErrorUnderline'))
Ejemplo n.º 20
0
from PyQt4.QtCore import Qt
from PyQt4.QtCore import SIGNAL
from PyQt4.QtCore import QDir

from ninja_ide import resources
from ninja_ide.core import settings
from ninja_ide.core import file_manager
from ninja_ide.core.filesystem_notifications.base_watcher import MODIFIED, \
                                                                DELETED
from ninja_ide.core.filesystem_notifications import NinjaFileSystemWatcher
from ninja_ide.gui.editor import editor
from ninja_ide.gui.main_panel import browser_widget

from ninja_ide.tools.logger import NinjaLogger

logger = NinjaLogger('ninja_ide.gui.main_panel.tab_widget')
DEBUG = logger.debug


class TabWidget(QTabWidget):

###############################################################################
# TabWidget SIGNALS
###############################################################################
    """
    tabCloseRequested(int)
    dropTab(QTabWidget)
    saveActualEditor()
    allTabsClosed()
    changeActualTab(QTabWidget)
    splitTab(QTabWidget, int, bool)
Ejemplo n.º 21
0
from PyQt4.Qsci import (QsciLexerBash, QsciLexerBatch,
                        QsciLexerCMake, QsciLexerCPP, QsciLexerCSS,
                        QsciLexerCSharp, 
                        QsciLexerD, QsciLexerDiff, QsciLexerFortran,
                        QsciLexerFortran77, QsciLexerHTML, QsciLexerIDL,
                        QsciLexerJava, QsciLexerJavaScript, QsciLexerLua,
                        QsciLexerMakefile, QsciLexerMatlab, QsciLexerOctave,
                        QsciLexerPOV, QsciLexerPascal,
                        QsciLexerPerl, QsciLexerPostScript, QsciLexerProperties,
                        QsciLexerPython, QsciLexerRuby, QsciLexerSQL,
                        QsciLexerSpice, QsciLexerTCL, QsciLexerTeX,
                        QsciLexerVHDL, QsciLexerVerilog, QsciLexerXML,
                        QsciLexerYAML)

from ninja_ide.tools.logger import NinjaLogger
logger = NinjaLogger('ninja_ide.gui.editor.extended_lexers.all_lexers')

pattern = re.compile(r'^([A-Z]).+$')


class BaseNinjaLexer(object):
    """WARNING: Only use this as the first part of a Lexer mixin"""

    def __init__(self, *args, **kwargs):
        self._settings_colored = None
        super(BaseNinjaLexer, self).__init__(*args, **kwargs)

    def initialize_color_scheme(self):
        self.scheme = {}
        self.background_color = QColor(resources.COLOR_SCHEME["EditorBackground"])
        detected_values = []
Ejemplo n.º 22
0
from ninja_ide.gui.ide import IDE
from ninja_ide.gui.editor import syntax_highlighter
from ninja_ide.gui.editor.syntaxes import python_syntax
#from ninja_ide.tools.completion import completer
#from ninja_ide.tools.completion import completer_widget

from ninja_ide.tools.logger import NinjaLogger

try:
    # For Python2
    str = unicode  # lint:ok
except NameError:
    # We are in Python3
    pass

logger = NinjaLogger('ninja_ide.gui.misc.console_widget')

BRACES = {"'": "'", '"': '"', '{': '}', '[': ']', '(': ')'}


class ConsoleWidget(QPlainTextEdit):
    def __init__(self):
        super(ConsoleWidget, self).__init__('>>> ')
        self.setUndoRedoEnabled(False)
        self.apply_editor_style()
        self.setToolTip(self.tr("Show/Hide (F4)"))
        self.moveCursor(QTextCursor.EndOfLine)

        self._patIsWord = re.compile('\w+')
        self.prompt = '>>> '
        self._console = console.Console()
Ejemplo n.º 23
0
from PyQt4.QtGui import QSystemTrayIcon
from PyQt4.QtGui import QAction
from PyQt4.QtGui import QMenu
from PyQt4.QtGui import QIcon
from PyQt4.QtGui import QMessageBox
from PyQt4.QtCore import QThread
from PyQt4.QtCore import SIGNAL

import ninja_ide
from ninja_ide import resources
from ninja_ide.core import settings
from ninja_ide.tools import json_manager
from ninja_ide.tools.logger import NinjaLogger

logger = NinjaLogger('ninja_ide.gui.updates')


class TrayIconUpdates(QSystemTrayIcon):

    def __init__(self, parent):
        QSystemTrayIcon.__init__(self, parent)
        icon = QIcon(resources.IMAGES['iconUpdate'])
        self.setIcon(icon)
        self.setup_menu()
        self.ide_version = '0'
        self.download_link = ''

        if settings.NOTIFY_UPDATES:
            self.thread = ThreadUpdates()
Ejemplo n.º 24
0
from ninja_ide.gui.main_panel import start_page
from ninja_ide.gui.main_panel import files_handler
from ninja_ide.gui.main_panel import add_file_folder
from ninja_ide.gui.main_panel import image_viewer
from ninja_ide.gui.main_panel import combo_editor
from ninja_ide.gui.main_panel.helpers import split_orientation
# from ninja_ide.gui.dialogs import from_import_dialog
from ninja_ide.tools.locator import (
    # locator,
    locator_widget)
# from ninja_ide.tools import runner
from ninja_ide.tools import ui_tools

from ninja_ide.tools.logger import NinjaLogger

logger = NinjaLogger('ninja_ide.gui.main_panel.main_container')


class _MainContainer(QWidget):

    ###############################################################################
    # MainContainer SIGNALS
    ###############################################################################
    """
    newFileOpened(QString)
    allTabClosed()
    runFile(QString)
    addToProject(QString)
    showFileInExplorer(QString)
    recentTabsModified()
    currentEditorChanged(QString)
Ejemplo n.º 25
0
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NINJA-IDE; If not, see <http://www.gnu.org/licenses/>.

from __future__ import absolute_import

from PyQt4.QtGui import QWidget
from PyQt4.QtGui import QTabWidget
from PyQt4.QtGui import QVBoxLayout

from ninja_ide.core import plugin_manager

from ninja_ide.tools.logger import NinjaLogger

logger = NinjaLogger('ninja_ide.gui.misc.plugin_preferences')


class PluginPreferences(QWidget):
    """
    Plugins section widget in NINJA-IDE Preferences
    """
    def __init__(self):
        QWidget.__init__(self)
        self.plugin_manager = plugin_manager.PluginManager()
        vbox = QVBoxLayout(self)
        self._tabs = QTabWidget()
        vbox.addWidget(self._tabs)
        # load widgets
        self._load_widgets()
Ejemplo n.º 26
0
                         QBrush, QPixmap, QPixmapCache, QIcon, QPen, QColor,
                         QImage, QKeySequence, qGray, qRgba, qAlpha)
from PyQt5.QtPrintSupport import (QPrinter, QPrintPreviewDialog)
from PyQt5.QtCore import (Qt, QSize, QDir, QUrl, QObject, QThread, pyqtSignal,
                          QEvent, QTimeLine, QTimer, QRect, QPoint,
                          QPropertyAnimation, QAbstractAnimation)

from ninja_ide import resources
from ninja_ide.core import settings
from ninja_ide.core.file_handling import file_manager
from ninja_ide.core.file_handling.file_manager import NinjaIOException
from ninja_ide.tools import json_manager

from ninja_ide.tools.logger import NinjaLogger

logger = NinjaLogger('ninja_ide.tools.ui_tools')


class NComboBox(QComboBox):
    def paintEvent(self, event):
        super().paintEvent(event)
        # painter = QStylePainter(self)
        # opt = QStyleOptionComboBox()
        # self.initStyleOption(opt)
        # arrow_rect = QRect((opt.rect.left() + opt.rect.right()) / 2 + 6,
        #                    opt.rect.center().y(), 7, 7)
        # arrow_rect.moveRight(opt.rect.width() - 10)
        # opt.rect = arrow_rect
        # opt.rect.translate(0, -6)
        # painter.drawPrimitive(QStyle.PE_IndicatorArrowUp, opt)
        # opt.rect.translate(0, 6)
Ejemplo n.º 27
0
from PyQt4.QtCore import QThread
from PyQt4.QtCore import Qt
from PyQt4.QtCore import QDir
from PyQt4.QtCore import QFile
from PyQt4.QtCore import QTextStream
from PyQt4.QtCore import SIGNAL

from ninja_ide import resources
from ninja_ide import translations
from ninja_ide.gui.ide import IDE
from ninja_ide.core.file_handling import file_manager
from ninja_ide.core import settings

from ninja_ide.tools.logger import NinjaLogger

logger = NinjaLogger('ninja_ide.tools.locator')

mapping_locations = {}

#@ FILES
#< CLASSES
#> FUNCTIONS
#- MODULE ATTRIBUTES
#! NO PYTHON FILES
#. SYMBOLS IN THIS FILE
#/ TABS OPENED
#: LINE NUMBER
FILTERS = {
    'files': '@',
    'classes': '<',
    'functions': '>',
Ejemplo n.º 28
0
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NINJA-IDE; If not, see <http://www.gnu.org/licenses/>.
#Based in pycomplete emacs module.

from __future__ import absolute_import

import sys
import types
#import inspect
import StringIO
from ninja_ide.tools.logger import NinjaLogger

logger = NinjaLogger('ninja_ide.tools.completion.completer')

_HELPOUT = StringIO.StringIO
_STDOUT = sys.stdout


def get_completions_per_type(object_dir):
    '''Return info about function parameters'''

    if not object_dir:
        return {}
    result = {'attributes': [], 'modules': [], 'functions': [], 'classes': []}
    type_assign = {
        types.ClassType: 'classes',
        types.FunctionType: 'functions',
        types.MethodType: 'functions',
Ejemplo n.º 29
0
# along with NINJA-IDE; If not, see <http://www.gnu.org/licenses/>.

import os
import shutil
from PyQt5.QtCore import (QObject, QFile, QFileSystemWatcher, QIODevice,
                          QTextStream, pyqtSignal)

from ninja_ide import translations
# FIXME: Obtain these form a getter
from ninja_ide.core import settings
from ninja_ide.tools.utils import SignalFlowControl
from .file_manager import NinjaIOException, NinjaNoFileNameException, \
    get_file_encoding, get_basename, get_file_extension

from ninja_ide.tools.logger import NinjaLogger
logger = NinjaLogger('ninja_ide.core.file_handling.nfile')
DEBUG = logger.debug
"""
How to continue:
    We need to have a filesystem representation object, said object, registers
    himself into the IDE on its __init__.py, thus avoiding all kinds of
    circular imports, this way all objects should start registering themselves
    and fail individually if they cant.
    So, to this object, whoever creates new NFiles should ask for a it, this
    way it keeps record of the files and can do closing when receives
    terminate from the ide, and decides to call a changed callback from each
    file when the watched, that should deppend on it notifies a change.
"""


class NFile(QObject):
Ejemplo n.º 30
0
from PyQt4.QtGui import QStyle
from PyQt4.QtGui import QIcon
from PyQt4.QtGui import QShortcut
from PyQt4.QtCore import SIGNAL
from PyQt4.QtCore import Qt

from ninja_ide import resources
from ninja_ide.core import settings
from ninja_ide.tools import locator
from ninja_ide.tools import ui_tools
from ninja_ide.gui import actions
from ninja_ide.gui.ide import IDE
from ninja_ide.gui.main_panel import main_container
from ninja_ide.tools.logger import NinjaLogger

logger = NinjaLogger('ninja_ide.gui.status_bar')
DEBUG = logger.debug


class _StatusBar(QStatusBar):
    def __init__(self):
        super(_StatusBar, self).__init__()

        self._widgetStatus = QWidget()
        vbox = QVBoxLayout(self._widgetStatus)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        #Search Layout
        self._searchWidget = SearchWidget(self)
        vbox.addWidget(self._searchWidget)
        #Replace Layout
from PyQt4.QtGui import QIcon
from PyQt4.QtGui import QFileDialog
from PyQt4.QtGui import QMessageBox
from PyQt4.QtGui import QSpinBox
from PyQt4.QtGui import QCheckBox
from PyQt4.QtCore import SIGNAL
from PyQt4.QtCore import Qt

from ninja_ide import resources
from ninja_ide.core import file_manager
from ninja_ide.core import settings
from ninja_ide.tools import json_manager
from ninja_ide.tools import ui_tools

from ninja_ide.tools.logger import NinjaLogger
logger = NinjaLogger('ninja_ide.gui.dialogs.project_properties_widget')
DEBUG = logger.debug


class ProjectProperties(QDialog):
    def __init__(self, item, parent=None):
        QDialog.__init__(self, parent, Qt.Dialog)
        self._item = item
        self.setWindowTitle(self.tr("Project Properties"))
        vbox = QVBoxLayout(self)
        self.tab_widget = QTabWidget()
        self.projectData = ProjectData(self)
        self.projectExecution = ProjectExecution(self)
        self.projectMetadata = ProjectMetadata(self)
        self.tab_widget.addTab(self.projectData, self.tr("Project Data"))
        self.tab_widget.addTab(self.projectExecution,
Ejemplo n.º 32
0
#
# You should have received a copy of the GNU General Public License
# along with NINJA-IDE; If not, see <http://www.gnu.org/licenses/>.

import os
try:
    import json
except ImportError:
    import simplejson as json

from ninja_ide import resources
from ninja_ide.core import settings

from ninja_ide.tools.logger import NinjaLogger

logger = NinjaLogger('ninja_ide.tools.json_manager')


def parse(descriptor):
    try:
        return json.load(descriptor)
    except:
        logger.error("The file couldn't be parsed'")
        logger.error(descriptor)
    return {}


def load_syntax():
    files = os.listdir(resources.SYNTAX_FILES)
    for f in files:
        if f.endswith('.json'):
Ejemplo n.º 33
0
# from ninja_ide.gui.dialogs import language_manager
# from ninja_ide.gui.dialogs import session_manager
from ninja_ide.gui.dialogs.preferences import preferences
# from ninja_ide.gui.dialogs import traceback_widget
# from ninja_ide.gui.dialogs import python_detect_dialog
# from ninja_ide.gui.dialogs import plugins_store
from ninja_ide.tools import ui_tools
# from ninja_ide.tools.completion import completion_daemon

###############################################################################
# LOGGER INITIALIZE
###############################################################################

from ninja_ide.tools.logger import NinjaLogger

logger = NinjaLogger('ninja_ide.gui.ide')
logger.setLevel(10)

###############################################################################
# IDE: MAIN CONTAINER
###############################################################################


class IDE(QMainWindow):
    """This class is like the Sauron's Ring:
    One ring to rule them all, One ring to find them,
    One ring to bring them all and in the darkness bind them.

    This Class knows all the containers, and its know by all the containers,
    but the containers don't need to know between each other, in this way we
    can keep a better api without the need to tie the behaviour between
Ejemplo n.º 34
0
from ninja_ide.gui.main_panel import actions
from ninja_ide.gui.main_panel import combo_editor
from ninja_ide.gui.main_panel import add_file_folder
from ninja_ide.gui.main_panel import start_page
from ninja_ide.gui.dialogs import from_import_dialog
from ninja_ide.gui.main_panel import image_viewer
from ninja_ide.gui.main_panel import files_handler
from ninja_ide.gui.main_panel.helpers import split_orientation
from ninja_ide.gui import dynamic_splitter
from ninja_ide import translations
from ninja_ide.tools.logger import NinjaLogger
from ninja_ide.gui.editor import editor
from ninja_ide.core.file_handling import file_manager
from ninja_ide.tools.locator import locator_widget

logger = NinjaLogger('main_panel.main_container')


class _MainContainer(QWidget):

    currentEditorChanged = pyqtSignal(str)
    fileOpened = pyqtSignal(str)
    beforeFileSaved = pyqtSignal(str)
    fileSaved = pyqtSignal(str)
    runFile = pyqtSignal(str)
    showFileInExplorer = pyqtSignal(str)
    addToProject = pyqtSignal(str)
    allFilesClosed = pyqtSignal()

    def __init__(self, parent=None):
        super().__init__(parent)
Ejemplo n.º 35
0
import json
import zipfile
import traceback
#lint:disable
try:
    from urllib.request import urlopen
    from urllib.error import URLError
except ImportError:
    from urllib2 import urlopen
    from urllib2 import URLError
#lint:enable

from ninja_ide import resources
from ninja_ide.tools.logger import NinjaLogger

logger = NinjaLogger('ninja_ide.core.plugin_manager')
REQUIREMENTS = 'requirements.txt'
COMMAND_FOR_PIP_INSTALL = 'pip install -r %s'
try:
    # For Python2
    str = unicode  # lint:ok
except NameError:
    # We are in Python3
    pass


class ServiceLocator(object):

    '''
    Hold the services and allows the interaction between NINJA-IDE and plugins
    '''
Ejemplo n.º 36
0
#NINJA-IDE Menus
from ninja_ide.gui.menus import menu_about
from ninja_ide.gui.menus import menu_file
from ninja_ide.gui.menus import menu_edit
from ninja_ide.gui.menus import menu_view
from ninja_ide.gui.menus import menu_plugins
from ninja_ide.gui.menus import menu_project
from ninja_ide.gui.menus import menu_source

###############################################################################
# LOGGER INITIALIZE
###############################################################################

from ninja_ide.tools.logger import NinjaLogger

logger = NinjaLogger('ninja_ide.gui.ide')

###############################################################################
# IDE: MAIN CONTAINER
###############################################################################
__ideInstance = None
#Save cursor flash time to restore it on close (necessary for Windows)
cursor_flash_time = 0


def IDE(*args, **kw):
    global __ideInstance
    if __ideInstance is None:
        __ideInstance = __IDE(*args, **kw)
    return __ideInstance
Ejemplo n.º 37
0
#
# NINJA-IDE is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NINJA-IDE; If not, see <http://www.gnu.org/licenses/>.
import _ast
import ast

from ninja_ide.intellisensei.analyzer import model

from ninja_ide.tools.logger import NinjaLogger

logger_imports = NinjaLogger('ninja_ide.tools.introspection.obtaining_imports')
logger_symbols = NinjaLogger('ninja_ide.tools.introspection.obtaining_symbols')

_map_type = {
    _ast.Tuple: 'tuple',
    _ast.List: 'list',
    _ast.Str: 'str',
    _ast.Dict: 'dict',
    _ast.Num: 'int',
    _ast.Call: 'function()',
}


def _parse_assign(symbol):
    assigns = {}
    attributes = {}
Ejemplo n.º 38
0
import re
import uuid

from PyQt5.QtWidgets import (
    QWidget,
    QVBoxLayout
)
from PyQt5.QtCore import Qt, QTimer
from PyQt5.QtQuickWidgets import QQuickWidget

from ninja_ide import resources
from ninja_ide.gui.ide import IDE
from ninja_ide.tools import ui_tools
from ninja_ide.tools.locator import locator
from ninja_ide.tools.logger import NinjaLogger
logger = NinjaLogger(__name__)


class FilesHandler(QWidget):

    def __init__(self, parent=None):
        super(FilesHandler, self).__init__(
            None, Qt.FramelessWindowHint | Qt.Popup)
        self.setAttribute(Qt.WA_TranslucentBackground)
        self._main_container = parent
        # Create the QML user interface.
        self.setFixedHeight(300)
        self.setFixedWidth(400)
        self.view = QQuickWidget()
        self.view.rootContext().setContextProperty(
            "theme", resources.QML_COLORS)
Ejemplo n.º 39
0
# from ninja_ide.gui.dialogs import language_manager
from ninja_ide.gui.dialogs import session_manager
from ninja_ide.gui.dialogs.preferences import preferences
# from ninja_ide.gui.dialogs import traceback_widget
# from ninja_ide.gui.dialogs import python_detect_dialog
# from ninja_ide.gui.dialogs import plugins_store
from ninja_ide.tools import ui_tools
# from ninja_ide.tools.completion import completion_daemon

###############################################################################
# LOGGER INITIALIZE
###############################################################################

from ninja_ide.tools.logger import NinjaLogger

logger = NinjaLogger('ninja_ide.gui.ide')
logger.setLevel(10)

###############################################################################
# IDE: MAIN CONTAINER
###############################################################################


class IDE(QMainWindow):
    """This class is like the Sauron's Ring:
    One ring to rule them all, One ring to find them,
    One ring to bring them all and in the darkness bind them.

    This Class knows all the containers, and its know by all the containers,
    but the containers don't need to know between each other, in this way we
    can keep a better api without the need to tie the behaviour between