diff --git a/src/bin/main.rs b/src/bin/main.rs index b05e9c680..4b6a43586 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -15,7 +15,6 @@ use swim::agent::datapath_reducer::DatapathReducer; use swim::agent::EmulationCoreAgent; use swim::emulation_core::mips::datapath::Stage; use swim::parser::parser_assembler_main::parser; -use swim::parser::parser_structs_and_enums::LabelInstance; use swim::parser::parser_structs_and_enums::ProgramInfo; use swim::ui::footer::component::Footer; use swim::ui::regview::component::Regview; diff --git a/src/ui/hex_editor/component.rs b/src/ui/hex_editor/component.rs index e4b56ec7c..e78795689 100644 --- a/src/ui/hex_editor/component.rs +++ b/src/ui/hex_editor/component.rs @@ -143,6 +143,10 @@ pub fn hex_editor(props: &HexEditorProps) -> Html { } let on_editor_created = { + let memory_curr_instr = props.memory_curr_instr.clone(); + let datapath_state = props.datapath_state.clone(); + memory_curr_instr.set(datapath_state.mips.registers.pc); + use_callback( move |editor_link: CodeEditorLink, (datapath_state, memory_text_model, memory_curr_instr)| { @@ -156,7 +160,7 @@ pub fn hex_editor(props: &HexEditorProps) -> Html { let raw_editor = editor.as_ref(); let cb_func = &cb.as_ref().unchecked_ref(); - let coords = get_hex_coords(*memory_curr_instr); + let coords = get_hex_coords(**memory_curr_instr); raw_editor.on_did_change_cursor_selection(cb_func); raw_editor.reveal_line_in_center(coords.line_number, Some(ScrollType::Smooth)); diff --git a/src/ui/swim_editor/component.rs b/src/ui/swim_editor/component.rs index 21ae6985e..858f5054d 100644 --- a/src/ui/swim_editor/component.rs +++ b/src/ui/swim_editor/component.rs @@ -21,6 +21,7 @@ use yew::prelude::*; use yew::{html, Callback, Properties}; use yew_hooks::prelude::*; +use crate::agent::datapath_reducer::DatapathReducer; use crate::emulation_core::mips::memory::Memory; use crate::emulation_core::mips::stack::Stack; use crate::ui::assembled_view::component::{StackFrameView, StackSegment}; @@ -105,8 +106,13 @@ pub fn SwimEditor(props: &SwimEditorProps) -> Html { let on_editor_created = { let curr_line = props.editor_curr_line.clone(); + let program_info = props.program_info.clone(); let lines_content = Rc::clone(&props.lines_content); + let list_of_line_numbers = program_info.address_to_line_number; + let index = props.pc as usize / 4; + curr_line.set(*list_of_line_numbers.get(index).unwrap_or(&0) as f64 + 1.0); // add one to account for the editor's line numbers + use_callback( move |editor_link: CodeEditorLink, curr_line| { match editor_link.with_editor(|editor| {