internal static void base64Encode() { try { var text = editor.GetSelText(); if (text.Length == 0) { MessageBox.Show("Please select the text to be encoded."); } string encodedString = Convert.ToBase64String(Encoding.UTF8.GetBytes(text)); editor.ReplaceSel(encodedString); } catch (Exception e) { MessageBox.Show(e.Message); } }
internal static void hexToBase64() { IScintillaGateway scintillaGateway = PluginBase.GetGatewayFactory()(); string selection = scintillaGateway.GetSelText(); if (string.IsNullOrEmpty(selection)) { Tuple <string, Position, Position> hex = extractHexFromCurrentPosition(scintillaGateway); if (hex != null) { string base64 = convertToBase64(hex.Item1); if (base64 != null) { scintillaGateway.SetSel(hex.Item2, hex.Item3); scintillaGateway.ReplaceSel(base64); } } } else { if (selection.Length % 2 != 0) { MessageBox.Show("selection length not divisible by 2"); return; } string base64 = convertToBase64(selection); if (base64 != null) { scintillaGateway.ReplaceSel(base64); } } }
internal static void mergeParamsInNewTab() { IScintillaGateway scintillaGateway = PluginBase.GetGatewayFactory()(); string selection = scintillaGateway.GetSelText(); if (string.IsNullOrEmpty(selection)) { MessageBox.Show("no selection"); return; } try { string sql; int lineNumber = 0; if (IsOneLineSelection(scintillaGateway, ref lineNumber)) { sql = FindSql(scintillaGateway, selection, lineNumber); } else { sql = FindInSelection(selection); } Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_MENUCOMMAND, 0, NppMenuCmd.IDM_FILE_NEW); scintillaGateway.SetText(sql); } catch (Exception e) { MessageBox.Show(e.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
internal static void removeWhitespaces() { IScintillaGateway scintillaGateway = PluginBase.GetGatewayFactory()(); string selection = scintillaGateway.GetSelText(); string result = ""; bool addedSpace = false; foreach (char ch in selection) { if (Char.IsWhiteSpace(ch)) { if (!addedSpace) { addedSpace = true; result += " "; } } else { addedSpace = false; result += ch; } } scintillaGateway.ReplaceSel(result); }
internal static void base64toHex() { IScintillaGateway scintillaGateway = PluginBase.GetGatewayFactory()(); string selection = scintillaGateway.GetSelText(); try { if (string.IsNullOrEmpty(selection)) { Tuple <string, Position, Position> base64AndRange = extractBase64FromCurrentPosition(scintillaGateway); if (base64AndRange != null) { string hex = convertBase64ToHex(base64AndRange.Item1); scintillaGateway.SetSel(base64AndRange.Item2, base64AndRange.Item3); scintillaGateway.ReplaceSel(hex); } } else { scintillaGateway.ReplaceSel(convertBase64ToHex(selection)); } } catch (FormatException e) { MessageBox.Show("FormatException " + e.Message); } }
public string Fill() { var selection = scintilla.GetSelText(); return(selection); }