Skip to content

Commit a37ebe1

Browse files
Improve gui/notes and gui/journal keyboard control
1 parent 8ad4fa1 commit a37ebe1

File tree

6 files changed

+29
-36
lines changed

6 files changed

+29
-36
lines changed

docs/gui/journal.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ Supported Features
2626
- New Lines: Easily insert new lines using the :kbd:`Enter` key, supporting multiline text input.
2727
- Text Wrapping: Text automatically wraps within the editor, ensuring lines fit within the display without manual adjustments.
2828
- Backspace Support: Use the backspace key to delete characters to the left of the cursor.
29-
- Delete Character: :kbd:`Ctrl` + :kbd:`D` deletes the character under the cursor.
30-
- Line Navigation: :kbd:`Ctrl` + :kbd:`H` (like "Home") moves the cursor to the beginning of the current line, and :kbd:`Ctrl` + :kbd:`E` (like "End") moves it to the end.
29+
- Delete Character: :kbd:`Delete` deletes the character under the cursor.
30+
- Line Navigation: :kbd:`Home` moves the cursor to the beginning of the current line, and :kbd:`End` moves it to the end.
3131
- Delete Current Line: :kbd:`Ctrl` + :kbd:`U` deletes the entire current line where the cursor is located.
3232
- Delete Rest of Line: :kbd:`Ctrl` + :kbd:`K` deletes text from the cursor to the end of the line.
3333
- Delete Last Word: :kbd:`Ctrl` + :kbd:`W` removes the word immediately before the cursor.

docs/notes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Creating a Note
2929
1. Use the keyboard cursor to select the desired map tile where you want to place a note.
3030
2. Execute ``notes add`` via the DFHack console.
3131
3. In the pop-up dialog, fill in the note's title and detailed comment.
32-
4. Press :kbd:`Alt` + :kbd:`S` to create the note.
32+
4. Press :kbd:`Ctrl` + :kbd:`S` to create the note.
3333

3434
Editing or Deleting a Note
3535
--------------------------

gui/notes.lua

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,6 @@ function NotesWindow:init()
5757
frame_inset={l=1,t=1,b=1,r=1},
5858
autoarrange_subviews=true,
5959
subviews={
60-
widgets.HotkeyLabel {
61-
key='CUSTOM_ALT_S',
62-
label='Search',
63-
frame={l=0},
64-
auto_width=true,
65-
on_activate=function() self.subviews.search:setFocus(true) end,
66-
},
6760
NotesSearchField{
6861
view_id='search',
6962
frame={l=0,h=3},
@@ -94,7 +87,7 @@ function NotesWindow:init()
9487
frame={l=1,b=1,h=1},
9588
auto_width=true,
9689
label='New note',
97-
key='CUSTOM_ALT_N',
90+
key='CUSTOM_CTRL_N',
9891
visible=edit_mode,
9992
on_activate=function()
10093
if self.on_note_add then
@@ -151,15 +144,15 @@ function NotesWindow:init()
151144
frame={l=0,t=0,h=1},
152145
auto_width=true,
153146
label='Edit',
154-
key='CUSTOM_ALT_U',
147+
key='CUSTOM_CTRL_E',
155148
on_activate=function() self:showNoteManager(self.selected_note) end,
156149
},
157150
widgets.HotkeyLabel{
158151
view_id='delete',
159152
frame={r=0,t=0,h=1},
160153
auto_width=true,
161154
label='Delete',
162-
key='CUSTOM_ALT_D',
155+
key='CUSTOM_CTRL_D',
163156
on_activate=function() self:deleteNote(self.selected_note) end,
164157
},
165158
}

