summaryrefslogtreecommitdiff
path: root/doc/elementary/entry.rst
blob: f25708f5e132e20875462700184d8a015ae8f28f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
.. currentmodule:: efl.elementary

Entry
#####

.. image:: /images/entry-preview.png


Widget description
==================

An entry is a convenience widget which shows a box that the user can
enter text into.

Entries by default don't scroll, so they grow to accommodate the entire text,
resizing the parent window as needed. This can be changed with the property
:py:attr:`~efl.elementary.entry.Entry.scrollable`.

They can also be single line or multi line (the default) and when set
to multi line mode they support text wrapping in any of the modes
indicated by :ref:`Elm_Wrap_Type`.

Other features include password mode, filtering of inserted text with
:py:meth:`~efl.elementary.entry.Entry.markup_filter_append` and related
functions, inline "items" and formatted markup text.


Scrollable Interface
====================

This widget supports the scrollable interface.

If you wish to control the scolling behaviour using these functions,
inherit both the widget class and the
:py:class:`~efl.elementary.scroller.Scrollable` class
using multiple inheritance, for example::

    class ScrollableGenlist(Genlist, Scrollable):
        def __init__(self, canvas, *args, **kwargs):
            Genlist.__init__(self, canvas)


Formatted text
==============

The markup tags supported by the Entry are defined by the theme, but
even when writing new themes or extensions it's a good idea to stick to
a sane default, to maintain coherency and avoid application breakages.
Currently defined by the default theme are the following tags:

``<br>``
    Inserts a line break.
``<ps>``
    Inserts a paragraph separator. This is preferred over line
    breaks.
``<tab>``
    Inserts a tab.
``<em>...</em>``
    Emphasis. Sets the *oblique* style for the
    enclosed text.
``<b>...</b>``
    Sets the **bold** style for the enclosed text.
``<link>...</link>``
    Underlines the enclosed text.
``<hilight>...</hilight>``
    Highlights the enclosed text.


Special markups
===============

Besides those used to format text, entries support two special markup
tags used to insert click-able portions of text or items inlined within
the text.


Anchors
-------

Anchors are similar to HTML anchors. Text can be surrounded by <a> and
</a> tags and an event will be generated when this text is clicked,
like this::

    This text is outside <a href=anc-01>but this one is an anchor</a>

The ``href`` attribute in the opening tag gives the name that will be
used to identify the anchor and it can be any valid utf8 string.

When an anchor is clicked, an ``"anchor,clicked"`` signal is emitted with
an :py:class:`EntryAnchorInfo` in the ``event_info`` parameter for the
callback function. The same applies for ``anchor,in`` (mouse in),
``anchor,out`` (mouse out), ``anchor,down`` (mouse down), and ``anchor,up``
(mouse up) events on an anchor.


Items
-----

Inlined in the text, any other :py:class:`~efl.elementary.object.Object` can
be inserted by using ``<item>`` tags this way::

    <item size=16x16 vsize=full href=emoticon/haha></item>

Just like with anchors, the ``href`` identifies each item, but these need,
in addition, to indicate their size, which is done using any one of
``size``, ``absize`` or ``relsize`` attributes. These attributes take their
value in the WxH format, where W is the width and H the height of the
item.

- absize: Absolute pixel size for the item. Whatever value is set will
  be the item's size regardless of any scale value the object may have
  been set to. The final line height will be adjusted to fit larger items.
- size: Similar to *absize*, but it's adjusted to the scale value set
  for the object.
- relsize: Size is adjusted for the item to fit within the current
  line height.

Besides their size, items are specified a ``vsize`` value that affects
how their final size and position are calculated. The possible values
are:

- ``ascent``: Item will be placed within the line's baseline and its
  ascent. That is, the height between the line where all characters are
  positioned and the highest point in the line. For ``size`` and
  ``absize`` items, the descent value will be added to the total line
  height to make them fit. ``relsize`` items will be adjusted to fit
  within this space.
- ``full``: Items will be placed between the descent and ascent, or the
  lowest point in the line and its highest.

