fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
fb2d427a4
master
1#!/usr/bin/env python3 2from pexpect_helper import SpawnedProc 3 4sp = SpawnedProc () 5sendline ,expect_prompt ,expect_str = sp .sendline ,sp .expect_prompt ,sp .expect_str 6expect_prompt () 7 8# Set up key bindings 9 10# Movement keys from the default key bindings 11home ,end = "\x01" ,"\x05" # Ctrl-A, Ctrl-E 12left ,right = "\x02" ,"\x06" # Ctrl-B, Ctrl-F 13 14# Additional keys to start selecting and dump the current selection 15select ,dump = "\x00" ,"!" # Ctrl-Space, "!" 16 17sendline ("bind ctrl-space begin-selection" ) 18expect_prompt () 19sendline ("bind ! 'echo -n \"<$(commandline --current-selection)>\"'" ) 20expect_prompt () 21 22# Test inclusive mode 23 24sendline ("set fish_cursor_selection_mode inclusive" ) 25 26# at the beginning of the line 27sendline ("echo" + home + select + dump ) 28expect_str ("<e>" ) 29sendline ("echo" + home + select + right + dump ) 30expect_str ("<ec>" ) 31sendline ("echo" + home + right + select + left + dump ) 32expect_str ("<ec>" ) 33 34# in the middle of the line 35sendline ("echo" + home + right + select + dump ) 36expect_str ("<c>" ) 37sendline ("echo" + home + right + select + right + dump ) 38expect_str ("<ch>" ) 39sendline ("echo" + home + right + right + select + left + dump ) 40expect_str ("<ch>" ) 41 42# at the end of the line 43sendline ("echo" + end + select + dump ) 44expect_str ("<>" ) 45sendline ("echo" + end + select + left + dump ) 46expect_str ("<o>" ) 47sendline ("echo" + end + left + select + right + dump ) 48expect_str ("<o>" ) 49 50# Test exclusive mode 51 52sendline ("set fish_cursor_selection_mode exclusive" ) 53 54# at the beginning of the line 55sendline ("echo" + home + select + dump ) 56expect_str ("<>" ) 57sendline ("echo" + home + select + right + dump ) 58expect_str ("<e>" ) 59sendline ("echo" + home + right + select + left + dump ) 60expect_str ("<e>" ) 61 62# in the middle of the line 63sendline ("echo" + home + right + select + dump ) 64expect_str ("<>" ) 65sendline ("echo" + home + right + select + right + dump ) 66expect_str ("<c>" ) 67sendline ("echo" + home + right + right + select + left + dump ) 68expect_str ("<c>" ) 69 70# at the end of the line 71sendline ("echo" + end + select + dump ) 72expect_str ("<>" ) 73sendline ("echo" + end + select + left + dump ) 74expect_str ("<o>" ) 75sendline ("echo" + end + left + select + right + dump ) 76expect_str ("<o>" ) 77 78# Test default setting. 79# We only test that the correct implementation is chosen and rely on the detailed tests from above. 80 81# without a configured selection mode 82sendline ("set -u fish_cursor_selection_mode" ) 83sendline ("echo" + home + right + select + right + dump ) 84expect_str ("<c>" ) 85 86# with an unknown setting 87sendline ("set fish_cursor_selection_mode unknown" ) 88sendline ("echo" + home + right + select + right + dump ) 89expect_str ("<c>" )