mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-21 14:34:09 +02:00
Add 'Apply ROT13' to non-editable selections to allow decoding tweets
This commit is contained in:
parent
00bfa68a57
commit
a3e9b15a8a
Core
@ -28,6 +28,7 @@ abstract class ContextMenuBase : IContextMenuHandler{
|
|||||||
private const CefMenuCommand MenuSaveMedia = (CefMenuCommand)26506;
|
private const CefMenuCommand MenuSaveMedia = (CefMenuCommand)26506;
|
||||||
private const CefMenuCommand MenuSaveTweetImages = (CefMenuCommand)26507;
|
private const CefMenuCommand MenuSaveTweetImages = (CefMenuCommand)26507;
|
||||||
private const CefMenuCommand MenuSearchInBrowser = (CefMenuCommand)26508;
|
private const CefMenuCommand MenuSearchInBrowser = (CefMenuCommand)26508;
|
||||||
|
private const CefMenuCommand MenuReadApplyROT13 = (CefMenuCommand)26509;
|
||||||
private const CefMenuCommand MenuOpenDevTools = (CefMenuCommand)26599;
|
private const CefMenuCommand MenuOpenDevTools = (CefMenuCommand)26599;
|
||||||
|
|
||||||
protected ContextInfo.LinkInfo LastLink { get; private set; }
|
protected ContextInfo.LinkInfo LastLink { get; private set; }
|
||||||
@ -57,6 +58,8 @@ public virtual void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser bro
|
|||||||
if (parameters.TypeFlags.HasFlag(ContextMenuType.Selection) && !parameters.TypeFlags.HasFlag(ContextMenuType.Editable)){
|
if (parameters.TypeFlags.HasFlag(ContextMenuType.Selection) && !parameters.TypeFlags.HasFlag(ContextMenuType.Editable)){
|
||||||
model.AddItem(MenuSearchInBrowser, "Search in browser");
|
model.AddItem(MenuSearchInBrowser, "Search in browser");
|
||||||
model.AddSeparator();
|
model.AddSeparator();
|
||||||
|
model.AddItem(MenuReadApplyROT13, "Apply ROT13");
|
||||||
|
model.AddSeparator();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasTweetImage = LastLink.IsImage;
|
bool hasTweetImage = LastLink.IsImage;
|
||||||
@ -173,6 +176,11 @@ void ViewImage(string path){
|
|||||||
TwitterUtils.DownloadImages(LastChirp.Images, LastChirp.Authors.LastOrDefault(), ImageQuality);
|
TwitterUtils.DownloadImages(LastChirp.Images, LastChirp.Authors.LastOrDefault(), ImageQuality);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MenuReadApplyROT13:
|
||||||
|
string selection = parameters.SelectionText;
|
||||||
|
control.InvokeAsyncSafe(() => FormMessage.Information("ROT13", StringUtils.ConvertRot13(selection), FormMessage.OK));
|
||||||
|
return true;
|
||||||
|
|
||||||
case MenuSearchInBrowser:
|
case MenuSearchInBrowser:
|
||||||
string query = parameters.SelectionText;
|
string query = parameters.SelectionText;
|
||||||
control.InvokeAsyncSafe(() => BrowserUtils.OpenExternalSearch(query));
|
control.InvokeAsyncSafe(() => BrowserUtils.OpenExternalSearch(query));
|
||||||
|
@ -16,7 +16,7 @@ sealed class ContextMenuBrowser : ContextMenuBase{
|
|||||||
private const CefMenuCommand MenuOpenQuotedTweetUrl = (CefMenuCommand)26612;
|
private const CefMenuCommand MenuOpenQuotedTweetUrl = (CefMenuCommand)26612;
|
||||||
private const CefMenuCommand MenuCopyQuotedTweetUrl = (CefMenuCommand)26613;
|
private const CefMenuCommand MenuCopyQuotedTweetUrl = (CefMenuCommand)26613;
|
||||||
private const CefMenuCommand MenuScreenshotTweet = (CefMenuCommand)26614;
|
private const CefMenuCommand MenuScreenshotTweet = (CefMenuCommand)26614;
|
||||||
private const CefMenuCommand MenuInputApplyROT13 = (CefMenuCommand)26615;
|
private const CefMenuCommand MenuWriteApplyROT13 = (CefMenuCommand)26615;
|
||||||
private const CefMenuCommand MenuSearchInColumn = (CefMenuCommand)26616;
|
private const CefMenuCommand MenuSearchInColumn = (CefMenuCommand)26616;
|
||||||
|
|
||||||
private const string TitleReloadBrowser = "Reload browser";
|
private const string TitleReloadBrowser = "Reload browser";
|
||||||
@ -44,7 +44,7 @@ public override void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser br
|
|||||||
if (isSelecting){
|
if (isSelecting){
|
||||||
if (isEditing){
|
if (isEditing){
|
||||||
model.AddSeparator();
|
model.AddSeparator();
|
||||||
model.AddItem(MenuInputApplyROT13, "Apply ROT13");
|
model.AddItem(MenuWriteApplyROT13, "Apply ROT13");
|
||||||
}
|
}
|
||||||
|
|
||||||
model.AddSeparator();
|
model.AddSeparator();
|
||||||
@ -141,7 +141,7 @@ public override bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser b
|
|||||||
SetClipboardText(form, LastChirp.QuoteUrl);
|
SetClipboardText(form, LastChirp.QuoteUrl);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case MenuInputApplyROT13:
|
case MenuWriteApplyROT13:
|
||||||
form.InvokeAsyncSafe(form.ApplyROT13);
|
form.InvokeAsyncSafe(form.ApplyROT13);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -19,6 +19,14 @@ public static string ConvertPascalCaseToScreamingSnakeCase(string str){
|
|||||||
return Regex.Replace(str, @"(\p{Ll})(\P{Ll})|(\P{Ll})(\P{Ll}\p{Ll})", "$1$3_$2$4").ToUpper();
|
return Regex.Replace(str, @"(\p{Ll})(\P{Ll})|(\P{Ll})(\P{Ll}\p{Ll})", "$1$3_$2$4").ToUpper();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string ConvertRot13(string str){
|
||||||
|
return Regex.Replace(str, @"[a-zA-Z]", match => {
|
||||||
|
int code = match.Value[0];
|
||||||
|
int start = code <= 90 ? 65 : 97;
|
||||||
|
return ((char)(start+(code-start+13)%26)).ToString();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public static int CountOccurrences(string source, string substring){
|
public static int CountOccurrences(string source, string substring){
|
||||||
int count = 0, index = 0;
|
int count = 0, index = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user