Commit 2808798d authored by Robert Sprowson's avatar Robert Sprowson Committed by ROOL
Browse files

[493] Bring to top when opening the same file twice

Follow the same logic as Draw and Edit, in that if a file is already open of the same name and unmodified, just bring the existing file to the top rather than open a confusing second copy in memory.

Version 2.47. Tagged as 'Paint-2_47'
parent 40e850c6
......@@ -9,12 +9,12 @@
GBLS Module_ApplicationDate
GBLS Module_HelpVersion
GBLS Module_ComponentName
Module_MajorVersion SETS "2.46"
Module_Version SETA 246
Module_MajorVersion SETS "2.47"
Module_Version SETA 247
Module_MinorVersion SETS ""
Module_Date SETS "12 Feb 2022"
Module_ApplicationDate SETS "12-Feb-22"
Module_Date SETS "06 Apr 2022"
Module_ApplicationDate SETS "06-Apr-22"
Module_ComponentName SETS "Paint"
Module_FullVersion SETS "2.46"
Module_HelpVersion SETS "2.46 (12 Feb 2022)"
Module_FullVersion SETS "2.47"
Module_HelpVersion SETS "2.47 (06 Apr 2022)"
END
/* (2.46)
/* (2.47)
*
* This file is automatically maintained by srccommit, do not edit manually.
*
*/
#define Module_MajorVersion_CMHG 2.46
#define Module_MajorVersion_CMHG 2.47
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 12 Feb 2022
#define Module_Date_CMHG 06 Apr 2022
#define Module_MajorVersion "2.46"
#define Module_Version 246
#define Module_MajorVersion "2.47"
#define Module_Version 247
#define Module_MinorVersion ""
#define Module_Date "12 Feb 2022"
#define Module_Date "06 Apr 2022"
#define Module_ApplicationDate "12-Feb-22"
#define Module_ApplicationDate "06-Apr-22"
#define Module_ComponentName "Paint"
#define Module_FullVersion "2.46"
#define Module_HelpVersion "2.46 (12 Feb 2022)"
#define Module_LibraryVersionInfo "2:46"
#define Module_FullVersion "2.47"
#define Module_HelpVersion "2.47 (06 Apr 2022)"
#define Module_LibraryVersionInfo "2:47"
......@@ -166,7 +166,7 @@ static main_template file_template;
static menu main_menu;
static main_file fudgefile =
{NULL, NULL, NULL, NULL, 0, 0, 1, 0, NULL /* &fudgewindow */};
{NULL, NULL, NULL, NULL, ~0, ~0, 0, 0, 1, 0, NULL /* &fudgewindow */};
static main_window fudgewindow = { NULL, 0, main_window_is_file,
NULL /* (main_info_block *) &fudgefile */ };
......@@ -1472,11 +1472,37 @@ int Load_File (main_window *window, char *filename, int merge,
}
}
else
filestr.start = flex_size ((flex_ptr) &ramfetch_buffer);
{ filestr.start = flex_size ((flex_ptr) &ramfetch_buffer);
filestr.loadaddr = filestr.execaddr = 0;
}
/*Set the file name.*/
if (!(merge || ramcopy || temp_file))
{ if (window->data->file.filename == NULL)
{ /*Before going ahead with allocating, see if this file is already open,
and not modified, and matches the stamp on disc. If so just bring that
window to the front.*/
main_window *w;
for (w = main_windows; w != NULL; w = w->link)
{ if (w->tag == main_window_is_file && !w->data->file.modified &&
w->data->file.load == filestr.loadaddr &&
w->data->file.exec == filestr.execaddr &&
strcmp (w->data->file.filename, filename) == 0)
{ wimp_wstate state;
wimp_caretstr caret;
/*Pop to top and gain the caret*/
wimpt_noerr (wimp_get_wind_state (w->handle, &state));
state.o.behind = -1;
wimpt_complain (wimp_open_wind (&state.o));
memset (&caret, 0, sizeof (caret));
caret.w = w->handle;
caret.i = -1;
wimp_set_caret_pos (&caret);
return 0; /* failed, but only in the sense that no file was loaded */
}
}
if (file->filename == NULL)
{ if (!(flex_alloc ((flex_ptr) &file->filename, strlen (filename) + 1)))
{ main_NO_ROOM ("file title");
return -1;
......@@ -1488,6 +1514,9 @@ int Load_File (main_window *window, char *filename, int merge,
return -1;
}
}
strcpy (file->filename, filename);
file->exec = filestr.execaddr;
file->load = filestr.loadaddr;
}
/*If ramcopy or merge, read the stuff to be loaded into ramfetch_buffer
......@@ -1646,8 +1675,6 @@ int Load_File (main_window *window, char *filename, int merge,
rc = -1;
}
if (!temp_file) strcpy (file->filename, filename);
sprptr = &file->sprites;
for (offset = psprite_first (&file->spritearea); offset != 0;
offset = psprite_next (&file->spritearea, offset))
......@@ -1677,7 +1704,7 @@ int Load_File (main_window *window, char *filename, int merge,
wimpt_noerr (wimp_open_wind ((wimp_openstr *) &curr));
}
if ((!merge || window->data->file.filename == NULL) &&
if ((!merge || file->filename == NULL) &&
!(ramcopy || temp_file))
{ /* Clear modified flag and redraw title */
file->modified = 0;
......@@ -2847,6 +2874,7 @@ main_window *main_new_window (BOOL open)
file->title = wind.title.indirecttext.buffer;
strcpy (file->title, msgs_lookup ("PntF4"));
file->load = file->exec = ~0;
file->fullinfo =
main_current_options.display.full_info; /*JRC 1 Dec '89*/
file->modified = 0;
......
......@@ -96,7 +96,7 @@ main_scaling_block tools_brushscale = { 1, 1, 1, 1 };
wimp_i tools_icons [tools_bicon_Max];
main_sprite *tools_brushsprite_ptr = NULL;
main_sprite *tools_brushmouse_ptr = NULL;
main_file tools_brushfile = {NULL, NULL, NULL, NULL, 0, 0, 1, 0, NULL};
main_file tools_brushfile = {NULL, NULL, NULL, NULL, ~0, ~0, 0, 0, 1, 0, NULL};
BOOL tools_flood_local = TRUE;
BOOL tools_exporting_sprite = FALSE;
......@@ -2827,7 +2827,7 @@ static void spraycanpaint_null (main_window *window, wimp_mousestr *mpos)
* the base sprite when the sprite window is redrawn. *
* It's necessary to avoid interference patterns where the brush sprite *
* overlaps previous plots of itself. */
main_file layersfile = {NULL, NULL, NULL, NULL, 0, 0, 1, 0, NULL};
main_file layersfile = {NULL, NULL, NULL, NULL, ~0, ~0, 0, 0, 1, 0, NULL};
tools_layer toolslayer = {NULL, NULL, FALSE};
/* Gets a sprite used as an additional layer, currently only used *
......
......@@ -198,6 +198,7 @@ typedef struct main_file
char *filename; /* flex array */
sprite_area *spritearea; /* flex array of bytes */
char *title; /* indirected title space */
unsigned int load, exec; /* file load/exec address */
char fullinfo; /* big icons or full info */
char modified;
char use_current_palette;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment