Skip to content

Commit 45ecda5

Browse files
authored
Merge branch 'develop' into infinitesky
2 parents 69ba0b6 + 3937555 commit 45ecda5

22 files changed

+5367
-73
lines changed

docs/about/Authors.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ Myk Taylor myk002
147147
Najeeb Al-Shabibi master-spike
148148
napagokc napagokc
149149
Neil Little nmlittle
150+
Nicholas McDaniel NicksWorld
150151
Nick Rart nickrart comestible
151152
Nicolas Ayala nicolasayala
152153
Nik Nyby nikolas

docs/changelog.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ Template for new versions:
5252
# Future
5353

5454
## New Tools
55-
- `infinite-sky`: (reinstated, renamed from ``infiniteSky``) tool for automatically creating new z-levels of sky
55+
- `infinite-sky`: (reinstated, renamed from ``infiniteSky``) tool for automatically creating new z-levels of sky to build in
56+
- `forceequip`: (reinstated) Forcibly move items into a unit's inventory
5657

5758
## New Features
5859
- `tweak`: ``realistic-melting``: change melting return for inorganic armor parts, shields, weapons, trap components and tools to stop smelters from creating metal, bring melt return for adamantine in line with other metals to ~95% of forging cost. wear reduces melt return by 10% per level
@@ -62,6 +63,7 @@ Template for new versions:
6263
- `autobutcher`: don't run a scanning and marking cycle on the first tick of a fortress to allow for all custom configuration to be set first
6364
- `nestboxes`: don't consider eggs to be infertile just because the mother has left the nest; eggs can still hatch in this situation
6465
- `timestream`: adjust the incubation counter on fertile eggs so they hatch at the expected time
66+
- `timestream`: fix potential crash in birthday tracking
6567
- `logistics`: don't ignore rotten items when applying stockpile logistics operations (e.g. autodump, autoclaim, etc.)
6668

6769
## Misc Improvements
@@ -86,6 +88,7 @@ Template for new versions:
8688
## Lua
8789

8890
- ``dfhack.units``: new function ``setPathGoal``
91+
- ``widgets.TabBar``: updated to allow for horizontal scrolling of tabs when there are too many to fit in the available space
8992

9093
## Removed
9194
- UI focus strings for squad panel flows combined into a single tree: ``dwarfmode/SquadEquipment`` -> ``dwarfmode/Squads/Equipment``, ``dwarfmode/SquadSchedule`` -> ``dwarfmode/Squads/Schedule``

docs/dev/Lua API.rst

Lines changed: 181 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5513,6 +5513,155 @@ The ``EditField`` class also provides the following functions:
55135513

55145514
Inserts the given text at the current cursor position.
55155515

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+
55165665
Scrollbar class
55175666
---------------
55185667

@@ -6194,9 +6343,16 @@ TabBar class
61946343
------------
61956344

61966345
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.
62006356
:key: Specifies a keybinding that can be used to switch to the next tab.
62016357
Defaults to ``CUSTOM_CTRL_T``.
62026358
: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.
62226378
itself as the second. The default implementation, which will handle most
62236379
situations, returns ``self.active_tab_pens``, if ``self.get_cur_page() == idx``,
62246380
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.
62256403

62266404
Tab class
62276405
---------

docs/plugins/forceequip.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ forceequip
33

44
.. dfhack-tool::
55
:summary: Move items into a unit's inventory.
6-
:tags: unavailable
6+
:tags: adventure fort animals items military units
77

88
This tool is typically used to equip specific clothing/armor items onto a dwarf,
99
but can also be used to put armor onto a war animal or to add unusual items

library/Core.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ void get_commands(color_ostream &con, std::vector<std::string> &commands) {
459459
static bool try_autocomplete(color_ostream &con, const std::string &first, std::string &completed)
460460
{
461461
std::vector<std::string> commands, possible;
462-
462+
get_commands(con, commands);
463463
for (auto &command : commands)
464464
if (command.substr(0, first.size()) == first)
465465
possible.push_back(command);

library/include/DataDefs.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ distribution.
3434

3535
#include "BitArray.h"
3636

37-
// Stop some MS stupidity
38-
#ifdef interface
39-
#undef interface
40-
#endif
41-
4237
typedef struct lua_State lua_State;
4338

4439
/*

library/include/DataFuncs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ distribution.
3030
#include <map>
3131
#include <type_traits>
3232

33+
#include "ColorText.h"
3334
#include "DataIdentity.h"
3435
#include "LuaWrapper.h"
3536

library/include/modules/DFSDL.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22

3+
#include "Error.h"
34
#include "Export.h"
45
#include "ColorText.h"
56

library/lua/dfhack.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ end
668668
---@nodiscard
669669
---@param self string
670670
---@param width number
671-
---@param opts {return_as_table:boolean, keep_trailing_spaces:boolean}
671+
---@param opts {return_as_table:boolean, keep_trailing_spaces:boolean, keep_original_newlines:boolean}
672672
---@return string|string[]
673673
function string:wrap(width, opts)
674674
width, opts = width or 72, opts or {}

library/lua/gui/widgets.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ FilteredList = require('gui.widgets.filtered_list')
2828
TabBar = require('gui.widgets.tab_bar')
2929
RangeSlider = require('gui.widgets.range_slider')
3030
DimensionsTooltip = require('gui.widgets.dimensions_tooltip')
31+
TextArea = require('gui.widgets.text_area')
3132

3233
Tab = TabBar.Tab
3334
makeButtonLabelText = Label.makeButtonLabelText

0 commit comments

Comments
 (0)