After the size for an item is calculated, the entry will request an object to
place in its space. For this, the functions set with
:py:meth:`~efl.elementary.entry.Entry.item_provider_append` and related
functions will be called in order until one of them returns a non-*None* value.
If no providers are available, or all of them return *None*, then the entry
falls back to one of the internal defaults, provided the name matches with one
of them.

All of the following are currently supported:

- emoticon/angry
- emoticon/angry-shout
- emoticon/crazy-laugh
- emoticon/evil-laugh
- emoticon/evil
- emoticon/goggle-smile
- emoticon/grumpy
- emoticon/grumpy-smile
- emoticon/guilty
- emoticon/guilty-smile
- emoticon/haha
- emoticon/half-smile
- emoticon/happy-panting
- emoticon/happy
- emoticon/indifferent
- emoticon/kiss
- emoticon/knowing-grin
- emoticon/laugh
- emoticon/little-bit-sorry
- emoticon/love-lots
- emoticon/love
- emoticon/minimal-smile
- emoticon/not-happy
- emoticon/not-impressed
- emoticon/omg
- emoticon/opensmile
- emoticon/smile
- emoticon/sorry
- emoticon/squint-laugh
- emoticon/surprised
- emoticon/suspicious
- emoticon/tongue-dangling
- emoticon/tongue-poke
- emoticon/uh
- emoticon/unhappy
- emoticon/very-sorry
- emoticon/what
- emoticon/wink
- emoticon/worried
- emoticon/wtf

Alternatively, an item may reference an image by its path, using
the URI form ``file:///path/to/an/image.png`` and the entry will then
use that image for the item.


Setting entry's style
=====================

There are 2 major ways to change the entry's style:

- Theme - set the "base" field to the desired style.
- User style - Pushing overrides to the theme style to the textblock object
  by using :py:meth:`~efl.elementary.entry.Entry.text_style_user_push`.

You should modify the theme when you would like to change the style for
aesthetic reasons. While the user style should be changed when you would
like to change the style to something specific defined at run-time, e.g,
setting font or font size in a text editor.


Loading and saving files
========================

Entries have convenience functions to load text from a file and save changes
back to it after a short delay. The automatic saving is enabled by default, but
can be disabled with :py:attr:`~efl.elementary.entry.Entry.autosave` and files
can be loaded directly as plain text or have any markup in them recognized. See
:py:attr:`~efl.elementary.entry.Entry.file` for more details.


Emitted signals
===============

- ``changed``: The text within the entry was changed.
- ``changed,user``: The text within the entry was changed because of user
  interaction.
- ``activated``: The enter key was pressed on a single line entry.
- ``aborted``: The escape key was pressed on a single line entry. (since 1.7)
- ``press``: A mouse button has been pressed on the entry.
- ``longpressed``: A mouse button has been pressed and held for a couple
  seconds.
- ``clicked``: The entry has been clicked (mouse press and release).
- ``clicked,double``: The entry has been double clicked.
- ``clicked,triple``: The entry has been triple clicked.
- ``focused``: The entry has received focus.
- ``unfocused``: The entry has lost focus.
- ``selection,paste``: A paste of the clipboard contents was requested.
- ``selection,copy``: A copy of the selected text into the clipboard was
  requested.
- ``selection,cut``: A cut of the selected text into the clipboard was
  requested.
- ``selection,start``: A selection has begun and no previous selection
  existed.
- ``selection,changed``: The current selection has changed.
- ``selection,cleared``: The current selection has been cleared.
- ``cursor,changed``: The cursor has changed position.
- ``anchor,clicked``: An anchor has been clicked. The event_info
  parameter for the callback will be an :py:class:`EntryAnchorInfo`.
- ``anchor,in``: Mouse cursor has moved into an anchor. The event_info
  parameter for the callback will be an :py:class:`EntryAnchorInfo`.
- ``anchor,out``: Mouse cursor has moved out of an anchor. The event_info
  parameter for the callback will be an :py:class:`EntryAnchorInfo`.
