Skip to content

Commit 317eaf3

Browse files
authored
Merge branch 'DFHack:develop' into cleaners_etc
2 parents 3876041 + 7df9089 commit 317eaf3

7 files changed

Lines changed: 31 additions & 37 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ project(dfhack)
88

99
# set up versioning.
1010
set(DF_VERSION "50.14")
11-
set(DFHACK_RELEASE "r1")
11+
set(DFHACK_RELEASE "r1.1")
1212
set(DFHACK_PRERELEASE FALSE)
1313

1414
set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}")

docs/changelog.txt

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ Template for new versions:
6060
- ``tile-material.lua``: made root tiles return tree material when not using GetLayerMat.
6161

6262
## Misc Improvements
63+
- DFHack text edit fields now delete the character at the cursor when you hit the Delete key
64+
- DFHack text edit fields now move the cursor by one word left or right with Ctrl-Left and Ctrl-Right
65+
- DFHack text edit fields now move the cursor to the beginning or end of the line with Home and End
6366

6467
## Documentation
6568

@@ -72,24 +75,10 @@ Template for new versions:
7275

7376
# 50.14-r1
7477

75-
## New Tools
76-
77-
## New Features
78-
7978
## Fixes
8079
- `preserve-rooms`: don't reserve a room for citizens that you expel from the fort
8180
- `autobutcher`: fix regression in ordering of butcherable animals
8281

83-
## Misc Improvements
84-
85-
## Documentation
86-
87-
## API
88-
89-
## Lua
90-
91-
## Removed
92-
9382
# 50.13-r5
9483

9584
## New Tools

docs/dev/Lua API.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5484,9 +5484,9 @@ The ``EditField`` cursor can be moved to where you want to insert/remove text.
54845484
You can click where you want the cursor to move or you can use any of the
54855485
following keyboard hotkeys:
54865486

5487-
- Left/Right arrow: move the cursor one character to the left or right.
5488-
- Ctrl-B/Ctrl-F: move the cursor one word back or forward.
5489-
- Ctrl-A/Ctrl-E: move the cursor to the beginning/end of the text.
5487+
- Left/Right arrow: move the cursor one character to the left or right
5488+
- Ctrl-Left/Ctrl-Right: move the cursor one word back or forward
5489+
- Home/End: move the cursor to the beginning/end of the text
54905490

54915491
The widget also supports integration with the system clipboard:
54925492

library/lua/gui/widgets.lua

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -988,14 +988,20 @@ function EditField:onInput(keys)
988988
end
989989
end
990990
return not not self.key
991+
elseif keys.CUSTOM_DELETE then
992+
local old = self.text
993+
local del_pos = self.cursor
994+
if del_pos <= #old then
995+
self:setText(old:sub(1, del_pos-1) .. old:sub(del_pos+1), del_pos)
996+
end
997+
return true
991998
elseif keys._STRING then
992999
local old = self.text
9931000
if keys._STRING == 0 then
9941001
-- handle backspace
9951002
local del_pos = self.cursor - 1
9961003
if del_pos > 0 then
997-
self:setText(old:sub(1, del_pos-1) .. old:sub(del_pos+1),
998-
del_pos)
1004+
self:setText(old:sub(1, del_pos-1) .. old:sub(del_pos+1), del_pos)
9991005
end
10001006
else
10011007
local cv = string.char(keys._STRING)
@@ -1009,23 +1015,22 @@ function EditField:onInput(keys)
10091015
elseif keys.KEYBOARD_CURSOR_LEFT then
10101016
self:setCursor(self.cursor - 1)
10111017
return true
1012-
elseif keys.CUSTOM_CTRL_B then -- back one word
1018+
elseif keys.CUSTOM_CTRL_LEFT then -- back one word
10131019
local _, prev_word_end = self.text:sub(1, self.cursor-1):
10141020
find('.*[%w_%-][^%w_%-]')
10151021
self:setCursor(prev_word_end or 1)
10161022
return true
1017-
-- commented out until we get HOME key support from DF
1018-
-- elseif keys.CUSTOM_CTRL_A then -- home
1019-
-- self:setCursor(1)
1020-
-- return true
1023+
elseif keys.CUSTOM_HOME then
1024+
self:setCursor(1)
1025+
return true
10211026
elseif keys.KEYBOARD_CURSOR_RIGHT then
10221027
self:setCursor(self.cursor + 1)
10231028
return true
1024-
elseif keys.CUSTOM_CTRL_F then -- forward one word
1029+
elseif keys.CUSTOM_CTRL_RIGHT then -- forward one word
10251030
local _,next_word_start = self.text:find('[^%w_%-][%w_%-]', self.cursor)
10261031
self:setCursor(next_word_start)
10271032
return true
1028-
elseif keys.CUSTOM_CTRL_E then -- end
1033+
elseif keys.CUSTOM_END then
10291034
self:setCursor()
10301035
return true
10311036
elseif keys.CUSTOM_CTRL_C then

library/xml

test/library/gui/widgets.EditField.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ function test.editfield_cursor()
2626
expect.eq(4, e.cursor)
2727
e:onInput{KEYBOARD_CURSOR_RIGHT=true}
2828
expect.eq(5, e.cursor)
29-
-- e:onInput{A_CARE_MOVE_W=true}
30-
-- expect.eq(1, e.cursor, 'interpret alt-left as home') -- uncomment when we have a home key
31-
e:onInput{CUSTOM_CTRL_F=true}
32-
expect.eq(6, e.cursor, 'interpret Ctrl-f as goto beginning of next word')
33-
e:onInput{CUSTOM_CTRL_E=true}
34-
expect.eq(16, e.cursor, 'interpret Ctrl-e as end')
35-
e:onInput{CUSTOM_CTRL_B=true}
36-
expect.eq(9, e.cursor, 'interpret Ctrl-b as goto end of previous word')
29+
e:onInput{CUSTOM_HOME=true}
30+
expect.eq(1, e.cursor, 'cursor should be at beginning of string')
31+
e:onInput{CUSTOM_CTRL_RIGHT=true}
32+
expect.eq(6, e.cursor, 'goto beginning of next word')
33+
e:onInput{CUSTOM_END=true}
34+
expect.eq(16, e.cursor, 'cursor should be at end of string')
35+
e:onInput{CUSTOM_CTRL_LEFT=true}
36+
expect.eq(9, e.cursor, 'goto end of previous word')
3737
end
3838

3939
function test.editfield_click()

0 commit comments

Comments
 (0)