Shells in OCaml
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

Support ctrl-left and ctrl-right

Changes to bruit.

+63 -11
+63 -11
vendor/bruit/src/bruit.ml
··· 147 147 c_vmin = 1; 148 148 } 149 149 in 150 - Unix.tcsetattr state.ifd TCSAFLUSH tio; 150 + Unix.tcsetattr state.ifd TCSADRAIN tio; 151 151 Fun.protect 152 152 ~finally:(fun () -> Unix.tcsetattr state.ifd TCSADRAIN saved_tio) 153 153 fn ··· 386 386 in 387 387 refresh_line s 388 388 389 + let move_right_next_word (state : State.t) = 390 + let pos = ref state.pos in 391 + while !pos < state.len && Bytes.get state.buf !pos = ' ' do 392 + incr pos 393 + done; 394 + while !pos < state.len && Bytes.get state.buf !pos <> ' ' do 395 + incr pos 396 + done; 397 + let s = State.override ~pos:!pos state in 398 + refresh_line s 399 + 400 + let move_left_next_word (state : State.t) = 401 + let pos = ref state.pos in 402 + while !pos > 0 && Bytes.get state.buf !pos = ' ' do 403 + decr pos 404 + done; 405 + while !pos > 0 && Bytes.get state.buf !pos <> ' ' do 406 + decr pos 407 + done; 408 + let s = State.override ~pos:!pos state in 409 + refresh_line s 410 + 389 411 let reverse_incr_search ~history (state : State.t) = 390 412 let has_match = ref true in 391 413 let search_buf = Buffer.create 16 in ··· 539 561 | Backspace -> Editing (edit_backspace state) 540 562 | Tab -> Editing state 541 563 | Escape_sequence -> ( 542 - let c1 = 564 + let c0 = 543 565 read_char state |> function `Some c -> c | _ -> assert false 544 566 in 545 - let c2 = 546 - read_char state |> function `Some c -> c | _ -> assert false 547 - in 548 - match (c1, c2) with 549 - | '[', 'A' -> Editing (edit_history `Prev history state) 550 - | '[', 'B' -> Editing (edit_history `Next history state) 551 - | '[', 'C' -> Editing (move_right state) 552 - | '[', 'D' -> Editing (move_left state) 567 + match c0 with 568 + | '[' -> 569 + let c1 = 570 + read_char state |> function 571 + | `Some c -> c 572 + | _ -> assert false 573 + in 574 + if Char.compare c1 '0' >= 0 && Char.compare c1 '9' <= 0 then 575 + let c2 = 576 + read_char state |> function 577 + | `Some c -> c 578 + | _ -> assert false 579 + in 580 + let c3 = 581 + match read_char state with 582 + | `Some c -> Some c 583 + | (exception _) | _ -> None 584 + in 585 + let c4 = 586 + match read_char state with 587 + | `Some c -> Some c 588 + | (exception _) | _ -> None 589 + in 590 + match (c2, c3) with 591 + | ';', Some '5' -> ( 592 + match c4 with 593 + | Some 'D' -> Editing (move_left_next_word state) 594 + | Some 'C' -> Editing (move_right_next_word state) 595 + | _ -> Editing state) 596 + | _ -> Editing state 597 + else begin 598 + match c1 with 599 + | 'A' -> Editing (edit_history `Prev history state) 600 + | 'B' -> Editing (edit_history `Next history state) 601 + | 'C' -> Editing (move_right state) 602 + | 'D' -> Editing (move_left state) 603 + | _ -> Editing state 604 + end 553 605 | _ -> Editing state) 554 - | Unknown _ | _ -> 606 + | _ -> 555 607 let state = edit_insert state uc in 556 608 Editing state)) 557 609