222 lines
5.5 KiB
Cython
222 lines
5.5 KiB
Cython
"""
|
|
|
|
Enumerations
|
|
============
|
|
|
|
.. _Ewe_Entry_Regex_Toggles:
|
|
|
|
Regex Flags
|
|
-------------
|
|
|
|
.. data:: EWE_REG_EXTENDED
|
|
|
|
Regex check option: Use Extended Regular Expressions.
|
|
|
|
.. data:: EWE_REG_ICASE
|
|
|
|
Regex check option: Ignore case in match.
|
|
|
|
|
|
.. _Ewe_Entry_Regex_Status:
|
|
|
|
Regex Status
|
|
------------
|
|
|
|
.. data:: EWE_REG_NOERROR
|
|
|
|
Regex Success: Regex maches to the Entrys text
|
|
|
|
.. data:: EWE_REG_NOMATCH
|
|
|
|
Regex Error: regexec() failed to match.
|
|
|
|
.. data:: EWE_REG_BADPAT
|
|
|
|
Regex Error: Invalid regular expression.
|
|
|
|
.. data:: EWE_REG_ECOLLATE
|
|
|
|
Regex Error: Invalid collating element referenced.
|
|
|
|
.. data:: EWE_REG_ECTYPE
|
|
|
|
Regex Error: Invalid character class type referenced.
|
|
|
|
.. data:: EWE_REG_EESCAPE
|
|
|
|
Regex Error: Trailing \ in pattern.
|
|
|
|
.. data:: EWE_REG_ESUBREG
|
|
|
|
Regex Error: Wrong back reference.
|
|
|
|
.. data:: EWE_REG_EBRACK
|
|
|
|
Regex Error: [ ] imbalance.
|
|
|
|
.. data:: EWE_REG_EPAREN
|
|
|
|
Regex Error: \( \) or ( ) imbalance.
|
|
|
|
.. data:: EWE_REG_EBRACE
|
|
|
|
Regex Error: \{ \} imbalance.
|
|
|
|
.. data:: EWE_REG_BADBR
|
|
|
|
Regex Error: Content of \{ \} invalid: not a number, number too large, more than two numbers, first larger than second.
|
|
|
|
.. data:: EWE_REG_ERANGE
|
|
|
|
Regex Error: Invalid endpoint in range expression.
|
|
|
|
.. data:: EWE_REG_ESPACE
|
|
|
|
Regex Error: Out of memory.
|
|
|
|
.. data:: EWE_REG_BADRPT
|
|
|
|
Regex Error: ?, * or + not preceded by valid regular expression.
|
|
|
|
"""
|
|
|
|
from efl.elementary.entry cimport Entry as elmEntry
|
|
from cpython cimport PyUnicode_AsUTF8String
|
|
from efl.utils.conversions cimport _ctouni
|
|
from efl.evas cimport Object as evasObject
|
|
|
|
cimport enums
|
|
|
|
EWE_REG_EXTENDED = enums.EWE_REG_EXTENDED
|
|
EWE_REG_ICASE = enums.EWE_REG_ICASE
|
|
|
|
EWE_REG_NOERROR = enums.EWE_REG_NOERROR
|
|
EWE_REG_NOMATCH = enums.EWE_REG_NOMATCH
|
|
EWE_REG_BADPAT = enums.EWE_REG_BADPAT
|
|
EWE_REG_ECOLLATE = enums.EWE_REG_ECOLLATE
|
|
EWE_REG_ECTYPE = enums.EWE_REG_ECTYPE
|
|
EWE_REG_EESCAPE = enums.EWE_REG_EESCAPE
|
|
EWE_REG_ESUBREG = enums.EWE_REG_ESUBREG
|
|
EWE_REG_EBRACK = enums.EWE_REG_EBRACK
|
|
EWE_REG_EPAREN = enums.EWE_REG_EPAREN
|
|
EWE_REG_EBRACE = enums.EWE_REG_EBRACE
|
|
EWE_REG_BADBR = enums.EWE_REG_BADBR
|
|
EWE_REG_ERANGE = enums.EWE_REG_ERANGE
|
|
EWE_REG_ESPACE = enums.EWE_REG_ESPACE
|
|
EWE_REG_BADRPT = enums.EWE_REG_BADRPT
|
|
|
|
cdef class Entry(elmEntry):
|
|
|
|
def __init__(self, evasObject parent not None, **kwargs):
|
|
"""This adds an entry to @p parent object.
|
|
|
|
By default, entries are:
|
|
|
|
- not scrolled
|
|
- multi-line
|
|
- word wrapped
|
|
- autosave is enabled
|
|
|
|
:param parent: The parent object
|
|
|
|
"""
|
|
self._set_obj(ewe_entry_add(parent.obj))
|
|
self._set_properties_from_keyword_args(kwargs)
|
|
|
|
def regex_set(self, regex_str not None, int flags):
|
|
"""Set regular expresion to be compiled and used.
|
|
|
|
:param regex_str: The text of regular expresion
|
|
:param flags: Compile flags for regex
|
|
:type flags: int value from or'ed :ref:`Ewe_Entry_Regex_Toggles`
|
|
:return: True on success, otherwise returns False.
|
|
|
|
"""
|
|
if isinstance(regex_str, unicode):
|
|
regex_str = PyUnicode_AsUTF8String(regex_str)
|
|
return bool(ewe_entry_regex_set(
|
|
self.obj,
|
|
<const char *>regex_str,
|
|
flags
|
|
))
|
|
|
|
def regex_unset(self):
|
|
"""Unset previoustly set regular expresion.
|
|
|
|
:return: True on success, otherwise returns False.
|
|
|
|
"""
|
|
return bool(ewe_entry_regex_unset(self.obj))
|
|
|
|
def regex_check(self):
|
|
"""Check current text of Entry with previoustly set regular expresion.
|
|
|
|
:return: True on success, otherwise returns False.
|
|
|
|
"""
|
|
return bool(ewe_entry_regex_check(self.obj))
|
|
|
|
property regex_glow:
|
|
"""Set if regex error signals for EDJE should be emitted.
|
|
|
|
:type: bool
|
|
|
|
"""
|
|
def __set__(self, bint glow):
|
|
if not ewe_entry_regex_glow_set(self.obj, glow):
|
|
raise RuntimeError("glow could not be set")
|
|
|
|
def __get__(self):
|
|
return bool(ewe_entry_regex_glow_get(self.obj))
|
|
|
|
def regex_error_get(self):
|
|
"""Returns last regex error
|
|
|
|
:return: The last regex error.
|
|
|
|
"""
|
|
return ewe_entry_regex_error_get(self.obj)
|
|
|
|
def regex_error_text_get(self):
|
|
"""Returns the string that contains last regex error.
|
|
This message updates on each regex setting and checking.
|
|
The string is deleted on Entry object deleteon.
|
|
|
|
:return: The last regex error. If regex is not set yet None would be returned.
|
|
|
|
"""
|
|
return _ctouni(ewe_entry_regex_error_text_get(self.obj))
|
|
|
|
property regex_autocheck:
|
|
"""Automatic regex check on "entry,changed".
|
|
|
|
Signals will be processed only for focused entry.
|
|
|
|
:type: bool
|
|
|
|
"""
|
|
def __set__(self, bint autocheck):
|
|
if not ewe_entry_regex_autocheck_set(self.obj, autocheck):
|
|
raise RuntimeError("could not enable autocheck")
|
|
|
|
def __get__(self):
|
|
return bool(ewe_entry_regex_autocheck_get(self.obj))
|
|
|
|
property entry:
|
|
"""This sets the text displayed within the entry to @p entry.
|
|
|
|
:param entry: The text to be displayed
|
|
|
|
.. note:: Using this function bypasses text filters
|
|
|
|
"""
|
|
def __get__(self):
|
|
return elmEntry.entry.__get__(self)
|
|
|
|
def __set__(self, text):
|
|
if isinstance(text, unicode): text = PyUnicode_AsUTF8String(text)
|
|
ewe_entry_entry_set(
|
|
self.obj,
|
|
<const char *>text if text is not None else NULL
|
|
)
|