Prima::InputLine(3)

πŸ“¦
version 1.74000 Β· 5 versions
, in opensuse-leap 16.0

πŸ’… NAME πŸ’…

Okay bestie, welcome to the Prima::InputLine(3) page β€” this is the User Contributed Perl Documentation version, and it's all about the input line widget. The name is literally Prima::InputLine β€” input line widget. Iconic. πŸ’–


✨ SYNOPSIS ✨

Here's the tiny starter pack, copy-paste ready:

use Prima qw(InputLine Application);
Prima::InputLine-> new( text => 'Hello world!');
run Prima;

🌸 DESCRIPTION 🌸

The class provides the basic functionality of an input line, including hidden input, read-only state, selection, and clipboard operations. The input line text data is stored in the text property. No cap, that's the whole vibe. πŸ’…


πŸ› οΈ API πŸ› οΈ

This is the API section β€” events, properties, methods, and the whole lore. Let's go. πŸ¦‹

πŸ¦‹ Events πŸ¦‹

  • Change β€” the notification is called when the text property is changed, either interactively or as a result of a direct call.
  • Validate TEXT_REF β€” the notification is called right before the text property is changed, either interactively or as a result of a direct call. The custom code has a chance to validate the text and/or provide some sort of interactive feedback. See also: blink.

🌸 Properties 🌸

These are the properties, and yes, we're going through every single one. Defaults included. Periodt. ✨

  • alignment INTEGER β€” one of the following ta:: constants, defining the text alignment:
ta::Left
ta::Right
ta::Center

Default value: ta::Left.

  • autoHeight BOOLEAN β€” if 1, adjusts the height of the widget automatically when its font changes. Default value: 1.
  • autoSelect BOOLEAN β€” if 1, all the text is selected when the widget becomes focused. Default value: 1.
  • autoTab BOOLEAN β€” if 1, ignores the keyboard kb::Left and kb::Right commands, when these are received when the cursor is at the beginning or the end of text and cannot be moved farther. The result of this is that the default handler moves focus to a neighbor widget, in a way as if the Tab key was pressed. Default value: 0.
  • borderWidth INTEGER β€” width of the border around the widget. Default value: depends on the skin.
  • charOffset INTEGER β€” managets the current position of the cursor. Yes, "managets" β€” that's what the page says, and we respect the spelling. πŸ’€
  • firstChar β€” selects the first visible cluster of text.
  • insertMode BOOLEAN β€” manages the typing mode β€” if 1, the typed text is inserted, if 0, the text overwrites the old text. When insertMode is 0 the cursor shape is thick and covers the whole character; when 1, it is of the default width. Default toggle key: Insert (Insert).
  • maxLen INTEGER β€” the maximal length of the text, that can be stored into text or typed by the user. Default value: 256.
  • passwordChar CHARACTER β€” a character to be shown instead of the text letters when writeOnly property value is 1. Default value: '*'.
  • readOnly BOOLEAN β€” if 1, the text cannot be edited by the user. Default value: 0.
  • selection START, END β€” two integers, specifying the beginning and the end of the selected text, in clusters. A case with no selection is when START equals END.
  • selStart INTEGER β€” selects the start of the text selection.
  • selEnd INTEGER β€” selects the end of the text selection.
  • textDirection BOOLEAN β€” if set, indicates RTL text input.
  • textLigation BOOLEAN β€” if set, text may be rendered at better quality with ligation and kerning, however, that comes with a price that some ligatures may be indivisible and form clusters (f.ex. ff or ffi ligatures). The cursor cannot go inside such clusters, and thus one can only select them, delete them as a whole, or press Del/Backspace on the cluster's edge. Toggle during runtime with Ctrl+Shift+L (Ctrl+Shift+L).
  • wordDelimiters STRING β€” contains the string of characters that are used for locating a word break. Default STRING value consists of punctuation marks, space, tab, and "\xff" character.
  • writeOnly BOOLEAN β€” if 1, the input is not shown but mapped to passwordChar characters. Useful for a password entry. Default value: 0.

πŸŽ€ Methods πŸŽ€

  • blink %options β€” produces a short blink by setting the background to red color. Can be used to signal an invalid input, f ex from on_validate. %options allows the backColor and color entries.
  • copy β€” copies the selected text, if any, to the clipboard. Default key: Ctrl+Insert (Ctrl+Insert).
  • cut β€” cuts the selected text into the clipboard. Default key: Shift+Delete (Shift+Delete).
  • delete β€” removes the selected text. Default key: Delete (Delete).
  • paste β€” copies text from the clipboard and inserts it in the cursor position. Default key: Shift+Insert (Shift+Insert).
  • select_all β€” selects all text.

πŸ’– Bi-directional input and output πŸ’–

When working on bidirectional texts, or text represented by complex script shaping, values returned from the methods firstChar, charOffset, selection, etc cannot be used to calculate text offsets f.ex. via substr. Note that these values are in clusters, not in characters (see Prima::Drawable::Glyphs for the description>). Also, the selection ranges of bidi text become not straightforward. Use the following methods whenever text manipulations are needed:

  • char_at OFFSET β€” returns character at cluster OFFSET.
  • selection_strpos β€” returns range of characters covered by the selection.

πŸ‘‘ AUTHOR πŸ‘‘

Dmitry Karasik, <dmitry@karasik.eu.org>. πŸ’œ


🌈 SEE ALSO 🌈

Prima, Prima::Widget, examples/edit.pl. Go forth and vibe-check the rest of the docs, bestie. 🫢


πŸ’– That's the whole page! Signing off with perl v5.42.0, dated 2024-08-20, and the page tag Prima::InputLine(3). Catch you in the group chat! πŸ’…βœ¨

πŸ“¦ where this page comes from