internal/journal/text_editor.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -786,13 +786,13 @@ function TextEditorView:onCursorInput(keys)
786786
local word_end = self:wordEndOffset()
787787
self:setCursor(word_end)
788788
return true
789-
elseif keys.CUSTOM_CTRL_H then
789+
elseif keys.CUSTOM_HOME then
790790
-- line start
791791
self:setCursor(
792792
self:lineStartOffset()
793793
)
794794
return true
795-
elseif keys.CUSTOM_CTRL_E then
795+
elseif keys.CUSTOM_END then
796796
-- line end
797797
self:setCursor(
798798
self:lineEndOffset()
@@ -890,7 +890,7 @@ function TextEditorView:onTextManipulationInput(keys)
890890
self:eraseSelection()
891891

892892
return true
893-
elseif keys.CUSTOM_CTRL_D then
893+
elseif keys.CUSTOM_DELETE then
894894
-- delete char, there is no support for `Delete` key
895895
self.history:store(HISTORY_ENTRY.DELETE, self.text, self.cursor)
896896

internal/notes/note_manager.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function NoteManager:init()
6565
frame={l=0,t=0,h=1},
6666
auto_width=true,
6767
label='Save',
68-
key='CUSTOM_ALT_S',
68+
key='CUSTOM_CTRL_S',
6969
visible=edit_mode,
7070
on_activate=function() self:saveNote() end,
7171
enabled=function() return #self.subviews.name:getText() > 0 end,
@@ -75,7 +75,7 @@ function NoteManager:init()
7575
frame={l=0,t=0,h=1},
7676
auto_width=true,
7777
label='Create',
78-
key='CUSTOM_ALT_S',
78+
key='CUSTOM_CTRL_S',
7979
visible=not edit_mode,
8080
on_activate=function() self:createNote() end,
8181
enabled=function() return #self.subviews.name:getText() > 0 end,
@@ -85,7 +85,7 @@ function NoteManager:init()
8585
frame={r=0,t=0,h=1},
8686
auto_width=true,
8787
label='Delete',
88-
key='CUSTOM_ALT_D',
88+
key='CUSTOM_CTRL_D',
8989
visible=edit_mode,
9090
on_activate=function() self:deleteNote() end,
9191
},

test/gui/journal.lua

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ function test.handle_delete()
772772
text_area:setCursor(1)
773773
journal:onRender()
774774

775-
simulate_input_keys('CUSTOM_CTRL_D')
775+
simulate_input_keys('CUSTOM_DELETE')
776776

