Skip to content

Commit

Permalink
New keybindings
Browse files Browse the repository at this point in the history
  • Loading branch information
JuneRousseau committed Aug 11, 2023
1 parent 1d4a440 commit b5943e6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@ For an interactive version of the interpreter: `./interpreter -I <file>`
| `SPACE` | next step |
| `n` | next 10 steps |
| `BACKSPACE` | cancel the last step(s) |
| `Arrow Up` | navigate up memory (1 adresse) |
| `Arrow Down` | navigate down memory (1 adresse) |
| `Arrow Up` | navigate up memory (1 address) |
| `Arrow Down` | navigate down memory (1 address) |
| `Arrow Left` | navigate up memory (1 page) |
| `Arrow Right` | navigate down memory (1 page) |
| `Arrow Left` + `SHIFT` | navigate up memory (10 pages) |
| `Arrow Right` + `SHIFT` | navigate down memory (10 pages) |
| `TAB` | follow the cursor of PC |
| `TAB` + `SHIFT` | follow the cursor of STK |


The `Arrow` keybindings can be combined with `CTLR` for navigating in the stack.
It is possible to scroll for navigating through the memory and the stack (depending on the position of cursor of the mouse). Combine mouse scroll + `CTLR` for navigating faster.
19 changes: 15 additions & 4 deletions lib/interactive_ui.ml
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,8 @@ module MkUi (Cfg: MachineConfig) : Ui = struct
else false
in
let rec loop
?(update_prog = Program_panel.follow_addr)
?(update_stk = Program_panel.follow_addr)
?(update_prog = Program_panel.id)
?(update_stk = Program_panel.id)
show_stack
m
history
Expand Down Expand Up @@ -504,23 +504,34 @@ module MkUi (Cfg: MachineConfig) : Ui = struct
then loop ~update_stk:upd_fnt show_stack m history
else loop ~update_prog:upd_fnt show_stack m history

| `Key (`Tab, l) ->
begin
match l with
| [`Shift] -> loop ~update_stk:Program_panel.follow_addr show_stack m history
| _ -> loop ~update_prog:Program_panel.follow_addr show_stack m history
end
| `Key (`ASCII 's', _) ->
loop ~update_prog:Program_panel.id
(toggle_show_stack show_stack) m history

| `Key (`ASCII ' ', _) ->
begin
match Machine.step m with
| Some m' -> loop show_stack m' (m::history)
| Some m' ->
loop ~update_prog:Program_panel.follow_addr ~update_stk:Program_panel.follow_addr show_stack m' (m::history)
| None -> (* XX *) loop show_stack m history
end
| `Key (`ASCII 'n', _) ->
begin
match Machine.step_n m 10 with
| Some m' when m != m'-> loop show_stack m' (m::history)
| Some m' when m != m'
-> loop ~update_prog:Program_panel.follow_addr ~update_stk:Program_panel.follow_addr show_stack m' (m::history)
| _ -> (* XX *) loop show_stack m history
end

(* TODO it would be great if backspace unrolls one "step", and
not the last "n-steps": it means that step_n actually returns a list
of machine_state, not only the last one *)
| `Key (`Backspace, _) ->
begin
match history with
Expand Down

0 comments on commit b5943e6

Please sign in to comment.