@@ -340,62 +340,67 @@ fn global_keybindings(world: &mut World) {
340340 } ,
341341 ) ;
342342
343- kb. bind ( GLOBAL , KeyBinding :: key ( KeyCode :: Enter ) , "Edit" , |world| {
344- let mode = world. get :: < EditorState > ( ) . mode . clone ( ) ;
345- if mode != EditorMode :: Normal {
346- return ;
347- }
343+ kb. bind_many (
344+ GLOBAL ,
345+ keys ! [ 'e' , KeyBinding :: key( KeyCode :: Enter ) ] ,
346+ "Edit" ,
347+ |world| {
348+ let mode = world. get :: < EditorState > ( ) . mode . clone ( ) ;
349+ if mode != EditorMode :: Normal {
350+ return ;
351+ }
348352
349- let selection = world. get :: < EditorState > ( ) . selection ;
350- match selection {
351- Selection :: Event ( idx) => {
352- let event_data = {
353- let diagram = world. get :: < SequenceDiagram > ( ) ;
354- diagram. events . get ( idx) . cloned ( )
355- } ;
356- match event_data {
357- Some ( Event :: Message { from, to, text } ) => {
358- let editor = world. get_mut :: < EditorState > ( ) ;
359- editor. editing_event_index = Some ( idx) ;
360- editor. message_from = Some ( from) ;
361- editor. message_to = Some ( to) ;
362- editor. input_buffer = text;
363- editor. selected_index = from;
364- editor. mode = EditorMode :: EditSelectFrom ;
353+ let selection = world. get :: < EditorState > ( ) . selection ;
354+ match selection {
355+ Selection :: Event ( idx) => {
356+ let event_data = {
357+ let diagram = world. get :: < SequenceDiagram > ( ) ;
358+ diagram. events . get ( idx) . cloned ( )
359+ } ;
360+ match event_data {
361+ Some ( Event :: Message { from, to, text } ) => {
362+ let editor = world. get_mut :: < EditorState > ( ) ;
363+ editor. editing_event_index = Some ( idx) ;
364+ editor. message_from = Some ( from) ;
365+ editor. message_to = Some ( to) ;
366+ editor. input_buffer = text;
367+ editor. selected_index = from;
368+ editor. mode = EditorMode :: EditSelectFrom ;
369+ }
370+ Some ( Event :: Note {
371+ position,
372+ participant_start,
373+ participant_end,
374+ text,
375+ } ) => {
376+ let editor = world. get_mut :: < EditorState > ( ) ;
377+ editor. editing_event_index = Some ( idx) ;
378+ editor. note_position = position;
379+ editor. note_participant_start = Some ( participant_start) ;
380+ editor. note_participant_end = Some ( participant_end) ;
381+ editor. input_buffer = text;
382+ editor. selected_index = participant_start;
383+ editor. mode = EditorMode :: EditNoteParticipant ;
384+ }
385+ None => { }
365386 }
366- Some ( Event :: Note {
367- position,
368- participant_start,
369- participant_end,
370- text,
371- } ) => {
387+ }
388+ Selection :: Participant ( idx) => {
389+ let name = {
390+ let diagram = world. get :: < SequenceDiagram > ( ) ;
391+ diagram. participants . get ( idx) . cloned ( )
392+ } ;
393+ if let Some ( name) = name {
372394 let editor = world. get_mut :: < EditorState > ( ) ;
373- editor. editing_event_index = Some ( idx) ;
374- editor. note_position = position;
375- editor. note_participant_start = Some ( participant_start) ;
376- editor. note_participant_end = Some ( participant_end) ;
377- editor. input_buffer = text;
378- editor. selected_index = participant_start;
379- editor. mode = EditorMode :: EditNoteParticipant ;
395+ editor. selected_index = idx;
396+ editor. input_buffer = name;
397+ editor. mode = EditorMode :: RenameParticipant ;
380398 }
381- None => { }
382- }
383- }
384- Selection :: Participant ( idx) => {
385- let name = {
386- let diagram = world. get :: < SequenceDiagram > ( ) ;
387- diagram. participants . get ( idx) . cloned ( )
388- } ;
389- if let Some ( name) = name {
390- let editor = world. get_mut :: < EditorState > ( ) ;
391- editor. selected_index = idx;
392- editor. input_buffer = name;
393- editor. mode = EditorMode :: RenameParticipant ;
394399 }
400+ Selection :: None => { }
395401 }
396- Selection :: None => { }
397- }
398- } ) ;
402+ } ,
403+ ) ;
399404
400405 kb. bind ( GLOBAL , 'r' , "Rename" , |world| {
401406 let mode = world. get :: < EditorState > ( ) . mode . clone ( ) ;
0 commit comments