Skip to content

Commit efd2b70

Browse files
committed
also make use of Ctrl-Home and Ctrl-End
1 parent 0dec633 commit efd2b70

File tree

3 files changed

+41
-25
lines changed

3 files changed

+41
-25
lines changed

docs/gui/journal.rst

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,46 @@ Supported Features
3030
multiline text input.
3131
- Text Wrapping: Text automatically wraps within the editor, ensuring lines fit
3232
within the display without manual adjustments.
33-
- Backspace Support: Use the backspace key to delete characters to the left of the cursor.
34-
- Delete Character: :kbd:`Ctrl` + :kbd:`D` deletes the character under the cursor.
35-
- 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.
36-
- Delete Current Line: :kbd:`Ctrl` + :kbd:`U` deletes the entire current line where the cursor is located.
37-
- Delete Rest of Line: :kbd:`Ctrl` + :kbd:`K` deletes text from the cursor to the end of the line.
38-
- Delete Last Word: :kbd:`Ctrl` + :kbd:`W` removes the word immediately before the cursor.
39-
- Text Selection: Select text with the mouse, with support for replacing or removing selected text.
40-
- Jump to Beginning/End: Quickly move the cursor to the beginning or end of the text using :kbd:`Shift` + :kbd:`Up` and :kbd:`Shift` + :kbd:`Down`.
41-
- Select Word/Line: Use double click to select current word, or triple click to select current line
33+
- Backspace Support: Use the backspace key to delete characters to the left of
34+
the cursor.
35+
- Delete Character: :kbd:`Delete` deletes the character under the cursor.
36+
- Line Navigation: :kbd:`Home` moves the cursor to the beginning of the current
37+
line, and :kbd:`End` moves it to the end.
38+
- Delete Current Line: :kbd:`Ctrl` + :kbd:`U` deletes the entire current line
39+
where the cursor is located.
40+
- Delete Rest of Line: :kbd:`Ctrl` + :kbd:`K` deletes text from the cursor to
41+
the end of the line.
42+
- Delete Last Word: :kbd:`Ctrl` + :kbd:`W` removes the word immediately before
43+
the cursor.
44+
- Text Selection: Select text with the mouse, with support for replacing or
45+
removing selected text.
46+
- Jump to Beginning/End: Quickly move the cursor to the beginning or end of the
47+
text using :kbd:`Ctrl` + :kbd:`Home` and :kbd:`Ctrl` + :kbd:`End`.
48+
- Select Word/Line: Use double click to select current word, or triple click to
49+
select current line
4250
- Select All: Select entire text by :kbd:`Ctrl` + :kbd:`A`
43-
- Undo/Redo: Undo/Redo changes by :kbd:`Ctrl` + :kbd:`Z` / :kbd:`Ctrl` + :kbd:`Y`
44-
- Clipboard Operations: Perform OS clipboard cut, copy, and paste operations on selected text, allowing you to paste the copied content into other applications.
51+
- Undo/Redo: Undo/Redo changes by :kbd:`Ctrl` + :kbd:`Z` / :kbd:`Ctrl` +
52+
:kbd:`Y`
53+
- Clipboard Operations: Perform OS clipboard cut, copy, and paste operations on
54+
selected text, allowing you to paste the copied content into other
55+
applications.
4556
- Copy Text: Use :kbd:`Ctrl` + :kbd:`C` to copy selected text.
4657
- copy selected text, if available
47-
- If no text is selected it copy the entire current line, including the terminating newline if present.
58+
- If no text is selected it copy the entire current line, including the
59+
terminating newline if present.
4860
- Cut Text: Use :kbd:`Ctrl` + :kbd:`X` to cut selected text.
4961
- cut selected text, if available
50-
- If no text is selected it will cut the entire current line, including the terminating newline if present
51-
- Paste Text: Use :kbd:`Ctrl` + :kbd:`V` to paste text from the clipboard into the editor.
62+
- If no text is selected it will cut the entire current line, including the
63+
terminating newline if present
64+
- Paste Text: Use :kbd:`Ctrl` + :kbd:`V` to paste text from the clipboard into
65+
the editor.
5266
- replace selected text, if available
5367
- If no text is selected, paste text in the cursor position
5468
- Scrolling behaviour for long text build-in
55-
- Table of contents (:kbd:`Ctrl` + :kbd:`O`), with headers line prefixed by '#', e.g. '# Fort history', '## Year 1'
56-
- Table of contents navigation: jump to previous/next section by :kbd:`Ctrl` + :kbd:`Up` / :kbd:`Ctrl` + :kbd:`Down`
69+
- Table of contents (:kbd:`Ctrl` + :kbd:`O`), with headers line prefixed by
70+
``#``, e.g. ``# Fort history``, ``## Year 1``
71+
- Table of contents navigation: jump to previous/next section by :kbd:`Ctrl` +
72+
:kbd:`Up` / :kbd:`Ctrl` + :kbd:`Down`
5773