- ``anchor,up``: Mouse button has been unpressed on an anchor. The event_info
  parameter for the callback will be an :py:class:`EntryAnchorInfo`.
- ``anchor,down``: Mouse button has been pressed on an anchor. The event_info
  parameter for the callback will be an :py:class:`EntryAnchorInfo`.
- ``preedit,changed``: The preedit string has changed.
- ``language,changed``: Program language changed.
- ``text,set,done``: Whole text has been set to the entry.
- ``rejected``: .Called when some of inputs are rejected by the filter. (since 1.9)


Layout content parts
====================

- ``icon`` - An icon in the entry
- ``end`` - A content in the end of the entry


Layout text parts
=================

- ``default`` - text of the entry
- ``guide`` - placeholder of the entry


Enumerations
============

.. _Elm_Entry_Autocapital_Type:

Autocapitalization types
------------------------

.. data:: ELM_AUTOCAPITAL_TYPE_NONE

    No auto-capitalization when typing

.. data:: ELM_AUTOCAPITAL_TYPE_WORD

    Autocapitalize each word typed

.. data:: ELM_AUTOCAPITAL_TYPE_SENTENCE

    Autocapitalize the start of each sentence

.. data:: ELM_AUTOCAPITAL_TYPE_ALLCHARACTER

    Autocapitalize all letters


.. _Elm_Entry_Cnp_Mode:

Copy & paste modes
------------------

.. data:: ELM_CNP_MODE_MARKUP

    Copy & paste text with markup tags

.. data:: ELM_CNP_MODE_NO_IMAGE

    Copy & paste text without item (image) tags

.. data:: ELM_CNP_MODE_PLAINTEXT

    Copy & paste text without markup tags


.. _Elm_Input_Hints:

Input Hints
-----------

.. data:: ELM_INPUT_HINT_NONE

    No active hints

    .. versionadded:: 1.12

.. data:: ELM_INPUT_HINT_AUTO_COMPLETE

    Suggest word auto completion

    .. versionadded:: 1.12

.. data:: ELM_INPUT_HINT_SENSITIVE_DATA

    typed text should not be stored

    .. versionadded:: 1.12


.. _Elm_Entry_Input_Panel_Lang:

Input panel language sort order
-------------------------------

.. data:: ELM_INPUT_PANEL_LANG_AUTOMATIC

    Automatic

.. data:: ELM_INPUT_PANEL_LANG_ALPHABET

    Alphabetic


.. _Elm_Entry_Input_Panel_Layout:

Input panel layouts
-------------------

.. data:: ELM_INPUT_PANEL_LAYOUT_NORMAL

    Default layout

.. data:: ELM_INPUT_PANEL_LAYOUT_NUMBER

    Number layout

.. data:: ELM_INPUT_PANEL_LAYOUT_EMAIL

    Email layout

.. data:: ELM_INPUT_PANEL_LAYOUT_URL

    URL layout

.. data:: ELM_INPUT_PANEL_LAYOUT_PHONENUMBER

    Phone number layout

.. data:: ELM_INPUT_PANEL_LAYOUT_IP

    IP layout

.. data:: ELM_INPUT_PANEL_LAYOUT_MONTH

    Month layout

.. data:: ELM_INPUT_PANEL_LAYOUT_NUMBERONLY

    Number only layout

.. data:: ELM_INPUT_PANEL_LAYOUT_INVALID

    Never use this

.. data:: ELM_INPUT_PANEL_LAYOUT_HEX

    Hexadecimal layout

.. data:: ELM_INPUT_PANEL_LAYOUT_TERMINAL

    Command-line terminal layout

.. data:: ELM_INPUT_PANEL_LAYOUT_PASSWORD

    Like normal, but no auto-correct, no auto-capitalization etc.

.. data:: ELM_INPUT_PANEL_LAYOUT_DATETIME

    Date and time layout

    .. versionadded:: 1.10

.. data:: ELM_INPUT_PANEL_LAYOUT_EMOTICON

    Emoticon layout

    .. versionadded:: 1.10


