Skip to content

Commit

Permalink
option SaveFilename to configure path and pattern for HTML and PNG sc…
Browse files Browse the repository at this point in the history
…reen dumps (mintty#1025),

default without colons
  • Loading branch information
mintty committed Jul 28, 2020
1 parent 106e22e commit 08a9d58
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 4 deletions.
5 changes: 5 additions & 0 deletions docs/mintty.1
Original file line number Diff line number Diff line change
Expand Up @@ -2084,6 +2084,11 @@ Disabling this setting disables logging initially.
If a log file name is specified with \fBLog=...\fP and \fBLogging=no\fP,
logging can be enabled (and toggled) from the extended context menu.

.TP
\fBFilename pattern for screen saving\fP (SaveFilename=mintty.%Y-%m-%d_%H-%M-%S)
This setting selects the location and filename pattern (which is expanded
with the strftime(3) function) for .html and .png screen dumps.

.TP
\fBWindow title\fP (Title=)
The \fBTitle\fP setting can be used to determine the initial window title.
Expand Down
18 changes: 18 additions & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ const config default_cfg = {
.char_narrowing = 75,
.emojis = 0,
.emoji_placement = 0,
.save_filename = W("mintty.%Y-%m-%d_%H-%M-%S"),
.app_id = W(""),
.app_name = W(""),
.app_launch_cmd = W(""),
Expand Down Expand Up @@ -456,6 +457,7 @@ options[] = {
{"CharNarrowing", OPT_INT, offcfg(char_narrowing)},
{"Emojis", OPT_EMOJIS, offcfg(emojis)},
{"EmojiPlacement", OPT_EMOJI_PLACEMENT, offcfg(emoji_placement)},
{"SaveFilename", OPT_WSTRING, offcfg(save_filename)},
{"AppID", OPT_WSTRING, offcfg(app_id)},
{"AppName", OPT_WSTRING, offcfg(app_name)},
{"AppLaunchCmd", OPT_WSTRING, offcfg(app_launch_cmd)},
Expand Down Expand Up @@ -651,6 +653,22 @@ static opt_val
#endif


char *
save_filename(char * suf)
{
char * pat = path_win_w_to_posix(cfg.save_filename);
// e.g. "mintty.%Y-%m-%d_%H-%M-%S"

struct timeval now;
gettimeofday(& now, 0);
char * fn = newn(char, MAX_PATH + 1 + strlen(suf));
strftime(fn, MAX_PATH, pat, localtime(& now.tv_sec));
free(pat);
strcat(fn, suf);
return fn;
}


#define dont_debug_opterror

static void
Expand Down
2 changes: 2 additions & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ typedef struct {
int char_narrowing;
char emojis;
char emoji_placement;
wstring save_filename;
wstring app_id;
wstring app_name;
wstring app_launch_cmd;
Expand Down Expand Up @@ -241,5 +242,6 @@ extern void copy_config(char * tag, config * dst, const config * src);
extern void apply_config(bool save);
extern wchar * getregstr(HKEY key, wstring subkey, wstring attribute);
extern uint getregval(HKEY key, wstring subkey, wstring attribute);
extern char * save_filename(char * suf);

#endif
3 changes: 1 addition & 2 deletions src/termclip.c
Original file line number Diff line number Diff line change
Expand Up @@ -953,8 +953,7 @@ term_export_html(bool do_open)
{
struct timeval now;
gettimeofday(& now, 0);
char * htmlf = newn(char, MAX_PATH + 1);
strftime(htmlf, MAX_PATH, "mintty.%F_%T.html", localtime (& now.tv_sec));
char * htmlf = save_filename(".html");

int hfd = open(htmlf, O_WRONLY | O_CREAT | O_EXCL, 0600);
if (hfd < 0) {
Expand Down
3 changes: 1 addition & 2 deletions src/winmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -1400,8 +1400,7 @@ term_save_image(void)
{
struct timeval now;
gettimeofday(& now, 0);
char * copf = newn(char, MAX_PATH + 1);
strftime(copf, MAX_PATH, "mintty.%F_%T.png", localtime (& now.tv_sec));
char * copf = save_filename(".png");
wchar * copyfn = path_posix_to_win_w(copf);
free(copf);

Expand Down
1 change: 1 addition & 0 deletions wiki/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Configuration
* New option PrintableControls to make controls visible (#1019).
* New options Tek*.
* New user-definable functions save-image, tek-copy, tek-page, tek-reset.
* New option SaveFilename.

### 3.2.0 (20 June 2020) ###

Expand Down

0 comments on commit 08a9d58

Please sign in to comment.