Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modification keys: SHIFT and CTRL #7

Merged
merged 3 commits into from
Mar 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions PasteIntoFile/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
<setting name="upgradePerformed" serializeAs="String">
<value>False</value>
</setting>
<setting name="subdirTemplate" serializeAs="String">
<value>{0:yyyy-MM-dd}</value>
</setting>
</PasteIntoFile.Properties.Settings>
</userSettings>
</configuration>
21 changes: 11 additions & 10 deletions PasteIntoFile/Dialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ public partial class Dialog : MasterForm

public Dialog(string location, bool forceShowDialog = false)
{
// always show GUI if shift pressed during start
forceShowDialog |= ModifierKeys == Keys.Shift;
// flag if key is pressed during start
bool invertAutosave = (ModifierKeys & Keys.Shift) == Keys.Shift;
bool saveIntoSubdir = (ModifierKeys & Keys.Control) == Keys.Control;

// Setup GUI
InitializeComponent();
Expand Down Expand Up @@ -58,7 +59,8 @@ public Dialog(string location, bool forceShowDialog = false)
var clipRead = readClipboard();

updateFilename();
txtCurrentLocation.Text = Path.GetFullPath(location);
if (saveIntoSubdir) location += @"\" + formatFilenameTemplate(Settings.Default.subdirTemplate);
txtCurrentLocation.Text = location;
chkClrClipboard.Checked = Settings.Default.clrClipboard;
chkContinuousMode.Checked = continuousMode;
updateSavebutton();
Expand All @@ -68,22 +70,21 @@ public Dialog(string location, bool forceShowDialog = false)

txtFilename.Select();

// show dialog or autosave option
if (forceShowDialog)
{
// show dialog or perform autosave
bool showDialog = forceShowDialog || !(Settings.Default.autoSave ^ invertAutosave);
if (showDialog) {
// Make sure to bring window to foreground (holding shift will open window in background)
WindowState = FormWindowState.Minimized;
Show();
BringToFront();
WindowState = FormWindowState.Normal;
}
// otherwise perform autosave if enabled
else if (Settings.Default.autoSave)
{
else {
var file = clipRead ? save() : null;
if (file != null)
{
ExplorerUtil.RequestFilenameEdit(file);
if (!saveIntoSubdir)
ExplorerUtil.RequestFilenameEdit(file);

Program.ShowBalloon(Resources.str_autosave_balloontitle,
new []{file, Resources.str_autosave_balloontext}, 10);
Expand Down
9 changes: 8 additions & 1 deletion PasteIntoFile/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ static class Program

class ArgsCommon
{
[Option('f', "filename", HelpText = "Filename template with optional date format variable such as {0:yyyyMMdd HHmmSS}")]
[Option('f', "filename", HelpText = "Filename template with optional format variables such as\n" +
"{0:yyyyMMdd HHmmSS} for current date and time\n" +
"{1:000} for batch-mode save counter")]
public string Filename { get; set; }

[Option("text-extension", HelpText = "File extension for text contents")]
Expand All @@ -25,6 +27,9 @@ class ArgsCommon
[Option("image-extension", HelpText = "File extension for image contents")]
public string ImageExtension { get; set; }

[Option("subdir", HelpText = "Template for name of subfolder to create when holding CTRL (see filename for format variables)")]
public string Subdir { get; set; }

[Option('c', "clear", HelpText = "Clear clipboard after save (true/false)")]
public bool? ClearClipboard { get; set; }

Expand Down Expand Up @@ -217,6 +222,8 @@ static void ApplyCommonArgs(ArgsCommon args)
Settings.Default.extensionText = args.TextExtension;
if (args.ImageExtension != null)
Settings.Default.extensionImage = args.ImageExtension;
if (args.Subdir != null)
Settings.Default.subdirTemplate = args.Subdir;
if (args.ClearClipboard != null)
Settings.Default.clrClipboard = (bool) args.ClearClipboard;
if (args.Autosave != null)
Expand Down
2 changes: 1 addition & 1 deletion PasteIntoFile/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion PasteIntoFile/Properties/Resources.de.resx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
<value>Autosave aktivieren</value>
</data>
<data name="str_wizard_autosave_info" xml:space="preserve">
<value>Das Programm kann so konfiguriert werden, dass Dateien automatisch gespeichert werden, ohne dass der Dialog zur Eingabe von Dateinamen und -typ geöffnet wird. Stattdessen wird die erstellte Datei im Explorer zum Umbenennen markiert. Um den Dialog wieder anzuzeigen kann PasteIntoFile ohne Argumente ausgeführt werden, oder während des Programmstarts die Umschalttaste gedrückt gehalten werden. Diese Einstellung kann später angepasst werden.</value>
<value>Das Programm kann so konfiguriert werden, dass Dateien automatisch gespeichert werden. Dabei wird der Dialog zur Eingabe von Dateinamen und -typ übersprungen, und die erstellte Datei im Explorer zum Umbenennen markiert. Diese Einstellung kann später angepasst und jederzeit durch halten der Umschalttaste einmalig umgekehrt werden. Wenn Paste Into File ohne Argumente ausgeführt wird, wird der Dialog stets angezeigt.</value>
</data>
<data name="str_wizard_autosave_title" xml:space="preserve">
<value>Datei automatisch ohne Dialog speichern?</value>
Expand Down
2 changes: 1 addition & 1 deletion PasteIntoFile/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ Do you want to overwrite it?</value>
<value>Finish setup</value>
</data>
<data name="str_wizard_autosave_info" xml:space="preserve">
<value>You can configure Paste Into File to automatically save the file without prompting for filename and extension. Instead, the file created will be selected for renaming in the explorer window. To show the dialog again, run the PasteInfoFile executable without arguments or hold the SHIFT key while selecting the context menu entry. You can change this setting later.</value>
<value>You can configure Paste Into File to automatically save the file. When enabled, the dialog prompting for filename and extension is skipped and the file will be created and selected for renaming in the explorer window instead. This setting can be changed later. To temporarily invert the setting, hold the SHIFT key when running Paste Into File. Note that the dialog is always shown when executing Paste Into File without command line arguments.</value>
</data>
<data name="str_continuous_mode" xml:space="preserve">
<value>Batch mode</value>
Expand Down
12 changes: 12 additions & 0 deletions PasteIntoFile/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions PasteIntoFile/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
<Setting Name="upgradePerformed" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="subdirTemplate" Type="System.String" Scope="User">
<Value Profile="(Default)">{0:yyyy-MM-dd}</Value>
</Setting>
</Settings>
</SettingsFile>

32 changes: 23 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@
[![Latest release](https://img.shields.io/github/v/release/eltos/PasteIntoFile)](https://github.com/eltos/PasteIntoFile/releases/latest)
[![Total downloads](https://img.shields.io/github/downloads/eltos/PasteIntoFile/total)](https://github.com/eltos/PasteIntoFile/releases)

## About

A Windows desktop application to paste clipboard contents into files and copy file contents to the clipboard via the context menu

----------------


_This is a fork of [sorge13248/PasteIntoFile](https://github.com/sorge13248/PasteIntoFile), itself being a fork of [EslaMx7/PasteIntoFile](https://github.com/EslaMx7/PasteIntoFile)._
_See the [contributors page](https://github.com/eltos/PasteIntoFile/graphs/contributors) for details on collaborators._

_This fork contains many new core functionalities such as clipboard monitoring, batch mode and rename inside the file explorer. In addition, the GUI was completely redesigned to make the layout resizeable and allow for comfortable text and image preview._
_This fork comes with many new features such as clipboard monitoring, batch mode, rename inside file explorer, copy file contents, paste into subdirectory, support for many additional formats and a new GUI with fluid layout and comfortable text, image, HTML and richt-text preview._
_The full changelog can be found on the [release page](https://github.com/eltos/PasteIntoFile/releases)._

----------------


## Features

Expand Down Expand Up @@ -47,13 +48,23 @@ Further options can be accessed through the main GUI or via command line options

Help is available via [GitHub discussions](https://github.com/eltos/PasteIntoFile/discussions/categories/q-a)

### Key modifiers

Hold the following keys while launching Paste Into File
- **SHIFT** inverts autosave settings once
When autosave is enabled, holding SHIFT will show the dialog anyways
When autosave is disabled, holding SHIFT will skip the dialog anyways
- **CTRL** saves to a subdirectory
Holding CTRL will save to an intermediate subdirectory
The subfolder name supports templates and can be configured via command line options


## Command Line Use

Use `help`, `help paste`, `help config` etc. to show available command line options, e.g.:
```powershell
```
> .\PasteIntoFile.exe help
PasteIntoFile 4.0.0.0
PasteIntoFile 4.2.0.0
Copyright © PasteIntoFile GitHub contributors

paste (Default Verb) Paste clipboard contents into file
Expand All @@ -65,14 +76,17 @@ Copyright © PasteIntoFile GitHub contributors
```
```
> .\PasteIntoFile.exe help paste
PasteIntoFile 4.0.0.0
PasteIntoFile 4.2.0.0
Copyright © PasteIntoFile GitHub contributors

-d, --directory Path of directory to save file into
-f, --filename Filename template with optional date format variable such
as {0:yyyyMMdd HHmmSS}
-f, --filename Filename template with optional format variables such as
{0:yyyyMMdd HHmmSS} for current date and time
{1:000} for batch-mode save counter
--text-extension File extension for text contents
--image-extension File extension for image contents
--subdir Template for name of subfolder to create when holding
CTRL (see filename for format variables)
-c, --clear Clear clipboard after save (true/false)
-a, --autosave Autosave file without prompt (true/false)
--help Display this help screen.
Expand Down