@@ -5513,6 +5513,155 @@ The ``EditField`` class also provides the following functions:
5513
5513
5514
5514
Inserts the given text at the current cursor position.
5515
5515
5516
+ TextArea class
5517
+ --------------
5518
+
5519
+ Subclass of Panel; implements a multi-line text field with features such as
5520
+ text wrapping, mouse control, text selection, clipboard support, history,
5521
+ and typical text editor shortcuts.
5522
+
5523
+ Cursor Behavior
5524
+ ~~~~~~~~~~~~~~~
5525
+
5526
+ The cursor in the ``TextArea `` class is index-based, starting from 1,
5527
+ consistent with Lua's text indexing conventions.
5528
+
5529
+ Each character, including newlines (``string.char(10) ``),
5530
+ occupies a single index in the text content.
5531
+
5532
+ Cursor movement and position are fully aware of line breaks,
5533
+ meaning they count as one unit in the offset.
5534
+
5535
+ The cursor always points to the position between characters,
5536
+ with 1 being the position before the first character and
5537
+ ``#text + 1 `` representing the position after the last character.
5538
+
5539
+ Cursor positions are preserved during text operations like insertion,
5540
+ deletion, or replacement. If changes affect the cursor's position,
5541
+ it will be adjusted to the nearest valid index.
5542
+
5543
+ TextArea Attributes:
5544
+
5545
+ * ``init_text ``: The initial text content for the text area.
5546
+
5547
+ * ``init_cursor ``: The initial cursor position within the text content.
5548
+ If not specified, defaults to end of the text (length of ``init_text `` + 1).
5549
+
5550
+ * ``text_pen ``: Optional pen used to draw the text. Default is ``COLOR_LIGHTCYAN ``.
5551
+
5552
+ * ``select_pen ``: Optional pen used for text selection. Default is ``COLOR_CYAN ``.
5553
+
5554
+ * ``ignore_keys ``: List of input keys to ignore.
5555
+ Functions similarly to the ``ignore_keys `` attribute in the ``EditField `` class.
5556
+
5557
+ * ``on_text_change ``: Callback function called whenever the text changes.
5558
+ The function signature should be ``on_text_change(new_text, old_text) ``.
5559
+
5560
+ * ``on_cursor_change ``: Callback function called whenever the cursor position changes.
5561
+ Expected function signature is ``on_cursor_change(new_cursor, old_cursor) ``.
5562
+
5563
+ * ``one_line_mode ``: If set to ``true ``, disables multi-line text features.
5564
+ In this mode the :kbd: `Enter ` key is not handled by the widget
5565
+ as if it were included in ``ignore_keys ``.
5566
+ If multiline text (including ``\n `` chars) is pasted into the widget, newlines are removed.
5567
+
5568
+ TextArea Functions:
5569
+
5570
+ * ``textarea:getText() ``
5571
+
5572
+ Returns the current text content of the ``TextArea `` widget as a string.
5573
+ "\n " characters (``string.char(10) ``) should be interpreted as new lines
5574
+
5575
+ * ``textarea:setText(text) ``
5576
+
5577
+ Sets the content of the ``TextArea `` to the specified string ``text ``.
5578
+ The cursor position will not be adjusted, so should be set separately.
5579
+
5580
+ * ``textarea:getCursor() ``
5581
+
5582
+ Returns the current cursor position within the text content.
5583
+ The position is represented as a single integer, starting from 1.
5584
+
5585
+ * ``textarea:setCursor(cursor) ``
5586
+
5587
+ Sets the cursor position within the text content.
5588
+
5589
+ * ``textarea:scrollToCursor() ``
5590
+
5591
+ Scrolls the text area view to ensure that the current cursor position is visible.
5592
+ This happens automatically when the user interactively moves the cursor or
5593
+ pastes text into the widget, but may need to be called when ``setCursor `` is
5594
+ called programmatically.
5595
+
5596
+ * ``textarea:clearHistory() ``
5597
+
5598
+ Clears undo/redo history of the widget.
5599
+
5600
+ Functionality
5601
+ ~~~~~~~~~~~~~
5602
+
5603
+ The TextArea widget provides a familiar and intuitive text editing experience with baseline features such as:
5604
+
5605
+ - Text Wrapping: Automatically fits text within the display area.
5606
+ - Mouse and Keyboard Support: Standard keys like :kbd: `Home `, :kbd: `End `, :kbd: `Backspace `, and :kbd: `Delete ` are supported,
5607
+ along with gestures like double-click to select a word or triple-click to select a line.
5608
+ - Clipboard Operations: copy, cut, and paste,
5609
+ with intuitive defaults when no text is selected.
5610
+ - Undo/Redo: :kbd: `Ctrl ` + :kbd: `Z ` and :kbd: `Ctrl ` + :kbd: `Y ` for quick changes.
5611
+ - Additional features include advanced navigation, line management,
5612
+ and smooth scrolling for handling long text efficiently.
5613
+
5614
+ Detailed list:
5615
+
5616
+ - Cursor Control: Navigate through text using arrow keys (Left, Right, Up,
5617
+ and Down) for precise cursor placement.
5618
+ - Mouse Control: Use the mouse to position the cursor within the text,
5619
+ providing an alternative to keyboard navigation.
5620
+ - Text Selection: Select text with the mouse, with support for replacing or
5621
+ removing selected text.
5622
+ - Select Word/Line: Use double click to select current word, or triple click to
5623
+ select current line.
5624
+ - Move By Word: Use :kbd: `Ctrl ` + :kbd: `Left ` and :kbd: `Ctrl ` + :kbd: `Right ` to
5625
+ move the cursor one word back or forward.
5626
+ - Line Navigation: :kbd: `Home ` moves the cursor to the beginning of the current
5627
+ line, and :kbd: `End ` moves it to the end.
5628
+ - Jump to Beginning/End: Quickly move the cursor to the beginning or end of the
5629
+ text using :kbd: `Ctrl ` + :kbd: `Home ` and :kbd: `Ctrl ` + :kbd: `End `.
5630
+ - Longest X Position Memory: The cursor remembers the longest x position when
5631
+ moving up or down, making vertical navigation more intuitive.
5632
+ - New Lines: Easily insert new lines using the :kbd: `Enter ` key, supporting
5633
+ multiline text input.
5634
+ - Text Wrapping: Text automatically wraps within the editor, ensuring lines fit
5635
+ within the display without manual adjustments.
5636
+ - Scrolling for long text entries.
5637
+ - Backspace Support: Use the backspace key to delete characters to the left of
5638
+ the cursor.
5639
+ - Delete Character: :kbd: `Delete ` deletes the character under the cursor.
5640
+ - Delete Current Line: :kbd: `Ctrl ` + :kbd: `U ` deletes the entire current line
5641
+ where the cursor is located.
5642
+ - Delete Rest of Line: :kbd: `Ctrl ` + :kbd: `K ` deletes text from the cursor to
5643
+ the end of the line.
5644
+ - Delete Last Word: :kbd: `Ctrl ` + :kbd: `W ` removes the word immediately before
5645
+ the cursor.
5646
+ - Select All: Select entire text by :kbd: `Ctrl ` + :kbd: `A `.
5647
+ - Undo/Redo: Undo/Redo changes by :kbd: `Ctrl ` + :kbd: `Z ` / :kbd: `Ctrl ` +
5648
+ :kbd: `Y `.
5649
+ - Clipboard Operations: Perform OS clipboard cut, copy, and paste operations on
5650
+ selected text, allowing you to paste the copied content into other
5651
+ applications.
5652
+ - Copy Text: Use :kbd: `Ctrl ` + :kbd: `C ` to copy selected text.
5653
+ - copy selected text, if available
5654
+ - if no text is selected it copy the entire current line, including the
5655
+ terminating newline if present
5656
+ - Cut Text: Use :kbd: `Ctrl ` + :kbd: `X ` to cut selected text.
5657
+ - cut selected text, if available
5658
+ - if no text is selected it will cut the entire current line, including the
5659
+ terminating newline if present
5660
+ - Paste Text: Use :kbd: `Ctrl ` + :kbd: `V ` to paste text from the clipboard into
5661
+ the editor.
5662
+ - replace selected text, if available
5663
+ - If no text is selected, paste text in the cursor position
5664
+
5516
5665
Scrollbar class
5517
5666
---------------
5518
5667
@@ -6194,9 +6343,16 @@ TabBar class
6194
6343
------------
6195
6344
6196
6345
This widget implements a set of one or more tabs to allow navigation between groups
6197
- of content. Tabs automatically wrap on the width of the window and will continue
6198
- rendering on the next line(s) if all tabs cannot fit on a single line.
6199
-
6346
+ of content.
6347
+
6348
+ :wrap: If true, tabs automatically wrap on the width of the window and will
6349
+ continue rendering on the next line(s) if all tabs cannot fit on a single line.
6350
+ If false, tabs will be truncated and can be scrolled using ``scroll_key ``
6351
+ and ``scroll_key_back ``, mouse wheel or by clicking on the scroll labels
6352
+ that will automatically appear on the left and right sides of the tab bar
6353
+ as needed. When clicking on a tab or using ``key `` or ``key_back `` to switch tabs,
6354
+ the selected tab will be scrolled into view if it is not already visible.
6355
+ Defaults to true.
6200
6356
:key: Specifies a keybinding that can be used to switch to the next tab.
6201
6357
Defaults to ``CUSTOM_CTRL_T ``.
6202
6358
:key_back: Specifies a keybinding that can be used to switch to the previous
@@ -6222,6 +6378,28 @@ rendering on the next line(s) if all tabs cannot fit on a single line.
6222
6378
itself as the second. The default implementation, which will handle most
6223
6379
situations, returns ``self.active_tab_pens ``, if ``self.get_cur_page() == idx ``,
6224
6380
otherwise returns ``self.inactive_tab_pens ``.
6381
+ :scroll_key: Specifies a keybinding that can be used to scroll the tabs to the right.
6382
+ Defaults to ``CUSTOM_ALT_T ``.
6383
+ :scroll_key_back: Specifies a keybinding that can be used to scroll the tabs to the left.
6384
+ Defaults to ``CUSTOM_ALT_Y ``.
6385
+ :scroll_left_text: The text to display on the left scroll label.
6386
+ Defaults to "<<<".
6387
+ :scroll_right_text: The text to display on the right scroll label.
6388
+ Defaults to ">>>".
6389
+ :scroll_label_text_pen: The pen to use for the scroll label text.
6390
+ Defaults to ``Label `` default.
6391
+ :scroll_label_text_hpen: The pen to use for the scroll label text when hovered.
6392
+ Defaults to ``scroll_label_text_pen `` with the background
6393
+ and foreground colors swapped.
6394
+ :scroll_step: The number of units to scroll tabs by.
6395
+ Defaults to 10.
6396
+ :fast_scroll_multiplier: The multiplier for fast scrolling (holding shift).
6397
+ Defaults to 3.
6398
+ :scroll_into_view_offset: After a selected tab is scrolled into view, this offset
6399
+ is added to the scroll position to ensure the tab is
6400
+ not flush against the edge of the tab bar, allowing
6401
+ some space for the user to see the next tab.
6402
+ Defaults to 5.
6225
6403
6226
6404
Tab class
6227
6405
---------
0 commit comments