Index: trunk/src/action_helper.c =================================================================== --- trunk/src/action_helper.c (revision 16599) +++ trunk/src/action_helper.c (revision 16600) @@ -183,7 +183,7 @@ pcb_tool_release_mode(); if (pcb_tool_is_saved) - pcb_crosshair_restore_mode(); + pcb_tool_restore(); pcb_tool_is_saved = pcb_false; pcb_draw(); } Index: trunk/src/crosshair.c =================================================================== --- trunk/src/crosshair.c (revision 16599) +++ trunk/src/crosshair.c (revision 16600) @@ -1074,10 +1074,6 @@ pcb_gui->destroy_gc(pcb_crosshair.GC); } -/************************* mode *************************************/ -static int mode_position = 0; -static int mode_stack[PCB_MAX_MODESTACK_DEPTH]; - /* sets the crosshair range to the current buffer extents */ void pcb_crosshair_range_to_buffer(void) { @@ -1094,22 +1090,6 @@ } } -void pcb_crosshair_save_mode(void) -{ - mode_stack[mode_position] = conf_core.editor.mode; - if (mode_position < PCB_MAX_MODESTACK_DEPTH - 1) - mode_position++; -} - -void pcb_crosshair_restore_mode(void) -{ - if (mode_position == 0) { - pcb_message(PCB_MSG_ERROR, "hace: underflow of restore mode\n"); - return; - } - pcb_tool_select_by_id(mode_stack[--mode_position]); -} - void pcb_crosshair_set_local_ref(pcb_coord_t X, pcb_coord_t Y, pcb_bool Showing) { static pcb_mark_t old; Index: trunk/src/crosshair.h =================================================================== --- trunk/src/crosshair.h (revision 16599) +++ trunk/src/crosshair.h (revision 16600) @@ -114,12 +114,8 @@ void pcb_crosshair_grid_fit(pcb_coord_t, pcb_coord_t); void pcb_center_display(pcb_coord_t X, pcb_coord_t Y); -/*** cursor/crosshair mode ***/ - /* sets the crosshair range to the current buffer extents */ void pcb_crosshair_range_to_buffer(void); -void pcb_crosshair_save_mode(void); -void pcb_crosshair_restore_mode(void); void pcb_crosshair_set_local_ref(pcb_coord_t X, pcb_coord_t Y, pcb_bool Showing); Index: trunk/src/gui_act.c =================================================================== --- trunk/src/gui_act.c (revision 16599) +++ trunk/src/gui_act.c (revision 16600) @@ -713,7 +713,7 @@ else if (conf_core.editor.mode == PCB_MODE_POLYGON && pcb_crosshair.AttachedLine.State != PCB_CH_STATE_FIRST) pcb_tool_select_by_id(PCB_MODE_POLYGON); else { - pcb_crosshair_save_mode(); + pcb_tool_save(); pcb_tool_is_saved = pcb_true; pcb_tool_select_by_id(PCB_MODE_ARROW); pcb_notify_mode(); @@ -729,12 +729,12 @@ pcb_tool_select_by_id(PCB_MODE_VIA); break; - case F_Restore: /* restore the last saved mode */ - pcb_crosshair_restore_mode(); + case F_Restore: /* restore the last saved tool */ + pcb_tool_restore(); break; - case F_Save: /* save currently selected mode */ - pcb_crosshair_save_mode(); + case F_Save: /* save currently selected tool */ + pcb_tool_save(); break; } pcb_notify_crosshair_change(pcb_true); Index: trunk/src/remove_act.c =================================================================== --- trunk/src/remove_act.c (revision 16599) +++ trunk/src/remove_act.c (revision 16600) @@ -62,10 +62,10 @@ switch (id) { case F_Object: pcb_gui->get_coords("Click on object to delete", &pcb_tool_note.X, &pcb_tool_note.Y); - pcb_crosshair_save_mode(); + pcb_tool_save(); pcb_tool_select_by_id(PCB_MODE_REMOVE); pcb_notify_mode(); - pcb_crosshair_restore_mode(); + pcb_tool_restore(); break; case F_Selected: pcb_remove_selected(); Index: trunk/src/tool.c =================================================================== --- trunk/src/tool.c (revision 16599) +++ trunk/src/tool.c (revision 16600) @@ -44,6 +44,8 @@ pcb_toolid_t pcb_tool_prev_id; pcb_toolid_t pcb_tool_next_id; +static int save_position = 0; +static int save_stack[PCB_MAX_MODESTACK_DEPTH]; static void default_tool_reg(void); static void default_tool_unreg(void); @@ -162,6 +164,25 @@ return pcb_tool_select_by_id(bestn); } +int pcb_tool_save(void) +{ + save_stack[save_position] = conf_core.editor.mode; + if (save_position < PCB_MAX_MODESTACK_DEPTH - 1) + save_position++; + else + return -1; + return 0; +} + +int pcb_tool_restore(void) +{ + if (save_position == 0) { + pcb_message(PCB_MSG_ERROR, "hace: underflow of restore mode\n"); + return -1; + } + return pcb_tool_select_by_id(save_stack[--save_position]); +} + /**** current tool function wrappers ****/ #define wrap(func, err_ret, prefix, args) \ do { \ Index: trunk/src/tool.h =================================================================== --- trunk/src/tool.h (revision 16599) +++ trunk/src/tool.h (revision 16600) @@ -95,6 +95,9 @@ int pcb_tool_select_by_id(pcb_toolid_t id); int pcb_tool_select_highest(void); +int pcb_tool_save(void); +int pcb_tool_restore(void); + /**** Tool function wrappers; calling these will operate on the current tool as defined in conf_core.editor.mode ****/ Index: trunk/src/tool_arrow.c =================================================================== --- trunk/src/tool_arrow.c (revision 16599) +++ trunk/src/tool_arrow.c (revision 16600) @@ -72,7 +72,7 @@ pcb_buffer_add_selected(PCB, PCB_PASTEBUFFER, pcb_tool_note.X, pcb_tool_note.Y, pcb_true); pcb_undo_save_serial(); pcb_remove_selected(); - pcb_crosshair_save_mode(); + pcb_tool_save(); pcb_tool_is_saved = pcb_true; pcb_tool_select_by_id(PCB_MODE_PASTE_BUFFER); } @@ -79,7 +79,7 @@ else if (pcb_tool_note.Hit && !pcb_gui->shift_is_pressed()) { pcb_box_t box; - pcb_crosshair_save_mode(); + pcb_tool_save(); pcb_tool_is_saved = pcb_true; pcb_tool_select_by_id(pcb_gui->control_is_pressed()? PCB_MODE_COPY : PCB_MODE_MOVE); pcb_crosshair.AttachedObject.Ptr1 = pcb_tool_note.ptr1;