-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.cs
69 lines (56 loc) · 1.81 KB
/
Main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System.Windows.Forms;
using Kbg.NppPluginNET.PluginInfrastructure;
namespace Kbg.NppPluginNET
{
class Main
{
internal const string PluginName = "CutNCopyLine";
public static void OnNotification(ScNotification notification)
{
}
internal static void CommandMenuInit()
{
PluginBase.SetCommand(0, "&Copy selection or line", CopySelectionOrLine, new ShortcutKey(true, false, false, Keys.C));
PluginBase.SetCommand(0, "C&ut selection or line", CutSelectionOrLine, new ShortcutKey(true, false, false, Keys.X));
PluginBase.SetCommand(0, "&About "+PluginName, ShowAbout, new ShortcutKey(false, false, false, Keys.None));
}
internal static void SetToolBarIcon()
{
}
internal static void PluginCleanUp()
{
}
private static void CopySelectionOrLine()
{
var scintilla = new ScintillaGateway(PluginBase.GetCurrentScintilla());
if (scintilla.GetSelectionLength() != 0)
scintilla.Copy();
else
scintilla.CopyAllowLine();
}
private static void CutSelectionOrLine()
{
var scintilla = new ScintillaGateway(PluginBase.GetCurrentScintilla());
if (scintilla.GetSelectionLength() != 0)
scintilla.Cut();
else
{
scintilla.CopyAllowLine();
scintilla.LineDelete();
}
}
private static void ShowAbout()
{
var message = @"Version: 1.01
This plugin changes how ctrl+c and ctrl+x work.
If no selection is made, the commands operate on the current line.
This means you can easily operate on lines - just don't select anything
before copying or cutting.
License: This is freeware (Apache v2.0 license).
Author: Kasper B. Graversen 2016-
Website: https://github.com/kbilsted/nppPluginCutNCopyLine";
var title = PluginName;
MessageBox.Show(message, title, MessageBoxButtons.OK);
}
}
}