Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.

Commit 4fc8a44

Browse files
committed
code generation support for "keymod"
1 parent 13aa6cc commit 4fc8a44

File tree

4 files changed

+56
-2
lines changed

4 files changed

+56
-2
lines changed

ToolsForMaintainersOfTheProjectTemplate/Scintilla_iface_synchronizer/cs.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def printLexCSFile(f):
2727
return out
2828

2929
def isTypeUnsupported(t):
30-
if t in ["keymod", "formatrange"]: return True
30+
if t in ["formatrange"]: return True
3131
return False
3232

3333
def translateType(t):
@@ -36,14 +36,15 @@ def translateType(t):
3636
if t == "position": return "Position"
3737
if t == "textrange": return "TextRange"
3838
if t == "findtext": return "TextToFind"
39+
if t == "keymod": return "KeyModifier"
3940
return t
4041

4142
def translateVariableAccess(name, type):
4243
if type == "bool": return name + " ? 1 : 0"
4344
if type in ["string", "stringresult", "Cells"]: return "(IntPtr) " +name+ "Ptr"
4445

4546
res = name if name else "Unused"
46-
if type in ["Colour", "Position"]:
47+
if type in ["Colour", "Position", "KeyModifier"]:
4748
res += ".Value"
4849
if type in ["TextRange", "TextToFind"]:
4950
res += ".NativePointer"

Visual Studio Project Template C#/GatewayDomain.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,41 @@ public int Value
7575
}
7676
}
7777

78+
/// <summary>
79+
/// Class containing key and modifiers
80+
///
81+
/// The key code is a visible or control character or a key from the SCK_* enumeration, which contains:
82+
/// SCK_ADD, SCK_BACK, SCK_DELETE, SCK_DIVIDE, SCK_DOWN, SCK_END, SCK_ESCAPE, SCK_HOME, SCK_INSERT, SCK_LEFT, SCK_MENU, SCK_NEXT(Page Down), SCK_PRIOR(Page Up), S
83+
/// CK_RETURN, SCK_RIGHT, SCK_RWIN, SCK_SUBTRACT, SCK_TAB, SCK_UP, and SCK_WIN.
84+
///
85+
/// The modifiers are a combination of zero or more of SCMOD_ALT, SCMOD_CTRL, SCMOD_SHIFT, SCMOD_META, and SCMOD_SUPER.
86+
/// On OS X, the Command key is mapped to SCMOD_CTRL and the Control key to SCMOD_META.SCMOD_SUPER is only available on GTK+ which is commonly the Windows key.
87+
/// If you are building a table, you might want to use SCMOD_NORM, which has the value 0, to mean no modifiers.
88+
/// </summary>
89+
public class KeyModifier
90+
{
91+
private readonly int value;
92+
93+
/// <summary>
94+
/// The key code is a visible or control character or a key from the SCK_* enumeration, which contains:
95+
/// SCK_ADD, SCK_BACK, SCK_DELETE, SCK_DIVIDE, SCK_DOWN, SCK_END, SCK_ESCAPE, SCK_HOME, SCK_INSERT, SCK_LEFT, SCK_MENU, SCK_NEXT(Page Down), SCK_PRIOR(Page Up),
96+
/// SCK_RETURN, SCK_RIGHT, SCK_RWIN, SCK_SUBTRACT, SCK_TAB, SCK_UP, and SCK_WIN.
97+
///
98+
/// The modifiers are a combination of zero or more of SCMOD_ALT, SCMOD_CTRL, SCMOD_SHIFT, SCMOD_META, and SCMOD_SUPER.
99+
/// On OS X, the Command key is mapped to SCMOD_CTRL and the Control key to SCMOD_META.SCMOD_SUPER is only available on GTK+ which is commonly the Windows key.
100+
/// If you are building a table, you might want to use SCMOD_NORM, which has the value 0, to mean no modifiers.
101+
/// </summary>
102+
public KeyModifier(SciMsg SCK_KeyCode, SciMsg SCMOD_modifier)
103+
{
104+
value = (int) SCK_KeyCode | ((int) SCMOD_modifier << 16);
105+
}
106+
107+
public int Value
108+
{
109+
get { return Value; }
110+
}
111+
}
112+
78113
[StructLayout(LayoutKind.Sequential)]
79114
public struct CharacterRange
80115
{

Visual Studio Project Template C#/IScintillaGateway.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,12 @@ public interface IScintillaGateway
400400
/// <summary>Set the foreground colour of the caret. (Scintilla feature 2069)</summary>
401401
void SetCaretFore(Colour fore);
402402

403+
/// <summary>When key+modifier combination km is pressed perform msg. (Scintilla feature 2070)</summary>
404+
void AssignCmdKey(KeyModifier km, int msg);
405+
406+
/// <summary>When key+modifier combination km is pressed do nothing. (Scintilla feature 2071)</summary>
407+
void ClearCmdKey(KeyModifier km);
408+
403409
/// <summary>Drop all key mappings. (Scintilla feature 2072)</summary>
404410
void ClearAllCmdKeys();
405411

Visual Studio Project Template C#/ScintillaGateway.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,18 @@ public void SetCaretFore(Colour fore)
852852
IntPtr res = Win32.SendMessage(scintilla, SciMsg.SCI_SETCARETFORE, fore.Value, Unused);
853853
}
854854

855+
/// <summary>When key+modifier combination km is pressed perform msg. (Scintilla feature 2070)</summary>
856+
public void AssignCmdKey(KeyModifier km, int msg)
857+
{
858+
IntPtr res = Win32.SendMessage(scintilla, SciMsg.SCI_ASSIGNCMDKEY, km.Value, msg);
859+
}
860+
861+
/// <summary>When key+modifier combination km is pressed do nothing. (Scintilla feature 2071)</summary>
862+
public void ClearCmdKey(KeyModifier km)
863+
{
864+
IntPtr res = Win32.SendMessage(scintilla, SciMsg.SCI_CLEARCMDKEY, km.Value, Unused);
865+
}
866+
855867
/// <summary>Drop all key mappings. (Scintilla feature 2072)</summary>
856868
public void ClearAllCmdKeys()
857869
{

0 commit comments

Comments
 (0)