mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-03 02:36:50 +13:00
Added "output" custom uploader syntax
This commit is contained in:
parent
b3907c918e
commit
6344565630
6 changed files with 94 additions and 36 deletions
35
ShareX.HelpersLib/Forms/OutputBox.Designer.cs
generated
35
ShareX.HelpersLib/Forms/OutputBox.Designer.cs
generated
|
@ -28,24 +28,21 @@ protected override void Dispose(bool disposing)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.txtText = new System.Windows.Forms.TextBox();
|
this.rtbText = new System.Windows.Forms.RichTextBox();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// txtText
|
// rtbText
|
||||||
//
|
//
|
||||||
this.txtText.BackColor = System.Drawing.Color.Black;
|
this.rtbText.BackColor = System.Drawing.Color.Black;
|
||||||
this.txtText.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
this.rtbText.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||||
this.txtText.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.rtbText.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.txtText.Font = new System.Drawing.Font("Lucida Console", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
|
this.rtbText.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
this.txtText.ForeColor = System.Drawing.Color.White;
|
this.rtbText.Location = new System.Drawing.Point(8, 8);
|
||||||
this.txtText.Location = new System.Drawing.Point(0, 0);
|
this.rtbText.Name = "rtbText";
|
||||||
this.txtText.Multiline = true;
|
this.rtbText.Size = new System.Drawing.Size(968, 745);
|
||||||
this.txtText.Name = "txtText";
|
this.rtbText.TabIndex = 1;
|
||||||
this.txtText.ReadOnly = true;
|
this.rtbText.Text = "";
|
||||||
this.txtText.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
this.rtbText.KeyUp += new System.Windows.Forms.KeyEventHandler(this.rtbText_KeyUp);
|
||||||
this.txtText.Size = new System.Drawing.Size(984, 761);
|
|
||||||
this.txtText.TabIndex = 0;
|
|
||||||
this.txtText.KeyUp += new System.Windows.Forms.KeyEventHandler(this.txtText_KeyUp);
|
|
||||||
//
|
//
|
||||||
// OutputBox
|
// OutputBox
|
||||||
//
|
//
|
||||||
|
@ -53,18 +50,18 @@ private void InitializeComponent()
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||||
this.BackColor = System.Drawing.Color.Black;
|
this.BackColor = System.Drawing.Color.Black;
|
||||||
this.ClientSize = new System.Drawing.Size(984, 761);
|
this.ClientSize = new System.Drawing.Size(984, 761);
|
||||||
this.Controls.Add(this.txtText);
|
this.Controls.Add(this.rtbText);
|
||||||
this.Name = "OutputBox";
|
this.Name = "OutputBox";
|
||||||
|
this.Padding = new System.Windows.Forms.Padding(8);
|
||||||
|
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
this.Text = "OutputBox";
|
this.Text = "OutputBox";
|
||||||
this.Shown += new System.EventHandler(this.OutputBox_Shown);
|
this.Shown += new System.EventHandler(this.OutputBox_Shown);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
private System.Windows.Forms.RichTextBox rtbText;
|
||||||
private System.Windows.Forms.TextBox txtText;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -30,16 +30,16 @@ namespace ShareX.HelpersLib
|
||||||
{
|
{
|
||||||
public partial class OutputBox : Form
|
public partial class OutputBox : Form
|
||||||
{
|
{
|
||||||
private bool scrollToEnd;
|
public bool ScrollToEnd { get; private set; }
|
||||||
|
|
||||||
public OutputBox(string text, string title, bool scrollToEnd = false)
|
private OutputBox(string text, string title, bool scrollToEnd = false)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
ShareXResources.ApplyTheme(this);
|
ShareXResources.ApplyTheme(this);
|
||||||
|
|
||||||
Text = "ShareX - " + title;
|
Text = "ShareX - " + title;
|
||||||
txtText.Text = text;
|
rtbText.Text = text;
|
||||||
this.scrollToEnd = scrollToEnd;
|
ScrollToEnd = scrollToEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Show(string text, string title, bool scrollToEnd = false)
|
public static void Show(string text, string title, bool scrollToEnd = false)
|
||||||
|
@ -54,18 +54,15 @@ private void OutputBox_Shown(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
this.ForceActivate();
|
this.ForceActivate();
|
||||||
|
|
||||||
if (scrollToEnd)
|
rtbText.SelectionStart = rtbText.TextLength;
|
||||||
|
|
||||||
|
if (ScrollToEnd)
|
||||||
{
|
{
|
||||||
txtText.SelectionStart = txtText.TextLength;
|
NativeMethods.SendMessage(rtbText.Handle, (int)WindowsMessages.VSCROLL, (int)ScrollBarCommands.SB_BOTTOM, 0);
|
||||||
txtText.ScrollToCaret();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
txtText.Select(0, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void txtText_KeyUp(object sender, KeyEventArgs e)
|
private void rtbText_KeyUp(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.KeyCode == Keys.Escape)
|
if (e.KeyCode == Keys.Escape)
|
||||||
{
|
{
|
||||||
|
|
|
@ -295,6 +295,11 @@ public void ParseResponse(UploadResult result, ResponseInfo responseInfo, Upload
|
||||||
if (!string.IsNullOrEmpty(URL))
|
if (!string.IsNullOrEmpty(URL))
|
||||||
{
|
{
|
||||||
url = parser.Parse(URL);
|
url = parser.Parse(URL);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(url) && !string.IsNullOrEmpty(URL) && URL.Contains("{output:"))
|
||||||
|
{
|
||||||
|
result.IsURLExpected = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
#region License Information (GPL v3)
|
||||||
|
|
||||||
|
/*
|
||||||
|
ShareX - A program that allows you to take screenshots and share any file type
|
||||||
|
Copyright (c) 2007-2023 ShareX Team
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endregion License Information (GPL v3)
|
||||||
|
|
||||||
|
using ShareX.HelpersLib;
|
||||||
|
|
||||||
|
namespace ShareX.UploadersLib
|
||||||
|
{
|
||||||
|
// Example: {output:text}
|
||||||
|
// Example: {output:title|text}
|
||||||
|
internal class CustomUploaderFunctionOutput : CustomUploaderFunction
|
||||||
|
{
|
||||||
|
public override string Name { get; } = "output";
|
||||||
|
|
||||||
|
public override int MinParameterCount { get; } = 1;
|
||||||
|
|
||||||
|
public override string Call(ShareXCustomUploaderSyntaxParser parser, string[] parameters)
|
||||||
|
{
|
||||||
|
string text, title;
|
||||||
|
|
||||||
|
if (parameters.Length > 1)
|
||||||
|
{
|
||||||
|
text = parameters[1];
|
||||||
|
title = parameters[0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
text = parameters[0];
|
||||||
|
title = "ShareX - Output";
|
||||||
|
}
|
||||||
|
|
||||||
|
OutputBox.Show(text, title);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -30,7 +30,7 @@ namespace ShareX.UploadersLib
|
||||||
{
|
{
|
||||||
// Example: {prompt}
|
// Example: {prompt}
|
||||||
// Example: {prompt:title}
|
// Example: {prompt:title}
|
||||||
// Example: {prompt:title|default value}
|
// Example: {prompt:title|default text}
|
||||||
internal class CustomUploaderFunctionPrompt : CustomUploaderFunction
|
internal class CustomUploaderFunctionPrompt : CustomUploaderFunction
|
||||||
{
|
{
|
||||||
public override string Name { get; } = "prompt";
|
public override string Name { get; } = "prompt";
|
||||||
|
@ -38,7 +38,7 @@ internal class CustomUploaderFunctionPrompt : CustomUploaderFunction
|
||||||
public override string Call(ShareXCustomUploaderSyntaxParser parser, string[] parameters)
|
public override string Call(ShareXCustomUploaderSyntaxParser parser, string[] parameters)
|
||||||
{
|
{
|
||||||
string title = "ShareX - Prompt";
|
string title = "ShareX - Prompt";
|
||||||
string defaultValue = "";
|
string defaultText = "";
|
||||||
|
|
||||||
if (parameters.Length > 0)
|
if (parameters.Length > 0)
|
||||||
{
|
{
|
||||||
|
@ -46,11 +46,11 @@ public override string Call(ShareXCustomUploaderSyntaxParser parser, string[] pa
|
||||||
|
|
||||||
if (parameters.Length > 1)
|
if (parameters.Length > 1)
|
||||||
{
|
{
|
||||||
defaultValue = parameters[1];
|
defaultText = parameters[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
using (InputBox inputBox = new InputBox(title, defaultValue))
|
using (InputBox inputBox = new InputBox(title, defaultText))
|
||||||
{
|
{
|
||||||
if (inputBox.ShowDialog() == DialogResult.OK)
|
if (inputBox.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
|
@ -58,7 +58,7 @@ public override string Call(ShareXCustomUploaderSyntaxParser parser, string[] pa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return defaultValue;
|
return defaultText;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -133,6 +133,7 @@
|
||||||
<Compile Include="CustomUploader\Functions\CustomUploaderFunctionBase64.cs" />
|
<Compile Include="CustomUploader\Functions\CustomUploaderFunctionBase64.cs" />
|
||||||
<Compile Include="CustomUploader\Functions\CustomUploaderFunctionFileName.cs" />
|
<Compile Include="CustomUploader\Functions\CustomUploaderFunctionFileName.cs" />
|
||||||
<Compile Include="CustomUploader\Functions\CustomUploaderFunctionInput.cs" />
|
<Compile Include="CustomUploader\Functions\CustomUploaderFunctionInput.cs" />
|
||||||
|
<Compile Include="CustomUploader\Functions\CustomUploaderFunctionOutput.cs" />
|
||||||
<Compile Include="CustomUploader\Functions\CustomUploaderFunctionResponseURL.cs" />
|
<Compile Include="CustomUploader\Functions\CustomUploaderFunctionResponseURL.cs" />
|
||||||
<Compile Include="CustomUploader\Functions\CustomUploaderFunctionResponse.cs" />
|
<Compile Include="CustomUploader\Functions\CustomUploaderFunctionResponse.cs" />
|
||||||
<Compile Include="CustomUploader\Functions\CustomUploaderFunctionPrompt.cs" />
|
<Compile Include="CustomUploader\Functions\CustomUploaderFunctionPrompt.cs" />
|
||||||
|
|
Loading…
Reference in a new issue