.. _Elm_Input_Panel_Layout_Normal_Variation:

Input panel normal layout variation
-----------------------------------

.. data:: ELM_INPUT_PANEL_LAYOUT_NORMAL_VARIATION_NORMAL

    The plain normal layout

    .. versionadded:: 1.12

.. data:: ELM_INPUT_PANEL_LAYOUT_NORMAL_VARIATION_FILENAME

    Filename layout. Symbols such as '/' should be disabled

    .. versionadded:: 1.12

.. data:: ELM_INPUT_PANEL_LAYOUT_NORMAL_VARIATION_PERSON_NAME

    The name of a person

    .. versionadded:: 1.12


.. _Elm_Input_Panel_Layout_Numberonly_Variation:

Input panel numberonly layout variation
---------------------------------------

.. data:: ELM_INPUT_PANEL_LAYOUT_NUMBERONLY_VARIATION_NORMAL

    The numberonly normal layout

    .. versionadded:: 1.12

.. data:: ELM_INPUT_PANEL_LAYOUT_NUMBERONLY_VARIATION_SIGNED

    The signed number layout

    .. versionadded:: 1.12

.. data:: ELM_INPUT_PANEL_LAYOUT_NUMBERONLY_VARIATION_DECIMAL

    The decimal number layout

    .. versionadded:: 1.12

.. data:: ELM_INPUT_PANEL_LAYOUT_NUMBERONLY_VARIATION_SIGNED_AND_DECIMAL

    The signed and decimal number layout

    .. versionadded:: 1.12


.. _Elm_Input_Panel_Layout_Password_Variation:

Input panel password layout variation
-------------------------------------

.. data:: ELM_INPUT_PANEL_LAYOUT_PASSWORD_VARIATION_NORMAL

    The normal password layout

    .. versionadded:: 1.12

.. data:: ELM_INPUT_PANEL_LAYOUT_PASSWORD_VARIATION_NUMBERONLY

    The password layout to allow only number

    .. versionadded:: 1.12


.. _Elm_Entry_Input_Panel_Return_Key_Type:

Input panel return key modes
----------------------------

.. data:: ELM_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT

    Default

.. data:: ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE

    Done

.. data:: ELM_INPUT_PANEL_RETURN_KEY_TYPE_GO

    Go

.. data:: ELM_INPUT_PANEL_RETURN_KEY_TYPE_JOIN

    Join

.. data:: ELM_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN

    Login

.. data:: ELM_INPUT_PANEL_RETURN_KEY_TYPE_NEXT

    Next

.. data:: ELM_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH

    Search

.. data:: ELM_INPUT_PANEL_RETURN_KEY_TYPE_SEND

    Send

.. data:: ELM_INPUT_PANEL_RETURN_KEY_TYPE_SIGNIN

    Sign-in

    .. versionadded:: 1.10


.. _Elm_Entry_Text_Format:

Text format
-----------

.. data:: ELM_TEXT_FORMAT_PLAIN_UTF8

    Plain UTF-8 type

.. data:: ELM_TEXT_FORMAT_MARKUP_UTF8

    UTF-8 with markup


.. _Elm_Wrap_Type:

Wrap mode
---------

.. data:: ELM_WRAP_NONE

    No wrap

.. data:: ELM_WRAP_CHAR

    Wrap between characters

.. data:: ELM_WRAP_WORD

    Wrap in allowed wrapping points (as defined in the unicode standard)

.. data:: ELM_WRAP_MIXED

    Word wrap, and if that fails, char wrap


Inheritance diagram
===================

.. inheritance-diagram:: Entry
    :parts: 2

.. autofunction:: markup_to_utf8
.. autofunction:: utf8_to_markup

.. autoclass:: Entry
.. autoclass:: EntryContextMenuItem
.. autoclass:: FilterLimitSize
.. autoclass:: FilterAcceptSet
.. autoclass:: EntryAnchorInfo
.. autoclass:: EntryAnchorHoverInfo