From e154748542e42d0f3add5812791219ee174f117c Mon Sep 17 00:00:00 2001 From: Ole Loots Date: Sun, 29 Dec 2013 22:23:51 +0100 Subject: Do not use tmpnam() but a custom function. --- atari/ctxmenu.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++---- atari/gemtk/gemtk.h | 4 ++++ atari/gemtk/utils.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 4 deletions(-) diff --git a/atari/ctxmenu.c b/atari/ctxmenu.c index 2170dec8c..3125012b3 100644 --- a/atari/ctxmenu.c +++ b/atari/ctxmenu.c @@ -23,7 +23,10 @@ #include #include #include -#include +#include +#include +#include +#include #include "desktop/gui.h" #include "desktop/netsurf.h" @@ -36,7 +39,8 @@ #include "content/urldb.h" #include "css/css.h" #include "utils/log.h" -#include "utils/messages.h" +#include "utils/messages.h" +#include "utils/utils.h" #include "atari/gui.h" #include "atari/rootwin.h" @@ -107,6 +111,39 @@ static struct s_context_info * get_context_info( struct gui_window * gw, short m return(&ctxinfo); +} + +/*** + * + * \param prefix + * \param sufffix + * \return pointer to static buffer owned by get_tmpfilename() + */ +static char * get_tmpfilename(const char * prefix, const char * suffix) +{ + int i=0; + static char tmpfilename[PATH_MAX]; + char * tmpdir; + const char * tmp_path_suffix = ""; + + // TODO: make function public? + tmpdir = getenv("TMPDIR"); + if(tmpdir == NULL){ + tmpdir = (char*)"u:\\tmp\\"; + } + + if(tmpdir[strlen(tmpdir)-1] != '\\'){ + tmp_path_suffix = "\\"; + } + + do{ + /* generate a new filename: */ + snprintf(tmpfilename, PATH_MAX, "%s%s%s%d%s", tmpdir, + tmp_path_suffix, prefix, i++, suffix); + /* check with cflib: */ + } while(file_exists(tmpfilename)); + + return(tmpfilename); } //TODO: do not open popup for gui_window, but for a rootwin? @@ -273,9 +310,11 @@ void context_popup(struct gui_window * gw, short x, short y) editor = nsoption_charp(atari_editor); if (editor != NULL && strlen(editor)>0) { data = content_get_source_data(gw->browser->bw->current_content, - &size); + &size); if (size > 0 && data != NULL){ - snprintf(tempfile, 127, "%s%s.htm", "u:", tmpnam(NULL)); + snprintf(tempfile, 127, "%s", get_tmpfilename("ns-", ".html")); + /* the GEMDOS cmdline contains the length of the commandline + in the first byte: */ cmdline[0] = (unsigned char)strlen(tempfile); LOG(("Creating temporay source file: %s\n", tempfile)); fp_tmpfile = fopen(tempfile, "w"); @@ -283,6 +322,10 @@ void context_popup(struct gui_window * gw, short x, short y) fwrite(data, size, 1, fp_tmpfile); fclose(fp_tmpfile); + // Send SH_WDRAW to notify files changed: + gemtk_send_msg(SH_WDRAW, 0, -1, 0, 0, 0, 0); + + // start application: if(strlen(tempfile)<=125){ shel_write(1, 1, 1, editor, cmdline); } diff --git a/atari/gemtk/gemtk.h b/atari/gemtk/gemtk.h index 44baba429..f16b4a7c0 100644 --- a/atari/gemtk/gemtk.h +++ b/atari/gemtk/gemtk.h @@ -60,6 +60,10 @@ void gemtk_clip_grect(VdiHdl vh, GRECT *rect); void gemtk_wind_get_str(short aes_handle, short mode, char *str, int len); +/* send application message */ +void gemtk_send_msg(short msg_type, short data2, short data3, short data4, + short data5, short data6, short data7); + #ifndef POINT_WITHIN # define POINT_WITHIN(_x,_y, r) ((_x >= r.g_x) && (_x <= r.g_x + r.g_w ) \ diff --git a/atari/gemtk/utils.c b/atari/gemtk/utils.c index 20fe5d424..aac293d21 100644 --- a/atari/gemtk/utils.c +++ b/atari/gemtk/utils.c @@ -95,10 +95,38 @@ void gemtk_clip_grect(VdiHdl vh, GRECT *rect) vs_clip_pxy(vh, pxy); } +/** Send an Message to a GUIWIN using AES message pipe +* \param win the GUIWIN which shall receive the message +* \param msg_type the WM_ message definition +* \param a the 4th parameter to appl_write +* \param b the 5th parameter to appl_write +* \param c the 6th parameter to appl_write +* \param d the 7th parameter to appl_write +*/ +void gemtk_send_msg(short msg_type, short data2, short data3, short data4, + short data5, short data6, short data7) +{ + short msg[8]; + + msg[0] = msg_type; + msg[1] = gl_apid; + msg[2] = data2; + msg[3] = data3; + msg[4] = data4; + msg[5] = data5; + msg[6] = data6; + msg[7] = data7; + + appl_write(gl_apid, 16, &msg); +} + + void gemtk_wind_get_str(short aes_handle, short mode, char *str, int len) { char tmp_str[255]; + // TODO: remove or implement function + if(len>255) { len = 255; } -- cgit v1.2.3 From ccde3fc1eb3a0258eb26e79a879c286a023711bc Mon Sep 17 00:00:00 2001 From: Ole Loots Date: Sun, 29 Dec 2013 22:26:14 +0100 Subject: Do not reload browser window on scal change --- atari/gui.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/atari/gui.c b/atari/gui.c index ace0f9848..cf1d1b384 100644 --- a/atari/gui.c +++ b/atari/gui.c @@ -359,8 +359,7 @@ void gui_window_set_scale(struct gui_window *gw, float scale) gw->scale = MAX(scale, 0.25); - browser_window_reload(gw->browser->bw, false); - gui_window_get_dimensions(gw, &width, &heigth, true); + gui_window_get_dimensions(gw, &width, &heigth, true); browser_window_reformat(gw->browser->bw, false, width, heigth); } @@ -768,6 +767,8 @@ void gui_set_clipboard(const char *buffer, size_t length, // convert utf8 input to atari encoding: + // TODO: send SC_CHANGED message + utf8_convert_ret ret; char *clip = NULL; -- cgit v1.2.3 From f31b7fa5c4c9d1c6003b42e9d848fa7df0b36abe Mon Sep 17 00:00:00 2001 From: Ole Loots Date: Sun, 29 Dec 2013 23:00:52 +0100 Subject: Minor documentation change --- atari/findfile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/atari/findfile.c b/atari/findfile.c index 61dc3a292..7badc7149 100755 --- a/atari/findfile.c +++ b/atari/findfile.c @@ -124,14 +124,14 @@ char *url_to_path(const char *url) /** * Locate a shared resource file by searching known places in order. + * Search order is: ./, NETSURF_GEM_RESPATH, ./$HOME/.netsurf/, $NETSURFRES/ + * (where NETSURFRES is an environment variable) * * \param buf buffer to write to. must be at least PATH_MAX chars * \param filename file to look for * \param def default to return if file not found * \return buf * - * Search order is: ./, NETSURF_GEM_RESPATH, ./$HOME/.netsurf/, $NETSURFRES/ (where NETSURFRES is an - * environment variable), */ #ifndef NETSURF_GEM_RESPATH #define NETSURF_GEM_RESPATH "./res/" -- cgit v1.2.3 From 4bf410a5834fce29145276f101c7c1a11dde6c3c Mon Sep 17 00:00:00 2001 From: Ole Loots Date: Sun, 29 Dec 2013 23:15:53 +0100 Subject: Extended documentation --- atari/ctxmenu.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/atari/ctxmenu.c b/atari/ctxmenu.c index 3125012b3..fb687b809 100644 --- a/atari/ctxmenu.c +++ b/atari/ctxmenu.c @@ -114,7 +114,10 @@ static struct s_context_info * get_context_info( struct gui_window * gw, short m } /*** - * + * Generates an unique filename for temp. files + * The generated filename includes the path. + * If TMPDIR environmenrt vairable is set, this will be used as path, + * otherwise U:\tmp\ * \param prefix * \param sufffix * \return pointer to static buffer owned by get_tmpfilename() -- cgit v1.2.3 From e65c91807e554737445916cfb25235b5d0a10c83 Mon Sep 17 00:00:00 2001 From: Ole Loots Date: Sun, 29 Dec 2013 23:16:30 +0100 Subject: Send SC_CHANGED after writing to scrap file --- atari/clipboard.c | 8 ++++++++ atari/gui.c | 2 -- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/atari/clipboard.c b/atari/clipboard.c index bcd4ee6df..254579bba 100644 --- a/atari/clipboard.c +++ b/atari/clipboard.c @@ -28,6 +28,7 @@ #include #include #include "atari/clipboard.h" +#include "atari/gemtk/gemtk.h" static int filesize(char * path) @@ -49,6 +50,13 @@ static int filesize(char * path) int scrap_txt_write(char *str) { scrap_wtxt(str); + + + // Send SC_CHANGED message: + gemtk_send_msg(SC_CHANGED, 0, 2, 0, 0, 0, 0); + + return(0); + } char *scrap_txt_read(void) diff --git a/atari/gui.c b/atari/gui.c index cf1d1b384..e52a6589c 100644 --- a/atari/gui.c +++ b/atari/gui.c @@ -767,8 +767,6 @@ void gui_set_clipboard(const char *buffer, size_t length, // convert utf8 input to atari encoding: - // TODO: send SC_CHANGED message - utf8_convert_ret ret; char *clip = NULL; -- cgit v1.2.3