5874
Usage
5975
-----

internal/journal/text_editor.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,10 +761,10 @@ function TextEditorView:onCursorInput(keys)
761761
self:setCursor(offset)
762762
self.last_cursor_x = last_cursor_x
763763
return true
764-
elseif keys.KEYBOARD_CURSOR_UP_FAST then
764+
elseif keys.CUSTOM_CTRL_HOME then
765765
self:setCursor(1)
766766
return true
767-
elseif keys.KEYBOARD_CURSOR_DOWN_FAST then
767+
elseif keys.CUSTOM_CTRL_END then
768768
-- go to text end
769769
self:setCursor(#self.text + 1)
770770
return true

test/gui/journal.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ function test.jump_to_text_end()
11101110
text_area:setCursor(1)
11111111
journal:onRender()
11121112

1113-
simulate_input_keys('KEYBOARD_CURSOR_DOWN_FAST')
1113+
simulate_input_keys('CUSTOM_CTRL_END')
11141114

11151115
expect.eq(read_rendered_text(text_area), table.concat({
11161116
'60: Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
@@ -1119,7 +1119,7 @@ function test.jump_to_text_end()
11191119
'60: Lorem ipsum dolor sit amet, consectetur adipiscing elit._',
11201120
}, '\n'));
11211121

1122-
simulate_input_keys('KEYBOARD_CURSOR_DOWN_FAST')
1122+
simulate_input_keys('CUSTOM_CTRL_END')
11231123

11241124
expect.eq(read_rendered_text(text_area), table.concat({
11251125
'60: Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
@@ -1142,7 +1142,7 @@ function test.jump_to_text_begin()
11421142

11431143
simulate_input_text(text)
11441144

1145-
simulate_input_keys('KEYBOARD_CURSOR_UP_FAST')
1145+
simulate_input_keys('CUSTOM_CTRL_HOME')
11461146

11471147
expect.eq(read_rendered_text(text_area), table.concat({
11481148
'_0: Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
@@ -1151,7 +1151,7 @@ function test.jump_to_text_begin()
11511151
'60: Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
11521152
}, '\n'));
11531153

1154-
simulate_input_keys('KEYBOARD_CURSOR_UP_FAST')
1154+
simulate_input_keys('CUSTOM_CTRL_HOME')
11551155

11561156
expect.eq(read_rendered_text(text_area), table.concat({
11571157
'_0: Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
@@ -1388,10 +1388,10 @@ function test.jump_begin_or_end_reset_selection()
13881388
'porttitor mi, vitae rutrum eros metus nec libero.',
13891389
}, '\n'));
13901390

1391-
simulate_input_keys('KEYBOARD_CURSOR_UP_FAST')
1391+
simulate_input_keys('CUSTOM_CTRL_HOME')
13921392
expect.eq(read_selected_text(text_area), '')
13931393

1394-
simulate_input_keys('KEYBOARD_CURSOR_DOWN_FAST')
1394+
simulate_input_keys('CUSTOM_CTRL_END')
13951395
expect.eq(read_selected_text(text_area), '')
13961396

13971397
journal:dismiss()
@@ -2426,7 +2426,7 @@ function test.scroll_follows_cursor()
24262426
'Ut gravida tortor ac accumsan suscipit.',
24272427
}, '\n'))
24282428

2429-
simulate_input_keys('KEYBOARD_CURSOR_UP_FAST')
2429+
simulate_input_keys('CUSTOM_CTRL_HOME')
24302430

24312431
simulate_mouse_click(text_area, 0, 9)
24322432
simulate_input_keys('KEYBOARD_CURSOR_DOWN')

0 commit comments

Comments
 (0)