diff --git a/doc/xschem_man/commands.html b/doc/xschem_man/commands.html
index d0809624..2c2da0c4 100644
--- a/doc/xschem_man/commands.html
+++ b/doc/xschem_man/commands.html
@@ -116,6 +116,8 @@ LeftButton Double click Terminate Polygon placement
XSCHEM KEY BINDINGS
----------------------------------------------------------------------
- BackSpace Back to parent schematic
+shift BackSpace Open last closed schematic
+ctrl BackSpace Open last opened or saved schematic
- Delete Delete selected objects
- Insert Insert element from library
shift Insert Open persistent insert symbol dialog box
diff --git a/doc/xschem_man/run_xschem.html b/doc/xschem_man/run_xschem.html
index 3c9b2c24..70d0f8c6 100644
--- a/doc/xschem_man/run_xschem.html
+++ b/doc/xschem_man/run_xschem.html
@@ -83,6 +83,8 @@ Options:
--plotfile <file> Use <file> as output for plot (png, svg, ps).
--rcfile <file> Use <file> as a rc file for startup instead of the
default xschemrc.
+ --lastclosed Open last closed file
+ --lastopened Open last opened or saved file
-p --postscript
--pdf Export pdf schematic.
--png Export png schematic.
diff --git a/src/actions.c b/src/actions.c
index b28c33a9..0b1d5fd8 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -605,7 +605,7 @@ void saveas(const char *f, int type) /* changed name from ask_save_file to save
return;
}
-void ask_new_file(int in_new_window)
+void ask_new_file(int in_new_window, char *filename)
{
char f[PATH_MAX]; /* overflow safe 20161125 */
@@ -613,8 +613,12 @@ void ask_new_file(int in_new_window)
if(!(in_new_window || tclgetboolvar("open_in_new_window")) && xctx->modified) {
if(save(1, 0) == -1 ) return; /* user cancels save, so do nothing. */
}
- tcleval("load_file_dialog {Load file} *.\\{sch,sym,tcl\\} INITIALLOADDIR");
- my_snprintf(f, S(f),"%s", tclresult());
+ if(!filename || !filename[0]) {
+ tcleval("load_file_dialog {Load file} *.\\{sch,sym,tcl\\} INITIALLOADDIR");
+ my_snprintf(f, S(f),"%s", tclresult());
+ } else {
+ my_strncpy(f, filename, S(f));
+ }
if(f[0]) {
char win_path[WINDOW_PATH_SIZE];
int skip = 0;
diff --git a/src/callback.c b/src/callback.c
index d1391eff..ba7a55be 100644
--- a/src/callback.c
+++ b/src/callback.c
@@ -3200,7 +3200,7 @@ static void handle_key_press(int event, KeySym key, int state, int rstate, int m
case 'o':
if(EQUAL_MODMASK) { /* load in new tab/window */
xctx->semaphore--;
- ask_new_file(1);
+ ask_new_file(1, NULL);
tcleval("load_additional_files");
xctx->semaphore++;
}
@@ -3212,7 +3212,7 @@ static void handle_key_press(int event, KeySym key, int state, int rstate, int m
);
} else {
xctx->semaphore--;
- ask_new_file(0);
+ ask_new_file(0, NULL);
tcleval("load_additional_files");
xctx->semaphore++;
}
@@ -3924,9 +3924,20 @@ static void handle_key_press(int event, KeySym key, int state, int rstate, int m
redraw_w_a_l_r_p_z_rubbers(1);
break;
- case XK_BackSpace: /* back */
+ case XK_BackSpace:
if(xctx->semaphore >= 2) break;
- go_back(1);
+ if(state == 0) go_back(1); /* go up in hierarchy */
+ else if(state == ShiftMask) {
+ /* load last closed file */
+ char f[PATH_MAX];
+ my_strncpy(f, tcleval("get_lastclosed"), S(f));
+ ask_new_file(0, f);
+ } else if(state == ControlMask) {
+ /* load last opened file */
+ char f[PATH_MAX];
+ my_strncpy(f, tcleval("lindex $tctx::recentfile 0"), S(f));
+ ask_new_file(0, f);
+ }
break;
#if defined(__unix__) && HAS_CAIRO==1
diff --git a/src/globals.c b/src/globals.c
index e1942621..afbaf0f4 100644
--- a/src/globals.c
+++ b/src/globals.c
@@ -213,6 +213,8 @@ char *cli_opt_preinit_command = NULL; /* tcl command given on command line with
* this commands will be executed before loading xschemrc */
char *cli_opt_tcl_post_command = NULL; /* tcl command given on command line with --command