Add TextType to ease gui generation

TextType is intended for formatted text (multiple lines),
whereas StringType is intended for a single line of text (without '\n')

Change-Id: Ibce29ae6b4e426bd8685f2cf7ff6966d81b0c6aa
Reviewed-on: https://forge.frm2.tum.de/review/20951
Tested-by: JenkinsCodeReview <bjoern_pedersen@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
This commit is contained in:
Enrico Faulhaber
2019-07-24 14:02:00 +02:00
parent 95d50fb51e
commit c7c9403d1f
3 changed files with 57 additions and 4 deletions

View File

@ -408,7 +408,7 @@ class StringType(DataType):
def __init__(self, minsize=0, maxsize=None):
if maxsize is None:
maxsize = minsize or 255*256
maxsize = minsize or 100
self.minsize = int(minsize)
self.maxsize = int(maxsize)
if self.minsize < 0:
@ -456,6 +456,20 @@ class StringType(DataType):
return repr(value)
# TextType is a special StringType intended for longer texts (i.e. embedding \n),
# whereas StringType is supposed to not contain '\n'
# unfortunately, SECoP makes no distinction here....
# note: content is supposed to follow the format of a git commit message, i.e. a line of text, 2 '\n' + a longer explanation
class TextType(StringType):
def __init__(self, maxsize=None):
if maxsize is None:
maxsize = 8000
super(TextType, self).__init__(0, maxsize)
def __repr__(self):
return u'TextType(%d, %d)' % (self.minsize, self.maxsize)
# Bool is a special enum
class BoolType(DataType):
default = False