fortrangoingonforty/fortsh / 3feed7f

Browse files

make Ctrl+X dual-mode: cut selection or enter process-kill

Authored by espadonne
SHA
3feed7fc8e26d2847b5fafcfc93473ff199e6eef
Parents
853c41e
Tree
4d6df57

2 changed files

StatusFile+-
M src/io/readline.f90 10 3
M tests/interactive/utils/keys.py 3 2
src/io/readline.f90modified
@@ -48,7 +48,7 @@ module readline
4848
   integer, parameter :: KEY_CTRL_C = 3
4949
   integer, parameter :: KEY_CTRL_D = 4
5050
   integer, parameter :: KEY_CTRL_V = 22   ! Paste from system clipboard / kill buffer
51
-  integer, parameter :: KEY_CTRL_X = 24   ! Process kill mode
51
+  integer, parameter :: KEY_CTRL_X = 24   ! Cut selection / Process kill mode
5252
   integer, parameter :: KEY_CTRL_A = 1    ! Home (beginning of line)
5353
   integer, parameter :: KEY_CTRL_E = 5    ! End (end of line)
5454
   integer, parameter :: KEY_CTRL_K = 11   ! Kill to end of line
@@ -1576,8 +1576,15 @@ contains
15761576
           done = .true.
15771577
 
15781578
         case(KEY_CTRL_X)
1579
-          ! Ctrl+X - Enter process kill mode (no-op in search mode)
1580
-          if (.not. module_input_state%in_search .and. &
1579
+          ! Ctrl+X — dual-mode (Sprint 5):
1580
+          !   1. If a selection is active, CUT (same as Ctrl+W on selection:
1581
+          !      copy to kill buffer + system clipboard, then delete range).
1582
+          !   2. Otherwise, enter process kill mode (existing behavior).
1583
+          if (module_input_state%selection_active) then
1584
+            call copy_selection_to_kill_buffer(module_input_state)
1585
+            call delete_selection(module_input_state)
1586
+            call update_autosuggestion(module_input_state)
1587
+          else if (.not. module_input_state%in_search .and. &
15811588
               .not. module_input_state%in_process_kill_mode) then
15821589
             call enter_process_kill_mode(module_input_state)
15831590
           end if
tests/interactive/utils/keys.pymodified
@@ -56,8 +56,8 @@ CTRL_S = "\x13" # Forward search / Suspend output
5656
 CTRL_T = "\x14"  # Transpose characters
5757
 CTRL_U = "\x15"  # Kill to beginning of line
5858
 CTRL_V = "\x16"  # Paste from clipboard / kill buffer
59
-CTRL_W = "\x17"  # Kill word backward
60
-CTRL_X = "\x18"  # Prefix
59
+CTRL_W = "\x17"  # Kill word backward / cut selection
60
+CTRL_X = "\x18"  # Cut selection / process kill mode
6161
 CTRL_Y = "\x19"  # Yank
6262
 CTRL_Z = "\x1a"  # Suspend (SIGTSTP)
6363
 
@@ -156,6 +156,7 @@ KEYS = {
156156
     "C-u": CTRL_U,
157157
     "C-v": CTRL_V,
158158
     "C-w": CTRL_W,
159
+    "C-x": CTRL_X,
159160
     "C-y": CTRL_Y,
160161
     "C-z": CTRL_Z,
161162