777777
expect.eq(read_rendered_text(text_area), table.concat({
778778
'_: Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
@@ -783,7 +783,7 @@ function test.handle_delete()
783783

784784
text_area:setCursor(124)
785785
journal:onRender()
786-
simulate_input_keys('CUSTOM_CTRL_D')
786+
simulate_input_keys('CUSTOM_DELETE')
787787

788788
expect.eq(read_rendered_text(text_area), table.concat({
789789
'0: Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
@@ -794,7 +794,7 @@ function test.handle_delete()
794794

795795
text_area:setCursor(123)
796796
journal:onRender()
797-
simulate_input_keys('CUSTOM_CTRL_D')
797+
simulate_input_keys('CUSTOM_DELETE')
798798

799799
expect.eq(read_rendered_text(text_area), table.concat({
800800
'0: Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
@@ -805,7 +805,7 @@ function test.handle_delete()
805805

806806
text_area:setCursor(171)
807807
journal:onRender()
808-
simulate_input_keys('CUSTOM_CTRL_D')
808+
simulate_input_keys('CUSTOM_DELETE')
809809

810810
expect.eq(read_rendered_text(text_area), table.concat({
811811
'0: Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
@@ -815,7 +815,7 @@ function test.handle_delete()
815815
}, '\n'));
816816

817817
for i=1,59 do
818-
simulate_input_keys('CUSTOM_CTRL_D')
818+
simulate_input_keys('CUSTOM_DELETE')
819819
end
820820

821821
expect.eq(read_rendered_text(text_area), table.concat({
@@ -824,7 +824,7 @@ function test.handle_delete()
824824
'nibhorttitor mi, vitae rutrum eros metus nec libero._',
825825
}, '\n'));
826826

827-
simulate_input_keys('CUSTOM_CTRL_D')
827+
simulate_input_keys('CUSTOM_DELETE')
828828

829829
expect.eq(read_rendered_text(text_area), table.concat({
830830
'0: Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
@@ -849,7 +849,7 @@ function test.line_end()
849849
text_area:setCursor(1)
850850
journal:onRender()
851851

852-
simulate_input_keys('CUSTOM_CTRL_E')
852+
simulate_input_keys('CUSTOM_END')
853853

854854
expect.eq(read_rendered_text(text_area), table.concat({
855855
'60: Lorem ipsum dolor sit amet, consectetur adipiscing elit._',
@@ -861,7 +861,7 @@ function test.line_end()
861861
text_area:setCursor(70)
862862
journal:onRender()
863863

864-
simulate_input_keys('CUSTOM_CTRL_E')
864+
simulate_input_keys('CUSTOM_END')
865865

866866
expect.eq(read_rendered_text(text_area), table.concat({
867867
'60: Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
@@ -873,7 +873,7 @@ function test.line_end()
873873
text_area:setCursor(200)
874874
journal:onRender()
875875

876-
simulate_input_keys('CUSTOM_CTRL_E')
876+
simulate_input_keys('CUSTOM_END')
877877

878878
expect.eq(read_rendered_text(text_area), table.concat({
879879
'60: Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
@@ -882,7 +882,7 @@ function test.line_end()
882882
'60: Lorem ipsum dolor sit amet, consectetur adipiscing elit._',
883883
}, '\n'));
884884

885-
simulate_input_keys('CUSTOM_CTRL_E')
885+
simulate_input_keys('CUSTOM_END')
886886

887887
expect.eq(read_rendered_text(text_area), table.concat({
888888
'60: Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
@@ -905,7 +905,7 @@ function test.line_beging()
905905

906906
simulate_input_text(text)
907907

908-
simulate_input_keys('CUSTOM_CTRL_H')
908+
simulate_input_keys('CUSTOM_HOME')
909909

910910
expect.eq(read_rendered_text(text_area), table.concat({
911911
'60: Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
@@ -917,7 +917,7 @@ function test.line_beging()
917917
text_area:setCursor(173)
918918
journal:onRender()
919919

920-
simulate_input_keys('CUSTOM_CTRL_H')
920+
simulate_input_keys('CUSTOM_HOME')
921921

922922
expect.eq(read_rendered_text(text_area), table.concat({
923923
'60: Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
@@ -929,7 +929,7 @@ function test.line_beging()
929929
text_area:setCursor(1)
930930
journal:onRender()
931931

932-
simulate_input_keys('CUSTOM_CTRL_H')
932+
simulate_input_keys('CUSTOM_HOME')
933933

934934
expect.eq(read_rendered_text(text_area), table.concat({
935935
'_0: Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
@@ -1355,10 +1355,10 @@ function test.line_navigation_reset_selection()
13551355
'porttitor mi, vitae rutrum eros metus nec libero.',
13561356
}, '\n'));
13571357

1358-
simulate_input_keys('CUSTOM_CTRL_H')
1358+
simulate_input_keys('CUSTOM_HOME')
13591359
expect.eq(read_selected_text(text_area), '')
13601360

1361-
simulate_input_keys('CUSTOM_CTRL_E')
1361+
simulate_input_keys('CUSTOM_END')
13621362
expect.eq(read_selected_text(text_area), '')
13631363

13641364
journal:dismiss()
@@ -1496,7 +1496,7 @@ function test.delete_char_delete_selection()
14961496
'porttitor mi, vitae rutrum ero',
14971497
}, '\n'));
14981498

1499-
simulate_input_keys('CUSTOM_CTRL_D')
1499+
simulate_input_keys('CUSTOM_DELETE')
15001500

15011501
expect.eq(read_rendered_text(text_area), table.concat({
15021502
'60: _ metus nec libero.',
@@ -2236,7 +2236,7 @@ function test.restore_text_between_sessions()
22362236
local journal, text_area = arrange_empty_journal({w=80,save_on_change=true})
22372237

22382238
simulate_input_keys('CUSTOM_CTRL_A')
2239-
simulate_input_keys('CUSTOM_CTRL_D')
2239+
simulate_input_keys('CUSTOM_DELETE')
22402240

22412241
local text = table.concat({
22422242
'60: Lorem ipsum dolor sit amet, consectetur adipiscing elit.',

0 commit comments

Comments
 (0)