util/MiniTextControler.py
author Edouard Tisserant
Tue, 11 Sep 2018 16:08:21 +0200
changeset 2272 28b0a783975e
parent 1881 091005ec69c4
child 3750 f62625418bff
permissions -rw-r--r--
Change behaviour of python_eval function block : if TRIG is false, then ACK is also false except a pulse precisely when receiving answer from interpreter
1511
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1347
diff changeset
     1
#!/usr/bin/env python
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1347
diff changeset
     2
# -*- coding: utf-8 -*-
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1347
diff changeset
     3
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1347
diff changeset
     4
# This file is part of Beremiz, a Integrated Development Environment for
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1347
diff changeset
     5
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival.
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1347
diff changeset
     6
#
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1347
diff changeset
     7
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1347
diff changeset
     8
#
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1347
diff changeset
     9
# See COPYING file for copyrights details.
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1347
diff changeset
    10
#
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1347
diff changeset
    11
# This program is free software; you can redistribute it and/or
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1347
diff changeset
    12
# modify it under the terms of the GNU General Public License
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1347
diff changeset
    13
# as published by the Free Software Foundation; either version 2
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1347
diff changeset
    14
# of the License, or (at your option) any later version.
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1347
diff changeset
    15
#
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1347
diff changeset
    16
# This program is distributed in the hope that it will be useful,
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1347
diff changeset
    17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1347
diff changeset
    18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1347
diff changeset
    19
# GNU General Public License for more details.
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1347
diff changeset
    20
#
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1347
diff changeset
    21
# You should have received a copy of the GNU General Public License
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1347
diff changeset
    22
# along with this program; if not, write to the Free Software
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1347
diff changeset
    23
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1347
diff changeset
    24
14
eb9fdd316a40 More precise design for plugins.... to be continued...
etisserant
parents: 13
diff changeset
    25
"""
725
31dade089db5 refactoring
Edouard Tisserant
parents: 722
diff changeset
    26
Minimal tab controller for a simple text editor
14
eb9fdd316a40 More precise design for plugins.... to be continued...
etisserant
parents: 13
diff changeset
    27
"""
eb9fdd316a40 More precise design for plugins.... to be continued...
etisserant
parents: 13
diff changeset
    28
1881
091005ec69c4 fix pylint py3k conversion warning: "(no-absolute-import) import missing `from __future__ import absolute_import`"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1831
diff changeset
    29
091005ec69c4 fix pylint py3k conversion warning: "(no-absolute-import) import missing `from __future__ import absolute_import`"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1831
diff changeset
    30
from __future__ import absolute_import
725
31dade089db5 refactoring
Edouard Tisserant
parents: 722
diff changeset
    31
import os
14
eb9fdd316a40 More precise design for plugins.... to be continued...
etisserant
parents: 13
diff changeset
    32
1736
7e61baa047f0 clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1735
diff changeset
    33
1831
56b48961cc68 fix (old-style-class) Old-style class defined error for most parts of
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1744
diff changeset
    34
class MiniTextControler(object):
1735
c02818d7e29f clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1511
diff changeset
    35
806
abf1afc1f04d Fix bug when closing IECCodeView and IECRawCodeView, reopening them was impossible
laurent
parents: 725
diff changeset
    36
    def __init__(self, filepath, controller):
65
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    37
        self.FilePath = filepath
806
abf1afc1f04d Fix bug when closing IECCodeView and IECRawCodeView, reopening them was impossible
laurent
parents: 725
diff changeset
    38
        self.BaseController = controller
1735
c02818d7e29f clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1511
diff changeset
    39
806
abf1afc1f04d Fix bug when closing IECCodeView and IECRawCodeView, reopening them was impossible
laurent
parents: 725
diff changeset
    40
    def __del__(self):
abf1afc1f04d Fix bug when closing IECCodeView and IECRawCodeView, reopening them was impossible
laurent
parents: 725
diff changeset
    41
        self.BaseController = None
1735
c02818d7e29f clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1511
diff changeset
    42
718
5d4dc150b956 refactoring
Edouard Tisserant
parents: 717
diff changeset
    43
    def CTNFullName(self):
716
180e4a7d945c Adding search field for finding function or function block in library tree
laurent
parents: 715
diff changeset
    44
        return ""
1735
c02818d7e29f clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1511
diff changeset
    45
74
8a726a62fbfc Some bugs fixed
lbessard
parents: 66
diff changeset
    46
    def SetEditedElementText(self, tagname, text):
65
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    47
        file = open(self.FilePath, "w")
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    48
        file.write(text)
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    49
        file.close()
1735
c02818d7e29f clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1511
diff changeset
    50
1744
69dfdb26f600 clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1736
diff changeset
    51
    def GetEditedElementText(self, tagname, debug=False):
65
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    52
        if os.path.isfile(self.FilePath):
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    53
            file = open(self.FilePath, "r")
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    54
            text = file.read()
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    55
            file.close()
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    56
            return text
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    57
        return ""
1735
c02818d7e29f clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1511
diff changeset
    58
1744
69dfdb26f600 clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1736
diff changeset
    59
    def GetEditedElementInterfaceVars(self, tagname, tree=False, debug=False):
74
8a726a62fbfc Some bugs fixed
lbessard
parents: 66
diff changeset
    60
        return []
1735
c02818d7e29f clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1511
diff changeset
    61
1744
69dfdb26f600 clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1736
diff changeset
    62
    def GetEditedElementType(self, tagname, debug=False):
74
8a726a62fbfc Some bugs fixed
lbessard
parents: 66
diff changeset
    63
        return "program"
1735
c02818d7e29f clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1511
diff changeset
    64
1744
69dfdb26f600 clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1736
diff changeset
    65
    def GetBlockType(self, type, inputs=None, debug=False):
806
abf1afc1f04d Fix bug when closing IECCodeView and IECRawCodeView, reopening them was impossible
laurent
parents: 725
diff changeset
    66
        return self.BaseController.GetBlockType(type, inputs, debug)
1735
c02818d7e29f clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1511
diff changeset
    67
1744
69dfdb26f600 clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1736
diff changeset
    68
    def GetBlockTypes(self, tagname="", debug=False):
806
abf1afc1f04d Fix bug when closing IECCodeView and IECRawCodeView, reopening them was impossible
laurent
parents: 725
diff changeset
    69
        return self.BaseController.GetBlockTypes(tagname, debug)
1735
c02818d7e29f clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1511
diff changeset
    70
1744
69dfdb26f600 clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1736
diff changeset
    71
    def GetDataTypes(self, tagname="", basetypes=True, only_locatables=False, debug=False):
806
abf1afc1f04d Fix bug when closing IECCodeView and IECRawCodeView, reopening them was impossible
laurent
parents: 725
diff changeset
    72
        return self.BaseController.GetDataTypes(tagname, basetypes, only_locatables, debug)
1735
c02818d7e29f clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1511
diff changeset
    73
1744
69dfdb26f600 clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1736
diff changeset
    74
    def GetEnumeratedDataValues(self, debug=False):
806
abf1afc1f04d Fix bug when closing IECCodeView and IECRawCodeView, reopening them was impossible
laurent
parents: 725
diff changeset
    75
        return self.BaseController.GetEnumeratedDataValues(debug)
1735
c02818d7e29f clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1511
diff changeset
    76
65
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    77
    def StartBuffering(self):
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    78
        pass
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    79
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    80
    def EndBuffering(self):
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    81
        pass
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    82
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    83
    def BufferProject(self):
e55d6faee9d1 Adding icons in Beremiz GUI
lbessard
parents: 64
diff changeset
    84
        pass